org.jboss.ha.timestamp
Class TimestampDiscrepancyService

java.lang.Object
  extended by org.jboss.ha.timestamp.TimestampDiscrepancyService
All Implemented Interfaces:
org.jboss.kernel.spi.dependency.KernelControllerContextAware

public class TimestampDiscrepancyService
extends Object
implements org.jboss.kernel.spi.dependency.KernelControllerContextAware

Service that tracks TimestampDiscrepancy information for current and past members of the cluster.

Discrepancy information is not persisted, so no knowledge of past members is retained across a cluster restart.

Version:
$Revision: $
Author:
Brian Stansberry

Nested Class Summary
static class TimestampDiscrepancyService.RemoteDiscrepancies
           
 class TimestampDiscrepancyService.RpcHandler
          Object we register with the HAPartition
static class TimestampDiscrepancyService.Server
           
static class TimestampDiscrepancyService.TimestampResponse
           
 
Constructor Summary
TimestampDiscrepancyService()
           
 
Method Summary
 long getLastPurge()
          Gets the time of the last attempt to purge non-active members from the @{link discrepancies map.
 long getLastStatusCheck()
          Gets the time of the last request to the cluster for timestamps.
 int getMaxDeadServers()
          Gets the maximum number of records for non-active servers we'll retain in our @{link discrepancies map after which we can attempt to remove non-active servers who we heard from less recently than getMinDeadServerTime().
 long getMinDeadServerTime()
          Gets the minimum period of time since last checking with the server that we'll retain a non-active server in our
 long getMinPurgeFrequency()
          Gets the minimum period between attempts to purge non-active members from the @{link discrepancies map.
 long getMinStatusCheckFrequency()
          Gets the minimum period between periodic status checks.
 org.jboss.ha.framework.interfaces.HAPartition getPartition()
           
 String getServiceHAName()
          Gets the name under which we register ourself with the HAPartition.
 Map<org.jboss.ha.framework.interfaces.ClusterNode,TimestampDiscrepancy> getTimestampDiscrepancies(boolean allowStatusCheck)
          Gets the map of TimestampDiscrepancy data tracked by this service.
 TimestampDiscrepancy getTimestampDiscrepancy(org.jboss.ha.framework.interfaces.ClusterNode node, boolean allowStatusCheck)
          Gets the TimestampDiscrepancy data associated with a particular node.
 TimestampDiscrepancy getTimestampDiscrepancy(String nodeName, boolean allowStatusCheck)
          Gets the TimestampDiscrepancy data associated with a particular node.
 boolean isServerActive(org.jboss.ha.framework.interfaces.ClusterNode node)
          Gets whether the particular node is one of the servers this service regards as active (i.e.
 boolean isStatusCheckRequired()
          Gets whether an event has occurred (e.g.
 void registerObserver(TimestampDiscrepancyObserver observer)
          Register a TimestampDiscrepancyObserver with this service.
 void setKernelControllerContext(org.jboss.kernel.spi.dependency.KernelControllerContext context)
          Registers the context name as the serviceHAName if it is not already set.
 void setMaxDeadServers(int maxDeadServers)
           
 void setMinDeadServerTime(long minDeadServerTime)
           
 void setMinPurgeFrequency(long minPurgeFrequency)
           
 void setMinStatusCheckFrequency(long minStatusCheckFrequency)
           
 void setPartition(org.jboss.ha.framework.interfaces.HAPartition partition)
           
 void setServiceHAName(String serviceHAName)
          Sets the name under which we register ourself with the HAPartition.
 void setThreadPool(org.jboss.util.threadpool.ThreadPool threadPool)
          Injects a thread pool for use in dispatching asynchronous tasks.
 void start()
          Bring the service into active operation.
 void stop()
          Remove the service from active operation.
 void unregisterObserver(TimestampDiscrepancyObserver observer)
          Unregister a TimestampDiscrepancyObserver with this service.
 void unsetKernelControllerContext(org.jboss.kernel.spi.dependency.KernelControllerContext context)
          This implementation is a no-op.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

TimestampDiscrepancyService

public TimestampDiscrepancyService()
Method Detail

getPartition

public org.jboss.ha.framework.interfaces.HAPartition getPartition()

setPartition

public void setPartition(org.jboss.ha.framework.interfaces.HAPartition partition)

getServiceHAName

public String getServiceHAName()
Gets the name under which we register ourself with the HAPartition.

Returns:
the name

setServiceHAName

public void setServiceHAName(String serviceHAName)
Sets the name under which we register ourself with the HAPartition.

Parameters:
serviceHAName - the name

getMaxDeadServers

public int getMaxDeadServers()
Gets the maximum number of records for non-active servers we'll retain in our @{link discrepancies map after which we can attempt to remove non-active servers who we heard from less recently than getMinDeadServerTime().

An active server is one that is include in the most recent view propagated by the HAPartition's DRM.

Returns:
the max number of servers

setMaxDeadServers

public void setMaxDeadServers(int maxDeadServers)

getMinDeadServerTime

public long getMinDeadServerTime()
Gets the minimum period of time since last checking with the server that we'll retain a non-active server in our

Returns:
the minimum period of time, in ms
See Also:
getMaxDeadServers()

setMinDeadServerTime

public void setMinDeadServerTime(long minDeadServerTime)

getMinStatusCheckFrequency

public long getMinStatusCheckFrequency()
Gets the minimum period between periodic status checks. A status check is a request to the cluster for each server's local timestamp, used to build the TimestampDiscrepancy for that server.

A status check can occur more frequently than this value if the service determines it is necessary, for example following a view change.

The default value is 20 minutes.

Returns:
the minimum frequency in ms

setMinStatusCheckFrequency

public void setMinStatusCheckFrequency(long minStatusCheckFrequency)

getMinPurgeFrequency

public long getMinPurgeFrequency()
Gets the minimum period between attempts to purge non-active members from the @{link discrepancies map.

Default is one hour

Returns:
the minimum frequency in ms
See Also:
getMaxDeadServers(), getMinDeadServerTime()

setMinPurgeFrequency

public void setMinPurgeFrequency(long minPurgeFrequency)

getLastStatusCheck

public long getLastStatusCheck()
Gets the time of the last request to the cluster for timestamps.

Returns:
the time of the last request, in ms since the epoch

isStatusCheckRequired

public boolean isStatusCheckRequired()
Gets whether an event has occurred (e.g. a view change) that requires a status check.

Returns:
true if a check is required

getLastPurge

public long getLastPurge()
Gets the time of the last attempt to purge non-active members from the @{link discrepancies map.

Returns:
the time of the last purge, in ms since the epoch

setThreadPool

public void setThreadPool(org.jboss.util.threadpool.ThreadPool threadPool)
Injects a thread pool for use in dispatching asynchronous tasks. If no thread pool is injected, threads will be spawned to handle such tasks.

Asynchronous tasks are generally associated with view changes.

Parameters:
threadPool - the thread pool

getTimestampDiscrepancies

public Map<org.jboss.ha.framework.interfaces.ClusterNode,TimestampDiscrepancy> getTimestampDiscrepancies(boolean allowStatusCheck)
Gets the map of TimestampDiscrepancy data tracked by this service.

Parameters:
allowStatusCheck - is calling into the cluster to update the discrepancies map before returning allowed?
Returns:
the map. Will not return null

getTimestampDiscrepancy

public TimestampDiscrepancy getTimestampDiscrepancy(org.jboss.ha.framework.interfaces.ClusterNode node,
                                                    boolean allowStatusCheck)
Gets the TimestampDiscrepancy data associated with a particular node.

Parameters:
node - the node
allowStatusCheck - is calling into the cluster to update the discrepancies map before returning allowed?
Returns:
the discrepancy data. Will return null if no data for node is stored.

getTimestampDiscrepancy

public TimestampDiscrepancy getTimestampDiscrepancy(String nodeName,
                                                    boolean allowStatusCheck)
Gets the TimestampDiscrepancy data associated with a particular node.

Parameters:
node - the name of the node
allowStatusCheck - is calling into the cluster to update the discrepancies map before returning allowed?
Returns:
the discrepancy data. Will return null if no data for node is stored.

isServerActive

public boolean isServerActive(org.jboss.ha.framework.interfaces.ClusterNode node)
Gets whether the particular node is one of the servers this service regards as active (i.e. part of the cluster topology for the service).

Parameters:
node - the node
Returns:
true if the node is active, false otherwise

start

public void start()
           throws Exception
Bring the service into active operation.

Throws:
Exception

stop

public void stop()
          throws Exception
Remove the service from active operation.

Throws:
Exception

registerObserver

public void registerObserver(TimestampDiscrepancyObserver observer)
Register a TimestampDiscrepancyObserver with this service.

Parameters:
observer - the observer

unregisterObserver

public void unregisterObserver(TimestampDiscrepancyObserver observer)
Unregister a TimestampDiscrepancyObserver with this service.

Parameters:
observer - the observer

setKernelControllerContext

public void setKernelControllerContext(org.jboss.kernel.spi.dependency.KernelControllerContext context)
                                throws Exception
Registers the context name as the serviceHAName if it is not already set.

Specified by:
setKernelControllerContext in interface org.jboss.kernel.spi.dependency.KernelControllerContextAware
Throws:
Exception

unsetKernelControllerContext

public void unsetKernelControllerContext(org.jboss.kernel.spi.dependency.KernelControllerContext context)
                                  throws Exception
This implementation is a no-op.

Specified by:
unsetKernelControllerContext in interface org.jboss.kernel.spi.dependency.KernelControllerContextAware
Throws:
Exception


Copyright © 2009 JBoss, a division of Red Hat, Inc.. All Rights Reserved.