org.compass.needle.terracotta
Class ManagedTerracottaDirectory

java.lang.Object
  extended by org.apache.lucene.store.Directory
      extended by org.compass.needle.terracotta.TerracottaDirectory
          extended by org.compass.needle.terracotta.ManagedTerracottaDirectory

public class ManagedTerracottaDirectory
extends TerracottaDirectory

Managed terracotta directory allows to use the terracotta directory by managing a more coarse grained transactions and operations against the directory. This should provide an improved performance with terracotta since there is no need to obtain locks on a fine grained level (CHM) within a transactional context.

The directory accepts a RWL, which should be managed by terracotta. In order to begin a transaction, the RWL read lock should be obtained. Releasing the transaction should be performed by unlocking the read lock.

Author:
kimchy

Field Summary
 
Fields inherited from class org.compass.needle.terracotta.TerracottaDirectory
DEFAULT_BUFFER_SIZE, DEFAULT_CHM_CONCURRENCY_LEVEL, DEFAULT_CHM_INITIAL_CAPACITY, DEFAULT_CHM_LOAD_FACTOR, DEFAULT_FLUSH_RATE, EMPTY_FILE
 
Fields inherited from class org.apache.lucene.store.Directory
lockFactory
 
Constructor Summary
ManagedTerracottaDirectory(ReadWriteLock rwl)
           
ManagedTerracottaDirectory(ReadWriteLock rwl, int bufferSize, int flushRate)
           
ManagedTerracottaDirectory(ReadWriteLock rwl, int bufferSize, int flushRate, int chmInitialCapacity, float chmLoadFactor, int chmConcurrencyLevel)
           
 
Method Summary
(package private)  void addFile(String name, TerracottaFile file)
           
protected  Map<String,TerracottaFile> createMap(int chmInitialCapacity, float chmLoadFactor, int chmConcurrencyLevel)
           
 void deleteFile(String name)
          Removes an existing file in the directory.
protected
<T> T
doWithWriteLock(org.compass.needle.terracotta.ManagedTerracottaDirectory.WriteLockTask<T> task)
           
 Lock makeLock(String name)
           
 void renameFile(String from, String to)
          Renames an existing file in the directory.
 
Methods inherited from class org.compass.needle.terracotta.TerracottaDirectory
close, createOutput, fileExists, fileLength, fileModified, getBufferSize, getFlushRate, getLockFactory, list, openInput, setLockFactory, touchFile
 
Methods inherited from class org.apache.lucene.store.Directory
clearLock, copy, ensureOpen, getLockID, openInput, sync
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ManagedTerracottaDirectory

public ManagedTerracottaDirectory(ReadWriteLock rwl)

ManagedTerracottaDirectory

public ManagedTerracottaDirectory(ReadWriteLock rwl,
                                  int bufferSize,
                                  int flushRate)

ManagedTerracottaDirectory

public ManagedTerracottaDirectory(ReadWriteLock rwl,
                                  int bufferSize,
                                  int flushRate,
                                  int chmInitialCapacity,
                                  float chmLoadFactor,
                                  int chmConcurrencyLevel)
Method Detail

createMap

protected Map<String,TerracottaFile> createMap(int chmInitialCapacity,
                                               float chmLoadFactor,
                                               int chmConcurrencyLevel)
Overrides:
createMap in class TerracottaDirectory

makeLock

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

deleteFile

public void deleteFile(String name)
                throws IOException
Description copied from class: TerracottaDirectory
Removes an existing file in the directory.

Overrides:
deleteFile in class TerracottaDirectory
Throws:
IOException - if the file does not exist

renameFile

public void renameFile(String from,
                       String to)
                throws IOException
Description copied from class: TerracottaDirectory
Renames an existing file in the directory.

Overrides:
renameFile in class TerracottaDirectory
Throws:
IOException

addFile

void addFile(String name,
             TerracottaFile file)
       throws IOException
Overrides:
addFile in class TerracottaDirectory
Throws:
IOException

doWithWriteLock

protected <T> T doWithWriteLock(org.compass.needle.terracotta.ManagedTerracottaDirectory.WriteLockTask<T> task)
                     throws IOException
Throws:
IOException


Copyright (c) 2004-2009 The Compass Project.