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): Stephane Giron.
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:stephane.giron@continuent.com">Stephane Giron</a>
31: * @version 1.0
32: */
33: public class DeleteLogEntriesAndCheckpointBetweenEvent implements
34: LogEvent {
35: private long fromId;
36: private long toId;
37:
38: /**
39: * Creates a new <code>DeleteLogEntriesAndCheckpointBetweenEvent</code>
40: * object. Used to delete a range of log entries in the recovery log.
41: *
42: * @param fromId the first id of the range
43: * @param toId the last id of the range
44: */
45: public DeleteLogEntriesAndCheckpointBetweenEvent(long fromId,
46: long toId) {
47: this .fromId = fromId;
48: this .toId = toId;
49: }
50:
51: /**
52: * @see org.continuent.sequoia.controller.recoverylog.events.LogEvent#belongToTransaction(long)
53: */
54: public boolean belongToTransaction(long tid) {
55: return false;
56: }
57:
58: /**
59: * @see org.continuent.sequoia.controller.recoverylog.events.LogEvent#execute(org.continuent.sequoia.controller.recoverylog.LoggerThread)
60: */
61: public void execute(LoggerThread loggerThread) {
62: try {
63: loggerThread.deleteLogEntriesAndCheckpointBetween(fromId,
64: toId);
65: } catch (SQLException e) {
66: loggerThread.invalidateLogStatements();
67: loggerThread.getLogger().error(
68: Translate.get(
69: "recovery.jdbc.loggerthread.shift.failed",
70: e.getMessage()), e);
71: // Push object back in the queue, it needs to be logged again
72: loggerThread.putBackAtHeadOfQueue(this , e);
73: }
74: }
75:
76: /**
77: * @see java.lang.Object#toString()
78: */
79: public String toString() {
80: return "Delete log entries from " + fromId + " to " + toId;
81: }
82:
83: }
|