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