org.apache.lucene.gdata.storage.lucenestorage
Class StorageCoreController

java.lang.Object
  extended by org.apache.lucene.gdata.storage.lucenestorage.StorageCoreController
All Implemented Interfaces:
ServerComponent, StorageController

public class StorageCoreController
extends Object
implements StorageController

Author:
Simon Willnauer

Field Summary
protected static org.apache.commons.logging.Log LOG
           
 
Constructor Summary
StorageCoreController()
          Creates a new StoragCoreController
 
Method Summary
protected  IndexModifier createIndexModifier()
          Creates a new IndexModifier on the storage index
 void destroy()
          will be called when the registry is going down e.g.
 void forceWrite()
          Forces the StorageModifier to write all buffered changes.
 int getBufferSize()
          The size of the StorageBuffer.
protected  Directory getDirectory()
           
 int getIndexOptimizeInterval()
           
protected  ConcurrentStorageLock getLock()
           
 int getPersistFactor()
          An integer value after how many changes to the StorageModifier the buffered changes will be persisted / written to the index
 Storage getStorage()
          Creates Storage instances to access the underlaying storage component
protected  StorageModifier getStorageModifier()
          returns the current storage modifier
protected  ReferenceCounter<StorageQuery> getStorageQuery()
          returns a StorageQuery to query the storage index.
 void initialize()
          will be call when the component is registered.
 boolean isKeepRecoveredFiles()
           
 boolean isRecover()
           
protected  void registerNewRecoverWriter()
           
protected  void registerNewStorageQuery()
          Forces the controller to register a new StorageQuery instance.
 String releaseId()
          Creates a unique ID to store as an id for ServerBaseEntry instances
protected  StorageBuffer releaseNewStorageBuffer()
          Creates a new StorageBuffer
 void setBufferSize(int storageBufferSize)
          The size of the StorageBuffer.
 void setDirectory(String storageDirectory)
           
 void setKeepRecoveredFiles(boolean keepRecoveredFiles)
           
 void setOptimizeInterval(int indexOptimizeInterval)
           
 void setPersistFactor(int storagePersistFactor)
           
 void setRecover(boolean recover)
           
 void setStorageDir(Directory storageDir)
           
protected  void writeRecoverEntry(StorageEntryWrapper wrapper)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static final org.apache.commons.logging.Log LOG
Constructor Detail

StorageCoreController

public StorageCoreController()
Creates a new StoragCoreController

Method Detail

initialize

public void initialize()
Description copied from interface: ServerComponent
will be call when the component is registered. if this fails the server must not startup.

Specified by:
initialize in interface ServerComponent
See Also:
ServerComponent.initialize()

getStorageModifier

protected StorageModifier getStorageModifier()
returns the current storage modifier

Returns:
- the current storage modifier

getStorageQuery

protected ReferenceCounter<StorageQuery> getStorageQuery()
returns a StorageQuery to query the storage index. The returned object is a reference counter to keep track of the references to the StorageQuery. The reference is already incremented before returned from this method.

if the reference counter has no remaining references the resource e.g. the StorageQuery will be closed. This ensures that a StorageQuery instance will be around as long as needed and the resources will be released. The reference counter should be decremented by clients after finished using the query instance.

Returns:
a ReferenceCounter instance holding the StorageQuery as a resource.

registerNewStorageQuery

protected void registerNewStorageQuery()
                                throws IOException
Forces the controller to register a new StorageQuery instance. This method will be called after an index has been modified to make the changes available for searching.

Throws:
IOException - - if an IO exception occurs

releaseNewStorageBuffer

protected StorageBuffer releaseNewStorageBuffer()
Creates a new StorageBuffer

Returns:
the new StorageBuffer

createIndexModifier

protected IndexModifier createIndexModifier()
                                     throws IOException
Creates a new IndexModifier on the storage index

Returns:
- a new modifier
Throws:
IOException - - if an IO exception occurs

forceWrite

public void forceWrite()
                throws IOException
Forces the StorageModifier to write all buffered changes.

Throws:
IOException - - if an IO exception occurs

releaseId

public String releaseId()
Creates a unique ID to store as an id for ServerBaseEntry instances

Specified by:
releaseId in interface StorageController
Returns:
- a unique id
Throws:
StorageException - - if no id can be released

destroy

public void destroy()
Description copied from interface: ServerComponent
will be called when the registry is going down e.g. when the GDataServerRegistry.destroy() method is called.

Specified by:
destroy in interface ServerComponent
Specified by:
destroy in interface StorageController
See Also:
StorageController.destroy()

getDirectory

protected Directory getDirectory()
Returns:
- the lucene directory used as a storage

getStorage

public Storage getStorage()
                   throws StorageException
Description copied from interface: StorageController
Creates Storage instances to access the underlaying storage component

Specified by:
getStorage in interface StorageController
Returns:
a storage instance
Throws:
StorageException - - if the storage instance can not be created
See Also:
StorageController.getStorage()

getLock

protected ConcurrentStorageLock getLock()

getBufferSize

public int getBufferSize()
The size of the StorageBuffer.

Returns:
- storage buffer size

setBufferSize

public void setBufferSize(int storageBufferSize)
The size of the StorageBuffer. This size should be at least as big as the persist factor to prevent the StorageBuffer from resizing

Parameters:
storageBufferSize -

getPersistFactor

public int getPersistFactor()
An integer value after how many changes to the StorageModifier the buffered changes will be persisted / written to the index

Returns:
- the persist factor

setPersistFactor

public void setPersistFactor(int storagePersistFactor)
Parameters:
storagePersistFactor -

getIndexOptimizeInterval

public int getIndexOptimizeInterval()
Returns:
Returns the indexOptimizeInterval.

setOptimizeInterval

public void setOptimizeInterval(int indexOptimizeInterval)
Parameters:
indexOptimizeInterval - The indexOptimizeInterval to set.

isKeepRecoveredFiles

public boolean isKeepRecoveredFiles()
Returns:
Returns the keepRecoveredFiles.

setKeepRecoveredFiles

public void setKeepRecoveredFiles(boolean keepRecoveredFiles)
Parameters:
keepRecoveredFiles - The keepRecoveredFiles to set.

isRecover

public boolean isRecover()
Returns:
Returns the recover.

setRecover

public void setRecover(boolean recover)
Parameters:
recover - The recover to set.

setStorageDir

public void setStorageDir(Directory storageDir)
Parameters:
storageDir - The storageDir to set.

setDirectory

public void setDirectory(String storageDirectory)
Parameters:
storageDirectory - The storageDirectory to set.

writeRecoverEntry

protected void writeRecoverEntry(StorageEntryWrapper wrapper)
                          throws RecoverException
Throws:
RecoverException

registerNewRecoverWriter

protected void registerNewRecoverWriter()
                                 throws IOException
Throws:
IOException


Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.