KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > controller > recoverylog > events > LogCommitEvent


1 /**
2  * Sequoia: Database clustering technology.
3  * Copyright (C) 2005 Emic Networks.
4  * Contact: sequoia@continuent.org
5  *
6  * Licensed under the Apache License, Version 2.0 (the "License");
7  * you may not use this file except in compliance with the License.
8  * You may obtain a copy of the License at
9  *
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  */

21
22 package org.continuent.sequoia.controller.recoverylog.events;
23
24 import java.sql.SQLException JavaDoc;
25
26 import org.continuent.sequoia.common.i18n.Translate;
27 import org.continuent.sequoia.common.log.Trace;
28 import org.continuent.sequoia.controller.recoverylog.LoggerThread;
29
30 /**
31  * This class defines a LogCommitEvent to log a Commit or potentially clean the
32  * recovery log for that transaction that Commits.
33  *
34  * @author <a HREF="mailto:emmanuel.cecchet@emicnetworks.com">Emmanuel Cecchet</a>
35  * @version 1.0
36  */

37 public class LogCommitEvent extends LogRequestEvent
38 {
39   /**
40    * Creates a new <code>LogCommitEvent</code> object
41    *
42    * @param entry a log entry that describes a Commit (the SQL query is ignored)
43    */

44   public LogCommitEvent(LogEntry entry)
45   {
46     super(entry);
47   }
48
49   /**
50    * @see org.continuent.sequoia.controller.recoverylog.events.LogEvent#execute(org.continuent.sequoia.controller.recoverylog.LoggerThread)
51    */

52   public void execute(LoggerThread loggerThread)
53   {
54     Trace logger = loggerThread.getLogger();
55
56     // First let's try to remove the empty transaction (if empty) from the log
57
// if no-one is currently processing the log
58
try
59     {
60       if (!loggerThread.getRecoveryLog().isRecovering())
61       {
62         if (loggerThread.removeEmptyTransaction(logEntry.getTid()))
63           return;
64       }
65     }
66     catch (SQLException JavaDoc e)
67     {
68       loggerThread.invalidateLogStatements();
69       logger.error(Translate.get("recovery.jdbc.loggerthread.log.failed",
70           new String JavaDoc[]{"Commit", String.valueOf(logEntry.getTid())}), e);
71       // Fallback to default logging
72
}
73
74     // Ok, someone has a lock on the log, just log the Commit.
75
super.execute(loggerThread);
76   }
77
78 }
79
Popular Tags