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

java.lang.Object
  extended by org.apache.lucene.gdata.storage.lucenestorage.StorageModifier

public class StorageModifier
extends Object

The StorageModifier is the a Singleton component of the LuceneStorage. There is one single instance of this class modifying the index used to store all the gdata Entities as Entries, Feeds and Users. This class contains an instance of IndexModifier used to manage all delete and add actions to the storage.

To prevent the storage component from opening and closing the IndexModifier for every modifying operation the incoming entry actions (DELETE, UPDATE, INSERT) will be buffered in a registered instance of StorageBuffer. When a certain amout (specified as the persistfactor in the configuration file) of modifications have been executed the StorageModifier will persist the buffered entries.

Feed and User operations won't be buffered. These actions occure not very often compared to entry actions. Every call of an user / feed modifying operation forces all changes to be written to the storage index.

Author:
Simon Willnauer

Field Summary
protected static org.apache.commons.logging.Log LOG
           
 
Constructor Summary
protected StorageModifier(StorageCoreController controller, IndexModifier modifier, StorageBuffer buffer, int persitsFactor, int optimizeInterval)
          Creates a new StorageModifier
 
Method Summary
protected  void close()
           
 void createAccount(StorageAccountWrapper account)
          Adds a new accountr to the storage.
 void createFeed(StorageFeedWrapper wrapper)
          Adds a new Feed to the storage.
 void deleteAccount(String accountName)
          Deletes the user with the given username.
 void deleteEntry(StorageEntryWrapper wrapper)
          Deletes the entry for the given entry id.
 void deleteFeed(String feedId)
          Deletes the feed with the given feed id Feed action will be not buffered.
 void forceWrite()
          Persists all changes imediately
 void insertEntry(StorageEntryWrapper wrapper)
          Inserts a new Entry to the Lucene index storage
 void updateAccount(StorageAccountWrapper user)
          User action will be not buffered.
 void updateEntry(StorageEntryWrapper wrapper)
          Updates the given entry.
 void updateFeed(StorageFeedWrapper wrapper)
          Feed action will be not buffered.
 
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

StorageModifier

protected StorageModifier(StorageCoreController controller,
                          IndexModifier modifier,
                          StorageBuffer buffer,
                          int persitsFactor,
                          int optimizeInterval)
Creates a new StorageModifier

Parameters:
controller - - the registered StorageController
modifier - - the IndexModifier
buffer - - the StorageBuffer
persitsFactor - - the factor when the changes will be persisted to the storage index
optimizeInterval - - after how many storage operations the index will be optimized
Method Detail

updateEntry

public void updateEntry(StorageEntryWrapper wrapper)
                 throws StorageException
Updates the given entry. First the alredy persisted entry will be removed, after marking as deleted the new Entry will be written.

Parameters:
wrapper - - the wrapper containing the entry
Throws:
StorageException - - if the entry can not be stored

insertEntry

public void insertEntry(StorageEntryWrapper wrapper)
                 throws StorageException
Inserts a new Entry to the Lucene index storage

Parameters:
wrapper - - the wrapper containing the entry
Throws:
StorageException - - if the entry can not be stored

deleteEntry

public void deleteEntry(StorageEntryWrapper wrapper)
                 throws StorageException
Deletes the entry for the given entry id.

Parameters:
wrapper - - the wrapper containing the information to delete
Throws:
StorageException - - if the entry can not be deleted

createFeed

public void createFeed(StorageFeedWrapper wrapper)
                throws StorageException
Adds a new Feed to the storage. Feed action will be not buffered. Call to this method forces the index to be written.

Parameters:
wrapper - - the wrapper containing the feed;
Throws:
StorageException - - if the feed can not be written

createAccount

public void createAccount(StorageAccountWrapper account)
                   throws StorageException
Adds a new accountr to the storage. User action will be not buffered. Call to this method forces the index to be written.

Parameters:
account - -the wrapper containig the user to be persisted
Throws:
StorageException - - if the user can not be persisted.

deleteAccount

public void deleteAccount(String accountName)
                   throws StorageException
Deletes the user with the given username. User action will be not buffered. Call to this method forces the index to be written.

Parameters:
accountName - - the user to be deleted
Throws:
StorageException - - If the user could not be deleted

updateAccount

public void updateAccount(StorageAccountWrapper user)
                   throws StorageException
User action will be not buffered. Call to this method forces the index to be written.

Parameters:
user - -the wrapper containig the user to be persisted
Throws:
StorageException - - if the user can not be persisted.

updateFeed

public void updateFeed(StorageFeedWrapper wrapper)
                throws StorageException
Feed action will be not buffered. Call to this method forces the index to be written.

Parameters:
wrapper - - the wrapper containig the feed
Throws:
StorageException - - if the feed can not be persisted

deleteFeed

public void deleteFeed(String feedId)
                throws StorageException
Deletes the feed with the given feed id Feed action will be not buffered. Call to this method forces the index to be written. All entries referencing the given feed id will be deleted as well!

Parameters:
feedId - - the id of the feed to delete
Throws:
StorageException - - if the feed can not be deleted

forceWrite

public void forceWrite()
                throws IOException
Persists all changes imediately

Throws:
IOException - -- if an IO Exception occures

close

protected void close()
              throws IOException
Throws:
IOException


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