atg.repository.search.indexing
Class ConfigStatePersister

java.lang.Object
  extended by atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
      extended by atg.nucleus.GenericService
          extended by atg.repository.search.indexing.ConfigStatePersister
All Implemented Interfaces:
NameContextBindingListener, NameContextElement, NameResolver, AdminableService, ApplicationLogging, atg.nucleus.logging.ApplicationLoggingSender, atg.nucleus.logging.TraceApplicationLogging, atg.nucleus.logging.VariableArgumentApplicationLogging, ComponentNameResolver, Service, ServiceListener, java.util.EventListener

public class ConfigStatePersister
extends GenericService

Handles persisting information about the state of the indexing configuration. Specifically, persists such information as:

A generation is merely a version number for a set of changes. The generation mechanism exists so that the incremental loader can queue up a set of changes (see IncrementalItemQueue), claim that generation and begin processing it, even as change events get queued up in the next generation.

Created: April 15 2005


Nested Class Summary
 class ConfigStatePersister.ConfigState
          Class which represents the configuration state.
static class ConfigStatePersister.IndexingReadLockedTransactionAction
          An inner class to do a transaction with the CLAIMED read lock.
static class ConfigStatePersister.IndexingWriteLockedTransactionAction
          An inner class to do a transaction with the CLAIMED write lock.
 
Field Summary
static java.lang.String CLASS_VERSION
          Class version string
 
Fields inherited from class atg.nucleus.GenericService
SERVICE_INFO_KEY
 
Fields inherited from interface atg.nucleus.logging.TraceApplicationLogging
DEFAULT_LOG_TRACE_STATUS
 
Fields inherited from interface atg.nucleus.logging.ApplicationLogging
DEFAULT_LOG_DEBUG_STATUS, DEFAULT_LOG_ERROR_STATUS, DEFAULT_LOG_INFO_STATUS, DEFAULT_LOG_WARNING_STATUS
 
Constructor Summary
ConfigStatePersister()
           
 
Method Summary
 int claimAndIncrementGeneration(java.lang.String pConfigPath, boolean pForIncrementalUpdate)
          Claim the current generation, increment the generation count, and return the number for the generation we just claimed.
 void completedFullIndex(java.lang.String pConfigPath, int pGeneration, boolean pCompletedSuccessfully)
           
 void completedIncrementalIndex(java.lang.String pConfigPath, int pGeneration, boolean pCompletedSuccessfully)
           
protected  void completedIndex(java.lang.String pConfigPath, int pGeneration, boolean pCompletedSuccessfully, boolean pIncremental)
           
protected  ConfigStatePersister.ConfigState createConfigState(RepositoryItem pItem)
          Create a configuration state from the specified repository item.
 void doStartService()
          Start up the service...
protected  RepositoryItem[] getClaimedConfigStateItems()
          Return the configuration items claimed by some server.
 java.lang.String getClaimedGenerationPropertyName()
          Get the claimed generation property name.
 ClientLockManager getClientLockManager()
          The client lock manager...
 java.lang.String getConfigPathPropertyName()
           
protected  RepositoryItem[] getConfigStateItemsByUniqueServerId(java.lang.String pUniqueServerId)
          Return the repository items that are owned by the specified server Id.
 java.lang.Object getConfigStateProperty(java.lang.String pConfigPath, java.lang.String pPropertyName)
           
 int getCurrentGenerationForConfig(java.lang.String pConfigPath)
          Get the current generation for the specified configuration.
 int getGenerationForConfig(java.lang.String pConfigPath)
          Get the generation for the specified config.
 java.lang.String getGenerationPropertyName()
           
 RepositoryItemDescriptor getItemDescriptor()
          Get the item descriptor used for storage.
 java.lang.String getItemDescriptorName()
           
