KickJava   Java API By Example, From Geeks To Geeks.

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


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): Emmanuel Cecchet.
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:emmanuel.cecchet@emicnetworks.com">Emmanuel Cecchet</a>
33  * @version 1.0
34  */

35 public class ResetLogEvent implements LogEvent
36 {
37   private long oldId;
38   private long newId;
39   private String JavaDoc checkpointName;
40
41   /**
42    * Creates a new <code>ResetLogEvent</code> object
43    *
44    * @param oldCheckpointId the old id of the checkpoint
45    * @param newCheckpointId the new checkpoint identifier
46    * @param checkpointName the checkpoint name to delete from.
47    */

48   public ResetLogEvent(long oldCheckpointId, long newCheckpointId,
49       String JavaDoc checkpointName)
50   {
51     this.oldId = oldCheckpointId;
52     this.newId = newCheckpointId;
53     this.checkpointName = checkpointName;
54   }
55
56   /**
57    * @see org.continuent.sequoia.controller.recoverylog.events.LogEvent#belongToTransaction(long)
58    */

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

67   public void execute(LoggerThread loggerThread)
68   {
69     try
70     {
71       loggerThread.deleteCheckpointTable();
72       loggerThread.storeCheckpointWithLogId(checkpointName, newId);
73       loggerThread.deleteLogEntriesBeforeId(oldId);
74     }
75     catch (SQLException JavaDoc e)
76     {
77       loggerThread.invalidateLogStatements();
78       loggerThread.getLogger().error(
79           Translate.get("recovery.jdbc.loggerthread.log.reset.failed",
80               checkpointName), e);
81       // Push object back in the queue, it needs to be logged again
82
loggerThread.putBackAtHeadOfQueue(this, e);
83     }
84   }
85
86   /**
87    * @see java.lang.Object#toString()
88    */

89   public String JavaDoc toString()
90   {
91     return "ResetLogEvent for checkpoint " + checkpointName;
92   }
93
94 }
95
Popular Tags