org.codehaus.wadi.dindex.impl
Class DIndex

java.lang.Object
  extended byorg.codehaus.wadi.dindex.impl.DIndex
All Implemented Interfaces:
ClusterListener, CoordinatorConfig, EventListener, SimplePartitionManager.Callback, StateManagerConfig

public class DIndex
extends Object
implements ClusterListener, CoordinatorConfig, SimplePartitionManager.Callback, StateManagerConfig


Field Summary
protected static String _birthTimeKey
           
protected  Cluster _cluster
           
protected  PartitionManagerConfig _config
           
protected  Coordinator _coordinator
           
protected  Latch _coordinatorLatch
           
protected  Object _coordinatorLock
           
protected  Node _coordinatorNode
           
protected static String _correlationIDMapKey
           
protected  Dispatcher _dispatcher
           
protected  Map _distributedState
           
protected  long _inactiveTime
           
protected  Collection _leavers
           
protected  Collection _left
           
protected  Log _lockLog
           
protected  Log _log
           
protected  String _nodeName
           
protected static String _nodeNameKey
           
protected static String _partitionKeysKey
           
protected  PartitionManager _partitionManager
           
protected  StateManager _stateManager
           
protected static String _timeStampKey
           
 
Constructor Summary
DIndex(String nodeName, int numPartitions, long inactiveTime, Dispatcher dispatcher, Map distributedState, PartitionMapper mapper)
           
 
Method Summary
 boolean amCoordinator()
           
 boolean contextualise(InvocationContext invocationContext, String id, Immoter immoter, Sync motionLock, boolean exclusiveOnly)
           
protected  void correlateStateUpdate(Map state)
           
 Collection[] createResultSet(int numPartitions, int[] keys)
           
 ObjectMessage forwardAndExchange(String name, RelocationRequest request, long timeout)
           
 Cluster getCluster()
           
 Node getCoordinator()
           
 Dispatcher getDispatcher()
           
 long getInactiveTime()
           
 Sync getInvocationLock(String name)
           
 Collection getLeavers()
           
 Collection getLeft()
           
 Node getLocalNode()
           
 String getLocalNodeName()
           
 String getNodeName(Destination destination)
           
static String getNodeName(Node node)
           
 int getNumPartitions()
           
 int getPartition()
           
 PartitionFacade getPartition(int key)
           
 PartitionFacade getPartition(Object key)
           
static PartitionKeys getPartitionKeys(Node node)
           
 PartitionManager getPartitionManager()
           
 Collection getRemoteNodes()
           
 Map getRendezVousMap()
           
 StateManager getStateManager()
           
 void init(PartitionManagerConfig config)
           
 boolean insert(String name, long timeout)
           
 boolean isCoordinator()
           
 void onCoordinatorChanged(ClusterEvent event)
           
 void onDismissal(ClusterEvent event)
           
 void onElection(ClusterEvent event)
           
 void onNodeAdd(ClusterEvent event)
           
 void onNodeFailed(ClusterEvent event)
           
 void onNodeRemoved(ClusterEvent event)
           
 void onNodeUpdate(ClusterEvent event)
           
protected  int printNode(Node node)
           
 void regenerateMissingPartitions(Node[] living, Node[] leaving)
           
 void relocate(String name)
           
 ObjectMessage relocate(String sessionName, String nodeName, int concurrentRequestThreads, boolean shuttingDown, long timeout)
           
 Motable relocate2(String sessionName, String nodeName, int concurrentRequestThreads, boolean shuttingDown, long timeout)
           
 void remove(String name)
           
 void start()
           
 void stop()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_nodeNameKey

protected static final String _nodeNameKey
See Also:
Constant Field Values

_partitionKeysKey

protected static final String _partitionKeysKey
See Also:
Constant Field Values

_timeStampKey

protected static final String _timeStampKey
See Also:
Constant Field Values

_birthTimeKey

protected static final String _birthTimeKey
See Also:
Constant Field Values

_correlationIDMapKey

protected static final String _correlationIDMapKey
See Also:
Constant Field Values

_distributedState

protected final Map _distributedState

_coordinatorLatch

protected final Latch _coordinatorLatch

_coordinatorLock

protected final Object _coordinatorLock

_dispatcher

protected final Dispatcher _dispatcher

_cluster

protected final Cluster _cluster

_nodeName

protected final String _nodeName

_log

protected final Log _log

_inactiveTime

protected final long _inactiveTime

_partitionManager

protected final PartitionManager _partitionManager

_stateManager

protected final StateManager _stateManager

_lockLog

protected final Log _lockLog

_coordinatorNode

protected Node _coordinatorNode

_coordinator

protected Coordinator _coordinator

_config

protected PartitionManagerConfig _config

