KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > continuent > sequoia > controller > virtualdatabase > protocol > InitiateDumpCopy


1 /**
2  * Sequoia: Database clustering technology.
3  * Copyright (C) 2005 Emic Networks.
4  * Contact: sequoia@continuent.org
5  *
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * 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): Damian Arregui.
21  */

22
23 package org.continuent.sequoia.controller.virtualdatabase.protocol;
24
25 import java.io.IOException JavaDoc;
26 import java.io.Serializable JavaDoc;
27
28 import org.continuent.hedera.common.Member;
29 import org.continuent.sequoia.common.exceptions.BackupException;
30 import org.continuent.sequoia.common.exceptions.ControllerException;
31 import org.continuent.sequoia.common.exceptions.VirtualDatabaseException;
32 import org.continuent.sequoia.common.jmx.management.DumpInfo;
33 import org.continuent.sequoia.controller.backup.Backuper;
34 import org.continuent.sequoia.controller.backup.DumpTransferInfo;
35 import org.continuent.sequoia.controller.virtualdatabase.DistributedVirtualDatabase;
36
37 /**
38  * This message is used to prepare the sending of a dump to a remote
39  * controller's vdb backup manager. This is used as an integrated remote-copy
40  * facility in the occurence of restore, e.g. after a rebuild of the remote
41  * recovery log from a live one. Upon reception of this message, the remote
42  * backup manager initiates a transfer onto the sending controller's backuper.
43  *
44  * @author <a HREF="mailto:Olivier.Fambon@emicnetworks.com>Olivier Fambon </a>
45  * @author <a HREF="mailto:Damian.Arregui@continuent.com>Damian Arregui </a> *
46  * @version 1.0
47  */

48 public class InitiateDumpCopy extends DistributedVirtualDatabaseMessage
49 {
50   private static final long serialVersionUID = 4674422809133556752L;
51
52   private DumpInfo dumpInfo;
53   private DumpTransferInfo dumpTransferInfo;
54
55   // private int timeout;
56

57   /**
58    * Creates a new <code>ReplicateLogEntries</code> message
59    *
60    * @param dumpInfo The DumpInfo object returned by the Backuper.
61    * @param dumpTransferInfo The dump transfer information
62    */

63   public InitiateDumpCopy(DumpInfo dumpInfo, DumpTransferInfo dumpTransferInfo)
64   {
65     this.dumpInfo = dumpInfo;
66     this.dumpTransferInfo = dumpTransferInfo;
67   }
68
69   /**
70    * Returns the dump info (name, checkpoint, etc).
71    *
72    * @return Returns the dump info (on the sending side).
73    */

74   public DumpInfo getDumpInfo()
75   {
76     return dumpInfo;
77   }
78
79   /**
80    * Returns the dump checkpoint name (global).
81    *
82    * @return Returns the dump CheckpointName.
83    */

84   public String JavaDoc getDumpCheckpointName()
85   {
86     return dumpInfo.getCheckpointName();
87   }
88
89   /**
90    * Return the dump name (sending side).
91    *
92    * @return the dump name (sending side).
93    */

94   public String JavaDoc getDumpName()
95   {
96     return dumpInfo.getDumpName();
97   }
98
99   /**
100    * Returns the session key to be used to authenticate the destination on the
101    * sender.
102    *
103    * @return the session key
104    */

105   public DumpTransferInfo getDumpTransferInfo()
106   {
107     return dumpTransferInfo;
108   }
109
110   /**
111    * @see org.continuent.sequoia.controller.virtualdatabase.protocol.DistributedVirtualDatabaseMessage#handleMessageMultiThreaded(org.continuent.sequoia.controller.virtualdatabase.DistributedVirtualDatabase,
112    * org.continuent.hedera.common.Member, java.lang.Object)
113    */

114   public Serializable JavaDoc handleMessageMultiThreaded(
115       DistributedVirtualDatabase dvdb, Member sender,
116       Object JavaDoc handleMessageSingleThreadedResult)
117   {
118     try
119     {
120       // check that no dump already exists locally
121
if (!dvdb.isDumpNameAvailable(dumpInfo.getDumpName()))
122         return new ControllerException("Remote dump '" + dumpInfo.getDumpName()
123             + "' already exists.");
124
125       // hand-off copy to backuper, if a copy is required
126
if (dumpTransferInfo != null)
127       {
128         Backuper backuper = dvdb.getRequestManager().getBackupManager()
129             .getBackuperByFormat(dumpInfo.getDumpFormat());
130
131         backuper.fetchDump(dumpTransferInfo, dumpInfo.getDumpPath(), dumpInfo
132             .getDumpName());
133       }
134
135       // update local recovery log dump tables
136
dvdb.getRecoveryLog().setDumpInfo(dumpInfo);
137     }
138     catch (IOException JavaDoc e)
139     {
140       return new ControllerException(e);
141     }
142     catch (BackupException e)
143     {
144       return new ControllerException(e);
145     }
146     catch (VirtualDatabaseException e)
147     {
148       return new ControllerException(e);
149     }
150     return null;
151   }
152
153   /**
154    * @see org.continuent.sequoia.controller.virtualdatabase.protocol.DistributedVirtualDatabaseMessage#handleMessageSingleThreaded(org.continuent.sequoia.controller.virtualdatabase.DistributedVirtualDatabase,
155    * org.continuent.hedera.common.Member)
156    */

157   public Object JavaDoc handleMessageSingleThreaded(DistributedVirtualDatabase dvdb,
158       Member sender)
159   {
160     return null;
161   }
162
163 }
Popular Tags