KickJava   Java API By Example, From Geeks To Geeks.

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


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.controller.recoverylog.LoggerThread;
27
28 /**
29  * This class defines a GetNumberOfLogEntriesEvent that finds a number of log
30  * entries available between 2 log id boundaries.
31  *
32  * @author <a HREF="mailto:emmanuel.cecchet@emicnetworks.com">Emmanuel Cecchet</a>
33  * @version 1.0
34  */

35 public class GetNumberOfLogEntriesEvent implements LogEvent
36 {
37   private long lowerId;
38   private long upperId;
39   private long nbOfLogEntries;
40
41   /**
42    * Creates a new <code>GetNumberOfLogEntriesEvent</code> object
43    *
44    * @param lowerLogId the lower log id
45    * @param upperLogId the upper log id
46    */

47   public GetNumberOfLogEntriesEvent(long lowerLogId, long upperLogId)
48   {
49     this.lowerId = lowerLogId;
50     this.upperId = upperLogId;
51   }
52
53   /**
54    * @see org.continuent.sequoia.controller.recoverylog.events.LogEvent#belongToTransaction(long)
55    */

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

64   public void execute(LoggerThread loggerThread)
65   {
66     try
67     {
68       nbOfLogEntries = loggerThread.getNumberOfLogEntries(lowerId, upperId);
69     }
70     catch (SQLException JavaDoc e)
71     {
72       loggerThread.invalidateLogStatements();
73       loggerThread.getLogger().error(
74           "Failed to retrieve number of log entries", e);
75       // Push object back in the queue, it needs to be logged again
76
loggerThread.putBackAtHeadOfQueue(this, e);
77     }
78     finally
79     {
80       synchronized (this)
81       {
82         notify();
83       }
84     }
85   }
86
87   /**
88    * Returns the nbOfLogEntries value. This value can only be retrieved after
89    * complete execution of the event.
90    *
91    * @return Returns the nbOfLogEntries.
92    */

93   public long getNbOfLogEntries()
94   {
95     return nbOfLogEntries;
96   }
97
98   /**
99    * @see java.lang.Object#toString()
100    */

101   public String JavaDoc toString()
102   {
103     return "Get number of log entries between " + lowerId + " and " + upperId;
104   }
105
106 }
107
Popular Tags