Main Page | Packages | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | Related Pages

org.objectweb.cjdbc.controller.backup.BackupManager Class Reference

List of all members.

Public Member Functions

 BackupManager (String backupDir, boolean cleanBackupFiles, boolean zipBackupFiles, int numberOfBackups)
 BackupManager ()
void backup (DatabaseBackend backend, String checkpoint, ArrayList tables, BackupListener listener) throws BackupException
synchronized void getResult (DatabaseBackend backend, long waitTime) throws BackupException, OctopusException
void restore (DatabaseBackend backend, String checkpoint, ArrayList tables, BackupListener listener) throws BackupException
File[] listAvailableDumpFiles ()
String getBackupDir ()
void setBackupDir (String backupDir)
boolean isCleanBackupFiles ()
void setCleanBackupFiles (boolean cleanBackupFiles)
int getNumberOfBackups ()
void setNumberOfBackups (int numberOfBackups)
boolean isZipBackupFiles ()
void setZipBackupFiles (boolean zipBackupFiles)
String getXml ()

Static Package Attributes

Trace logger

Detailed Description

This class defines a BackupManager

Author:
Nicolas Modrzyk

Emmanuel Cecchet

Version:
1.0

Definition at line 50 of file BackupManager.java.


Constructor & Destructor Documentation

org.objectweb.cjdbc.controller.backup.BackupManager.BackupManager String  backupDir,
boolean  cleanBackupFiles,
boolean  zipBackupFiles,
int  numberOfBackups
 

Creates a new BackupManager object

Parameters:
backupDir the directory used for backup
cleanBackupFiles should we clean temp backup files
zipBackupFiles should we zip backup files
numberOfBackups number of backups before deleting others, not used

Definition at line 69 of file BackupManager.java.

00071   {
00072     this();
00073     this.backupDir = backupDir;
00074     this.cleanBackupFiles = cleanBackupFiles;
00075     this.zipBackupFiles = zipBackupFiles;
00076     this.numberOfBackups = numberOfBackups;
00077 
00078   }

org.objectweb.cjdbc.controller.backup.BackupManager.BackupManager  ) 
 

Creates a new BackupManager object

Definition at line 83 of file BackupManager.java.

00084   {
00085     threads = new Hashtable();
00086   }


Member Function Documentation

void org.objectweb.cjdbc.controller.backup.BackupManager.backup DatabaseBackend  backend,
String  checkpoint,
ArrayList  tables,
BackupListener  listener
throws BackupException
 

Create a backup from the content of a backend

Parameters:
backend the target backend to backup from
checkpoint the checkpoint name of the backup to create
tables the list of tables to consider for backup
listener handback object to notify
Exceptions:
BackupException if backup fails for unknown reasons

Definition at line 97 of file BackupManager.java.

00099   {
00100     logger.info(Translate.get("backup.manager.backuping.backend", new String[]{
00101         backend.getName(), checkpoint}));
00102     Octopus octopus = new Octopus(backend, checkpoint, tables);
00103     octopus.setZipOctopus(zipBackupFiles);
00104     octopus.setCleanOctopus(cleanBackupFiles);
00105     octopus.setOctopusDirectory(backupDir);
00106     octopus.setOctopusMode(Octopus.MODE_BACKUP);
00107     if (listener != null)
00108       octopus.setListener(listener);
00109     threads.put(backend, octopus);
00110     octopus.start();
00111   }

String org.objectweb.cjdbc.controller.backup.BackupManager.getBackupDir  ) 
 

Returns the backupDir value.

Returns:
Returns the backupDir.

Definition at line 206 of file BackupManager.java.

00207   {
00208     return backupDir;
00209   }

int org.objectweb.cjdbc.controller.backup.BackupManager.getNumberOfBackups  ) 
 

Returns the numberOfBackups value.

Returns:
Returns the numberOfBackups.

Definition at line 246 of file BackupManager.java.

00247   {
00248     return numberOfBackups;
00249   }

synchronized void org.objectweb.cjdbc.controller.backup.BackupManager.getResult DatabaseBackend  backend,
long  waitTime
throws BackupException, OctopusException
 

Get the result of the backup/recovery process for the given backend

Parameters:
backend the backend we started a backup recovery process on
waitTime the time to wait to join the octopus thread
Exceptions:
BackupException if backup fails for unknown reasons
OctopusException if backup fails because of Octopus

Definition at line 121 of file BackupManager.java.

00123   {
00124     logger.info(Translate.get("backup.manager.waiting.backend.result",
00125         new String[]{backend.getName(), String.valueOf((waitTime / 1000))}));
00126     Octopus backup = (Octopus) threads.get(backend);
00127     try
00128     {
00129       backup.join(waitTime);
00130     }
00131     catch (InterruptedException e)
00132     {
00133       logger.error("Interrupted while joining on backend:" + backend.getName(),
00134           e);
00135     }
00136     Exception e = backup.getRunException();
00137     if (e != null)
00138     {
00139       if (e instanceof BackupException)
00140         throw (BackupException) e;
00141       else if (e instanceof OctopusException)
00142         throw (OctopusException) e;
00143     }
00144 
00145   }

