001: /**
002: * Sequoia: Database clustering technology.
003: * Copyright (C) 2005 Emic Networks.
004: * Contact: sequoia@continuent.org
005: *
006: *
007: * Licensed under the Apache License, Version 2.0 (the "License");
008: * you may not use this file except in compliance with the License.
009: * You may obtain a copy of the License at
010: *
011: * http://www.apache.org/licenses/LICENSE-2.0
012: *
013: * Unless required by applicable law or agreed to in writing, software
014: * distributed under the License is distributed on an "AS IS" BASIS,
015: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016: * See the License for the specific language governing permissions and
017: * limitations under the License.
018: *
019: * Initial developer(s): Olivier Fambon.
020: * Contributor(s): Damian Arregui.
021: */package org.continuent.sequoia.controller.virtualdatabase.protocol;
022:
023: import java.io.IOException;
024: import java.io.Serializable;
025:
026: import org.continuent.hedera.common.Member;
027: import org.continuent.sequoia.common.exceptions.BackupException;
028: import org.continuent.sequoia.common.exceptions.ControllerException;
029: import org.continuent.sequoia.common.exceptions.VirtualDatabaseException;
030: import org.continuent.sequoia.common.jmx.management.DumpInfo;
031: import org.continuent.sequoia.controller.backup.Backuper;
032: import org.continuent.sequoia.controller.backup.DumpTransferInfo;
033: import org.continuent.sequoia.controller.virtualdatabase.DistributedVirtualDatabase;
034:
035: /**
036: * This message is used to prepare the sending of a dump to a remote
037: * controller's vdb backup manager. This is used as an integrated remote-copy
038: * facility in the occurence of restore, e.g. after a rebuild of the remote
039: * recovery log from a live one. Upon reception of this message, the remote
040: * backup manager initiates a transfer onto the sending controller's backuper.
041: *
042: * @author <a href="mailto:Olivier.Fambon@emicnetworks.com>Olivier Fambon </a>
043: * @author <a href="mailto:Damian.Arregui@continuent.com>Damian Arregui </a> *
044: * @version 1.0
045: */
046: public class InitiateDumpCopy extends DistributedVirtualDatabaseMessage {
047: private static final long serialVersionUID = 4674422809133556752L;
048:
049: private DumpInfo dumpInfo;
050: private DumpTransferInfo dumpTransferInfo;
051:
052: // private int timeout;
053:
054: /**
055: * Creates a new <code>ReplicateLogEntries</code> message
056: *
057: * @param dumpInfo The DumpInfo object returned by the Backuper.
058: * @param dumpTransferInfo The dump transfer information
059: */
060: public InitiateDumpCopy(DumpInfo dumpInfo,
061: DumpTransferInfo dumpTransferInfo) {
062: this .dumpInfo = dumpInfo;
063: this .dumpTransferInfo = dumpTransferInfo;
064: }
065:
066: /**
067: * Returns the dump info (name, checkpoint, etc).
068: *
069: * @return Returns the dump info (on the sending side).
070: */
071: public DumpInfo getDumpInfo() {
072: return dumpInfo;
073: }
074:
075: /**
076: * Returns the dump checkpoint name (global).
077: *
078: * @return Returns the dump CheckpointName.
079: */
080: public String getDumpCheckpointName() {
081: return dumpInfo.getCheckpointName();
082: }
083:
084: /**
085: * Return the dump name (sending side).
086: *
087: * @return the dump name (sending side).
088: */
089: public String getDumpName() {
090: return dumpInfo.getDumpName();
091: }
092:
093: /**
094: * Returns the session key to be used to authenticate the destination on the
095: * sender.
096: *
097: * @return the session key
098: */
099: public DumpTransferInfo getDumpTransferInfo() {
100: return dumpTransferInfo;
101: }
102:
103: /**
104: * @see org.continuent.sequoia.controller.virtualdatabase.protocol.DistributedVirtualDatabaseMessage#handleMessageMultiThreaded(org.continuent.sequoia.controller.virtualdatabase.DistributedVirtualDatabase,
105: * org.continuent.hedera.common.Member, java.lang.Object)
106: */
107: public Serializable handleMessageMultiThreaded(
108: DistributedVirtualDatabase dvdb, Member sender,
109: Object handleMessageSingleThreadedResult) {
110: try {
111: // check that no dump already exists locally
112: if (!dvdb.isDumpNameAvailable(dumpInfo.getDumpName()))
113: return new ControllerException("Remote dump '"
114: + dumpInfo.getDumpName() + "' already exists.");
115:
116: // hand-off copy to backuper, if a copy is required
117: if (dumpTransferInfo != null) {
118: Backuper backuper = dvdb.getRequestManager()
119: .getBackupManager().getBackuperByFormat(
120: dumpInfo.getDumpFormat());
121:
122: backuper.fetchDump(dumpTransferInfo, dumpInfo
123: .getDumpPath(), dumpInfo.getDumpName());
124: }
125:
126: // update local recovery log dump tables
127: dvdb.getRecoveryLog().setDumpInfo(dumpInfo);
128: } catch (IOException e) {
129: return new ControllerException(e);
130: } catch (BackupException e) {
131: return new ControllerException(e);
132: } catch (VirtualDatabaseException e) {
133: return new ControllerException(e);
134: }
135: return null;
136: }
137:
138: /**
139: * @see org.continuent.sequoia.controller.virtualdatabase.protocol.DistributedVirtualDatabaseMessage#handleMessageSingleThreaded(org.continuent.sequoia.controller.virtualdatabase.DistributedVirtualDatabase,
140: * org.continuent.hedera.common.Member)
141: */
142: public Object handleMessageSingleThreaded(
143: DistributedVirtualDatabase dvdb, Member sender) {
144: return null;
145: }
146:
147: }
|