org.activecluster.group
Class GroupModel

java.lang.Object
  extended byorg.activecluster.group.GroupModel
Direct Known Subclasses:
BuddyGroupModel

public class GroupModel
extends Object

Represents a collection of zero or more groups in a cluster. The default implementation will create groups as nodes are added to the cluster; filling the groups with its required number of buddies / slaves until a new group can be created.

Nodes which are not allowed to be master nodes will be kept around in a pool ready to be added as slaves when a new master arrives and forces the creation of a group.

Version:
$Revision: 1.1 $
See Also:
Group

Constructor Summary
GroupModel()
           
 
Method Summary
protected  void addGroup(Group group)
           
 void addNode(Node node)
          Adds the new node to this group model; we assume the node has not been added before.
protected  void addNodeToGroup(Group group, Node node)
           
protected  boolean addToExistingGroup(Node node)
          Attempts to add the node to an incomplete group, or a not-full group and returns true if its possible - else returns false
protected  boolean addToIncompleteGroup(Node node)
           
protected  boolean addToNotFullGroup(Node node)
           
protected  boolean addToPendingGroup(LinkedList list, Node node)
          Adds the given node to the first pending group if possible
protected  void addToUnusedNodes(Node node)
           
protected  boolean canBeMaster(Node node)
          Returns true if the given node can be a master
protected  boolean canCreateGroup(Node node)
          Returns true if we can add a new group to the cluster
protected  Group createGroup(Node node)
           
 List getGroups()
          Returns a snapshot of the groups currently available
 NodeFilter getMasterFilter()
           
 int getMaximumGroups()
           
 int getMaximumMemberCount()
           
 int getMaximumWeighting()
           
 int getMinimumMemberCount()
           
protected  Group makeNewGroup(Node node)
          Attempt to make a new group with the current node as the master or if the node cannot be a master node
 void removeNode(Node node)
          Removes the node from the group model
protected  boolean removeNodeFromGroup(Group group, Node node)
           
 void setMasterFilter(NodeFilter masterFilter)
           
 void setMaximumGroups(int maximumGroups)
           
 void setMaximumMemberCount(int maximumMemberCount)
           
 void setMaximumWeighting(int maximumWeighting)
           
 void setMinimumMemberCount(int minimumMemberCount)
           
protected  boolean tryToAddBuddy(Group group)
           
protected  void tryToFillGroupWithBuddies(Group group)
           
protected  void updateGroupCollections(Group group, boolean wasFull, boolean wasUsable)
          Lets move the group from its current state collection to the new collection if its state has changed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GroupModel

public GroupModel()
Method Detail

addNode

public void addNode(Node node)
Adds the new node to this group model; we assume the node has not been added before.

Parameters:
node -

removeNode

public void removeNode(Node node)
Removes the node from the group model

Parameters:
node -

getGroups

public List getGroups()
Returns a snapshot of the groups currently available


getMasterFilter

public NodeFilter getMasterFilter()

setMasterFilter

public void setMasterFilter(NodeFilter masterFilter)

getMaximumGroups

public int getMaximumGroups()

setMaximumGroups

public void setMaximumGroups(int maximumGroups)

getMaximumMemberCount

public int getMaximumMemberCount()

setMaximumMemberCount

public void setMaximumMemberCount(int maximumMemberCount)

getMinimumMemberCount

public int getMinimumMemberCount()

setMinimumMemberCount

public void setMinimumMemberCount(int minimumMemberCount)

getMaximumWeighting

public int getMaximumWeighting()

setMaximumWeighting

public void setMaximumWeighting(int maximumWeighting)

makeNewGroup

protected Group makeNewGroup(Node node)
Attempt to make a new group with the current node as the master or if the node cannot be a master node

Returns:
the newly created group or false if none was created.

tryToFillGroupWithBuddies

protected void tryToFillGroupWithBuddies(Group group)

tryToAddBuddy

protected boolean tryToAddBuddy(Group group)

updateGroupCollections

protected void updateGroupCollections(Group group,
                                      boolean wasFull,
                                      boolean wasUsable)
Lets move the group from its current state collection to the new collection if its state has changed


addToUnusedNodes

protected void addToUnusedNodes(Node node)

addToExistingGroup

protected boolean addToExistingGroup(Node node)
Attempts to add the node to an incomplete group, or a not-full group and returns true if its possible - else returns false

Returns:
true if the node has been added to a groupu

addToNotFullGroup

protected boolean addToNotFullGroup(Node node)

addToIncompleteGroup

protected boolean addToIncompleteGroup(Node node)

addToPendingGroup

protected boolean addToPendingGroup(LinkedList list,
                                    Node node)
Adds the given node to the first pending group if possible

Returns:
true if the node was added to the first available group

addNodeToGroup

protected void addNodeToGroup(Group group,
                              Node node)

removeNodeFromGroup

protected boolean removeNodeFromGroup(Group group,
                                      Node node)

addGroup

protected void addGroup(Group group)

createGroup

protected Group createGroup(Node node)

canCreateGroup

protected boolean canCreateGroup(Node node)
Returns true if we can add a new group to the cluster


canBeMaster

protected boolean canBeMaster(Node node)
Returns true if the given node can be a master



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