String org.objectweb.cjdbc.controller.backup.BackupManager.getXml  ) 
 

See also:
org.objectweb.cjdbc.common.xml.XmlComponent.getXml()

Definition at line 284 of file BackupManager.java.

00285   {
00286     return "<" + DatabasesXmlTags.ELT_Backup + " " + DatabasesXmlTags.ATT_dir
00287         + "=\"" + backupDir + "\" " + DatabasesXmlTags.ATT_clean + "=\""
00288         + cleanBackupFiles + "\" " + DatabasesXmlTags.ATT_zip + "=\""
00289         + zipBackupFiles + "\" " + "/>";
00290   }

boolean org.objectweb.cjdbc.controller.backup.BackupManager.isCleanBackupFiles  ) 
 

Returns the cleanBackupFiles value.

Returns:
Returns the cleanBackupFiles.

Definition at line 226 of file BackupManager.java.

00227   {
00228     return cleanBackupFiles;
00229   }

boolean org.objectweb.cjdbc.controller.backup.BackupManager.isZipBackupFiles  ) 
 

Returns the zipBackupFiles value.

Returns:
Returns the zipBackupFiles.

Definition at line 266 of file BackupManager.java.

00267   {
00268     return zipBackupFiles;
00269   }

File [] org.objectweb.cjdbc.controller.backup.BackupManager.listAvailableDumpFiles  ) 
 

List all the files this backup manager has access to.

Returns:
a File[] object that can be empty, but cannot be null

See also:
java.io.FilenameFilter#accept(java.io.File, java.lang.String)

Definition at line 178 of file BackupManager.java.

00179   {
00180     File f = new File(backupDir);
00181     if (f.exists())
00182     {
00183       return f.listFiles(new FilenameFilter()
00184       {
00185         /**
00186          * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String)
00187          */
00188         public boolean accept(File dir, String name)
00189         {
00190           if (name.endsWith(Constants.ZIP_EXT))
00191             return true;
00192           else
00193             return false;
00194         }
00195       });
00196     }
00197     else
00198       return new File[0];
00199   }

void org.objectweb.cjdbc.controller.backup.BackupManager.restore DatabaseBackend  backend,
String  checkpoint,
ArrayList  tables,
BackupListener  listener
throws BackupException
 

Restore the content of a backup onto a specific backend

Parameters:
backend the target backend to restore to
checkpoint the checkpoint name of the backup to restore
tables the list of tables to consider for restore
listener handback object to notify
Exceptions:
BackupException if backup fails for unknown reasons

Definition at line 156 of file BackupManager.java.

00158   {
00159     logger.info(Translate.get("backup.manager.restoring.backend", new String[]{
00160         backend.getName(), checkpoint}));
00161     Octopus octopus = new Octopus(backend, checkpoint, tables);
00162     octopus.setZipOctopus(zipBackupFiles);
00163     octopus.setCleanOctopus(cleanBackupFiles);
00164     octopus.setOctopusDirectory(backupDir);
00165     if (listener != null)
00166       octopus.setListener(listener);
00167     octopus.setOctopusMode(Octopus.MODE_RECOVERY);
00168     threads.put(backend, octopus);
00169     octopus.start();
00170   }

void org.objectweb.cjdbc.controller.backup.BackupManager.setBackupDir String  backupDir  ) 
 

Sets the backupDir value.

Parameters:
backupDir The backupDir to set.

Definition at line 216 of file BackupManager.java.

00217   {
00218     this.backupDir = backupDir;
00219   }

void org.objectweb.cjdbc.controller.backup.BackupManager.setCleanBackupFiles boolean  cleanBackupFiles  ) 
 

Sets the cleanBackupFiles value.

Parameters:
cleanBackupFiles The cleanBackupFiles to set.

Definition at line 236 of file BackupManager.java.

00237   {
00238     this.cleanBackupFiles = cleanBackupFiles;
00239   }

void org.objectweb.cjdbc.controller.backup.BackupManager.setNumberOfBackups int  numberOfBackups  ) 
 

Sets the numberOfBackups value.

Parameters:
numberOfBackups The numberOfBackups to set.

Definition at line 256 of file BackupManager.java.

00257   {
00258     this.numberOfBackups = numberOfBackups;
00259   }

void org.objectweb.cjdbc.controller.backup.BackupManager.setZipBackupFiles boolean  zipBackupFiles  ) 
 

Sets the zipBackupFiles value.

Parameters:
zipBackupFiles The zipBackupFiles to set.

Definition at line 276 of file BackupManager.java.

00277   {
00278     this.zipBackupFiles = zipBackupFiles;
00279   }


Member Data Documentation

Trace org.objectweb.cjdbc.controller.backup.BackupManager.logger [static, package]
 

Initial value:

 Trace.getLogger(BackupManager.class
                                         .getName())

Definition at line 52 of file BackupManager.java.


The documentation for this class was generated from the following file:
Generated on Mon Apr 11 22:03:27 2005 for C-JDBC by  doxygen 1.3.9.1