Class DelegatingBackupRepository
- java.lang.Object
-
- org.apache.solr.core.backup.repository.AbstractBackupRepository
-
- org.apache.solr.core.backup.repository.DelegatingBackupRepository
-
- All Implemented Interfaces:
Closeable,AutoCloseable,BackupRepository,NamedListInitializedPlugin
public class DelegatingBackupRepository extends AbstractBackupRepository
Delegates to anotherBackupRepository.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.apache.solr.core.backup.repository.BackupRepository
BackupRepository.PathType
-
-
Field Summary
Fields Modifier and Type Field Description protected BackupRepositorydelegatestatic StringPARAM_DELEGATE_REPOSITORY_NAME-
Fields inherited from class org.apache.solr.core.backup.repository.AbstractBackupRepository
config, PARAM_VERIFY_CHECKSUM, shouldVerifyChecksum
-
-
Constructor Summary
Constructors Constructor Description DelegatingBackupRepository()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Checksumchecksum(org.apache.lucene.store.Directory dir, String fileName)Get checksum offileNameatdir.voidclose()voidcopyFileFrom(org.apache.lucene.store.Directory sourceDir, String fileName, URI dest)Copy a file from specifiedsourceDirto the destination repository (i.e.voidcopyFileTo(URI sourceRepo, String fileName, org.apache.lucene.store.Directory dest)Copy a file from specifiedsourceRepoto the destination directory (i.e.voidcopyIndexFileFrom(org.apache.lucene.store.Directory sourceDir, String sourceFileName, URI destDir, String destFileName)Copy an index file from specifiedsourceDirto the destination repository (i.e.voidcopyIndexFileFrom(org.apache.lucene.store.Directory sourceDir, String sourceFileName, org.apache.lucene.store.Directory destDir, String destFileName)Copies an index file from a specifiedDirectoryto a destinationDirectory.voidcopyIndexFileTo(URI sourceRepo, String sourceFileName, org.apache.lucene.store.Directory dest, String destFileName)Copy an index file from specifiedsourceRepoto the destination directory (i.e.voidcreateDirectory(URI path)This method creates a directory at the specified path.URIcreateDirectoryURI(String path)This method returns the directory URI representation for the specified path.OutputStreamcreateOutput(URI path)This method returns a OutputStream instance for the specifiedpathURIcreateURI(String path)This method returns the URI representation for the specified path.voiddelete(URI path, Collection<String> files)DeletefilesatpathvoiddeleteDirectory(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.StringgetBackupLocation(String override)This method returns the location where the backup should be stored (or restored from).<T> TgetConfigProperty(String name)This method returns the value of the specified configuration property.protected org.apache.solr.common.util.NamedList<?>getDelegateInitArgs(org.apache.solr.common.util.NamedList<?> initArgs)BackupRepository.PathTypegetPathType(URI path)This method returns the type of a specified pathString[]listAll(URI path)This method returns all the entries (files and directories) in the specified directory.String[]listAllOrEmpty(URI path)List all files or directories directly underpath.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).URIresolveDirectory(URI baseUri, String... pathComponents)This method resolves a directory URI using the specified path components (as method arguments).protected voidsetDelegate(BackupRepository delegate)-
Methods inherited from class org.apache.solr.core.backup.repository.AbstractBackupRepository
getBooleanConfig, init
-
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
copyFileNoChecksum, delete
-
-
-
-
Field Detail
-
PARAM_DELEGATE_REPOSITORY_NAME
public static final String PARAM_DELEGATE_REPOSITORY_NAME
- See Also:
- Constant Field Values
-
delegate
protected BackupRepository delegate
-
-
Method Detail
-
getDelegateInitArgs
protected org.apache.solr.common.util.NamedList<?> getDelegateInitArgs(org.apache.solr.common.util.NamedList<?> initArgs)
-
setDelegate
protected void setDelegate(BackupRepository delegate)
-
getBackupLocation
public String getBackupLocation(String override)
Description copied from interface:BackupRepositoryThis method returns the location where the backup should be stored (or restored from).- Parameters:
override- The location parameter supplied by the user.- Returns:
- If
overrideis not null then return the same value Otherwise return the default configuration value for the CoreAdminParams.BACKUP_LOCATION parameter.
-
getConfigProperty
public <T> T getConfigProperty(String name)
Description copied from interface:BackupRepositoryThis method returns the value of the specified configuration property.
-
createURI
public URI createURI(String path)
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.- Parameters:
path- The path specified by the user.- Returns:
- the URI representation of the user supplied value
-
createDirectoryURI
public URI createDirectoryURI(String path)
Description copied from interface:BackupRepositoryThis method returns the directory URI representation for the specified path. Note - the specified path could be a fully qualified URI OR a relative path for a file-system.- Parameters:
path- The path specified by the user.- Returns:
- the URI representation of the user supplied value, ensured to look like a directory.
-
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).- 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
-
resolveDirectory
public URI resolveDirectory(URI baseUri, String... pathComponents)
Description copied from interface:BackupRepositoryThis method resolves a directory URI using the specified path components (as method arguments).- 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, ensured to look like a directory
-
exists
public boolean exists(URI path) throws IOException
Description copied from interface:BackupRepositoryThis method checks if the specified path exists in this repository.- 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
-
getPathType
public BackupRepository.PathType getPathType(URI path) throws IOException
Description copied from interface:BackupRepositoryThis method returns the type of a specified path- Parameters:
path- The path whose type needs to be checked.- Returns:
- the BackupRepository.PathType for the specified path
- Throws:
IOException- in case of errors
-
listAll
public String[] listAll(URI path) throws IOException
Description copied from interface:BackupRepositoryThis method returns all the entries (files and directories) in the specified directory.- Parameters:
path- The directory path- Returns:
- an array of strings, one for each entry in the directory
- 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.- 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- Parameters:
path- The path for which OutputStream needs to be created- Returns:
- OutputStream instance for the specified
path - Throws:
IOException- in case of errors
-
createDirectory
public void createDirectory(URI path) throws IOException
Description copied from interface:BackupRepositoryThis method creates a directory at the specified path. If the directory already exist, this will be a no-op.- 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.- Parameters:
path- The path referring to the directory to be deleted.- 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).- Parameters:
sourceDir- The source directory hosting the file to be copied.fileName- The name of the file to be copieddest- The destination backup location.- Throws:
IOException- in case of errors
-
copyFileTo
public void copyFileTo(URI sourceRepo, 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).- Parameters:
sourceRepo- The source URI hosting the file to be copied.fileName- The name of the file to be copieddest- The destination where the file should be copied.- Throws:
IOException- in case of errors.
-
listAllOrEmpty
public String[] listAllOrEmpty(URI path)
Description copied from interface:BackupRepositoryList all files or directories directly underpath.- Returns:
- an empty array in case of IOException
-
copyIndexFileFrom
public void copyIndexFileFrom(org.apache.lucene.store.Directory sourceDir, String sourceFileName, org.apache.lucene.store.Directory destDir, String destFileName) throws IOExceptionDescription copied from class:AbstractBackupRepositoryCopies an index file from a specifiedDirectoryto a destinationDirectory. Also verifies the checksum unlessAbstractBackupRepository.PARAM_VERIFY_CHECKSUMwas false in theAbstractBackupRepository.init(NamedList)arguments.- Specified by:
copyIndexFileFromin interfaceBackupRepository- Overrides:
copyIndexFileFromin classAbstractBackupRepository- Parameters:
sourceDir- The source directory hosting the file to be copied.sourceFileName- The name of the file to be copieddestDir- The destination directory.- Throws:
CorruptIndexException- in case checksum of the file does not match with precomputed checksum stored at the end of the fileIOException
-
delete
public void delete(URI path, Collection<String> files) throws IOException
Description copied from interface:BackupRepositoryDeletefilesatpath- Throws:
IOException
-
checksum
public Checksum checksum(org.apache.lucene.store.Directory dir, String fileName) throws IOException
Description copied from interface:BackupRepositoryGet checksum offileNameatdir. This method only be called on Lucene index files- Throws:
IOException
-
copyIndexFileFrom
public void copyIndexFileFrom(org.apache.lucene.store.Directory sourceDir, String sourceFileName, URI destDir, String destFileName) throws IOExceptionDescription copied from interface:BackupRepositoryCopy an index file from specifiedsourceDirto the destination repository (i.e. backup).- Parameters:
sourceDir- The source directory hosting the file to be copied.sourceFileName- The name of the file to be copieddestDir- The destination backup location.- Throws:
IOException- in case of errorsorg.apache.lucene.index.CorruptIndexException- in case checksum of the file does not match with precomputed checksum stored at the end of the file
-
copyIndexFileTo
public void copyIndexFileTo(URI sourceRepo, String sourceFileName, org.apache.lucene.store.Directory dest, String destFileName) throws IOException
Description copied from interface:BackupRepositoryCopy an index file from specifiedsourceRepoto the destination directory (i.e. restore).- Parameters:
sourceRepo- The source URI hosting the file to be copied.dest- The destination where the file should be copied.- Throws:
IOException- in case of errors.
-
close
public void close() throws IOException- Throws:
IOException
-
-