orca.cod
Class NodeGroup

java.lang.Object
  extended by orca.cod.NodeGroup
All Implemented Interfaces:
IConcreteSet, IRecover, ISerialize

public class NodeGroup
extends java.lang.Object
implements IConcreteSet

ConcreteSet resource set implementation for sets of nodes (e.g., for COD Authority or Service Manager/VCM).

These methods are called from mapper classes and the slices ResourceSet class through the ConcreteSet interface. See note on synchronization at slices.ConcreteSet interface.

At this level we deal with sets of nodes that may be linked onto various ResourceSets/ConcreteSets. The underlying Resource Abstraction Layer (RAL/database) is authoritative for node state; state cached in these node sets is always subject to change at the level below us.

The size() of a NodeGroup depends on whether the NodeGroup has flavor standard, virtual, or VMM.

- A "standard" NodeGroup is a set of nodes. Whether the nodes are virtual or physical, the size is the number of nodes.

- A "virtual" NodeGroup consists entirely of virtual nodes. Its size is the sum of computons allocated to its nodes.

- A "VMM" NodeGroup consists entirely of physical nodes capable of hosting virtual machines. Its size is the total number of computons available in the pool.

This distinction affects only how size() is reported, and does not affect any other aspects of NodeGroup.


Field Summary
protected  int closing
          How many nodes are closing in this group
protected  int computonsPerNode
          Number of computons per node
protected  boolean isModified
          Scratch field that does not need to be saved/restored.
static int LocationTransferIn
           
protected  LoggingTool logger
          The logger
protected  NodeSet modified
          Modified nodes from this group
protected  int modifying
          How many nodes are in the process of being modified
protected  int opening
          How many nodes are opening in this group
protected  boolean pendingChange
          Indicates that this NodeGroup is about to undergo some modifications.
protected  IShirakoPlugin plugin
          The slices plugin
static java.lang.String PropertyComputons
           
static java.lang.String PropertyVirtual
           
static java.lang.String PropertyVmm
           
protected  ResourceReservation reservation
          The reservation these concrete resources belong to
protected  boolean virtual
          True if the nodes in this NodeGroup represent a VM pool
protected  boolean vmm
          True if the nodes in this NodeGroup represent a VMM pool
 
Constructor Summary
NodeGroup()
          Creates a default node group: standard
NodeGroup(IShirakoPlugin plugin)
          Instantiates an empty standard node group using the specified slices plugin.
NodeGroup(NodeGroup cset, IShirakoPlugin plugin)
          Create a standard clone of the node group using the specified plugin
NodeGroup(NodeSet nodes, IShirakoPlugin plugin)
          Creates a standard node group using the specified nodes and plugin
 
Method Summary
 void add(IConcreteSet concrete, boolean configure)
          Merges another NodeGroup into this NodeGroup.
 void add(Node n)
          Adds a node to a NodeGroup.
protected  void addModifiedNode(Node node)
          Adds a node to the modified set
 void addToPool(BinPool pool)
          Adds VMM free set to a pool of "bins" for computons.
 void change(IConcreteSet concrete, Term term, boolean configure)
          Make changes to the resources committed to this concrete set.
protected  boolean checkClosing(Node n)
          Updates status of a node with a pending close.
protected  boolean checkModifying(Node n)
          Updates status of a node with a pending modify.
protected  boolean checkOpening(Node n)
          Updates the status of a node with a pending open.
 IConcreteSet clone()
          Makes a clone of the concrete set.
 IConcreteSet cloneEmpty()
          Makes an "empty" clone of this concrete set.
 void close()
          Initiates close (transferOut) on all nodes in this group.
 IConcreteSet collectReleased()
          Collects closed and failed nodes from this set.
protected  void completeClose(Node n)
          Records that a node close is complete.
protected  void completeModify(Node n)
          Records that a node modify is complete.
protected  void completeOpen(Node n)
          Records that a node open is complete.
 void destroy()
          Destroys a closed resource set and reservation (remove from database).
protected  void error(java.lang.String err)
          Report an error and throw an exception
 void extend(Term term)
          Informs the concrete set that its term has been extended.
 IConcreteSet extract(int count)
          Extract the specified number of nodes from this node group.
 IConcreteSet extract(int count, Term term, java.util.Properties properties, AuthToken client)
          Extracts the specified units of resources for the given period of time.
