com.continuent.tungsten.replicator.backup
Class FileSystemStorageAgent

java.lang.Object
  extended by com.continuent.tungsten.replicator.backup.FileSystemStorageAgent
All Implemented Interfaces:
BackupPlugin, StorageAgent

public class FileSystemStorageAgent
extends java.lang.Object
implements StorageAgent

Implements a storage agent to store files in a directory on the file system. This could be on a shared file system, e.g., using NFS. To use this storage clients must at least set the directory location to hold files.

Version:
1.0
Author:
Robert Hodges

Constructor Summary
FileSystemStorageAgent()
           
 
Method Summary
 void configure()
          Complete plug-in configuration.
protected  long copyFile(java.io.File fromFile, java.io.File toFile)
           
protected  java.net.URI createUri(java.io.File file)
           
 boolean delete(java.net.URI uri)
          Deletes the indicated backup if it exists.
 boolean deleteAll()
          Deletes all backups.
protected  java.lang.String formatErrorMessage(java.lang.String message, java.net.URI uri, java.io.File file)
           
 java.io.File getDirectory()
          Returns the directory location of the storage service.
 int getRetention()
          Returns the number of backup files that should be retained before deleting old files.
 StorageSpecification getSpecification(java.net.URI uri)
          Returns the storage specification of a particular backup or null if no such specification exists.
 boolean isCrcCheckingEnabled()
          Returns true if CRC checking is enabled.
 java.net.URI last()
          Returns the URI of the most recent backup in storage or null if no backups exist
 StorageSpecification[] list()
          Returns the storage specifications of all backups in storage ordered from oldest to most recent.
protected  StorageIndex loadAndIncrementStorageIndex()
           
protected  TungstenProperties loadProperties(java.io.File propFile, java.lang.String exceptionMessage)
           
 void release()
          Release all resources used by plug-in.
protected  long renameFile(java.io.File fromFile, java.io.File toFile)
           
 BackupSpecification retrieve(java.net.URI uri)
          Retrieves the backup corresponding to a particular URI.
 void setCrcCheckingEnabled(boolean crcCheckingEnabled)
          Enables CRC checking on retrieved files.
 void setDirectory(java.io.File directory)
          Sets the directory location of the storage service.
 void setRetention(int numberOfBackups)
          Sets the number of backup files to retain.
 java.net.URI store(BackupSpecification backupSpec)
          Stores a backup described by a particular backup specification, returning the URL of the backup.
protected  void storeProperties(java.io.File propFile, TungstenProperties props, java.lang.String exceptionMessage)
           
protected  void validateUri(java.net.URI uri)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileSystemStorageAgent

public FileSystemStorageAgent()
Method Detail

getRetention

public int getRetention()
Returns the number of backup files that should be retained before deleting old files.

Specified by:
getRetention in interface StorageAgent
See Also:
StorageAgent.getRetention()

setRetention

public void setRetention(int numberOfBackups)
Sets the number of backup files to retain.

Specified by:
setRetention in interface StorageAgent
See Also:
StorageAgent.setRetention(int)

getDirectory

public java.io.File getDirectory()
Returns the directory location of the storage service.


setDirectory

public void setDirectory(java.io.File directory)
Sets the directory location of the storage service.


isCrcCheckingEnabled

public boolean isCrcCheckingEnabled()
Returns true if CRC checking is enabled.


setCrcCheckingEnabled

public void setCrcCheckingEnabled(boolean crcCheckingEnabled)
Enables CRC checking on retrieved files.

Parameters:
crcCheckingEnabled -

list

public StorageSpecification[] list()
                            throws BackupException
Returns the storage specifications of all backups in storage ordered from oldest to most recent.

Specified by:
list in interface StorageAgent
Throws:
BackupException
See Also:
StorageAgent.list()

last

public java.net.URI last()
                  throws BackupException
Returns the URI of the most recent backup in storage or null if no backups exist

Specified by:
last in interface StorageAgent
Throws:
BackupException
See Also:
StorageAgent.last()

getSpecification

public StorageSpecification getSpecification(java.net.URI uri)
                                      throws BackupException
Returns the storage specification of a particular backup or null if no such specification exists.

Specified by:
getSpecification in interface StorageAgent
Throws:
BackupException
See Also:
StorageAgent.getSpecification(java.net.URI)

retrieve

public BackupSpecification retrieve(java.net.URI uri)
                             throws BackupException
Retrieves the backup corresponding to a particular URI.

Specified by:
retrieve in interface StorageAgent
Throws:
BackupException
See Also:
StorageAgent.retrieve(java.net.URI)

store

public java.net.URI store(BackupSpecification backupSpec)
                   throws BackupException
Stores a backup described by a particular backup specification, returning the URL of the backup.

Specified by:
store in interface StorageAgent
Throws:
BackupException
See Also:
StorageAgent.store(com.continuent.tungsten.replicator.backup.BackupSpecification)

delete

public boolean delete(java.net.URI uri)
               throws BackupException
Deletes the indicated backup if it exists.

Specified by:
delete in interface StorageAgent
Returns:
True if backup was found and deleted, otherwise false
Throws:
BackupException
See Also:
StorageAgent.delete(java.net.URI)

deleteAll

public boolean deleteAll()
                  throws BackupException
Deletes all backups.

Specified by:
deleteAll in interface StorageAgent
Returns:
True if all backups were successfully deleted (also returns true if there are no backups found)
Throws:
BackupException
See Also:
StorageAgent.deleteAll()

configure

public void configure()
               throws BackupException
Complete plug-in configuration. This is called after setters are invoked.

Specified by:
configure in interface BackupPlugin
Throws:
BackupException
See Also:
BackupPlugin.configure()

release

public void release()
             throws BackupException
Release all resources used by plug-in. This is called before the plug-in is deallocated.

Specified by:
release in interface BackupPlugin
Throws:
BackupException
See Also:
BackupPlugin.release()

validateUri

protected void validateUri(java.net.URI uri)
                    throws BackupException
Throws:
BackupException

loadAndIncrementStorageIndex

protected StorageIndex loadAndIncrementStorageIndex()
                                             throws BackupException
Throws:
BackupException

loadProperties

protected TungstenProperties loadProperties(java.io.File propFile,
                                            java.lang.String exceptionMessage)
                                     throws BackupException
Throws:
BackupException

storeProperties

protected void storeProperties(java.io.File propFile,
                               TungstenProperties props,
                               java.lang.String exceptionMessage)
                        throws BackupException
Throws:
BackupException

renameFile

protected long renameFile(java.io.File fromFile,
                          java.io.File toFile)
                   throws BackupException
Throws:
BackupException

copyFile

protected long copyFile(java.io.File fromFile,
                        java.io.File toFile)
                 throws BackupException
Throws:
BackupException

formatErrorMessage

protected java.lang.String formatErrorMessage(java.lang.String message,
                                              java.net.URI uri,
                                              java.io.File file)

createUri

protected java.net.URI createUri(java.io.File file)
                          throws BackupException
Throws:
BackupException