org.codehaus.activecluster.impl
Class StateServiceImpl

java.lang.Object
  extended byorg.codehaus.activecluster.impl.StateServiceImpl
All Implemented Interfaces:
StateService

public class StateServiceImpl
extends Object
implements StateService

Represents a node list

Version:
$Revision: 1.10 $

Nested Class Summary
protected static class StateServiceImpl.NodeEntry
           
 
Constructor Summary
StateServiceImpl(Cluster cluster, Object clusterLock, Runnable localNodePing, Timer timer, long inactiveTime)
           
 
Method Summary
 void addClusterListener(ClusterListener listener)
           
 void checkForTimeouts()
           
protected  void coordinatorChanged(Node node)
           
 TimerTask createTimerTask()
           
protected  void doElection()
           
 ElectionStrategy getElectionStrategy()
           
 long getInactiveTime()
           
 Map getNodes()
           
protected  long getTimeMillis()
          For performance we may wish to use a less granualar timing mechanism only updating the time every x millis since we're only using the time as a judge of when a node has not pinged for at least a few hundred millis etc.
 void keepAlive(Node node)
          Sends a keep alive to the cluster
protected  void nodeAdded(Node node)
           
protected  void nodeFailed(Node node)
           
protected  void nodeUpdated(Node node)
           
 void removeClusterListener(ClusterListener listener)
           
 void setElectionStrategy(ElectionStrategy electionStrategy)
          set the election strategy
 void setInactiveTime(long inactiveTime)
           
 void shutdown(Node node)
          Sends a shutdown message to the cluster
protected  boolean stateHasChanged(Node oldNode, Node newNode)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StateServiceImpl

public StateServiceImpl(Cluster cluster,
                        Object clusterLock,
                        Runnable localNodePing,
                        Timer timer,
                        long inactiveTime)
Method Detail

getElectionStrategy

public ElectionStrategy getElectionStrategy()
Returns:
the current election strategy

setElectionStrategy

public void setElectionStrategy(ElectionStrategy electionStrategy)
set the election strategy

Parameters:
electionStrategy -

getInactiveTime

public long getInactiveTime()

setInactiveTime

public void setInactiveTime(long inactiveTime)

getNodes

public Map getNodes()

keepAlive

public void keepAlive(Node node)
Description copied from interface: StateService
Sends a keep alive to the cluster

Specified by:
keepAlive in interface StateService
Parameters:
node -

shutdown

public void shutdown(Node node)
Description copied from interface: StateService
Sends a shutdown message to the cluster

Specified by:
shutdown in interface StateService

checkForTimeouts

public void checkForTimeouts()

createTimerTask

public TimerTask createTimerTask()

addClusterListener

public void addClusterListener(ClusterListener listener)

removeClusterListener

public void removeClusterListener(ClusterListener listener)

nodeAdded

protected void nodeAdded(Node node)

nodeUpdated

protected void nodeUpdated(Node node)

nodeFailed

protected void nodeFailed(Node node)

coordinatorChanged

protected void coordinatorChanged(Node node)

doElection

protected void doElection()

getTimeMillis

protected long getTimeMillis()
For performance we may wish to use a less granualar timing mechanism only updating the time every x millis since we're only using the time as a judge of when a node has not pinged for at least a few hundred millis etc.

Returns:

stateHasChanged

protected boolean stateHasChanged(Node oldNode,
                                  Node newNode)
Returns:
true if the node has changed state from the old in memory copy to the newly arrived copy


Copyright © 2004-2005 Protique, Ltd.. All Rights Reserved.