protected  void failNode(Node n, java.lang.String prefix)
          Transitions a node to failed and adds it to the failed set.
 NodeSet getClosed()
          Returns the closed node set.
 NodeSet getFailed()
          Returns the failed node set.
 Node getNode(NodeID nid)
           
 java.util.Iterator getNodes()
          Returns an iterator for the nodes in this NodeGroup.
 NodeSet getNodeSet()
          Returns the underlying NodeSet (for use by the RAL.resetFree).
 Node[] getNodesLocked()
          Returns the nodes in this node group.
 java.lang.String getNotices()
          Reports the error messages
 IShirakoPlugin getPlugin()
          Returns the slices plugin
 IAuthorityProxy getSiteProxy()
          ConcreteSet method that is a no-op for NodeGroup.
 int getUnits()
          Returns the number of nodes in the node group.
 int holding(java.util.Date slotDate)
          Returns how many units are in the set at the given time instance.
 int holding(Term t)
          Returns how many units will be in the set for the given period of time.
protected  void inheritFlavor(NodeGroup parent)
          Inherits the flavor of this NodeGroup from its parent.
 boolean isActive()
          A NodeGroup is considered "active" if it is bound to a reservation and it has no nodes with pending operations.
 boolean isModified()
          Returns the value of the modified flag
protected  boolean isOnReservation()
          Is this NodeGroup bound to a reservation?
 boolean isStandard()
          Is this a "standard" NodeGroup (physical machines).
 boolean isVirtual()
           
 boolean isVMM()
           
 void modify(IConcreteSet set, boolean configure)
          Updates the units in the current set with information contained in the passed set.
protected  void notify(int id, IReservation r)
          Raises the specified event
 void probe()
          Probes all nodes and refreshes node state from RAL.
 void releaseToPool(BinPool pool)
          Releases a group of virtual nodes, restoring the computons to their hosting VMMs.
 void remove(IConcreteSet concrete, boolean configure)
          Removes the passed set from the current set.
 void remove(Node n)
          Removes the node from the node group
 void reset(java.util.Properties p)
          De-serializes the object from the given properties list.
 void revisit()
          Revisits all nodes for reset/recovery.
 void revisit(IActor actor, java.util.Properties p)
          Recovers state of the component using a previously saved properties list and a references to the actor this component belongs to.
protected  void revisit(Node node)
          Revisits a node for reset/recovery.
 void revisitAtPool(BinPool pool, NodeGroup igroup)
          Revisits a group of virtual nodes, re-reserving the computons from their hosting VMMs.
protected  boolean sameFlavor(NodeGroup that)
          Compares flavor of the passed NodeGroup to this.
 java.util.Properties save()
          Serializes the object into a properties list.
 void save(java.util.Properties p)
          Serializes the object into the given properties list.
 IConcreteSet selectExtract(int count, java.util.Properties p)
          
 void setComputonsPerNode(int cpn)
          Sets #computons per node, and marks the NodeGroup as a "VMM" flavored node pool, i.e., a group of nodes that can host virtual machines.
 void setLogger(LoggingTool logger)
          Sets the logger for this NodeGroup.
 void setModified(boolean isModified)
          Sets the modified flag
 void setReservation(ResourceReservation reservation)
          Sets the reservation this node group belongs to
 void setShirakoPlugin(IShirakoPlugin plugin)
          Sets the plugin
 void setSiteProxy(IAuthorityProxy auth)
          ConcreteSet method that is a no-op for NodeGroup.
 void setup(ResourceReservation reservation)
          Initializes the concrete set with information about the containing reservation.
 void setVMM()
           
protected  void startClose(Node n)
          Records that a node is closing.
protected  void startModify(Node n)
          Records that a node is modifying.
protected  void startOpen(Node n)
          Records that a node is opening.
 Node takeAnyNode()
          Extract and return one node from the group.
 java.lang.String toString()
           
 void transferOut(Node node)
           
 void transferOutNodes()
           
 void validateConcrete(ResourceType type, int units, Term t)
          Currently unused.
 void validateIncoming()
          Currently no-op.
 void validateOutgoing()
          Currently no-op.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

