Class LocalFileSystemRepository
- java.lang.Object
-
- org.apache.solr.core.backup.repository.LocalFileSystemRepository
-
- All Implemented Interfaces:
Closeable,AutoCloseable,BackupRepository,NamedListInitializedPlugin
public class LocalFileSystemRepository extends Object implements BackupRepository
A concrete implementation of BackupRepository interface supporting backup/restore of Solr indexes to a local file-system. (Note - This can even be used for a shared file-system if it is exposed via a local file-system interface e.g. NFS).
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.solr.core.backup.repository.BackupRepository
BackupRepository.PathType
-
-
Constructor Summary
Constructors Constructor Description LocalFileSystemRepository()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidcopyFileFrom(org.apache.lucene.store.Directory sourceDir, String fileName, URI dest)Copy a file from specifiedsourceDirto the destination repository (i.e.voidcopyFileTo(URI sourceDir, String fileName, org.apache.lucene.store.Directory dest)Copy a file from specifiedsourceRepoto the destination directory (i.e.voidcreateDirectory(URI path)This method creates a directory at the specified path.OutputStreamcreateOutput(URI path)This method returns a OutputStream instance for the specifiedpathURIcreateURI(String location)This method returns the URI representation for the specified path.voiddeleteDirectory(URI path)This method deletes a directory at the specified path.booleanexists(URI path)This method checks if the specified path exists in this repository.<T> TgetConfigProperty(String name)This method returns the value of the specified configuration property.BackupRepository.PathTypegetPathType(URI path)This method returns the type of a specified pathvoidinit(NamedList args)String[]listAll(URI dirPath)This method returns all the entries (files and directories) in the specified directory.org.apache.lucene.store.IndexInputopenInput(URI dirPath, String fileName, org.apache.lucene.store.IOContext ctx)This method returns a Lucene input stream reading an existing file.URIresolve(URI baseUri, String... pathComponents)This method resolves a URI using the specified path components (as method arguments).-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.solr.core.backup.repository.BackupRepository
getBackupLocation
-
-
-
-
Method Detail
-
init
public void init(NamedList args)
- Specified by:
initin interfaceNamedListInitializedPlugin
-
getConfigProperty
public <T> T getConfigProperty(String name)
Description copied from interface:BackupRepositoryThis method returns the value of the specified configuration property.- Specified by:
getConfigPropertyin interfaceBackupRepository
-
createURI
public URI createURI(String location)
Description copied from interface:BackupRepositoryThis method returns the URI representation for the specified path. Note - the specified path could be a fully qualified URI OR a relative path for a file-system.- Specified by:
createURIin interfaceBackupRepository- Parameters:
location- The path specified by the user.- Returns:
- the URI representation of the user supplied value
-
resolve
public URI resolve(URI baseUri, String... pathComponents)
Description copied from interface:BackupRepositoryThis method resolves a URI using the specified path components (as method arguments).- Specified by:
resolvein interfaceBackupRepository- Parameters:
baseUri- The base URI to use for creating the pathpathComponents- The directory (or file-name) to be included in the URI.- Returns:
- A URI containing absolute path
-
createDirectory
public void createDirectory(URI path) throws IOException
Description copied from interface:BackupRepositoryThis method creates a directory at the specified path.- Specified by:
createDirectoryin interfaceBackupRepository- Parameters:
path- The path where the directory needs to be created.- Throws:
IOException- in case of errors
-
deleteDirectory
public void deleteDirectory(URI path) throws IOException
Description copied from interface:BackupRepositoryThis method deletes a directory at the specified path.- Specified by:
deleteDirectoryin interfaceBackupRepository- Parameters:
path- The path referring to the directory to be deleted.- Throws:
IOException- in case of errors
-
exists
public boolean exists(URI path) throws IOException
Description copied from interface:BackupRepositoryThis method checks if the specified path exists in this repository.- Specified by:
existsin interfaceBackupRepository- Parameters:
path- The path whose existence needs to be checked.- Returns:
- if the specified path exists in this repository.
- Throws:
IOException- in case of errors
-
openInput
public org.apache.lucene.store.IndexInput openInput(URI dirPath, String fileName, org.apache.lucene.store.IOContext ctx) throws IOException
Description copied from interface:BackupRepositoryThis method returns a Lucene input stream reading an existing file.- Specified by:
openInputin interfaceBackupRepository- Parameters:
dirPath- The parent directory of the file to be readfileName- The name of the file to be readctx- the Lucene IO context- Returns:
- Lucene IndexInput reference
- Throws:
IOException- in case of errors
-
createOutput
public OutputStream createOutput(URI path) throws IOException
Description copied from interface:BackupRepositoryThis method returns a OutputStream instance for the specifiedpath- Specified by:
createOutputin interfaceBackupRepository- Parameters:
path- The path for which OutputStream needs to be created- Returns:
- OutputStream instance for the specified
path - Throws:
IOException- in case of errors
-
listAll
public String[] listAll(URI dirPath) throws IOException
Description copied from interface:BackupRepositoryThis method returns all the entries (files and directories) in the specified directory.- Specified by:
listAllin interfaceBackupRepository- Parameters:
dirPath- The directory path- Returns:
- an array of strings, one for each entry in the directory
- Throws:
IOException- in case of errors
-
getPathType
public BackupRepository.PathType getPathType(URI path) throws IOException
Description copied from interface:BackupRepositoryThis method returns the type of a specified path- Specified by:
getPathTypein interfaceBackupRepository- Parameters:
path- The path whose type needs to be checked.- Returns:
- the BackupRepository.PathType for the specified path
- Throws:
IOException- in case of errors
-
copyFileFrom
public void copyFileFrom(org.apache.lucene.store.Directory sourceDir, String fileName, URI dest) throws IOExceptionDescription copied from interface:BackupRepositoryCopy a file from specifiedsourceDirto the destination repository (i.e. backup).- Specified by:
copyFileFromin interfaceBackupRepository- Parameters:
sourceDir- The source directory hosting the file to be copied.fileName- The name of the file to by copieddest- The destination backup location.- Throws:
IOException- in case of errors
-
copyFileTo
public void copyFileTo(URI sourceDir, String fileName, org.apache.lucene.store.Directory dest) throws IOException
Description copied from interface:BackupRepositoryCopy a file from specifiedsourceRepoto the destination directory (i.e. restore).- Specified by:
copyFileToin interfaceBackupRepository- Parameters:
sourceDir- The source URI hosting the file to be copied.fileName- The name of the file to by copieddest- The destination where the file should be copied.- Throws:
IOException- in case of errors.
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
-