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.common.log.Trace;
26: import org.continuent.sequoia.controller.recoverylog.LoggerThread;
27:
28: /**
29: * This class defines a LogRollbackEvent to log a rollback or potentially clean
30: * the recovery log for that transaction that rollbacks.
31: *
32: * @author <a href="mailto:emmanuel.cecchet@emicnetworks.com">Emmanuel Cecchet</a>
33: * @version 1.0
34: */
35: public class LogRollbackEvent extends LogRequestEvent {
36: /**
37: * Creates a new <code>LogRollbackEvent</code> object
38: *
39: * @param entry a log entry that describes a rollback (the SQL query is
40: * ignored)
41: */
42: public LogRollbackEvent(LogEntry entry) {
43: super (entry);
44: }
45:
46: /**
47: * @see org.continuent.sequoia.controller.recoverylog.events.LogEvent#execute(org.continuent.sequoia.controller.recoverylog.LoggerThread)
48: */
49: public void execute(LoggerThread loggerThread) {
50: Trace logger = loggerThread.getLogger();
51:
52: // First let's try to remove the transaction from the log if no-one is
53: // currently processing the log
54: try {
55: if (!loggerThread.getRecoveryLog().isRecovering()) {
56: if (loggerThread.removeEmptyTransaction(logEntry
57: .getTid()))
58: return;
59: }
60: } catch (SQLException e) {
61: loggerThread.invalidateLogStatements();
62: logger.error(Translate.get(
63: "recovery.jdbc.loggerthread.log.failed",
64: new String[] { "rollback",
65: String.valueOf(logEntry.getTid()) }), e);
66: // Fallback to default logging
67: }
68:
69: // Ok, someone has a lock on the log, just log the rollback.
70: super.execute(loggerThread);
71: }
72:
73: }
|