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, createTempOutput, fileLength, getDelegate, listAll, obtainLock, openInput, toString, unwrap
ensureOpen, openChecksumInput
public void deleteFile(String name) throws IOException
Directory
deleteFile
in class FilterDirectory
IOException
public IndexOutput createOutput(String name, IOContext context) throws IOException
Directory
createOutput
in class FilterDirectory
IOException
public void copyFrom(Directory from, String src, String dest, IOContext context) throws IOException
Directory
If 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 Directory
IOException
public void renameFile(String source, String dest) throws IOException
Directory
source
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 FilterDirectory
IOException
public void sync(Collection<String> names) throws IOException
Directory
sync
in class FilterDirectory
IOException
Copyright © 2000-2016 Apache Software Foundation. All Rights Reserved.