java.lang.Object
com.aoindustries.aoserv.backup.FileEnvironment
- All Implemented Interfaces:
BackupEnvironment
- Direct Known Subclasses:
MacOsXEnvironment
,PosixFileEnvironment
,WindowsEnvironment
A
BackupEnvironment
for files.- Author:
- AO Industries, Inc.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
cleanup
(FileReplication ffr) Called in a finally block after any backup-pass completes, no data will be obtained from the environment after this is called.Gets the default source IP address orInetAddress.UNSPECIFIED
to use the system default.long
getDeviceIdentifier
(FileReplication ffr, String filename) Gets the device file major and minor.String[]
getDirectoryList
(FileReplication ffr, String filename) Gets the listing for a directory.int
Gets the number of items per batch.A fast pseudo-random number generator for non-cryptographic purposes.protected File
getFile
(FileReplication ffr, String filename) Gets the file for the given path.Gets theIterator
of filenames ornull
if completed.protected abstract Map
<String, FilesystemIteratorRule> Gets the default set of filesystem prefix rules for this environment.protected abstract Map
<String, FilesystemIteratorRule> Gets the default set of filesystem rules for this environment.int
getGid
(FileReplication ffr, String filename) Gets the group ID.getInputStream
(FileReplication ffr, String filename) Gets a stream reading the file.long
getLength
(FileReplication ffr, String filename) Gets the length of the file.long
getModifyTime
(FileReplication ffr, String filename) Gets the modified time.getNameOfFile
(FileReplication ffr, String filename) Gets the name of a file (the part after the last slash).Gets the list of MySQL server versions (in the same order as the list returned bygetReplicatedMysqlServers
.Gets the list of MySQL server instance names that are being replicated.Gets the set of paths that must be found in the backup set.getServerPath
(FileReplication ffr, String filename) Converts an environment-specific filename into a server path.long
getStatMode
(FileReplication ffr, String filename) Gets the stat mode (or a generated and equivalent one) for a file.int
getUid
(FileReplication ffr, String filename) Gets the user ID.void
init
(FileReplication ffr) Called before any backup-pass data is retrieved from the environment.void
Called right after a backup pass ends.void
preBackup
(FileReplication ffr) Called right before a backup pass begins.readLink
(FileReplication ffr, String filename) Reads a symbolic link.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.aoindustries.aoserv.backup.BackupEnvironment
getConnector, getLogger, getThisHost
-
Constructor Details
-
FileEnvironment
public FileEnvironment()
-
-
Method Details
-
getFile
Gets the file for the given path. -
getStatMode
Description copied from interface:BackupEnvironment
Gets the stat mode (or a generated and equivalent one) for a file.- Specified by:
getStatMode
in interfaceBackupEnvironment
- Throws:
IOException
-
getDirectoryList
Description copied from interface:BackupEnvironment
Gets the listing for a directory.- Specified by:
getDirectoryList
in interfaceBackupEnvironment
- Throws:
IOException
-
getUid
Description copied from interface:BackupEnvironment
Gets the user ID.- Specified by:
getUid
in interfaceBackupEnvironment
- Throws:
IOException
-
getGid
Description copied from interface:BackupEnvironment
Gets the group ID.- Specified by:
getGid
in interfaceBackupEnvironment
- Throws:
IOException
-
getModifyTime
Description copied from interface:BackupEnvironment
Gets the modified time.- Specified by:
getModifyTime
in interfaceBackupEnvironment
- Throws:
IOException
-
getLength
Description copied from interface:BackupEnvironment
Gets the length of the file.- Specified by:
getLength
in interfaceBackupEnvironment
- Throws:
IOException
-
readLink
Description copied from interface:BackupEnvironment
Reads a symbolic link.- Specified by:
readLink
in interfaceBackupEnvironment
- Throws:
IOException
-
getDeviceIdentifier
Description copied from interface:BackupEnvironment
Gets the device file major and minor.- Specified by:
getDeviceIdentifier
in interfaceBackupEnvironment
- Throws:
IOException
-
getInputStream
Description copied from interface:BackupEnvironment
Gets a stream reading the file.- Specified by:
getInputStream
in interfaceBackupEnvironment
- Throws:
IOException
-
getNameOfFile
Description copied from interface:BackupEnvironment
Gets the name of a file (the part after the last slash).- Specified by:
getNameOfFile
in interfaceBackupEnvironment
-
getFailoverBatchSize
Description copied from interface:BackupEnvironment
Gets the number of items per batch. A higher value will consume more RAM but better hide latency.- Specified by:
getFailoverBatchSize
in interfaceBackupEnvironment
- Throws:
IOException
SQLException
-
preBackup
Description copied from interface:BackupEnvironment
Called right before a backup pass begins. Implementations should call super.preBackup first.The process is:
- preBackup
- init
- cleanup (always)
- postBackup (only when backup pass successful)
- Specified by:
preBackup
in interfaceBackupEnvironment
- Throws:
IOException
SQLException
-
init
Description copied from interface:BackupEnvironment
Called before any backup-pass data is retrieved from the environment.cleanup()
will also be called in a finally block. Implementations should call super.init first.- Specified by:
init
in interfaceBackupEnvironment
- Throws:
IOException
SQLException
- See Also:
-
cleanup
Description copied from interface:BackupEnvironment
Called in a finally block after any backup-pass completes, no data will be obtained from the environment after this is called. Implementations should call super.cleanup in a finally block.- Specified by:
cleanup
in interfaceBackupEnvironment
- Throws:
IOException
SQLException
- See Also:
-
postBackup
Description copied from interface:BackupEnvironment
Called right after a backup pass ends. Implementations should call super.postBackup last.- Specified by:
postBackup
in interfaceBackupEnvironment
- Throws:
IOException
SQLException
- See Also:
-
getRequiredFilenames
Description copied from interface:BackupEnvironment
Gets the set of paths that must be found in the backup set. These paths must not include any trailing separators.- Specified by:
getRequiredFilenames
in interfaceBackupEnvironment
- Throws:
IOException
SQLException
-
getFilenameIterator
Description copied from interface:BackupEnvironment
Gets theIterator
of filenames ornull
if completed.- Specified by:
getFilenameIterator
in interfaceBackupEnvironment
- Throws:
IOException
SQLException
-
getFilesystemIteratorRules
protected abstract Map<String,FilesystemIteratorRule> getFilesystemIteratorRules(FileReplication ffr) throws IOException, SQLException Gets the default set of filesystem rules for this environment. This should not include file backup settings, they will override the values returned here. The returned map may be modified, to maintain internal consistency, return a copy of the map if needed.- Throws:
IOException
SQLException
-
getFilesystemIteratorPrefixRules
protected abstract Map<String,FilesystemIteratorRule> getFilesystemIteratorPrefixRules(FileReplication ffr) throws IOException, SQLException Gets the default set of filesystem prefix rules for this environment.- Throws:
IOException
SQLException
-
getDefaultSourceIpAddress
Description copied from interface:BackupEnvironment
Gets the default source IP address orInetAddress.UNSPECIFIED
to use the system default.- Specified by:
getDefaultSourceIpAddress
in interfaceBackupEnvironment
- Throws:
IOException
SQLException
-
getReplicatedMysqlServers
public List<Server.Name> getReplicatedMysqlServers(FileReplication ffr) throws IOException, SQLException Description copied from interface:BackupEnvironment
Gets the list of MySQL server instance names that are being replicated. This is only used for failover mode (retention == 1), and should only be used for a replication that includes MySQL replication (Server only)- Specified by:
getReplicatedMysqlServers
in interfaceBackupEnvironment
- Throws:
IOException
SQLException
- See Also:
-
getReplicatedMysqlMinorVersions
public List<String> getReplicatedMysqlMinorVersions(FileReplication ffr) throws IOException, SQLException Description copied from interface:BackupEnvironment
Gets the list of MySQL server versions (in the same order as the list returned bygetReplicatedMysqlServers
. This is only used for failover mode (retention == 1), and should only be used for a replication that includes MySQL replication (Server only)- Specified by:
getReplicatedMysqlMinorVersions
in interfaceBackupEnvironment
- Throws:
IOException
SQLException
- See Also:
-
getFastRandom
A fast pseudo-random number generator for non-cryptographic purposes.Gets a Random source for the backup daemon. This does not need to be cryptographically strong because it is only used to randomize some sleep times to distribute load on the server processes.
Uses the random source from
AoservConnector.getFastRandom()
.- Specified by:
getFastRandom
in interfaceBackupEnvironment
-
getServerPath
Description copied from interface:BackupEnvironment
Converts an environment-specific filename into a server path. The server path must begin with /, may not contain /../, and must use / as the path separator.- Specified by:
getServerPath
in interfaceBackupEnvironment
-