protected  RepositoryItem getItemForConfig(java.lang.String pConfigPath, boolean pMutable)
          Get or create the repository item for the specified configuration.
 java.lang.String getLastActivityPropertyName()
           
 java.lang.String getLastFullIndexPropertyName()
           
 java.util.Date getLastFullIndexTime(java.lang.String pConfigPath)
          Get the last full index time.
 java.lang.String getLastIncrementalIndexPropertyName()
           
 java.util.Date getLastIncrementalIndexTime(java.lang.String pConfigPath)
          Get the last incremental index time.
 java.net.InetAddress getLocalHost()
          Returns the InetAddress of this host
 java.lang.String getNextIncrementalGenerationPropertyName()
           
 long getRefreshCurrentGenerationMsecs()
          The number of seconds before cached information about the current generation for a configuration is considered stale.
 MutableRepository getRepository()
          The repository to store items.
 java.net.InetAddress getSessionIdAddress()
          Returns the IP address that will be stamped into generated session id's
 int getSessionIdPort()
          Returns the IP address that will be stamped into generated session id's
 long getTimeOutMsecs()
          Get the number of milliseconds of inactivity before a claimed index is considered timed out.
 javax.transaction.TransactionManager getTransactionManager()
          Get the transaction manager used to manager transactions.
protected  RepositoryItem[] getUnclaimedConfigStateItems()
          Return the configuration items claimed by some server.
 ConfigStatePersister.ConfigState[] getUnclaimedConfigStates()
          Get the generation for the specified config.
 java.lang.String getUniqueServerId()
          This is a uniq id for each dyanmo server.
 java.lang.String getUniqueServerIdPropertyName()
           
protected  boolean hasTimedOut(long pLastActivity)
          Whether the last activity time is considered timed out.
protected  boolean hasTimedOut(RepositoryItem pItem)
          Whether the lastActivity property on pItem is longer ago than timeOutMsecs.
 boolean isAlwaysAcquireWriteLock()
          Whether to always acquire a write lock from the lock manager.
 void releaseAllConfigurations()
          Release all configurations claimed by this server.
 void releaseTimedOutConfigurations()
          Release all configurations claimed by this server.
 void removedCachedValueForConfig(java.lang.String pConfigPath)
          Remove cached information for the specified configuration path, so that it will be fetched anew next time it is needed.
 void setAlwaysAcquireWriteLock(boolean pAlwaysAcquireWriteLock)
          Whether to always acquire a write lock from the lock manager.
 void setClaimedGenerationPropertyName(java.lang.String pClaimedGenerationPropertyName)
          Set the claimed generation property name.
 void setClientLockManager(ClientLockManager pClientLockManager)
          The client lock manager...
 void setConfigPathPropertyName(java.lang.String pConfigPathPropertyName)
           
 void setGenerationPropertyName(java.lang.String pGenerationPropertyName)
           
 void setItemDescriptorName(java.lang.String pItemDescriptorName)
           
 void setLastActivityPropertyName(java.lang.String pLastActivityPropertyName)
           
 void setLastFullIndexPropertyName(java.lang.String pLastFullIndexPropertyName)
           
 void setLastIncrementalIndexPropertyName(java.lang.String pLastIncrementalIndexPropertyName)
           
 void setNextIncrementalGenerationPropertyName(java.lang.String pNextIncrementalGenerationPropertyName)
           
 void setRefreshCurrentGenerationMsecs(long pRefreshCurrentGenerationMsecs)
          The number of seconds before cached information about the current generation for a configuration is considered stale.
 void setRepository(MutableRepository pRepository)
          The repository to store items.
 void setSessionIdAddress(java.net.InetAddress pSessionIdAddress)
          Sets the IP address that will be stamped into generated session id's
 void setSessionIdPort(int pSessionIdPort)
          Sets the IP address that will be stamped into generated session id's
 void setTimeOutMsecs(long pTimeOutMsecs)
          Set the number of milliseconds of inactivity before a claimed index is considered timed out.
 void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
          Set the transaction manager used to manager transactions.
 void setUniqueServerIdPropertyName(java.lang.String pUniqueServerIdPropertyName)
           
 void updateLastActivityTime(java.lang.String pConfigPath, int pGeneration)
          Update the activity time for the specified generation.
 void updateLastActivityTime(java.lang.String pConfigPath, int pGeneration, long pLastActivityTime)
          Update the activity time for the specified generation.
 
