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.Throttling |
Directory.IndexInputSlicerdelegateisOpen, lockFactory| Constructor and Description |
|---|
MockDirectoryWrapper(Random random,
Directory delegate) |
| Modifier and Type | Method and Description |
|---|---|
void |
clearCrash() |
void |
clearLock(String name) |
void |
close() |
void |
copy(Directory to,
String src,
String dest,
IOContext context) |
void |
crash()
Simulates a crash of OS or machine by overwriting
unsynced files.
|
IndexOutput |
createOutput(String name,
IOContext context) |
Directory.IndexInputSlicer |
createSlicer(String name,
IOContext context) |
void |
deleteFile(String name) |
void |
failOn(MockDirectoryWrapper.Failure fail)
add a Failure object to the list of objects to be evaluated
at every potential failure point
|
boolean |
fileExists(String name) |
long |
fileLength(String name) |
int |
getInputCloneCount() |
LockFactory |
getLockFactory() |
String |
getLockID() |
long |
getMaxSizeInBytes() |
long |
getMaxUsedSizeInBytes()
Returns the peek actual storage used (bytes) in this
directory.
|
boolean |
getNoDeleteOpenFile() |
Set<String> |
getOpenDeletedFiles() |
double |
getRandomIOExceptionRate() |
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 |
makeLock(String name) |
IndexInput |
openInput(String name,
IOContext context) |
void |
removeIndexInput(IndexInput in,
String name) |
void |
removeIndexOutput(IndexOutput out,
String name) |
void |
resetMaxUsedSizeInBytes() |
void |
setAssertNoUnrefencedFilesOnClose(boolean v) |
void |
setFailOnCreateOutput(boolean v) |
void |
setFailOnOpenInput(boolean v) |
void |
setLockFactory(LockFactory lockFactory) |
void |
setMaxSizeInBytes(long maxSize) |
void |
setNoDeleteOpenFile(boolean value)
Emulate windows whereby deleting an open file is not
allowed (raise IOException).
|
void |
setPreventDoubleWrite(boolean value)
If set to true, we throw an IOException if the same
file is opened by createOutput, ever.
|
void |
setRandomIOExceptionRate(double rate)
If 0.0, no exceptions will be thrown.
|
void |
setThrottling(MockDirectoryWrapper.Throttling throttling) |
void |
setTrackDiskUsage(boolean v) |
long |
sizeInBytes() |
void |
sync(Collection<String> names) |
String |
toString() |
getCheckIndexOnClose, getCrossCheckTermVectorsOnClose, indexPossiblyExists, isOpen, setCheckIndexOnClose, setCrossCheckTermVectorsOnCloseensureOpenpublic int getInputCloneCount()
public void setTrackDiskUsage(boolean v)
public void setPreventDoubleWrite(boolean value)
public void setThrottling(MockDirectoryWrapper.Throttling throttling)
public void sync(Collection<String> names) throws IOException
sync in class BaseDirectoryWrapperIOExceptionpublic String toString()
toString in class BaseDirectoryWrapperpublic final long sizeInBytes()
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 setNoDeleteOpenFile(boolean value)
public boolean getNoDeleteOpenFile()
public void setRandomIOExceptionRate(double rate)
public double getRandomIOExceptionRate()
public void deleteFile(String name) throws IOException
deleteFile in class BaseDirectoryWrapperIOExceptionpublic void setFailOnCreateOutput(boolean v)
public IndexOutput createOutput(String name, IOContext context) throws IOException
createOutput in class BaseDirectoryWrapperIOExceptionpublic void setFailOnOpenInput(boolean v)
public IndexInput openInput(String name, IOContext context) throws IOException
openInput in class BaseDirectoryWrapperIOExceptionpublic 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 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 BaseDirectoryWrapperIOExceptionpublic boolean fileExists(String name) throws IOException
fileExists in class BaseDirectoryWrapperIOExceptionpublic long fileLength(String name) throws IOException
fileLength in class BaseDirectoryWrapperIOExceptionpublic Lock makeLock(String name)
makeLock in class BaseDirectoryWrapperpublic void clearLock(String name) throws IOException
clearLock in class BaseDirectoryWrapperIOExceptionpublic void setLockFactory(LockFactory lockFactory) throws IOException
setLockFactory in class BaseDirectoryWrapperIOExceptionpublic LockFactory getLockFactory()
getLockFactory in class BaseDirectoryWrapperpublic String getLockID()
getLockID in class BaseDirectoryWrapperpublic void copy(Directory to, String src, String dest, IOContext context) throws IOException
copy in class BaseDirectoryWrapperIOExceptionpublic Directory.IndexInputSlicer createSlicer(String name, IOContext context) throws IOException
createSlicer in class BaseDirectoryWrapperIOExceptionCopyright © 2000-2012 Apache Software Foundation. All Rights Reserved.