01: /**
02: * Sequoia: Database clustering technology.
03: * Copyright (C) 2005 Emic Networks.
04: * Contact: sequoia@continuent.org
05: *
06: * Licensed under the Apache License, Version 2.0 (the "License");
07: * you may not use this file except in compliance with the License.
08: * You may obtain a copy of the License at
09: *
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: */package org.continuent.sequoia.controller.recoverylog.events;
21:
22: import java.sql.SQLException;
23:
24: import org.continuent.sequoia.common.i18n.Translate;
25: import org.continuent.sequoia.controller.recoverylog.LoggerThread;
26:
27: /**
28: * This class defines a ResetLogEvent to reset the log
29: *
30: * @author <a href="mailto:emmanuel.cecchet@emicnetworks.com">Emmanuel Cecchet</a>
31: * @version 1.0
32: */
33: public class ResetLogEvent implements LogEvent {
34: private long oldId;
35: private long newId;
36: private String checkpointName;
37:
38: /**
39: * Creates a new <code>ResetLogEvent</code> object
40: *
41: * @param oldCheckpointId the old id of the checkpoint
42: * @param newCheckpointId the new checkpoint identifier
43: * @param checkpointName the checkpoint name to delete from.
44: */
45: public ResetLogEvent(long oldCheckpointId, long newCheckpointId,
46: String checkpointName) {
47: this .oldId = oldCheckpointId;
48: this .newId = newCheckpointId;
49: this .checkpointName = checkpointName;
50: }
51:
52: /**
53: * @see org.continuent.sequoia.controller.recoverylog.events.LogEvent#belongToTransaction(long)
54: */
55: public boolean belongToTransaction(long tid) {
56: return false;
57: }
58:
59: /**
60: * @see org.continuent.sequoia.controller.recoverylog.events.LogEvent#execute(org.continuent.sequoia.controller.recoverylog.LoggerThread)
61: */
62: public void execute(LoggerThread loggerThread) {
63: try {
64: loggerThread.deleteCheckpointTable();
65: loggerThread
66: .storeCheckpointWithLogId(checkpointName, newId);
67: loggerThread.deleteLogEntriesBeforeId(oldId);
68: } catch (SQLException e) {
69: loggerThread.invalidateLogStatements();
70: loggerThread
71: .getLogger()
72: .error(
73: Translate
74: .get(
75: "recovery.jdbc.loggerthread.log.reset.failed",
76: checkpointName), e);
77: // Push object back in the queue, it needs to be logged again
78: loggerThread.putBackAtHeadOfQueue(this , e);
79: }
80: }
81:
82: /**
83: * @see java.lang.Object#toString()
84: */
85: public String toString() {
86: return "ResetLogEvent for checkpoint " + checkpointName;
87: }
88:
89: }
|