com.ace.moab.api.node
Class Nodes

java.lang.Object
  extended by com.ace.moab.api.node.Nodes
All Implemented Interfaces:
java.io.Serializable, java.lang.Iterable<MoabNode>

public class Nodes
extends java.lang.Object
implements java.lang.Iterable<MoabNode>, java.io.Serializable

This class represents a collection of Nodes found in Moab. This groups multiple nodes into one object to allow group wide operations to be done on Nodes such as adding and deleting and searching for nodes.

Author:
Brady Kimball
See Also:
Serialized Form

Constructor Summary
Nodes()
          Initializes an empty collection of nodes.
Nodes(java.util.Collection<MoabNode> nodes)
          Initialize the collection of nodes based on the collection of nodes given.
 
Method Summary
 void addAll(java.util.Collection<? extends MoabNode> nodeCollection)
           
 void addNode(MoabNode node)
          Adds a node to the collection.
 MoabNode findNode(java.lang.String id)
          Attempts to find a node with the respective node name.
 java.util.List<MoabNode> getComputeNodeList()
          Returns only the compute nodes in the collection in sorted order.
 java.util.List<java.lang.String> getNodeNames()
          Returns a list of all the node names in the collection in alphabetical order.
 boolean isEmpty()
          Returns true if no nodes are in the collection.
 java.util.Iterator<MoabNode> iterator()
          
 void removeNode(MoabNode node)
          Attempts to remove a node from the collection.
 void removeNode(java.lang.String id)
          Attempts to remove a node from the collection.
 int size()
          Returns the number of nodes in the collection.
 java.util.List<MoabNode> toList()
          Converts the collection of nodes into a list of node objects.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Nodes

public Nodes()
Initializes an empty collection of nodes.


Nodes

public Nodes(java.util.Collection<MoabNode> nodes)
Initialize the collection of nodes based on the collection of nodes given. If the nodes passed in is null, an empty collection is initialized.

Parameters:
nodes - the nodes to store in the collection.
Method Detail

addNode

public void addNode(MoabNode node)
Adds a node to the collection. If the node already exists, then the add call is simply ignored.

Parameters:
node - the node to be added.

findNode

public MoabNode findNode(java.lang.String id)
Attempts to find a node with the respective node name. If the node name is null, null is returned. Similarly, if the node cannot be found, null is returned.

Parameters:
id - the name of the node to search for.
Returns:
the respective node object that matches the node name.

getComputeNodeList

public java.util.List<MoabNode> getComputeNodeList()
Returns only the compute nodes in the collection in sorted order.

Returns:
a sorted list of nodes in the collection.

getNodeNames

public java.util.List<java.lang.String> getNodeNames()
Returns a list of all the node names in the collection in alphabetical order.

Returns:
a list of all the node names in the collection in alphabetical order.

isEmpty

public boolean isEmpty()
Returns true if no nodes are in the collection.

Returns:
if true, no nodes are in the collection.

iterator

public java.util.Iterator<MoabNode> iterator()

Specified by:
iterator in interface java.lang.Iterable<MoabNode>

removeNode

public void removeNode(MoabNode node)
Attempts to remove a node from the collection. If the node cannot be found, the removal request is simply ignored.

Parameters:
node - the node to be removed.

removeNode

public void removeNode(java.lang.String id)
Attempts to remove a node from the collection. If the node with the respective name cannot be found, the removal request is simply ignored.

Parameters:
id - the name of the node to be removed.

toList

public java.util.List<MoabNode> toList()
Converts the collection of nodes into a list of node objects.

Returns:
a list of nodes in the collection.

size

public int size()
Returns the number of nodes in the collection.

Returns:
the number of nodes in the collection.

addAll

public void addAll(java.util.Collection<? extends MoabNode> nodeCollection)


Copyright © 2001-2009 Cluster Resources, Inc. All Rights Reserved.