public class MockDirectoryWrapper extends BaseDirectoryWrapper
LuceneTestCase.newDirectory() are tracked
to ensure they are closed by the test.
| Modifier and Type | Class and Description |
|---|---|
static class |
MockDirectoryWrapper.Failure
Objects that represent fail-able conditions.
|
static class |
MockDirectoryWrapper.FakeIOException
Use this when throwing fake
IOException,
e.g. |
static class |
MockDirectoryWrapper.Throttling
Enum for controlling hard disk throttling.
|
isOpenin| Constructor and Description |
|---|
MockDirectoryWrapper(Random random,
Directory delegate) |
| Modifier and Type | Method and Description |
|---|---|
void |
clearCrash() |
void |
close() |
void |
copyFrom(Directory from,
String src,
String dest,
IOContext context) |
void |
corruptFiles(Collection<String> files) |
void |
corruptUnknownFiles() |
void |
crash()
Simulates a crash of OS or machine by overwriting
unsynced files.
|
IndexOutput |
createOutput(String name,
IOContext context) |
IndexOutput |
createTempOutput(String prefix,
String suffix,
IOContext context) |
void |
deleteFile(String name) |
protected void |
ensureOpen() |
void |
failOn(MockDirectoryWrapper.Failure fail)
add a Failure object to the list of objects to be evaluated
at every potential failure point
|
long |
fileLength(String name) |
boolean |
getAssertNoDeleteOpenFile() |
long |
getFileHandleCount()
returns current open file handle count
|
int |
getInputCloneCount() |
long |
getMaxSizeInBytes() |
long |
getMaxUsedSizeInBytes()
Returns the peek actual storage used (bytes) in this
directory.
|
Set<String> |
getOpenDeletedFiles() |
double |
getRandomIOExceptionRate() |
double |
getRandomIOExceptionRateOnOpen() |
long |
getRecomputedActualSizeInBytes()
Like getRecomputedSizeInBytes(), but, uses actual file
lengths rather than buffer allocations (which are
quantized up to nearest
RAMOutputStream.BUFFER_SIZE (now 1024) bytes.
|
long |
getRecomputedSizeInBytes()
Provided for testing purposes.
|
String[] |
listAll() |
Lock |
obtainLock(String name) |
ChecksumIndexInput |
openChecksumInput(String name,
IOContext context) |
IndexInput |
openInput(String name,
IOContext context) |
void |
removeIndexInput(IndexInput in,
String name) |
void |
removeIndexOutput(IndexOutput out,
String name) |
void |
rename(String source,
String dest) |
void |
resetMaxUsedSizeInBytes() |
void |
setAllowRandomFileNotFoundException(boolean value)
If set to true (the default), when we throw random
IOException on openInput or createOutput, we may
sometimes throw FileNotFoundException or
NoSuchFileException.
|
void |
setAllowReadingFilesStillOpenForWrite(boolean value)
If set to true, you can open an inputstream on a file
that is still open for writes.
|
void |
setAssertNoDeleteOpenFile(boolean value)
Trip a test assert if there is an attempt
to delete an open file.
|
void |
setAssertNoUnrefencedFilesOnClose(boolean v) |
void |
setFailOnCreateOutput(boolean v) |
void |
setFailOnOpenInput(boolean v) |
void |
setMaxSizeInBytes(long maxSize) |
void |
setRandomIOExceptionRate(double rate)
If 0.0, no exceptions will be thrown.
|
void |
setRandomIOExceptionRateOnOpen(double rate)
If 0.0, no exceptions will be thrown during openInput
and createOutput.
|
void |
setThrottling(MockDirectoryWrapper.Throttling throttling) |
void |
setTrackDiskUsage(boolean v) |
void |
setUseSlowOpenClosers(boolean v)
Add a rare small sleep to catch race conditions in open/close
|
void |
setVerboseClone(boolean v)
If set to true, we print a fake exception
with filename and stacktrace on every indexinput clone()
|
long |
sizeInBytes() |
void |
sync(Collection<String> names) |
void |
syncMetaData() |
String |
toString() |
getCheckIndexOnClose, getCrossCheckTermVectorsOnClose, isOpen, setCheckIndexOnClose, setCrossCheckTermVectorsOnClosegetDelegate, getPendingDeletions, unwrapgetTempFileNamepublic int getInputCloneCount()
public void setVerboseClone(boolean v)
public void setTrackDiskUsage(boolean v)
public void setAllowRandomFileNotFoundException(boolean value)
public void setAllowReadingFilesStillOpenForWrite(boolean value)
public void setThrottling(MockDirectoryWrapper.Throttling throttling)
public void setUseSlowOpenClosers(boolean v)
You can enable this if you need it.
public void sync(Collection<String> names) throws IOException
sync in class FilterDirectoryIOExceptionpublic void rename(String source, String dest) throws IOException
rename in class FilterDirectoryIOExceptionpublic void syncMetaData()
throws IOException
syncMetaData in class FilterDirectoryIOExceptionpublic final long sizeInBytes()
throws IOException
IOExceptionpublic void corruptUnknownFiles()
throws IOException
IOExceptionpublic void corruptFiles(Collection<String> files) throws IOException
IOExceptionpublic void crash()
throws IOException
IOExceptionpublic void clearCrash()
public void setMaxSizeInBytes(long maxSize)
public long getMaxSizeInBytes()
public long getMaxUsedSizeInBytes()
public void resetMaxUsedSizeInBytes()
throws IOException
IOExceptionpublic void setAssertNoDeleteOpenFile(boolean value)
public boolean getAssertNoDeleteOpenFile()
public void setRandomIOExceptionRate(double rate)
public double getRandomIOExceptionRate()
public void setRandomIOExceptionRateOnOpen(double rate)
public double getRandomIOExceptionRateOnOpen()
public long getFileHandleCount()
public void deleteFile(String name) throws IOException
deleteFile in class FilterDirectoryIOExceptionpublic void setFailOnCreateOutput(boolean v)
public IndexOutput createOutput(String name, IOContext context) throws IOException
createOutput in class FilterDirectoryIOExceptionpublic IndexOutput createTempOutput(String prefix, String suffix, IOContext context) throws IOException
createTempOutput in class FilterDirectoryIOExceptionpublic void setFailOnOpenInput(boolean v)
public IndexInput openInput(String name, IOContext context) throws IOException
openInput in class FilterDirectoryIOExceptionpublic final long getRecomputedSizeInBytes()
throws IOException
IOExceptionpublic final long getRecomputedActualSizeInBytes()
throws IOException
IOExceptionpublic void setAssertNoUnrefencedFilesOnClose(boolean v)
public void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class BaseDirectoryWrapperIOExceptionpublic void removeIndexOutput(IndexOutput out, String name)
public void removeIndexInput(IndexInput in, String name)
public void failOn(MockDirectoryWrapper.Failure fail)
public String[] listAll() throws IOException
listAll in class FilterDirectoryIOExceptionpublic long fileLength(String name) throws IOException
fileLength in class FilterDirectoryIOExceptionpublic Lock obtainLock(String name) throws IOException
obtainLock in class FilterDirectoryIOExceptionpublic String toString()
toString in class FilterDirectorypublic final ChecksumIndexInput openChecksumInput(String name, IOContext context) throws IOException
openChecksumInput in class DirectoryIOExceptionpublic final void copyFrom(Directory from, String src, String dest, IOContext context) throws IOException
copyFrom in class DirectoryIOExceptionprotected final void ensureOpen()
throws AlreadyClosedException
ensureOpen in class DirectoryAlreadyClosedExceptionCopyright © 2000-2021 Apache Software Foundation. All Rights Reserved.