KickJava   Java API By Example, From Geeks To Geeks.

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


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

35 public class ShiftLogEntriesEvent implements LogEvent
36 {
37   private long fromId;
38   private long shift;
39
40   /**
41    * Creates a new <code>ResetLogEvent</code> object
42    *
43    * @param fromId the id to start shifting from
44    * @param shift the increase to apply to log ids
45    */

46   public ShiftLogEntriesEvent(long fromId, long shift)
47   {
48     this.fromId = fromId;
49     this.shift = shift;
50   }
51
52   /**
53    * @see org.continuent.sequoia.controller.recoverylog.events.LogEvent#belongToTransaction(long)
54    */

55   public boolean belongToTransaction(long tid)
56   {
57     return false;
58   }
59
60   /**
61    * @see org.continuent.sequoia.controller.recoverylog.events.LogEvent#execute(org.continuent.sequoia.controller.recoverylog.LoggerThread)
62    */

63   public void execute(LoggerThread loggerThread)
64   {
65     try
66     {
67       loggerThread.shiftLogEntriesAfterId(fromId, shift);
68     }
69     catch (SQLException JavaDoc e)
70     {
71       loggerThread.invalidateLogStatements();
72       loggerThread.getLogger().error(
73           Translate.get("recovery.jdbc.loggerthread.shift.failed", e
74               .getMessage()), e);
75       // Push object back in the queue, it needs to be logged again
76
loggerThread.putBackAtHeadOfQueue(this, e);
77     }
78   }
79
80   /**
81    * @see java.lang.Object#toString()
82    */

83   public String JavaDoc toString()
84   {
85     return "Shift log entries from " + fromId + " with shift of " + shift;
86   }
87
88 }
89
Popular Tags