public final class LockValidatingDirectoryWrapper extends FilterDirectory
Lock
is valid before any destructive filesystem operation.in| Constructor and Description |
|---|
LockValidatingDirectoryWrapper(Directory in,
Lock writeLock) |
| Modifier and Type | Method and Description |
|---|---|
void |
copyFrom(Directory from,
String src,
String dest,
IOContext context)
Copies the file src in from to this directory under the new
file name dest.
|
IndexOutput |
createOutput(String name,
IOContext context)
Creates a new, empty file in the directory with the given name.
|
void |
deleteFile(String name)
Removes an existing file in the directory.
|
void |
renameFile(String source,
String dest)
Renames
source to dest as an atomic operation,
where dest does not yet exist in the directory. |
void |
sync(Collection<String> names)
Ensure that any writes to these files are moved to
stable storage.
|
close, fileLength, getDelegate, listAll, obtainLock, openInput, toString, unwrapensureOpen, openChecksumInputpublic void deleteFile(String name) throws IOException
DirectorydeleteFile in class FilterDirectoryIOExceptionpublic IndexOutput createOutput(String name, IOContext context) throws IOException
DirectorycreateOutput in class FilterDirectoryIOExceptionpublic void copyFrom(Directory from, String src, String dest, IOContext context) throws IOException
DirectoryIf you want to copy the entire source directory to the destination one, you can do so like this:
Directory to; // the directory to copy to
for (String file : dir.listAll()) {
to.copyFrom(dir, file, newFile, IOContext.DEFAULT); // newFile can be either file, or a new name
}
NOTE: this method does not check whether dest exist and will overwrite it if it does.
copyFrom in class DirectoryIOExceptionpublic void renameFile(String source, String dest) throws IOException
Directorysource to dest as an atomic operation,
where dest does not yet exist in the directory.
Notes: This method is used by IndexWriter to publish commits.
It is ok if this operation is not truly atomic, for example
both source and dest can be visible temporarily.
It is just important that the contents of dest appear
atomically, or an exception is thrown.
renameFile in class FilterDirectoryIOExceptionpublic void sync(Collection<String> names) throws IOException
Directorysync in class FilterDirectoryIOExceptionCopyright © 2000-2016 Apache Software Foundation. All Rights Reserved.