PropertyVmm

public static final java.lang.String PropertyVmm
See Also:
Constant Field Values

PropertyVirtual

public static final java.lang.String PropertyVirtual
See Also:
Constant Field Values

PropertyComputons

public static final java.lang.String PropertyComputons
See Also:
Constant Field Values

LocationTransferIn

public static final int LocationTransferIn
See Also:
Constant Field Values

modified

protected NodeSet modified
Modified nodes from this group


opening

protected int opening
How many nodes are opening in this group


closing

protected int closing
How many nodes are closing in this group


modifying

protected int modifying
How many nodes are in the process of being modified


plugin

protected IShirakoPlugin plugin
The slices plugin


logger

protected LoggingTool logger
The logger


reservation

protected ResourceReservation reservation
The reservation these concrete resources belong to


vmm

protected boolean vmm
True if the nodes in this NodeGroup represent a VMM pool


virtual

protected boolean virtual
True if the nodes in this NodeGroup represent a VM pool


computonsPerNode

protected int computonsPerNode
Number of computons per node


isModified

protected boolean isModified
Scratch field that does not need to be saved/restored. Used by selectExtract to convey that a modification has occurred.


pendingChange

protected boolean pendingChange
Indicates that this NodeGroup is about to undergo some modifications. This is necessary to prevent a NodeGroup that is derived from cloneEmpty to be considered as active.

Constructor Detail

NodeGroup

public NodeGroup()
Creates a default node group: standard


NodeGroup

public NodeGroup(IShirakoPlugin plugin)
Instantiates an empty standard node group using the specified slices plugin.

Parameters:
plugin - The slices plugin

NodeGroup

public NodeGroup(NodeSet nodes,
                 IShirakoPlugin plugin)
Creates a standard node group using the specified nodes and plugin

Parameters:
nodes - Nodes
plugin - Slices plugin

NodeGroup

public NodeGroup(NodeGroup cset,
                 IShirakoPlugin plugin)
Create a standard clone of the node group using the specified plugin

Parameters:
cset - The node group to clone
plugin - The slices plugin to use
Method Detail

cloneEmpty

public IConcreteSet cloneEmpty()
Description copied from interface: IConcreteSet
Makes an "empty" clone of this concrete set. An "empty" clone is a copy of a concrete set with the "set" removed from it.

Specified by:
cloneEmpty in interface IConcreteSet
Returns:
an "empty" clone of this concrete set

clone

public IConcreteSet clone()
Description copied from interface: IConcreteSet
Makes a clone of the concrete set. Unlike IConcreteSet.cloneEmpty(), this method preserves the set: the set elements are the same objects as the original IConcreteSet, but the indexing structures are different. That is, adding/removing units to the original should not affect the clone. But modifications to an individual unit should be visible form the original and the clone.

Specified by:
clone in interface IConcreteSet
Overrides:
clone in class java.lang.Object
Returns:
a clone of the concrete set

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

extract

public IConcreteSet extract(int count,
                            Term term,
                            java.util.Properties properties,
                            AuthToken client)
                     throws java.lang.Exception
Extracts the specified units of resources for the given period of time. Transfers control over the extracted resources to the client. Annotates the extracted resources with the passed properties. This is an inventory method.

The concrete set is not required to maintain bookkeeping to verify if the extract operation can actually be completed successfully. The caller is responsible for all bookkeeping and ensuring that the concrete set has sufficient units to satisfy this request. Extract should not decrement the available units from the concrete set.

This method will typically be called with the kernel lock on.

Specified by:
extract in interface IConcreteSet
Parameters:
count - number of units to extract
term - the term for extraction
properties - properties to attach to the extracted resources. If any, these properties will replace any properties contained in the set the resources are being extracted from.
client - the client to extract resources to
Returns:
new IConcreteSet representing the extracted resources.
Throws:
java.lang.Exception

extract

public IConcreteSet extract(int count)
                     throws java.lang.Exception
Extract the specified number of nodes from this node group. Should be used only for an idle node group, since it does not update the counts of pending operations.

Parameters:
count -
Returns:
Throws:
java.lang.Exception

takeAnyNode

public Node takeAnyNode()
Extract and return one node from the group. This method should be used only for an idle node group, since it does not update counts of opening and closing nodes, etc.


