org.objectweb.cjdbc.controller.backup
Class OctopusBackuper

java.lang.Object
  extended byorg.objectweb.cjdbc.controller.backup.OctopusBackuper
All Implemented Interfaces:
Backuper

public class OctopusBackuper
extends java.lang.Object
implements Backuper

This class defines a Backuper based on Octopus v2.8.

The only option supported by this Backuper is 'zip=[true,false]' which defines if the dump directory must be compressed in a zip file.

Version:
1.0
Author:
Emmanuel Cecchet , Nicolas Modrzyk

Nested Class Summary
(package private)  class OctopusBackuper.DumpTransferServerThread
           
 
Field Summary
private static java.lang.String COPY_MODE
           
private static java.lang.String[] CSV
           
private static int DB_NAME
           
private static int DRIVER
           
private static int FULL_NAME
           
private static java.lang.String[] HSQL
           
private static java.lang.String[] JTURBO
           
(package private) static Trace logger
           
private static java.lang.String[] MSSQL
           
private static java.lang.String[] MYSQL
           
private static java.lang.String OCTOPUS_INCLUDE_HREF
           
private static java.lang.String[] ORACLE
           
private static java.lang.String[] POSTGRESQL
           
private static int PREFIX_URL
           
private static java.lang.String TYPE_CSV
           
(package private) static java.util.Hashtable TYPES
           
private  boolean zipBackupFiles
           
 
Constructor Summary
OctopusBackuper()
          Creates a new OctopusBackuper object
 
Method Summary
 java.util.Date backup(DatabaseBackend backend, java.lang.String login, java.lang.String password, java.lang.String dumpName, java.lang.String path, java.util.ArrayList tables)
          Create a backup from the content of a backend.
private  void callOctopusLoader(java.lang.String sourceType, java.lang.String sourceUrl, java.lang.String sourceDriver, java.lang.String sourceUser, java.lang.String sourcePassword, java.lang.String targetType, java.lang.String targetDriver, java.lang.String targetUrl, java.lang.String targetUser, java.lang.String targetPassword, boolean backup, boolean generateAllVendors, java.lang.String octopusDir)
           
private  void cleanUp(java.lang.String octopusDir)
           
private  java.lang.String[] convertTablesToArray(java.util.ArrayList tablesList)
           
private  java.lang.String createCsvDir(java.lang.String octopusDir)
           
private  java.lang.String createOctopusDir(java.lang.String path, java.lang.String dumpName)
           
 void deleteDump(java.lang.String path, java.lang.String dumpName)
          Delete the specified dump.
 void fetchDump(DumpTransferInfo dumpTransferInfo, java.lang.String path, java.lang.String dumpName)
          Client side: Fetch a remote dump from specified dump server.
 BackupManager getBackupManager()
          Return the BackupManager this Backuper belongs to.
private  java.lang.String getDatabaseType(java.lang.String url)
           
 java.lang.String getDumpFormat()
          Returns a String representing the format handled by this Backuper.
private  java.lang.String getLoaderJobFile(java.lang.String octopusDir)
           
private  java.lang.String getOctopusDriver(java.lang.String type)
          Get octopus driver.
private  java.lang.String getOctopusType(java.lang.String type)
          Get octopus type.
 java.lang.String getOptions()
          Retrieve the backuper options that were used to initialize the backuper.
private  java.lang.String getUrlPrefix(java.lang.String type)
          Get Octopus url prefix
private  void launchOctopus(java.lang.String octopusDir, java.lang.String dumpName, java.util.ArrayList tables)
          This start octopus with previously generated LoaderJob file
private  void redirectOutputStream()
           
 void restore(DatabaseBackend backend, java.lang.String login, java.lang.String password, java.lang.String dumpName, java.lang.String path, java.util.ArrayList tables)
          Restore a dump on a specific backend.
private  void setOctopusLoaderJob(java.lang.String octopusDir, java.lang.String sourceType)
           
 void setOptions(java.lang.String options)
          Options that can be set at backuper initialization.
 DumpTransferInfo setupServer()
          Server side: setup a server and returns a DumpTransferInfo suitable for authenticated communication by a client using fetchDump().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

static Trace logger

zipBackupFiles

