org.openanzo.server.repository.indexer
Class IndexUpdateHandler

java.lang.Object
  extended by org.openanzo.server.repository.indexer.IndexUpdateHandler

public class IndexUpdateHandler
extends java.lang.Object

Handler for index updates. Hook it into UpdateResultsHandler.

Author:
Wing Yung (wingyung@us.ibm.com)

Nested Class Summary
 class IndexUpdateHandler.IndexerUpdateHandler
          Handler for parsing transaction events that come from UpdateHandler.
 
Constructor Summary
IndexUpdateHandler(ModelServiceApi modelServiceApi, java.util.Properties properties, org.openanzo.server.repository.indexer.IndexQueryApi.UserAclTable userAclTable)
          NOTE: If the index update handler is started in asynchronous mode, it will start running immediately (you do not need to call start().
 
Method Summary
 IIndexer getIndexer()
          Returns the underlying indexer.
 void handle(byte[] bytes)
          Handles bytes from UpdateResultsHandler, to be parsed as a transaction.
 boolean isAsynchronous()
          Returns true if the indexing is asynchronous, false otherwise.
 boolean isIndexEnabled()
          Determine if indexing is enabled.
 boolean isStarted()
          Determine if service is started
 void reset()
          Reset the index (clear all contents).
 void setAsynchronous(boolean asynchronous)
          Sets asynchronicity of the indexing.
 void start()
          If the indexing is asynchronous, this will start indexing.
 void stop()
          If the indexing is asynchronous, this will stop the indexing.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IndexUpdateHandler

public IndexUpdateHandler(ModelServiceApi modelServiceApi,
                          java.util.Properties properties,
                          org.openanzo.server.repository.indexer.IndexQueryApi.UserAclTable userAclTable)
NOTE: If the index update handler is started in asynchronous mode, it will start running immediately (you do not need to call start().

Parameters:
modelServiceApi - Used to get RepositoryConnection for rebuilding the index, if necessary.
properties - Contains properties for setting up the indexer.
userAclTable - cache of user to acl mappings
Method Detail

isIndexEnabled

public boolean isIndexEnabled()
Determine if indexing is enabled.

Returns:
true if indexing is enabled.

getIndexer

public IIndexer getIndexer()
Returns the underlying indexer.

Returns:
the underlying indexer.

reset

public void reset()
           throws IndexerException
Reset the index (clear all contents).

Throws:
IndexerException

isStarted

public boolean isStarted()
Determine if service is started

Returns:
if service is started

start

public void start()
If the indexing is asynchronous, this will start indexing. Statements added and removed will result in the appropriate index updates.


stop

public void stop()
If the indexing is asynchronous, this will stop the indexing. The index will not be changed while the indexer is stopped. Pending asynchronous index changes will be allowed to complete.


isAsynchronous

public boolean isAsynchronous()
Returns true if the indexing is asynchronous, false otherwise.

Returns:
true if the indexing is asynchronous, false otherwise.

setAsynchronous

public void setAsynchronous(boolean asynchronous)
Sets asynchronicity of the indexing. If asynchronicity was previously false and is set to true, a new QueuedExecutor is created. Note that it must be started. If asynchronicity was previously true and is set to false, all queued indexing tasks are completed.

Parameters:
asynchronous - true for asynchronous indexing

handle

public void handle(byte[] bytes)
            throws AnzoException
Handles bytes from UpdateResultsHandler, to be parsed as a transaction.

Parameters:
bytes - Contents of the update results.
Throws:
AnzoException


Copyright © 2007 Cambridge Semantics Inc.. All Rights Reserved.