org.opends.server.types
Class BackupDirectory

java.lang.Object
  extended by org.opends.server.types.BackupDirectory

@PublicAPI(stability=VOLATILE,
           mayInstantiate=true,
           mayExtend=false,
           mayInvoke=true)
public final class BackupDirectory
extends java.lang.Object

This class defines a data structure for holding information about a filesystem directory that contains data for one or more backups associated with a backend. Only backups for a single backend may be placed in any given directory.


Field Summary
static java.lang.String PROPERTY_BACKEND_CONFIG_DN
          The name of the property that will be used to provide the DN of the configuration entry for the backend associated with the backups in this directory.
 
Constructor Summary
BackupDirectory(java.lang.String path, DN configEntryDN)
          Creates a new backup directory object with the provided information.
BackupDirectory(java.lang.String path, DN configEntryDN, java.util.LinkedHashMap<java.lang.String,BackupInfo> backups)
          Creates a new backup directory object with the provided information.
 
Method Summary
 void addBackup(BackupInfo backupInfo)
          Adds information about the provided backup to this backup directory.
 BackupInfo getBackupInfo(java.lang.String backupID)
          Retrieves the backup info structure for the backup with the specified ID.
 java.util.LinkedHashMap<java.lang.String,BackupInfo> getBackups()
          Retrieves the set of backups in this backup directory, as a mapping between the backup ID and the associated backup info.
 DN getConfigEntryDN()
          Retrieves the DN of the configuration entry for the backend with which this backup directory is associated.
 java.lang.String getDescriptorPath()
          Retrieves a path to the backup descriptor file that should be used for this backup directory.
 BackupInfo getLatestBackup()
          Retrieves the most recent backup for this backup directory, according to the backup date.
 java.lang.String getPath()
          Retrieves the path to the directory containing the backup file(s).
static BackupDirectory readBackupDirectoryDescriptor(java.lang.String path)
          Reads the backup descriptor file in the specified path and uses the information it contains to create a new backup directory structure.
 void removeBackup(java.lang.String backupID)
          Removes the backup with the specified backup ID from this backup directory.
 void writeBackupDirectoryDescriptor()
          Writes the descriptor with the information contained in this structure to disk in the appropriate directory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROPERTY_BACKEND_CONFIG_DN

public static final java.lang.String PROPERTY_BACKEND_CONFIG_DN
The name of the property that will be used to provide the DN of the configuration entry for the backend associated with the backups in this directory.

See Also:
Constant Field Values
Constructor Detail

BackupDirectory

public BackupDirectory(java.lang.String path,
                       DN configEntryDN)
Creates a new backup directory object with the provided information.

Parameters:
path - The path to the directory containing the backup file(s).
configEntryDN - The DN of the configuration entry for the backend with which this backup directory is associated.

BackupDirectory

public BackupDirectory(java.lang.String path,
                       DN configEntryDN,
                       java.util.LinkedHashMap<java.lang.String,BackupInfo> backups)
Creates a new backup directory object with the provided information.

Parameters:
path - The path to the directory containing the backup file(s).
configEntryDN - The DN of the configuration entry for the backend with which this backup directory is associated.
backups - Information about the set of backups available within the specified directory.
Method Detail

getPath

public java.lang.String getPath()
Retrieves the path to the directory containing the backup file(s).

Returns:
The path to the directory containing the backup file(s).

getConfigEntryDN

public DN getConfigEntryDN()
Retrieves the DN of the configuration entry for the backend with which this backup directory is associated.

Returns:
The DN of the configuration entry for the backend with which this backup directory is associated.

getBackups

public java.util.LinkedHashMap<java.lang.String,BackupInfo> getBackups()
Retrieves the set of backups in this backup directory, as a mapping between the backup ID and the associated backup info. The iteration order for the map will be the order in which the backups were created.

Returns:
The set of backups in this backup directory.

getBackupInfo

public BackupInfo getBackupInfo(java.lang.String backupID)
Retrieves the backup info structure for the backup with the specified ID.

Parameters:
backupID - The backup ID for the structure to retrieve.
Returns:
The requested backup info structure, or null if no such structure exists.

getLatestBackup

public BackupInfo getLatestBackup()
Retrieves the most recent backup for this backup directory, according to the backup date.

Returns:
The most recent backup for this backup directory, according to the backup date, or null if there are no backups in the backup directory.

addBackup

public void addBackup(BackupInfo backupInfo)
               throws ConfigException
Adds information about the provided backup to this backup directory.

Parameters:
backupInfo - The backup info structure for the backup to be added.
Throws:
ConfigException - If another backup already exists with the same backup ID.

removeBackup

public void removeBackup(java.lang.String backupID)
                  throws ConfigException
Removes the backup with the specified backup ID from this backup directory.

Parameters:
backupID - The backup ID for the backup to remove from this backup directory.
Throws:
ConfigException - If it is not possible to remove the requested backup for some reason (e.g., no such backup exists, or another backup is dependent on it).

getDescriptorPath

public java.lang.String getDescriptorPath()
Retrieves a path to the backup descriptor file that should be used for this backup directory.

Returns:
A path to the backup descriptor file that should be used for this backup directory.

writeBackupDirectoryDescriptor

public void writeBackupDirectoryDescriptor()
                                    throws java.io.IOException
Writes the descriptor with the information contained in this structure to disk in the appropriate directory.

Throws:
java.io.IOException - If a problem occurs while writing to disk.

readBackupDirectoryDescriptor

public static BackupDirectory readBackupDirectoryDescriptor(java.lang.String path)
                                                     throws java.io.IOException,
                                                            ConfigException
Reads the backup descriptor file in the specified path and uses the information it contains to create a new backup directory structure.

Parameters:
path - The path to the directory containing the backup descriptor file to read.
Returns:
The backup directory structure created from the contents of the descriptor file.
Throws:
java.io.IOException - If a problem occurs while trying to read the contents of the descriptor file.
ConfigException - If the contents of the descriptor file cannot be parsed to create a backup directory structure.