KickJava   Java API By Example, From Geeks To Geeks.

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


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.controller.recoverylog.LoggerThread;
30
31 /**
32  * This class defines a ResetLogEvent to reset the log
33  *
34  * @author <a HREF="mailto:emmanuel.cecchet@emicnetworks.com">Emmanuel Cecchet</a>
35  * @version 1.0
36  */

37 public class ResetLogEvent implements LogEvent
38 {
39   private long oldId;
40   private long newId;
41   private String JavaDoc checkpointName;
42
43   /**
44    * Creates a new <code>ResetLogEvent</code> object
45    *
46    * @param oldCheckpointId the old id of the checkpoint
47    * @param newCheckpointId the new checkpoint identifier
48    * @param checkpointName the checkpoint name to delete from.
49    */

50   public ResetLogEvent(long oldCheckpointId, long newCheckpointId,
51       String JavaDoc checkpointName)
52   {
53     this.oldId = oldCheckpointId;
54     this.newId = newCheckpointId;
55     this.checkpointName = checkpointName;
56   }
57
58   /**
59    * @see org.objectweb.cjdbc.controller.recoverylog.events.LogEvent#belongToTransaction(long)
60    */

61   public boolean belongToTransaction(long tid)
62   {
63     return false;
64   }
65
66   /**
67    * @see org.objectweb.cjdbc.controller.recoverylog.events.LogEvent#execute(org.objectweb.cjdbc.controller.recoverylog.LoggerThread)
68    */

69   public void execute(LoggerThread loggerThread)
70   {
71     try
72     {
73       loggerThread.deleteCheckpointTable();
74       loggerThread.storeCheckpoint(checkpointName, newId);
75       loggerThread.deleteLogEntriesBeforeId(oldId);
76       loggerThread.shiftLogEntriesIds(newId - oldId);
77     }
78     catch (SQLException JavaDoc e)
79     {
80       loggerThread.invalidateLogStatements();
81       loggerThread.getLogger().error(
82           Translate.get("recovery.jdbc.loggerthread.log.reset.failed",
83               checkpointName), e);
84       // Push object back in the queue, it needs to be logged again
85
loggerThread.putBackAtHeadOfQueue(this);
86     }
87   }
88
89 }
90
Popular Tags