selectExtract

public IConcreteSet selectExtract(int count,
                                  java.util.Properties p)
                           throws java.lang.Exception

Throws:
java.lang.Exception

add

public void add(Node n)
Adds a node to a NodeGroup. E.g., used to add new nodes to a NodeGroup as they are allocated, or donated to a free pool, or released back to a free pool.


remove

public void remove(Node n)
Removes the node from the node group

Parameters:
n - Node to remove

collectReleased

public IConcreteSet collectReleased()
                             throws java.lang.Exception
Collects closed and failed nodes from this set.

Specified by:
collectReleased in interface IConcreteSet
Returns:
closed and failed nodes from this set
Throws:
java.lang.Exception

isOnReservation

protected boolean isOnReservation()
Is this NodeGroup bound to a reservation?

Returns:
true iff this NodeGroup is bound to a reservation

isActive

public boolean isActive()
A NodeGroup is considered "active" if it is bound to a reservation and it has no nodes with pending operations.

Specified by:
isActive in interface IConcreteSet
Returns:
true iff NodeGroup is bound and active

getUnits

public int getUnits()
Returns the number of nodes in the node group.

Specified by:
getUnits in interface IConcreteSet
Returns:
number of units contained in the set

holding

public int holding(Term t)
Returns how many units will be in the set for the given period of time.

Specified by:
holding in interface IConcreteSet
Parameters:
t - period of time
Returns:
how many units will be in the set for the given period of time

holding

public int holding(java.util.Date slotDate)
Returns how many units are in the set at the given time instance.

Specified by:
holding in interface IConcreteSet
Parameters:
slotDate - time instance
Returns:
how many units how many units will be in the set for the given period of time

startOpen

protected void startOpen(Node n)
Records that a node is opening. Caller must hold the node group lock

Parameters:
n - the node

checkOpening

protected boolean checkOpening(Node n)
Updates the status of a node with a pending open. Caller must hold the node group lock.

Parameters:
n - the node
Returns:
true iff the caller must remove the node

completeOpen

protected void completeOpen(Node n)
Records that a node open is complete. Caller must hold node group lock.

Parameters:
n - the node

startModify

protected void startModify(Node n)
Records that a node is modifying. Caller must hold node group lock.

Parameters:
n - node

checkModifying

protected boolean checkModifying(Node n)
Updates status of a node with a pending modify. Caller must hold node group lock.

Parameters:
n - the node
Returns:
true iff caller should remove node from set

completeModify

protected void completeModify(Node n)
Records that a node modify is complete. Caller must hold node group lock.

Parameters:
n - the node

startClose

protected void startClose(Node n)
Records that a node is closing. If this close is interrupting an open, complete the open. Caller must hold the node group lock.

Parameters:
n - the node

checkClosing

protected boolean checkClosing(Node n)
Updates status of a node with a pending close. Caller must hold the node group lock/

Parameters:
n - the node
Returns:
true iff caller should remove node from set

completeClose

protected void completeClose(Node n)
Records that a node close is complete. Caller must hold the node group lock.

Parameters:
n - the node

addModifiedNode

protected void addModifiedNode(Node node)
Adds a node to the modified set

Parameters:
node -

failNode

protected void failNode(Node n,
                        java.lang.String prefix)
Transitions a node to failed and adds it to the failed set. It is the callers responsibility to remove it from the node set. The caller must hold the node group lock.

Parameters:
n - the node

revisit

public void revisit(IActor actor,
                    java.util.Properties p)
             throws java.lang.Exception
Recovers state of the component using a previously saved properties list and a references to the actor this component belongs to. The component can use the actor object to access other objects necessary for its complete recovery.

Specified by:
revisit in interface IRecover
Parameters:
actor - actor object the component belongs to
p - properties list containing configuration data about the component
Throws:
java.lang.Exception

revisit

public void revisit()
Revisits all nodes for reset/recovery. Upcall the slice to mark soft resources (e.g., IP addresses, hostname) held by the node as reserved.


revisit

protected void revisit(Node node)
Revisits a node for reset/recovery. Upcall the slice to mark soft resources (e.g., IP addresses, hostname) held by the node as reserved.

Parameters:
n - the node

setup