_leavers

protected final Collection _leavers

_left

protected final Collection _left
Constructor Detail

DIndex

public DIndex(String nodeName,
              int numPartitions,
              long inactiveTime,
              Dispatcher dispatcher,
              Map distributedState,
              PartitionMapper mapper)
Method Detail

init

public void init(PartitionManagerConfig config)

start

public void start()
           throws Exception
Throws:
Exception

stop

public void stop()
          throws Exception
Throws:
Exception

getCluster

public Cluster getCluster()
Specified by:
getCluster in interface CoordinatorConfig

getDispatcher

public Dispatcher getDispatcher()
Specified by:
getDispatcher in interface CoordinatorConfig

getPartitionManager

public PartitionManager getPartitionManager()

getPartition

public int getPartition()

onNodeUpdate

public void onNodeUpdate(ClusterEvent event)
Specified by:
onNodeUpdate in interface ClusterListener

correlateStateUpdate

protected void correlateStateUpdate(Map state)

onNodeAdd

public void onNodeAdd(ClusterEvent event)
Specified by:
onNodeAdd in interface ClusterListener

onNodeRemoved

public void onNodeRemoved(ClusterEvent event)
Specified by:
onNodeRemoved in interface ClusterListener

amCoordinator

public boolean amCoordinator()

onNodeFailed

public void onNodeFailed(ClusterEvent event)
Specified by:
onNodeFailed in interface ClusterListener

onCoordinatorChanged

public void onCoordinatorChanged(ClusterEvent event)
Specified by:
onCoordinatorChanged in interface ClusterListener

createResultSet

public Collection[] createResultSet(int numPartitions,
                                    int[] keys)

onElection

public void onElection(ClusterEvent event)

onDismissal

public void onDismissal(ClusterEvent event)

getNodeName

public static String getNodeName(Node node)

isCoordinator

public boolean isCoordinator()

getCoordinator

public Node getCoordinator()

getNumPartitions

public int getNumPartitions()
Specified by:
getNumPartitions in interface CoordinatorConfig

getLocalNode

public Node getLocalNode()
Specified by:
getLocalNode in interface CoordinatorConfig

getRemoteNodes

public Collection getRemoteNodes()
Specified by:
getRemoteNodes in interface CoordinatorConfig

getRendezVousMap

public Map getRendezVousMap()
Specified by:
getRendezVousMap in interface CoordinatorConfig

getLeavers

public Collection getLeavers()
Specified by:
getLeavers in interface CoordinatorConfig

getLeft

public Collection getLeft()
Specified by:
getLeft in interface CoordinatorConfig

printNode

protected int printNode(Node node)

insert

public boolean insert(String name,
                      long timeout)

remove

public void remove(String name)

relocate

public void relocate(String name)

relocate

public ObjectMessage relocate(String sessionName,
                              String nodeName,
                              int concurrentRequestThreads,
                              boolean shuttingDown,
                              long timeout)
                       throws Exception
Throws:
Exception

relocate2

public Motable relocate2(String sessionName,
                         String nodeName,
                         int concurrentRequestThreads,
                         boolean shuttingDown,
                         long timeout)
                  throws Exception
Throws:
Exception

forwardAndExchange

public ObjectMessage forwardAndExchange(String name,
                                        RelocationRequest request,
                                        long timeout)
                                 throws Exception
Throws:
Exception

getPartition

public PartitionFacade getPartition(Object key)
Specified by:
getPartition in interface StateManagerConfig

getNodeName

public String getNodeName(Destination destination)
Specified by:
getNodeName in interface StateManagerConfig

getInactiveTime

public long getInactiveTime()
Specified by:
getInactiveTime in interface CoordinatorConfig

regenerateMissingPartitions

public void regenerateMissingPartitions(Node[] living,
                                        Node[] leaving)
Specified by:
regenerateMissingPartitions in interface CoordinatorConfig

getPartitionKeys

public static PartitionKeys getPartitionKeys(Node node)

getPartition

public PartitionFacade getPartition(int key)
Specified by:
getPartition in interface StateManagerConfig

getStateManager

public StateManager getStateManager()

getLocalNodeName

public String getLocalNodeName()
Specified by:
getLocalNodeName in interface StateManagerConfig

contextualise

public boolean contextualise(InvocationContext invocationContext,
                             String id,
                             Immoter immoter,
                             Sync motionLock,
                             boolean exclusiveOnly)
                      throws InvocationException
Specified by:
contextualise in interface StateManagerConfig
Throws:
InvocationException

getInvocationLock

public Sync getInvocationLock(String name)
Specified by:
getInvocationLock in interface StateManagerConfig


Copyright © 2004-2008 Core Developers Network Ltd.. All Rights Reserved.