KickJava   Java API By Example, From Geeks To Geeks.

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


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 Checchet.
19  * Contributor(s): Olivier Fambon.
20  */

21
22 package org.continuent.sequoia.controller.recoverylog.events;
23
24 import java.io.Serializable JavaDoc;
25
26 /**
27  * This class defines a recovery log entry that needs to be stored in the
28  * recovery database. This is also sent over the wire between controllers, when
29  * copying recovery log entries to a remote controller (copyLogFromCheckpoint).
30  *
31  * @author <a HREF="mailto:emmanuel.cecchet@emicnetworks.com">Emmanuel Cecchet
32  * </a>
33  * @version 1.0
34  */

35 public class LogEntry implements Serializable JavaDoc
36 {
37   private static final long serialVersionUID = 1363084035201225164L;
38
39   private String JavaDoc autoConnTrans;
40   private String JavaDoc executionStatus;
41   private long tid;
42   private String JavaDoc query;
43   private String JavaDoc queryParams;
44   private String JavaDoc login;
45   private long logId;
46   private boolean escapeProcessing = false;
47   private long requestId = 0;
48   private long executionTimeInMs = 0;
49   private int updateCountResult = -1;
50   private long completionLogId = -1;
51
52   /**
53    * auto_conn_trans value for a request in autoCommit mode (no persistent
54    * connection)
55    */

56   public static final String JavaDoc AUTOCOMMIT = "A";
57   /** auto_conn_trans value for a persistent connection */
58   public static final String JavaDoc PERSISTENT_CONNECTION = "C";
59   /** auto_conn_trans value for a transaction */
60   public static final String JavaDoc TRANSACTION = "T";
61
62   /** Execution status value to executing */
63   public static final String JavaDoc EXECUTING = "E";
64   /** Execution status value to success */
65   public static final String JavaDoc SUCCESS = "S";
66   /** Execution status value to failed */
67   public static final String JavaDoc FAILED = "F";
68   /** Execution status value to unknown */
69   public static final String JavaDoc UNKNOWN = "U";
70   /** Status that will be used if the statement is not found in the recovery log */
71   public static final String JavaDoc MISSING = "M";
72
73   /**
74    * Create a log entry with a default execution status set to EXECUTING.
75    *
76    * @param logId the recovery log unique id
77    * @param login login used for this request
78    * @param query query to log
79    * @param queryParams query parameters if this is a PreparedStatement
80    * @param autoConnTrans AUTOCOMMIT, PERSISTENT_CONNECTION or TRANSACTION
81    * @param tid transaction id of this request
82    */

83   public LogEntry(long logId, String JavaDoc login, String JavaDoc query, String JavaDoc queryParams,
84       String JavaDoc autoConnTrans, long tid)
85   {
86     if (query == null)
87       throw new NullPointerException JavaDoc("Invalid null query in log entry");
88     if (login == null)
89       throw new NullPointerException JavaDoc("Invalid null login in log entry");
90
91     this.logId = logId;
92     this.login = login;
93     this.query = query;
94     this.queryParams = queryParams;
95     this.autoConnTrans = autoConnTrans;
96     this.tid = tid;
97     this.executionStatus = EXECUTING;
98   }
99
100   /**
101    * Create a log object.
102    *
103    * @param logId the recovery log unique id
104    * @param login login used for this request
105    * @param query query to log
106    * @param queryParams query parameters if this is a PreparedStatement
107    * @param autoConnTrans 'A' if autoCommit, 'C' if persistent connection, 'T'
108    * if transaction
109    * @param tid transaction id of this request
110    * @param escapeProcessing true if escape processing must be done
111    * @param requestId the unique request id
112    * @param executionTime the estimated execution time of the request in
113    * milliseconds
114    * @param updateCountResult the result of this query if it returned an update
115    * count
116    */

117   public LogEntry(long logId, String JavaDoc login, String JavaDoc query, String JavaDoc queryParams,
118       String JavaDoc autoConnTrans, long tid, boolean escapeProcessing, long requestId,
119       long executionTime, int updateCountResult)
120   {
121     this(logId, login, query, queryParams, autoConnTrans, tid,
122         escapeProcessing, requestId, executionTime);
123     this.updateCountResult = updateCountResult;
124   }
125
126   /**
127    * Create a log object.
128    *
129    * @param logId the recovery log unique id
130    * @param login login used for this request
131    * @param query query to log
132    * @param queryParams query parameters if this is a PreparedStatement
133    * @param autoConnTrans 'A' if autoCommit, 'C' if persistent connection, 'T'
134    * if transaction
135    * @param tid transaction id of this request
136    * @param escapeProcessing true if escape processing must be done
137    * @param requestId the unique request id
138    * @param executionTime the estimated execution time of the request in
139    * milliseconds
140    * @param updateCountResult the result of this query if it returned an update
141    * count
142    * @param status execution status as defined in LogEntry constants
143    * @param completionLogId the last log id that had been assigned when
144    * this request completed
145    */

146   public LogEntry(long logId, String JavaDoc login, String JavaDoc query, String JavaDoc queryParams,
147       String JavaDoc autoConnTrans, long tid, boolean escapeProcessing, long requestId,
148       long executionTime, int updateCountResult, String JavaDoc status, long completionLogId)
149   {
150     this(logId, login, query, queryParams, autoConnTrans, tid,
151         escapeProcessing, requestId, executionTime, updateCountResult);
152     this.executionStatus = status;
153     this.completionLogId = completionLogId;
154   }
155
156   /**
157    * Create a log object.
158    *
159    * @param logId the recovery log unique id
160    * @param login login used for this request
161    * @param query query to log
162    * @param queryParams query parameters if this is a PreparedStatement
163    * @param autoConnTrans 'A' if autoCommit, 'C' if persistent connection, 'T'
164    * if transaction
165    * @param tid transaction id of this request
166    * @param escapeProcessing true if escape processing must be done
167    * @param requestId the unique request id
168    * @param executionTime the estimated execution time of the request in
169    * milliseconds
170    */

171   public LogEntry(long logId, String JavaDoc login, String JavaDoc query, String JavaDoc queryParams,
172       String JavaDoc autoConnTrans, long tid, boolean escapeProcessing, long requestId,
173       long executionTime)
174   {
175     this(logId, login, query, queryParams, autoConnTrans, tid);
176     this.escapeProcessing = escapeProcessing;
177     this.requestId = requestId;
178     this.executionTimeInMs = executionTime;
179   }
180
181   /**
182    * Returns the autoConnTrans value.
183    *
184    * @return Returns the autoConnTrans.
185    */

186   public String JavaDoc getAutoConnTrans()
187   {
188     return autoConnTrans;
189   }
190
191   /**
192    * @return true if escape processing is needed
193    */

194   public boolean getEscapeProcessing()
195   {
196     return escapeProcessing;
197   }
198
199   /**
200    * Returns the executionStatus value.
201    *
202    * @return Returns the executionStatus.
203    */

204   public final String JavaDoc getExecutionStatus()
205   {
206     return executionStatus;
207   }
208
209   /**
210    * Sets the executionStatus value.
211    *
212    * @param executionStatus The executionStatus to set.
213    */

214   public final void setExecutionStatus(String JavaDoc executionStatus)
215   {
216     this.executionStatus = executionStatus;
217   }
218
219   /**
220    * Returns the executionTime value.
221    *
222    * @return Returns the executionTime.
223    */

224   public long getExecutionTimeInMs()
225   {
226     return executionTimeInMs;
227   }
228
229   /**
230    * @return the request id
231    */

232   public long getLogId()
233   {
234     return logId;
235   }
236
237   /**
238    * @return the login used for this request
239    */

240   public String JavaDoc getLogin()
241   {
242     return login;
243   }
244
245   /**
246    * @return the request itself
247    */

248   public String JavaDoc getQuery()
249   {
250     return query;
251   }
252
253   /**
254    * Returns the queryParams value.
255    *
256    * @return Returns the queryParams.
257    */

258   public final String JavaDoc getQueryParams()
259   {
260     return queryParams;
261   }
262
263   /**
264    * Returns the requestId value.
265    *
266    * @return Returns the requestId.
267    */

268   public long getRequestId()
269   {
270     return requestId;
271   }
272
273   /**
274    * @return the transaction id
275    */

276   public long getTid()
277   {
278     return tid;
279   }
280
281   /**
282    * Returns the result value.
283    *
284    * @return Returns the result.
285    */

286   public int getUpdateCountResult()
287   {
288     return updateCountResult;
289   }
290
291   /**
292    * Sets the logId value.
293    *
294    * @param logId The logId to set.
295    */

296   public final void setLogId(long logId)
297   {
298     this.logId = logId;
299   }
300
301   /**
302    * Retrieves the value of the completionLogId. This is the highest
303    * assigned logId when this request completed. This is a conservation
304    * indicator of the requests that were concurrently active. This is
305    * used to prevent unsafe parallel execution during recovery.
306    *
307    * @return the value of the completionLogId
308    */

309   public long getCompletionLogId()
310   {
311     return completionLogId;
312   }
313
314   /**
315    * Sets the value of the completionLogId
316    *
317    * @param completionLogId the new value
318    */

319   public void setCompletionLogId(long completionLogId)
320   {
321     this.completionLogId = completionLogId;
322   }
323
324   /**
325    * @see java.lang.Object#toString()
326    */

327   public String JavaDoc toString()
328   {
329     return "Log entry: log id" + logId + " (" + autoConnTrans
330         + ") transactionId:" + tid + " requestId:" + requestId + " vlogin:"
331         + login + " status: " + executionStatus + " sql:" + query + " params:"
332         + queryParams + " completionLogId: " + completionLogId;
333   }
334
335 }
Popular Tags