public void setup(ResourceReservation reservation)
Initializes the concrete set with information about the containing reservation. This method is called with the manager lock on and hence should not block for long periods of time.

Specified by:
setup in interface IConcreteSet
Parameters:
reservation - reservation this concrete set belongs to

modify

public void modify(IConcreteSet set,
                   boolean configure)
            throws java.lang.Exception
Updates the units in the current set with information contained in the passed set. Note that the passed set may contain only a subset of the units contained in the current set. Optionally triggers configuration actions for all removed units. If the lease term for the concrete set has changed, this call must be followed by a call to IConcreteSet.extend(Term).

Specified by:
modify in interface IConcreteSet
Parameters:
set - set containing the update data
configure - if true, configuration actions will be triggered for all modified units
Throws:
java.lang.Exception

add

public void add(IConcreteSet concrete,
                boolean configure)
         throws java.lang.Exception
Merges another NodeGroup into this NodeGroup.

Specified by:
add in interface IConcreteSet
Parameters:
concrete - the NodeGroup (ConcreteSet) to add
configure - if true, configuration actions will be triggered for all added units
Throws:
java.lang.Exception - unidentified rare error case

remove

public void remove(IConcreteSet concrete,
                   boolean configure)
            throws java.lang.Exception
Description copied from interface: IConcreteSet
Removes the passed set from the current set. Optionally triggers configuration actions for all removed units. If the lease term for the concrete set has changed, this call must be followed by a call to IConcreteSet.extend(Term).

Specified by:
remove in interface IConcreteSet
Parameters:
concrete - set to remove
configure - if true, configuration actions will be triggered for all removed units
Throws:
java.lang.Exception

change

public void change(IConcreteSet concrete,
                   Term term,
                   boolean configure)
            throws java.lang.Exception
Make changes to the resources committed to this concrete set. Currently this is used on Service Manager only: the concrete set is the complete set of nodes in the lease (may be null).

Specified by:
change in interface IConcreteSet
Parameters:
concrete - NodeGroup of nodes in updated lease
term - current reservation term; may have been modified
properties - current reservation properties; may have been modified
Throws:
java.lang.Exception - if something is wrong

extend

public void extend(Term term)
            throws java.lang.Exception
Informs the concrete set that its term has been extended.

Specified by:
extend in interface IConcreteSet
Parameters:
term - new term
Throws:
java.lang.Exception

probe

public void probe()
           throws java.lang.Exception
Probes all nodes and refreshes node state from RAL.

Specified by:
probe in interface IConcreteSet
Throws:
java.lang.Exception

close

public void close()
           throws java.lang.Exception
Initiates close (transferOut) on all nodes in this group.

Specified by:
close in interface IConcreteSet
Throws:
java.lang.Exception

destroy

public void destroy()
             throws java.lang.Exception
Destroys a closed resource set and reservation (remove from database).

Specified by:
destroy in interface IConcreteSet
Throws:
java.lang.Exception

transferOutNodes

public void transferOutNodes()

transferOut

public void transferOut(Node node)

setComputonsPerNode

public void setComputonsPerNode(int cpn)
Sets #computons per node, and marks the NodeGroup as a "VMM" flavored node pool, i.e., a group of nodes that can host virtual machines. The size() of a VMM pool is reported as the number of computons that the pool can host.

Parameters:
cpn - computons per host VMM in this group

addToPool

public void addToPool(BinPool pool)
Adds VMM free set to a pool of "bins" for computons. Could be a generic ConcreteSet method.

Parameters:
pool - the pool of host VMMs

releaseToPool

public void releaseToPool(BinPool pool)
Releases a group of virtual nodes, restoring the computons to their hosting VMMs. The nodes must be closed or down.

Parameters:
pool - the pool of host VMMs

revisitAtPool

public void revisitAtPool(BinPool pool,
                          NodeGroup igroup)
Revisits a group of virtual nodes, re-reserving the computons from their hosting VMMs. Used on reset/recovery.

Parameters:
pool - the pool of host VMMs
igroup - the NodeGroup for the pool (for indexing)

validateIncoming

public void validateIncoming()
                      throws java.lang.Exception
Currently no-op.

Specified by:
validateIncoming in interface IConcreteSet
Throws:
java.lang.Exception - if validation fails

