Package org.opends.server.backup
Class FileSystemBackupStorage
- java.lang.Object
-
- org.opends.server.backup.FileSystemBackupStorage
-
- All Implemented Interfaces:
Closeable,AutoCloseable,BackupStorage
public final class FileSystemBackupStorage extends Object implements BackupStorage
A backup storage implementation that reads and writes files in a file system directory.
-
-
Constructor Summary
Constructors Constructor Description FileSystemBackupStorage(Path backupDirectory)Creates a new data storage for reading and writing files in the provided directory.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddeleteIfExists(String fileName)Deletes the file with the provided name.booleanexists(String fileName)Tests whether this storage contains a file with the provided name.Stream<String>list()Returns a stream containing the existing file names.InputStreamnewInputStream(String fileName)Opens an input stream for reading the file with the provided name.OutputStreamnewOutputStream(String fileName)Opens an output stream for writing data to the file with the provided name.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.opends.server.backup.BackupStorage
close
-
-
-
-
Constructor Detail
-
FileSystemBackupStorage
public FileSystemBackupStorage(Path backupDirectory) throws IOException
Creates a new data storage for reading and writing files in the provided directory.- Parameters:
backupDirectory- The directory where this storage will read and write data.- Throws:
IOException- If the directory does not exist or is not a directory.
-
-
Method Detail
-
exists
public boolean exists(String fileName)
Description copied from interface:BackupStorageTests whether this storage contains a file with the provided name.- Specified by:
existsin interfaceBackupStorage- Parameters:
fileName- the name of the file.- Returns:
- whether this storage contains a file with the provided name.
-
deleteIfExists
public void deleteIfExists(String fileName) throws IOException
Description copied from interface:BackupStorageDeletes the file with the provided name.- Specified by:
deleteIfExistsin interfaceBackupStorage- Parameters:
fileName- the name of the file to be deleted.- Throws:
IOException- if an I/O error occurs.
-
list
public Stream<String> list() throws IOException
Description copied from interface:BackupStorageReturns a stream containing the existing file names.- Specified by:
listin interfaceBackupStorage- Returns:
- a stream containing the existing file names.
- Throws:
IOException- if an I/O error occurs.
-
newInputStream
public InputStream newInputStream(String fileName) throws IOException
Description copied from interface:BackupStorageOpens an input stream for reading the file with the provided name. The stream will not be buffered and is not required to support theInputStream.mark(int)orInputStream.reset()methods.- Specified by:
newInputStreamin interfaceBackupStorage- Parameters:
fileName- the name of the file to be read.- Returns:
- a new input stream.
- Throws:
IOException- if an I/O error occurs.
-
newOutputStream
public OutputStream newOutputStream(String fileName) throws IOException
Description copied from interface:BackupStorageOpens an output stream for writing data to the file with the provided name. If the file already exists, the data is overwritten, otherwise a new file is created. The resulting stream will not be buffered.- Specified by:
newOutputStreamin interfaceBackupStorage- Parameters:
fileName- the name of the file to write data to.- Returns:
- a new output stream.
- Throws:
IOException- if an I/O error occurs.
-
-