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