private boolean zipBackupFiles

DB_NAME

private static final int DB_NAME
See Also:
Constant Field Values

DRIVER

private static final int DRIVER
See Also:
Constant Field Values

FULL_NAME

private static final int FULL_NAME
See Also:
Constant Field Values

PREFIX_URL

private static final int PREFIX_URL
See Also:
Constant Field Values

HSQL

private static final java.lang.String[] HSQL

CSV

private static final java.lang.String[] CSV

MYSQL

private static final java.lang.String[] MYSQL

POSTGRESQL

private static final java.lang.String[] POSTGRESQL

ORACLE

private static final java.lang.String[] ORACLE

JTURBO

private static final java.lang.String[] JTURBO

MSSQL

private static final java.lang.String[] MSSQL

TYPES

static final java.util.Hashtable TYPES

TYPE_CSV

private static final java.lang.String TYPE_CSV
See Also:
Constant Field Values

COPY_MODE

private static final java.lang.String COPY_MODE
See Also:
Constant Field Values

OCTOPUS_INCLUDE_HREF

private static final java.lang.String OCTOPUS_INCLUDE_HREF
See Also:
Constant Field Values
Constructor Detail

OctopusBackuper

public OctopusBackuper()
Creates a new OctopusBackuper object

Method Detail

getDumpFormat

public java.lang.String getDumpFormat()
Description copied from interface: Backuper
Returns a String representing the format handled by this Backuper. This field should be human readable and as detailed as possible so that no confusion can be made by the administrator.

Specified by:
getDumpFormat in interface Backuper
Returns:
the Backuper specific format
See Also:
Backuper.getDumpFormat()

backup

public java.util.Date backup(DatabaseBackend backend,
                             java.lang.String login,
                             java.lang.String password,
                             java.lang.String dumpName,
                             java.lang.String path,
                             java.util.ArrayList tables)
                      throws BackupException
Description copied from interface: Backuper
Create a backup from the content of a backend.

Specified by:
backup in interface Backuper
Parameters:
backend - the target backend to backup
login - the login to use to connect to the database for the backup operation
password - the password to use to connect to the database for the backup operation
dumpName - the name of the dump to create
path - the path where to store the dump
tables - the list of tables to backup, null means all tables
Returns:
the timestamp for the dump if the backup was sucessful, null otherwise
Throws:
BackupException - if the backup operation fails
See Also:
Backuper.backup(org.objectweb.cjdbc.controller.backend.DatabaseBackend, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.util.ArrayList)

restore

public void restore(DatabaseBackend backend,
                    java.lang.String login,
                    java.lang.String password,
                    java.lang.String dumpName,
                    java.lang.String path,
                    java.util.ArrayList tables)
             throws BackupException
Description copied from interface: Backuper
Restore a dump on a specific backend.

Specified by:
restore in interface Backuper
Parameters:
backend - the target backend to restore to
login - the login to use to connect to the database for the restore operation
password - the password to use to connect to the database for the restore operation
dumpName - the name of the dump to restore
path - the path where to retrieve the dump
tables - the list of tables to restore, null means all tables
Throws:
BackupException - if the restore operation failed
See Also:
Backuper.restore(org.objectweb.cjdbc.controller.backend.DatabaseBackend, java.lang.String, java.lang.String, java.lang.String, java.lang.String, java.util.ArrayList)

deleteDump

public void deleteDump(java.lang.String path,
                       java.lang.String dumpName)
                throws BackupException
Description copied from interface: Backuper
Delete the specified dump.

Specified by:
deleteDump in interface Backuper
Parameters:
path - the path where to retrieve the dump
dumpName - the dump to delete
Throws:
BackupException - if we failed to delete the dump
See Also:
Backuper.deleteDump(java.lang.String, java.lang.String)

callOctopusLoader

private void callOctopusLoader(java.lang.String sourceType,
                               java.lang.String sourceUrl,
                               java.lang.String sourceDriver,
                               java.lang.String sourceUser,
                               java.lang.String sourcePassword,
                               java.lang.String targetType,
                               java.lang.String targetDriver,
                               java.lang.String targetUrl,
                               java.lang.String targetUser,
                               java.lang.String targetPassword,
                               boolean backup,
                               boolean generateAllVendors,
                               java.lang.String octopusDir)
                        throws OctopusException
