01: /**
02: * Sequoia: Database clustering technology.
03: * Copyright (C) 2005 AmicoSoft, Inc. dba Emic Networks
04: * Copyright (C) 2005-2006 Continuent, Inc.
05: * Contact: sequoia@continuent.org
06: *
07: * Licensed under the Apache License, Version 2.0 (the "License");
08: * you may not use this file except in compliance with the License.
09: * You may obtain a copy of the License at
10: *
11: * http://www.apache.org/licenses/LICENSE-2.0
12: *
13: * Unless required by applicable law or agreed to in writing, software
14: * distributed under the License is distributed on an "AS IS" BASIS,
15: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16: * See the License for the specific language governing permissions and
17: * limitations under the License.
18: *
19: * Initial developer(s): Olivier Fambon.
20: * Contributor(s): Emmanuel Cecchet.
21: */package org.continuent.sequoia.controller.recoverylog.events;
22:
23: import java.sql.SQLException;
24:
25: import org.continuent.sequoia.controller.recoverylog.LoggerThread;
26:
27: /**
28: * This class is used to Store a Checkpoint in the recovery log checkpoint
29: * tables so that it is available e.g. for restore operations.
30: *
31: * @author <a href="mailto:olivier.fambon@emicnetworks.com">Olivier Fambon</a>
32: * @author <a href="mailto:emmanuel.cecchet@continuent.com">Emmanuel Cecchet</a>
33: * @version 1.0
34: */
35: public class StoreCheckpointWithLogIdEvent implements LogEvent {
36: private long checkpointId;
37: private String checkpointName;
38:
39: /**
40: * Creates a new <code>StoreCheckpointWithLogIdEvent</code> object
41: *
42: * @param checkpointName the checkpoint name to create.
43: * @param checkpointId the id of the checkpoint
44: */
45: public StoreCheckpointWithLogIdEvent(String checkpointName,
46: long checkpointId) {
47: this .checkpointId = checkpointId;
48: this .checkpointName = checkpointName;
49: }
50:
51: /**
52: * @see org.continuent.sequoia.controller.recoverylog.events.LogEvent#belongToTransaction(long)
53: */
54: public boolean belongToTransaction(long tid) {
55: return false;
56: }
57:
58: /**
59: * @see org.continuent.sequoia.controller.recoverylog.events.LogEvent#execute(org.continuent.sequoia.controller.recoverylog.LoggerThread)
60: */
61: public void execute(LoggerThread loggerThread) {
62: try {
63: loggerThread.storeCheckpointWithLogId(checkpointName,
64: checkpointId);
65: } catch (SQLException e) {
66: // Push object back in the queue, it needs to be logged again => potential
67: // infinite loop
68: loggerThread.putBackAtHeadOfQueue(this , e);
69: }
70: }
71:
72: /**
73: * @see java.lang.Object#toString()
74: */
75: public String toString() {
76: return "Storing checkpoint " + checkpointName + " with id "
77: + checkpointId;
78: }
79:
80: }
|