Methods inherited from class atg.nucleus.GenericService
addLogListener, createAdminServlet, doStopService, getAbsoluteName, getAdminServlet, getLoggingForVlogging, getLogListenerCount, getLogListeners, getName, getNameContext, getNucleus, getRoot, getServiceConfiguration, getServiceInfo, isLoggingDebug, isLoggingError, isLoggingInfo, isLoggingTrace, isLoggingWarning, isRunning, logDebug, logDebug, logDebug, logError, logError, logError, logInfo, logInfo, logInfo, logTrace, logTrace, logTrace, logWarning, logWarning, logWarning, nameContextElementBound, nameContextElementUnbound, removeLogListener, resolveName, resolveName, resolveName, resolveName, sendLogEvent, setLoggingDebug, setLoggingError, setLoggingInfo, setLoggingTrace, setLoggingWarning, setNucleus, setServiceInfo, startService, stopService
 
Methods inherited from class atg.nucleus.logging.VariableArgumentApplicationLoggingImpl
vlogDebug, vlogDebug, vlogDebug, vlogDebug, vlogError, vlogError, vlogError, vlogError, vlogInfo, vlogInfo, vlogInfo, vlogInfo, vlogTrace, vlogTrace, vlogTrace, vlogTrace, vlogWarning, vlogWarning, vlogWarning, vlogWarning
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASS_VERSION

public static final java.lang.String CLASS_VERSION
Class version string

See Also:
Constant Field Values
Constructor Detail

ConfigStatePersister

public ConfigStatePersister()
Method Detail

setRepository

public void setRepository(MutableRepository pRepository)
The repository to store items.


getRepository

public MutableRepository getRepository()
The repository to store items.


setItemDescriptorName

public void setItemDescriptorName(java.lang.String pItemDescriptorName)

getItemDescriptorName

public java.lang.String getItemDescriptorName()

setTransactionManager

public void setTransactionManager(javax.transaction.TransactionManager pTransactionManager)
Set the transaction manager used to manager transactions.


getTransactionManager

public javax.transaction.TransactionManager getTransactionManager()
Get the transaction manager used to manager transactions.


getItemDescriptor

public RepositoryItemDescriptor getItemDescriptor()
Get the item descriptor used for storage.


setConfigPathPropertyName

public void setConfigPathPropertyName(java.lang.String pConfigPathPropertyName)

getConfigPathPropertyName

public java.lang.String getConfigPathPropertyName()

setGenerationPropertyName

public void setGenerationPropertyName(java.lang.String pGenerationPropertyName)

getGenerationPropertyName

public java.lang.String getGenerationPropertyName()

setUniqueServerIdPropertyName

public void setUniqueServerIdPropertyName(java.lang.String pUniqueServerIdPropertyName)

getUniqueServerIdPropertyName

public java.lang.String getUniqueServerIdPropertyName()

setLastActivityPropertyName

public void setLastActivityPropertyName(java.lang.String pLastActivityPropertyName)

getLastActivityPropertyName

public java.lang.String getLastActivityPropertyName()

setLastFullIndexPropertyName

public void setLastFullIndexPropertyName(java.lang.String pLastFullIndexPropertyName)

getLastFullIndexPropertyName

public java.lang.String getLastFullIndexPropertyName()

setLastIncrementalIndexPropertyName

public void setLastIncrementalIndexPropertyName(java.lang.String pLastIncrementalIndexPropertyName)

getLastIncrementalIndexPropertyName

public java.lang.String getLastIncrementalIndexPropertyName()

setTimeOutMsecs

public void setTimeOutMsecs(long pTimeOutMsecs)
Set the number of milliseconds of inactivity before a claimed index is considered timed out.


getTimeOutMsecs