validateOutgoing

public void validateOutgoing()
                      throws java.lang.Exception
Currently no-op.

Specified by:
validateOutgoing in interface IConcreteSet
Throws:
java.lang.Exception - if validation fails

validateConcrete

public void validateConcrete(ResourceType type,
                             int units,
                             Term t)
                      throws java.lang.Exception
Currently unused.

Specified by:
validateConcrete in interface IConcreteSet
Parameters:
type - abstract resources resource type
units - abstract resources units
t - abstract resources term
Throws:
java.lang.Exception

save

public java.util.Properties save()
                          throws java.lang.Exception
Serializes the object into a properties list.

Specified by:
save in interface ISerialize
Returns:
properties list representing this object
Throws:
java.lang.Exception

save

public void save(java.util.Properties p)
          throws java.lang.Exception
Serializes the object into the given properties list.

Specified by:
save in interface ISerialize
Parameters:
p - properties list to serialize the object into
Throws:
java.lang.Exception

reset

public void reset(java.util.Properties p)
           throws java.lang.Exception
De-serializes the object from the given properties list.

Specified by:
reset in interface ISerialize
Parameters:
p - properties list containing the serialized version of the object
Throws:
java.lang.Exception

notify

protected void notify(int id,
                      IReservation r)
Raises the specified event

Parameters:
id - event id
r - reservation this event is associated with
Throws:
java.lang.Exception

error

protected void error(java.lang.String err)
              throws java.lang.Exception
Report an error and throw an exception

Throws:
java.lang.Exception

inheritFlavor

protected void inheritFlavor(NodeGroup parent)
Inherits the flavor of this NodeGroup from its parent.


sameFlavor

protected boolean sameFlavor(NodeGroup that)
Compares flavor of the passed NodeGroup to this.

Parameters:
that - NodeGroup for comparison to this
Returns:
true iff NodeGroup has same flavor

isStandard

public boolean isStandard()
Is this a "standard" NodeGroup (physical machines).

Returns:
true iff standard

isVirtual

public boolean isVirtual()

isVMM

public boolean isVMM()

setVMM

public void setVMM()

getSiteProxy

public IAuthorityProxy getSiteProxy()
                             throws java.lang.Exception
ConcreteSet method that is a no-op for NodeGroup.

Specified by:
getSiteProxy in interface IConcreteSet
Returns:
null
Throws:
java.lang.Exception

setSiteProxy

public void setSiteProxy(IAuthorityProxy auth)
                  throws java.lang.Exception
ConcreteSet method that is a no-op for NodeGroup.

Specified by:
setSiteProxy in interface IConcreteSet
Throws:
java.lang.Exception - if called

getNodeSet

public NodeSet getNodeSet()
Returns the underlying NodeSet (for use by the RAL.resetFree).

Returns:
the NodeSet around which this NodeGroup is wrapped

getNodes

public java.util.Iterator getNodes()
Returns an iterator for the nodes in this NodeGroup.

Returns:
iterator for all nodes that are not closed or failed

getNodesLocked

public Node[] getNodesLocked()
Returns the nodes in this node group.

Returns:

getNotices

public java.lang.String getNotices()
Reports the error messages

Specified by:
getNotices in interface IConcreteSet

setLogger

public void setLogger(LoggingTool logger)
Sets the logger for this NodeGroup.


setShirakoPlugin

public void setShirakoPlugin(IShirakoPlugin plugin)
Sets the plugin

Specified by:
setShirakoPlugin in interface IConcreteSet
Parameters:
plugin - The slices plugin

setReservation

public void setReservation(ResourceReservation reservation)
Sets the reservation this node group belongs to

Parameters:
reservation -

getClosed

public NodeSet getClosed()
Returns the closed node set.

Returns:

getFailed

public NodeSet getFailed()
Returns the failed node set.

Returns:

isModified

public boolean isModified()
Returns the value of the modified flag

Returns:

setModified

public void setModified(boolean isModified)
Sets the modified flag

Parameters:
isModified -

getPlugin

public IShirakoPlugin getPlugin()
Returns the slices plugin

Returns:

getNode

public Node getNode(NodeID nid)


Copyright © 2007 Network/Internet Computing Lab. All Rights Reserved.