KickJava   Java API By Example, From Geeks To Geeks.

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


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 LogRollbackEvent to log a rollback or potentially clean
32  * the recovery log for that transaction that rollbacks.
33  *
34  * @author <a HREF="mailto:emmanuel.cecchet@emicnetworks.com">Emmanuel Cecchet</a>
35  * @version 1.0
36  */

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

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

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