public long getTimeOutMsecs()
Get the number of milliseconds of inactivity before a claimed index is considered timed out.


setRefreshCurrentGenerationMsecs

public void setRefreshCurrentGenerationMsecs(long pRefreshCurrentGenerationMsecs)
The number of seconds before cached information about the current generation for a configuration is considered stale.


getRefreshCurrentGenerationMsecs

public long getRefreshCurrentGenerationMsecs()
The number of seconds before cached information about the current generation for a configuration is considered stale.


setClaimedGenerationPropertyName

public void setClaimedGenerationPropertyName(java.lang.String pClaimedGenerationPropertyName)
Set the claimed generation property name.


getClaimedGenerationPropertyName

public java.lang.String getClaimedGenerationPropertyName()
Get the claimed generation property name.


setNextIncrementalGenerationPropertyName

public void setNextIncrementalGenerationPropertyName(java.lang.String pNextIncrementalGenerationPropertyName)

getNextIncrementalGenerationPropertyName

public java.lang.String getNextIncrementalGenerationPropertyName()

getUniqueServerId

public java.lang.String getUniqueServerId()
This is a uniq id for each dyanmo server. IpAddress and DprPort. (###.###.###.###:####)


getSessionIdAddress

public java.net.InetAddress getSessionIdAddress()
Returns the IP address that will be stamped into generated session id's


setSessionIdAddress

public void setSessionIdAddress(java.net.InetAddress pSessionIdAddress)
Sets the IP address that will be stamped into generated session id's


getSessionIdPort

public int getSessionIdPort()
Returns the IP address that will be stamped into generated session id's


setSessionIdPort

public void setSessionIdPort(int pSessionIdPort)
Sets the IP address that will be stamped into generated session id's


getLocalHost

public java.net.InetAddress getLocalHost()
Returns the InetAddress of this host


setClientLockManager

public void setClientLockManager(ClientLockManager pClientLockManager)
The client lock manager... used to prevent multiple servers from claiming/unclaiming a configuration.


getClientLockManager

public ClientLockManager getClientLockManager()
The client lock manager... used to prevent multiple servers from claiming/unclaiming a configuration.


setAlwaysAcquireWriteLock

public void setAlwaysAcquireWriteLock(boolean pAlwaysAcquireWriteLock)
Whether to always acquire a write lock from the lock manager.


isAlwaysAcquireWriteLock

public boolean isAlwaysAcquireWriteLock()
Whether to always acquire a write lock from the lock manager.


getItemForConfig

protected RepositoryItem getItemForConfig(java.lang.String pConfigPath,
                                          boolean pMutable)
                                   throws RepositoryException
Get or create the repository item for the specified configuration.

Throws:
RepositoryException

getGenerationForConfig

public int getGenerationForConfig(java.lang.String pConfigPath)
                           throws IndexingException
Get the generation for the specified config. Will create a repository entry if none exists.

Throws:
IndexingException

updateLastActivityTime

public void updateLastActivityTime(java.lang.String pConfigPath,
                                   int pGeneration)
                            throws IndexingException
Update the activity time for the specified generation. The specified generation must match the currently claimed generation.

Throws:
IndexingException

updateLastActivityTime

public void updateLastActivityTime(java.lang.String pConfigPath,
                                   int pGeneration,
                                   long pLastActivityTime)
                            throws IndexingException
Update the activity time for the specified generation. The specified generation must match the currently claimed generation.

Parameters:
pConfigPath - the configuration path for the config status
pGeneration - the generation claimed whose last activity time needs to be update
pLastActivityTime - the new last activity time to be written
Throws:
IndexingException

claimAndIncrementGeneration

public int claimAndIncrementGeneration(java.lang.String pConfigPath,
                                       boolean pForIncrementalUpdate)
                                throws IndexingException,
                                       ConfigurationClaimedIndexingException
Claim the current generation, increment the generation count, and return the number for the generation we just claimed.

Parameters:
pConfigPath - The configuration path of the configuration to claim.
Returns:
the claimed generation, or -1 if this server already claimed the configuration (presumably in a different thread).
Throws:
IndexingException
ConfigurationClaimedIndexingException

completedFullIndex

public void completedFullIndex(java.lang.String pConfigPath,
                               int pGeneration,
                               boolean pCompletedSuccessfully)
                        throws IndexingException
Throws:
IndexingException

completedIncrementalIndex

public void completedIncrementalIndex(java.lang.String pConfigPath,
                                      int pGeneration,
                                      boolean pCompletedSuccessfully)
                               throws IndexingException
Throws:
IndexingException

completedIndex

protected void completedIndex(java.lang.String pConfigPath,
                              int pGeneration,
                              boolean pCompletedSuccessfully,
                              boolean pIncremental)
                       throws IndexingException
Throws:
IndexingException

getLastFullIndexTime

public java.util.Date getLastFullIndexTime(java.lang.String pConfigPath)
                                    throws IndexingException
Get the last full index time.

Throws:
IndexingException

getLastIncrementalIndexTime

public java.util.Date getLastIncrementalIndexTime(java.lang.String pConfigPath)
                                           throws IndexingException
Get the last incremental index time.

Throws:
IndexingException

getConfigStateProperty

public java.lang.Object getConfigStateProperty(java.lang.String pConfigPath,
                                               java.lang.String pPropertyName)
                                        throws IndexingException
Throws:
IndexingException

getConfigStateItemsByUniqueServerId

protected RepositoryItem[] getConfigStateItemsByUniqueServerId(java.lang.String pUniqueServerId)
                                                        throws RepositoryException
Return the repository items that are owned by the specified server Id. This method expects a transaction already in place.

Throws:
RepositoryException

getClaimedConfigStateItems

protected RepositoryItem[] getClaimedConfigStateItems()
                                               throws RepositoryException
Return the configuration items claimed by some server. Assumes a transaction is already in place.

Throws:
RepositoryException

getUnclaimedConfigStateItems

protected RepositoryItem[] getUnclaimedConfigStateItems()
                                                 throws RepositoryException
Return the configuration items claimed by some server. Assumes a transaction is already in place.

Throws:
RepositoryException

getUnclaimedConfigStates

public ConfigStatePersister.ConfigState[] getUnclaimedConfigStates()
                                                            throws IndexingException
Get the generation for the specified config. Will create a repository entry if none exists.

Throws:
IndexingException

createConfigState

protected ConfigStatePersister.ConfigState createConfigState(RepositoryItem pItem)
Create a configuration state from the specified repository item.


hasTimedOut

protected boolean hasTimedOut(RepositoryItem pItem)
Whether the lastActivity property on pItem is longer ago than timeOutMsecs.

Parameters:
pItem - the item whose lastActivity property will be consulted to look at timeout.

hasTimedOut

protected boolean hasTimedOut(long pLastActivity)
Whether the last activity time is considered timed out.

Parameters:
pLastActivity - The last activity time expressed in milliseconds.

releaseAllConfigurations

public void releaseAllConfigurations()
                              throws IndexingException
Release all configurations claimed by this server. This method is called by doStartService().

Throws:
IndexingException

releaseTimedOutConfigurations

public void releaseTimedOutConfigurations()
                                   throws IndexingException
Release all configurations claimed by this server. This method is called by doStartService().

Throws:
IndexingException

getCurrentGenerationForConfig

public int getCurrentGenerationForConfig(java.lang.String pConfigPath)
                                  throws IndexingException
Get the current generation for the specified configuration.

Throws:
IndexingException

removedCachedValueForConfig

public void removedCachedValueForConfig(java.lang.String pConfigPath)
Remove cached information for the specified configuration path, so that it will be fetched anew next time it is needed.


doStartService

public void doStartService()
                    throws ServiceException
Start up the service...

Overrides:
doStartService in class GenericService
Throws:
ServiceException - if the Service had a problem starting up