public final class LockValidatingDirectoryWrapper extends FilterDirectory
Lock
is valid before any destructive filesystem operation.| Modifier and Type | Field and Description |
|---|---|
private Lock |
writeLock |
in| Constructor and Description |
|---|
LockValidatingDirectoryWrapper(Directory in,
Lock writeLock) |
| Modifier and Type | Method and Description |
|---|---|
void |
copyFrom(Directory from,
java.lang.String src,
java.lang.String dest,
IOContext context)
Copies the file src in from to this directory under the new
file name dest.
|
IndexOutput |
createOutput(java.lang.String name,
IOContext context)
Creates a new, empty file in the directory with the given name.
|
void |
deleteFile(java.lang.String name)
Removes an existing file in the directory.
|
void |
renameFile(java.lang.String source,
java.lang.String dest)
Renames
source to dest as an atomic operation,
where dest does not yet exist in the directory. |
void |
sync(java.util.Collection<java.lang.String> names)
Ensure that any writes to these files are moved to
stable storage.
|
close, createTempOutput, fileLength, getDelegate, listAll, obtainLock, openInput, toString, unwrapensureOpen, openChecksumInputprivate final Lock writeLock
public void deleteFile(java.lang.String name)
throws java.io.IOException
DirectorydeleteFile in class FilterDirectoryjava.io.IOExceptionpublic IndexOutput createOutput(java.lang.String name, IOContext context) throws java.io.IOException
DirectorycreateOutput in class FilterDirectoryjava.io.IOExceptionpublic void copyFrom(Directory from, java.lang.String src, java.lang.String dest, IOContext context) throws java.io.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.
public void renameFile(java.lang.String source,
java.lang.String dest)
throws java.io.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 FilterDirectoryjava.io.IOExceptionpublic void sync(java.util.Collection<java.lang.String> names)
throws java.io.IOException
Directorysync in class FilterDirectoryjava.io.IOException