org.apache.lucene.store.wrapper
Class AsyncMemoryMirrorDirectoryWrapper

java.lang.Object
  extended by org.apache.lucene.store.Directory
      extended by org.apache.lucene.store.wrapper.AsyncMemoryMirrorDirectoryWrapper

public class AsyncMemoryMirrorDirectoryWrapper
extends Directory

Wraps a Lucene Directory with an in memory directory which mirrors it asynchronously.

The original directory is read into memory when this wrapper is constructed. All read realted operations are performed against the in memory directory. All write related operations are performed against the in memeory directory and are scheduled to be performed against the original directory (using ExecutorService). Locking is performed using the in memory directory.

NOTE: This wrapper will only work in cases when either the index is read only (i.e. only search operations are performed against it), or when there is a single instance which updates the directory.

Author:
kimchy

Nested Class Summary
 class AsyncMemoryMirrorDirectoryWrapper.AsyncMemoryMirrorIndexOutput
           
 
Field Summary
 
Fields inherited from class org.apache.lucene.store.Directory
lockFactory
 
Constructor Summary
AsyncMemoryMirrorDirectoryWrapper(Directory dir)
           
AsyncMemoryMirrorDirectoryWrapper(Directory dir, long awaitTermination)
           
AsyncMemoryMirrorDirectoryWrapper(Directory dir, long awaitTermination, ExecutorService executorService)
           
 
Method Summary
 void close()
           
 IndexOutput createOutput(String name)
           
 void deleteFile(String name)
           
 boolean fileExists(String name)
           
 long fileLength(String name)
           
 long fileModified(String name)
           
 String[] list()
           
 Lock makeLock(String name)
           
 IndexInput openInput(String name)
           
 void renameFile(String from, String to)
           
 void touchFile(String name)
           
 
Methods inherited from class org.apache.lucene.store.Directory
clearLock, copy, ensureOpen, getLockFactory, getLockID, openInput, setLockFactory, sync
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsyncMemoryMirrorDirectoryWrapper

public AsyncMemoryMirrorDirectoryWrapper(Directory dir)
                                  throws IOException
Throws:
IOException

AsyncMemoryMirrorDirectoryWrapper

public AsyncMemoryMirrorDirectoryWrapper(Directory dir,
                                         long awaitTermination)
                                  throws IOException
Throws:
IOException

AsyncMemoryMirrorDirectoryWrapper

public AsyncMemoryMirrorDirectoryWrapper(Directory dir,
                                         long awaitTermination,
                                         ExecutorService executorService)
                                  throws IOException
Throws:
IOException
Method Detail

deleteFile

public void deleteFile(String name)
                throws IOException
Specified by:
deleteFile in class Directory
Throws:
IOException

fileExists

public boolean fileExists(String name)
                   throws IOException
Specified by:
fileExists in class Directory
Throws:
IOException

fileLength

public long fileLength(String name)
                throws IOException
Specified by:
fileLength in class Directory
Throws:
IOException

fileModified

public long fileModified(String name)
                  throws IOException
Specified by:
fileModified in class Directory
Throws:
IOException

list

public String[] list()
              throws IOException
Specified by:
list in class Directory
Throws:
IOException

renameFile

public void renameFile(String from,
                       String to)
                throws IOException
Specified by:
renameFile in class Directory
Throws:
IOException

touchFile

public void touchFile(String name)
               throws IOException
Specified by:
touchFile in class Directory
Throws:
IOException

makeLock

public Lock makeLock(String name)
Overrides:
makeLock in class Directory

close

public void close()
           throws IOException
Specified by:
close in class Directory
Throws:
IOException

openInput

public IndexInput openInput(String name)
                     throws IOException
Specified by:
openInput in class Directory
Throws:
IOException

createOutput

public IndexOutput createOutput(String name)
                         throws IOException
Specified by:
createOutput in class Directory
Throws:
IOException


Copyright (c) 2004-2008 The Compass Project.