com.sun.sgs.impl.service.nodemap.policy
Class AbstractNodePolicy

java.lang.Object
  extended by com.sun.sgs.impl.service.nodemap.policy.AbstractNodePolicy
All Implemented Interfaces:
NodeAssignPolicy
Direct Known Subclasses:
RoundRobinPolicy

public abstract class AbstractNodePolicy
extends Object
implements NodeAssignPolicy

Abstract node policy class. This class manages the list of nodes that are available for assignment. Subclasses must implement the logic for making the assignments.

See Also:
NodeAssignPolicy.chooseNode(long), NodeAssignPolicy.chooseNode(long, com.sun.sgs.auth.Identity)

Field Summary
protected  List<Long> availableNodes
          The list of available nodes.
 
Fields inherited from interface com.sun.sgs.impl.service.nodemap.NodeAssignPolicy
SERVER_NODE
 
Constructor Summary
protected AbstractNodePolicy()
          Creates a new instance of the AbstractNodePolicy.
 
Method Summary
 long chooseNode(long requestingNode, Identity id)
          Choose a node to assign an identity to.
 void nodeAvailable(long nodeId)
          Inform the policy that a node is now available.
 void nodeUnavailable(long nodeId)
          Inform the policy that a node is no longer available.
 void reset()
          Reset the policy, informing it that no nodes are available.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.sgs.impl.service.nodemap.NodeAssignPolicy
chooseNode
 

Field Detail

availableNodes

protected final List<Long> availableNodes
The list of available nodes. Access to this list must be synchronized.

Constructor Detail

AbstractNodePolicy

protected AbstractNodePolicy()
Creates a new instance of the AbstractNodePolicy.

Method Detail

chooseNode

public long chooseNode(long requestingNode,
                       Identity id)
                throws NoNodesAvailableException
Choose a node to assign an identity to. This implementation simply calls NodeAssignPolicy.chooseNode(long), ignoring the id parameter.

Specified by:
chooseNode in interface NodeAssignPolicy
Parameters:
requestingNode - the id of the node making the request, or SERVER_NODE if the system is making the request
id - the identity which needs an assignment.
Returns:
the chosen node's id
Throws:
NoNodesAvailableException - if there are no live nodes to assign to

nodeAvailable

public void nodeAvailable(long nodeId)
Inform the policy that a node is now available.

Specified by:
nodeAvailable in interface NodeAssignPolicy
Parameters:
nodeId - the node ID

nodeUnavailable

public void nodeUnavailable(long nodeId)
Inform the policy that a node is no longer available.

Specified by:
nodeUnavailable in interface NodeAssignPolicy
Parameters:
nodeId - the node ID

reset

public void reset()
Reset the policy, informing it that no nodes are available.

Specified by:
reset in interface NodeAssignPolicy

RedDwarf, Version 0.10.1
2010-03-14 10:56:12

Copyright © 2010 The RedDwarf Authors. All rights reserved
Copyright © 2007-2010 Sun Microsystems, Inc. All rights reserved