Throws:
OctopusException

launchOctopus

private void launchOctopus(java.lang.String octopusDir,
                           java.lang.String dumpName,
                           java.util.ArrayList tables)
                    throws OctopusException
This start octopus with previously generated LoaderJob file

Parameters:
octopusDir - the working directory
tables - the list of tables to backup, null means all tables
Throws:
OctopusException - if octopus fails

cleanUp

private void cleanUp(java.lang.String octopusDir)

convertTablesToArray

private java.lang.String[] convertTablesToArray(java.util.ArrayList tablesList)

createOctopusDir

private java.lang.String createOctopusDir(java.lang.String path,
                                          java.lang.String dumpName)
                                   throws BackupException
Throws:
BackupException

createCsvDir

private java.lang.String createCsvDir(java.lang.String octopusDir)
                               throws BackupException
Throws:
BackupException

getDatabaseType

private java.lang.String getDatabaseType(java.lang.String url)
                                  throws BackupException
Throws:
BackupException

getLoaderJobFile

private java.lang.String getLoaderJobFile(java.lang.String octopusDir)

redirectOutputStream

private void redirectOutputStream()

setOctopusLoaderJob

private void setOctopusLoaderJob(java.lang.String octopusDir,
                                 java.lang.String sourceType)
                          throws OctopusException
Throws:
OctopusException

getOctopusType

private java.lang.String getOctopusType(java.lang.String type)
Get octopus type.

Parameters:
type - from url
Returns:
value from hashtable or null

getOctopusDriver

private java.lang.String getOctopusDriver(java.lang.String type)
Get octopus driver.

Parameters:
type - from url
Returns:
value from hashtable or null

getUrlPrefix

private java.lang.String getUrlPrefix(java.lang.String type)
Get Octopus url prefix

Parameters:
type - from url
Returns:
value from hashtable or null

getOptions

public java.lang.String getOptions()
Description copied from interface: Backuper
Retrieve the backuper options that were used to initialize the backuper.

Specified by:
getOptions in interface Backuper
Returns:
the backuper options
See Also:
Backuper.getOptions()

setOptions

public void setOptions(java.lang.String options)
Description copied from interface: Backuper
Options that can be set at backuper initialization. These options are provided in the definition of the Backuper element (see dtd).

Specified by:
setOptions in interface Backuper
Parameters:
options - Backuper specific options
See Also:
Backuper.setOptions(java.lang.String)

getBackupManager

public BackupManager getBackupManager()
Description copied from interface: Backuper
Return the BackupManager this Backuper belongs to.

Specified by:
getBackupManager in interface Backuper
Returns:
the BackupManager this Backuper belongs to.
See Also:
Backuper.getBackupManager()

fetchDump

public void fetchDump(DumpTransferInfo dumpTransferInfo,
                      java.lang.String path,
                      java.lang.String dumpName)
               throws BackupException,
                      java.io.IOException
Description copied from interface: Backuper
Client side: Fetch a remote dump from specified dump server.

Specified by:
fetchDump in interface Backuper
Parameters:
dumpTransferInfo - the address and session key of the dump server to contact for fetching.
path - the path part of the remote dump spec (interpreted by server)
dumpName - the name part of the remote dump spec (interpreted by server)
Throws:
BackupException - in any error case: authentication error, transfer error, else.
java.io.IOException - if an error occurs during the transfer
See Also:
Backuper.fetchDump(org.objectweb.cjdbc.controller.backup.DumpTransferInfo, java.lang.String, java.lang.String)

setupServer

public DumpTransferInfo setupServer()
                             throws java.io.IOException
Description copied from interface: Backuper
Server side: setup a server and returns a DumpTransferInfo suitable for authenticated communication by a client using fetchDump().

Specified by:
setupServer in interface Backuper
Returns:
a DumpTransferInfo to be used by a client for authenticated communication upon fetchDump invocation.
Throws:
java.io.IOException - if an error occurs during the transfer
See Also:
Backuper.setupServer()


Copyright © 2002, 2005 - ObjectWeb Consortium - All Rights Reserved.