KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > cjdbc > controller > backup > Backuper


1 /**
2  * C-JDBC: Clustered JDBC.
3  * Copyright (C) 2005 Emic Networks.
4  * Contact: c-jdbc@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published by the
8  * Free Software Foundation; either version 2.1 of the License, or any later
9  * version.
10  *
11  * This library is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
14  * for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this library; if not, write to the Free Software Foundation,
18  * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
19  *
20  * Initial developer(s): Emmanuel Cecchet.
21  * Contributor(s): ______________________.
22  */

23
24 package org.objectweb.cjdbc.controller.backup;
25
26 import java.io.IOException JavaDoc;
27 import java.util.ArrayList JavaDoc;
28 import java.util.Date JavaDoc;
29
30 import org.objectweb.cjdbc.common.exceptions.BackupException;
31 import org.objectweb.cjdbc.controller.backend.DatabaseBackend;
32
33 /**
34  * This interface defines a Backuper that is in charge of doing backup/restore
35  * operations and manage dumps according to its own internal format. The user
36  * will manipulate logical names and the Backuper is responsible to maintain the
37  * logical name/physical name mapping.
38  *
39  * @author <a HREF="mailto:emmanuel.cecchet@emicnetworks.com">Emmanuel Cecchet</a>
40  * @version 1.0
41  */

42 public interface Backuper
43 {
44
45   //
46
// Backuper information
47
//
48

49   /**
50    * Returns a String representing the format handled by this Backuper. This
51    * field should be human readable and as detailed as possible so that no
52    * confusion can be made by the administrator.
53    *
54    * @return the Backuper specific format
55    */

56   String JavaDoc getDumpFormat();
57
58   /**
59    * Retrieve the backuper options that were used to initialize the backuper.
60    *
61    * @return the backuper options
62    * @see #setOptions(String)
63    */

64   String JavaDoc getOptions();
65
66   /**
67    * Options that can be set at backuper initialization. These options are
68    * provided in the definition of the Backuper element (see dtd).
69    *
70    * @param options Backuper specific options
71    */

72   void setOptions(String JavaDoc options);
73
74   //
75
// Backup/Restore operations
76
//
77

78   /**
79    * Create a backup from the content of a backend.
80    *
81    * @param backend the target backend to backup
82    * @param login the login to use to connect to the database for the backup
83    * operation
84    * @param password the password to use to connect to the database for the
85    * backup operation
86    * @param dumpName the name of the dump to create
87    * @param path the path where to store the dump
88    * @param tables the list of tables to backup, null means all tables
89    * @return the timestamp for the dump if the backup was sucessful, null
90    * otherwise
91    * @throws BackupException if the backup operation fails
92    */

93   Date JavaDoc backup(DatabaseBackend backend, String JavaDoc login, String JavaDoc password,
94       String JavaDoc dumpName, String JavaDoc path, ArrayList JavaDoc tables) throws BackupException;
95
96   /**
97    * Restore a dump on a specific backend.
98    *
99    * @param backend the target backend to restore to
100    * @param login the login to use to connect to the database for the restore
101    * operation
102    * @param password the password to use to connect to the database for the
103    * restore operation
104    * @param dumpName the name of the dump to restore
105    * @param path the path where to retrieve the dump
106    * @param tables the list of tables to restore, null means all tables
107    * @throws BackupException if the restore operation failed
108    */

109   void restore(DatabaseBackend backend, String JavaDoc login, String JavaDoc password,
110       String JavaDoc dumpName, String JavaDoc path, ArrayList JavaDoc tables) throws BackupException;
111
112   //
113
// Dump manipulation functions
114
//
115

116   /**
117    * Delete the specified dump.
118    *
119    * @param path the path where to retrieve the dump
120    * @param dumpName the dump to delete
121    * @throws BackupException if we failed to delete the dump
122    */

123   void deleteDump(String JavaDoc path, String JavaDoc dumpName) throws BackupException;
124
125   //
126
// Remote dump copy
127
//
128

129   /**
130    * Client side: Fetch a remote dump from specified dump server.
131    *
132    * @param dumpTransferInfo the address and session key of the dump server to
133    * contact for fetching.
134    * @param path the path part of the remote dump spec (interpreted by server)
135    * @param dumpName the name part of the remote dump spec (interpreted by
136    * server)
137    * @throws BackupException in any error case: authentication error, transfer
138    * error, else.
139    * @throws IOException if an error occurs during the transfer
140    */

141   void fetchDump(DumpTransferInfo dumpTransferInfo, String JavaDoc path, String JavaDoc dumpName)
142       throws BackupException, IOException JavaDoc;
143
144   /**
145    * Server side: setup a server and returns a DumpTransferInfo suitable for
146    * authenticated communication by a client using fetchDump().
147    *
148    * @return a DumpTransferInfo to be used by a client for authenticated
149    * communication upon fetchDump invocation.
150    * @throws IOException if an error occurs during the transfer
151    */

152   DumpTransferInfo setupServer() throws IOException JavaDoc;
153
154   // The idea is to have the BackupManager
155
// - supposed to be singleton, per controller -
156
// implement common client/server-side features, for use by Backupers.
157
/**
158    * Return the BackupManager this Backuper belongs to.
159    *
160    * @return the BackupManager this Backuper belongs to.
161    */

162   BackupManager getBackupManager();
163
164 }
165
Popular Tags