KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > controller > recoverylog > events > LogRollbackEvent


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2005 Emic Networks.
4  * Contact: c-jdbc@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published by the
8  * Free Software Foundation; either version 2.1 of the License, or any later
9  * version.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14  * for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library; if not, write to the Free Software Foundation,
18  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19  *
20  * Initial developer(s): Emmanuel Cecchet.
21  * Contributor(s): ______________________.
22  */

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

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

47   public LogRollbackEvent(LogEntry entry)
48   {
49     super(entry);
50   }
51
52   /**
53    * @see org.objectweb.cjdbc.controller.recoverylog.events.LogEvent#execute(org.objectweb.cjdbc.controller.recoverylog.LoggerThread)
54    */

55   public void execute(LoggerThread loggerThread)
56   {
57     Trace logger = loggerThread.getLogger();
58
59     // Fist let's try to remove the transaction from the log if no-one is
60
// currently processing the log
61
try
62     {
63       if (!loggerThread.getRecoveryLog().isRecovering())
64       {
65         loggerThread.removeRollbackedTransaction(logEntry.getId());
66         return;
67       }
68     }
69     catch (SQLException JavaDoc e)
70     {
71       loggerThread.invalidateLogStatements();
72       logger.error(Translate.get("recovery.jdbc.loggerthread.log.failed",
73           new String JavaDoc[]{"rollback", String.valueOf(logEntry.getTid())}), e);
74       // Push object back in the queue, it needs to be logged again
75
loggerThread.putBackAtHeadOfQueue(this);
76     }
77
78     // Ok, someone has a lock on the log, just log the rollback.
79
super.execute(loggerThread);
80   }
81
82 }
83
Popular Tags