KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > controller > recoverylog > events > DeleteLogEntriesAndCheckpointBetweenEvent


1 /**
2  * Sequoia: Database clustering technology.
3  * Copyright (C) 2005 Emic Networks.
4  * Contact: sequoia@continuent.org
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  *
18  * Initial developer(s): Stephane Giron.
19  * Contributor(s): ______________________.
20  */

21
22 package org.continuent.sequoia.controller.recoverylog.events;
23
24 import java.sql.SQLException JavaDoc;
25
26 import org.continuent.sequoia.common.i18n.Translate;
27 import org.continuent.sequoia.controller.recoverylog.LoggerThread;
28
29 /**
30  * This class defines a ResetLogEvent to reset the log
31  *
32  * @author <a HREF="mailto:stephane.giron@continuent.com">Stephane Giron</a>
33  * @version 1.0
34  */

35 public class DeleteLogEntriesAndCheckpointBetweenEvent implements LogEvent
36 {
37   private long fromId;
38   private long toId;
39
40   /**
41    * Creates a new <code>DeleteLogEntriesAndCheckpointBetweenEvent</code>
42    * object. Used to delete a range of log entries in the recovery log.
43    *
44    * @param fromId the first id of the range
45    * @param toId the last id of the range
46    */

47   public DeleteLogEntriesAndCheckpointBetweenEvent(long fromId, long toId)
48   {
49     this.fromId = fromId;
50     this.toId = toId;
51   }
52
53   /**
54    * @see org.continuent.sequoia.controller.recoverylog.events.LogEvent#belongToTransaction(long)
55    */

56   public boolean belongToTransaction(long tid)
57   {
58     return false;
59   }
60
61   /**
62    * @see org.continuent.sequoia.controller.recoverylog.events.LogEvent#execute(org.continuent.sequoia.controller.recoverylog.LoggerThread)
63    */

64   public void execute(LoggerThread loggerThread)
65   {
66     try
67     {
68       loggerThread.deleteLogEntriesAndCheckpointBetween(fromId, toId);
69     }
70     catch (SQLException JavaDoc e)
71     {
72       loggerThread.invalidateLogStatements();
73       loggerThread.getLogger().error(
74           Translate.get("recovery.jdbc.loggerthread.shift.failed", e
75               .getMessage()), e);
76       // Push object back in the queue, it needs to be logged again
77
loggerThread.putBackAtHeadOfQueue(this, e);
78     }
79   }
80
81   /**
82    * @see java.lang.Object#toString()
83    */

84   public String JavaDoc toString()
85   {
86     return "Delete log entries from " + fromId + " to " + toId;
87   }
88
89 }
90
Popular Tags