Public Member Functions | |
Octopus (DatabaseBackend database, String dumpName) throws BackupException | |
Octopus (DatabaseBackend database, String dumpName, boolean backupMode) throws BackupException | |
Octopus (DatabaseBackend database, String dumpName, ArrayList tables, boolean backupMode) throws BackupException | |
Octopus (DatabaseBackend database, String dumpName, ArrayList tables) throws BackupException | |
void | backup () throws BackupException, OctopusException |
void | restore () throws BackupException, OctopusException |
void | run () |
void | sanityCheck () throws BackupException |
boolean | deleteDir (File dir) |
boolean | isCleanOctopus () |
boolean | isZipOctopus () |
final String | getOctopusDirectory () |
Exception | getRunException () |
final void | setOctopusDirectory (String path) |
void | setOctopusMode (int mode) |
void | setCleanOctopus (boolean cleanOctopus) |
void | setListener (BackupListener listener) |
void | setZipOctopus (boolean zipOctopus) |
Static Public Attributes | |
final int | MODE_BACKUP = 0 |
final int | MODE_RECOVERY = 1 |
Package Functions | |
final Hashtable | getOctopusStrings (DatabaseBackend database) throws BackupException |
final void | generateMetadata (String sourceType, String sourceUrl, String sourceDriver, String sourceUser, String sourcePassword, String targetType, String targetDriver, String targetUrl, String targetUser, String targetPassword, boolean backup) throws OctopusException |
final void | prepareOctopus (String sourceType, String sourceUrl, String sourceDriver, String sourceUser, String sourcePassword, String targetType, String targetDriver, String targetUrl, String targetUser, String targetPassword, boolean backup) throws OctopusException |
final void | callOctopusLoader (String sourceType, String sourceUrl, String sourceDriver, String sourceUser, String sourcePassword, String targetType, String targetDriver, String targetUrl, String targetUser, String targetPassword, boolean backup, boolean generateAllVendors) throws OctopusException |
Static Package Functions | |
[static initializer] | |
Package Attributes | |
boolean | cleanOctopus = false |
boolean | zipOctopus = true |
Static Package Attributes | |
Trace | logger |
final String | TYPE_CSV = "csv" |
final String | COPY_MODE = "copy" |
final String | OVERRIDE_MODE = "sync" |
final String | GENERATE_DOC = "sql" |
final String | OCTOPUS_LOG_FILE = "octopusLog.txt" |
final int | ZIP_MODE_CREATE = 0 |
final int | ZIP_MODE_EXPAND = 1 |
final int | OCTOPUS_MODE_FROM_CSV = 0 |
final int | OCTOPUS_MODE_TO_CSV = 1 |
String | mainDirectory |
Definition at line 66 of file Octopus.java.
|
Instanciate hook to octopus
Definition at line 124 of file Octopus.java. 00126 { 00127 logger = Trace.getLogger(this.getClass().getName()); 00128 // Prepare references 00129 this.database = database; 00130 this.dumpName = dumpName; 00131 this.tables = null; 00132 00133 // Retrieve information 00134 getUserLogin(); 00135 setPaths(); 00136 }
|
|
Creates a new
Definition at line 147 of file Octopus.java. 00149 { 00150 this(database, dumpName); 00151 this.backupMode = backupMode; 00152 }
|
|
Use Octopus only for a set of tables
Definition at line 163 of file Octopus.java. 00165 { 00166 this(database, dumpName, backupMode); 00167 this.tables = tables; 00168 }
|
|
Use Octopus only for a set of tables
Definition at line 178 of file Octopus.java. 00180 { 00181 this(database, dumpName); 00182 this.tables = tables; 00183 }
|
|
Convert database to csv and zip the files
Definition at line 191 of file Octopus.java. References org.objectweb.cjdbc.controller.backup.Octopus.prepareOctopus(), and org.objectweb.cjdbc.controller.backup.Octopus.sanityCheck(). Referenced by org.objectweb.cjdbc.controller.backup.Octopus.callOctopusLoader(), org.objectweb.cjdbc.controller.backup.Octopus.prepareOctopus(), and org.objectweb.cjdbc.controller.backup.Octopus.run(). 00192 { 00193 sanityCheck(); 00194 prepareOctopus(OCTOPUS_MODE_TO_CSV); 00195 launchOctopus(); 00196 if (zipOctopus) 00197 zipOctopus(ZIP_MODE_CREATE); 00198 if (cleanOctopus) 00199 cleanUp(); 00200 }
|
|
Generate all the metadata Definition at line 376 of file Octopus.java. References org.objectweb.cjdbc.controller.backup.Octopus.backup(). Referenced by org.objectweb.cjdbc.controller.backup.Octopus.prepareOctopus(). 00381 { 00382 try 00383 { 00384 if (logger.isDebugEnabled()) 00385 { 00386 logger.debug("Source Type:" + sourceType); 00387 logger.debug("Source Driver:" + sourceDriver); 00388 logger.debug("Source URL :" + sourceUrl); 00389 logger.debug("Source User :" + sourceUser); 00390 logger.debug("Target Type:" + targetType); 00391 logger.debug("Target Driver:" + targetDriver); 00392 logger.debug("Target URL:" + targetUrl); 00393 logger.debug("Target User :" + targetUser); 00394 if (backup) 00395 logger.debug("Backup Mode"); 00396 else 00397 logger.debug("Restore Mode"); 00398 logger.debug("Generate SQL for all vendors :" + generateAllVendors); 00399 } 00400 LoaderGenerator loader = new LoaderGenerator(sourceType, // sourceType 00401 sourceUrl, // sourceDatabase Url? 00402 COPY_MODE, // valueMode 00403 octopusDir, // generatorOutput 00404 sourceDriver, // sourceDriverName 00405 targetDriver, // TargetDriverName 00406 targetUrl, // targetDataBase 00407 targetType, // TargetType 00408 sourceUser, // sourceUser 00409 sourcePassword, // sourcePassword 00410 targetUser, // targetUser 00411 targetPassword, //targetPassword 00412 "", // domlPath 00413 "org.webdoc.util.loader", // package name 00414 "true", // generate drop table stmt 00415 "true", // generate drop integrity statement 00416 "true", // generate create table stmt 00417 "true", // generate create pk statement 00418 "true", // generate create fk statement 00419 "true", // generate create index stmt 00420 String.valueOf(generateAllVendors), // generate 00421 // sql 00422 // for 00423 // all 00424 // vendors 00425 String.valueOf(!generateAllVendors), // generate 00426 // xml 00427 "false", // generate doml 00428 String.valueOf(!generateAllVendors), // full 00429 // mode 00430 // ?? 00431 String.valueOf(!backup), // restore mode 00432 null, //convertTablesToSemicolonSeparatedList(database.getTables()), 00433 // // tables list 00434 null // Jar file structure 00435 ); 00436 loader.generate(); 00437 } 00438 catch (Exception e) 00439 { 00440 throw new OctopusException(e); 00441 } 00442 }
|
|
Delete a directory by deleting all sub files
Definition at line 311 of file Octopus.java. 00312 { 00313 if (dir.isDirectory()) 00314 { 00315 String[] children = dir.list(); 00316 for (int i = 0; i < children.length; i++) 00317 { 00318 boolean success = deleteDir(new File(dir, children[i])); 00319 if (!success) 00320 { 00321 return false; 00322 } 00323 } 00324 } 00325 // The directory is now empty so delete it 00326 return dir.delete(); 00327 }
|
|
Retrieve the path for the octopus directory
Definition at line 478 of file Octopus.java. 00479 {
00480 return mainDirectory;
00481 }
|
|
Returns the runException value.
Definition at line 488 of file Octopus.java. 00489 {
00490 return runException;
00491 }
|
|
Returns the cleanOctopus value.
Definition at line 458 of file Octopus.java. 00459 {
00460 return cleanOctopus;
00461 }
|
|
Returns the zipOctopus value.
Definition at line 468 of file Octopus.java. 00469 {
00470 return zipOctopus;
00471 }
|
|
Prepare the loader job file for octopus Definition at line 360 of file Octopus.java. References org.objectweb.cjdbc.controller.backup.Octopus.backup(), and org.objectweb.cjdbc.controller.backup.Octopus.callOctopusLoader(). Referenced by org.objectweb.cjdbc.controller.backup.Octopus.backup(), and org.objectweb.cjdbc.controller.backup.Octopus.restore(). 00365 { 00366 if (logger.isDebugEnabled()) 00367 logger.debug("### Generating loader job ###"); 00368 callOctopusLoader(sourceType, sourceUrl, sourceDriver, sourceUser, 00369 sourcePassword, targetType, targetDriver, targetUrl, targetUser, 00370 targetPassword, backup, false); 00371 }
|
|
Recover database from zipped csv the files
Definition at line 208 of file Octopus.java. References org.objectweb.cjdbc.controller.backup.Octopus.prepareOctopus(). Referenced by org.objectweb.cjdbc.controller.backup.Octopus.run(). 00209 { 00210 if (zipOctopus) 00211 zipOctopus(ZIP_MODE_EXPAND); 00212 prepareOctopus(OCTOPUS_MODE_FROM_CSV); 00213 setOctopusLoaderJob(); 00214 launchOctopus(); 00215 if (cleanOctopus) 00216 cleanUp(); 00217 }
|
|
Definition at line 222 of file Octopus.java. References org.objectweb.cjdbc.controller.backup.Octopus.backup(), and org.objectweb.cjdbc.controller.backup.Octopus.restore(). 00223 { 00224 if (backupMode) 00225 try 00226 { 00227 database.setState(BackendState.BACKUPING); 00228 backup(); 00229 database.notifyJmx(CjdbcNotificationList.VIRTUALDATABASE_NEW_DUMP_LIST); 00230 // Backend keeps its dumpName (it should have disabled with dumpName 00231 // prior this backup operation). 00232 database.setState(BackendState.DISABLED); 00233 if (listener != null) 00234 listener.success(database.getName()); 00235 } 00236 catch (Exception e) 00237 { 00238 database.setState(BackendState.UNKNOWN); 00239 runException = e; 00240 if (listener != null) 00241 listener.failure(database.getName(), e); 00242 } 00243 else 00244 { 00245 try 00246 { 00247 database.setState(BackendState.RECOVERING); 00248 restore(); 00249 // Set the dumpName corresponding to this database dump 00250 database.setLastKnownCheckpoint(dumpName); 00251 database.setState(BackendState.DISABLED); 00252 if (listener != null) 00253 listener.success(database.getName()); 00254 } 00255 catch (Exception e1) 00256 { 00257 database.setState(BackendState.UNKNOWN); 00258 runException = e1; 00259 if (listener != null) 00260 listener.failure(database.getName(), e1); 00261 } 00262 } 00263 00264 // Wake up everybody waiting on the listener 00265 if (listener != null) 00266 { 00267 synchronized (listener) 00268 { 00269 listener.notifyAll(); 00270 } 00271 } 00272 }
|
|
Check if backup can be executed.
Definition at line 279 of file Octopus.java. Referenced by org.objectweb.cjdbc.controller.backup.Octopus.backup(). 00280 { 00281 boolean notEnabled = false, noPendingRequests = false; 00282 if (database.isReadEnabled() == false) 00283 notEnabled = true; 00284 00285 Vector pending = database.getPendingRequests(); 00286 int size = pending.size(); 00287 noPendingRequests = (size == 0) ? true : false; 00288 if (logger.isDebugEnabled()) 00289 { 00290 if (!noPendingRequests) 00291 { 00292 for (int i = 0; i < size; i++) 00293 { 00294 logger.debug("Pending:" + pending.get(i).toString()); 00295 } 00296 } 00297 logger.debug("Pending Requests:" + database.getPendingRequests().size()); 00298 logger.debug("Read enabled:" + database.isReadEnabled()); 00299 logger.debug("Write enabled:" + database.isWriteEnabled()); 00300 } 00301 if (!(notEnabled && noPendingRequests)) 00302 throw new BackupException(Translate.get("backend.not.ready.for.backup")); 00303 }
|
|
Sets the cleanOctopus value.
Definition at line 531 of file Octopus.java. 00532 {
00533 this.cleanOctopus = cleanOctopus;
00534 }
|
|
Set the callback listener of this octopus process
Definition at line 541 of file Octopus.java. 00542 {
00543 this.listener = listener;
00544 }
|
|
Set the default path of octopus directory to a new one
Definition at line 498 of file Octopus.java. 00499 { 00500 mainDirectory = path; 00501 }
|
|
When used as a thread Octopus needs to know if this will be a backup or restore operation.
Definition at line 510 of file Octopus.java. References org.objectweb.cjdbc.controller.backup.Octopus.MODE_BACKUP, and org.objectweb.cjdbc.controller.backup.Octopus.MODE_RECOVERY. 00511 { 00512 switch (mode) 00513 { 00514 case MODE_BACKUP : 00515 this.backupMode = true; 00516 break; 00517 case MODE_RECOVERY : 00518 this.backupMode = false; 00519 break; 00520 default : 00521 throw new RuntimeException("Invalid mode " + mode 00522 + " in setOctopusMode"); 00523 } 00524 }
|
|
Sets the zipOctopus value.
Definition at line 551 of file Octopus.java. 00552 {
00553 this.zipOctopus = zipOctopus;
00554 }
|
|
Initial value: ".." + File.separator + "backup" Definition at line 108 of file Octopus.java. |
|
Mode for backup using octopus Definition at line 93 of file Octopus.java. Referenced by org.objectweb.cjdbc.controller.backup.Octopus.setOctopusMode(). |
|
Mode for recovery using octopus Definition at line 95 of file Octopus.java. Referenced by org.objectweb.cjdbc.controller.backup.Octopus.setOctopusMode(). |