orca.cod.control
Class IdControlChange

java.lang.Object
  extended by orca.cod.control.IdControlChange
All Implemented Interfaces:
IResourceControl, IInitialize, IRecover, ISerialize
Direct Known Subclasses:
BestFitIdControlChange

public class IdControlChange
extends java.lang.Object
implements IResourceControl

Site authority assignment policy, which follows strictly broker allocation. Current limitation:


Nested Class Summary
 class IdControlChange.ControlState
           
 
Field Summary
protected  IActor actor
          The actor this control belongs to
protected  IAuthority authority
          The actor, cast to a SlottedAuthority (for convenience)
protected  AuthorityCalendar calendar
          The actor calendar
protected  ID guid
           
protected  java.util.Hashtable<ID,Machine> identifiers
          Mapping of logical identifiers to machines
static int IndexBandwidth
           
static int IndexCpu
           
static int IndexMemory
           
static int IndexStorage
           
protected  long inplace
           
protected  boolean lazyClose
          True if we are using lazy revocation of leased resources
protected  LoggingTool logger
           
protected  java.util.HashMap<NodeID,Machine> machines
          Set of all donated machines.
protected  java.util.ArrayList<Machine> machinesFailed
          Machines that host un-released/failed resources
protected  java.util.ArrayList<Machine> machinesFree
          Machines not in use
protected  java.util.ArrayList<Machine> machinesHosting
          Physical machines currently in use
protected  long migrations
           
protected  java.util.Hashtable<NodeID,Node> nodes
           
static java.lang.String PropertyBandwidth
           
static java.lang.String PropertyCpu
           
static java.lang.String PropertyDimensions
           
static java.lang.String PropertyGuid
           
static java.lang.String PropertyMaxPrefix
           
static java.lang.String PropertyMemory
           
static java.lang.String PropertyNamePrefix
           
static java.lang.String PropertyResourceType
           
static java.lang.String PropertyStorage
           
protected  long restores
           
protected  long saves
           
protected  ResourceType type
           
 
Constructor Summary
IdControlChange()
           
 
Method Summary
protected  NodeGroup allocateNodes(java.util.Vector<ID> ids, long[] shares, AuthorityReservation reservation)
          Allocates new nodes
 ResourceSet assign(AuthorityReservation r)
           
 void available(ResourceSet set)
           
 void calculateChanges(NodeGroup current, java.util.Vector<ID> ids, NodeSet inList, NodeSet notInList, java.util.Vector<ID> newIds)
          This function calculates the difference between the current association of nodes and logicalIds and the new association received with the extend request.
protected  void checkLazyClose(Machine m)
          Checks if this machine contains nodes from expired reservations.
 void configure(java.util.Properties p)
           
protected  java.lang.String convert(long[] data)
          Converts and array to a string
 ResourceSet correctDeficit(AuthorityReservation r)
           
 ResourceSet correctFailed(ResourceSet rset)
           
 void donate(ResourceSet set)
          Note: must be able to handle multiple donates of the same resources
 java.lang.String dumpStats()
           
 void eject(ResourceSet set)
           
protected  void fail(Machine host)
           
protected  int findIndex(java.util.ArrayList<Machine> machines, Node n)
           
protected  void forceClose(NodeGroup lost)
          Forces the nodes in this group to be lost
 void freed(ResourceSet r)
           
protected  AuthorityCodDatabase getDb()
           
protected  long[] getGrowing(long[] difference)
          Returns max(difference[i],0)
 ID getGuid()
           
protected  java.util.Vector<ID> getIdentifiers(java.util.Properties p)
          Extracts identifiers from the specified properties list
protected  java.util.Vector<ID> getIds(NodeGroup currentNodes)
          Returns the logical ids of the nodes contained in this nodegroup
protected  int getInUse()
           
protected  Machine getMachine(ID id)
          Returns the machine associated with the given logical id
protected  Machine getMachineForNodeRevisit(Node node)
          Obtains the host machine for the given node during recovery.
protected  java.util.Vector<ID> getNewIds(java.util.Vector<ID> ids, NodeGroup currentNodes)
          Returns a hashtable of the identifiers not present in the node group
protected  AuthorityReservation getReservation(Node node)
           
protected  long[] getShares(Node n)
          Extracts the shares from the specified node
protected  long[] getShares(java.util.Properties p)
          Extracts the shares from the specified properties list
 IdControlChange.ControlState getState()
           
protected  NodeSet getToModify(NodeGroup currentNodes, NodeGroup lost)
          Returns the difference between currentNodes and lost
 ResourceType[] getTypes()
           
protected  boolean handleChangedIds(NodeSet nodes, java.util.Vector<ID> ids, AuthorityReservation reservation)
          Schedules migrations (saves) for the nodes that have changed their identifiers.
protected  void handleRelease(java.util.Iterator iter)
           
protected  boolean hasChanged(long[] current, long[] requested)
          Returns true if the passed resource specifications are different
 void initialize()
          Initializes the object.
protected  boolean inProgress(AuthorityReservation r)
          Determines if there are nodes in this reservation that have pending modify/close operation
protected  boolean isExpired(AuthorityReservation r, long now)
          Checks if the specified reservation has expired
protected  NodeGroup modify(AuthorityReservation r, NodeSet inList, long[] capacity)
          Modify all nodes u
protected  boolean pendingRestore(AuthorityReservation r)
          Checks if nodes in this reservation need to be restored
protected  void release(Node node, boolean remove)
           
protected  void release(NodeGroup group)
           
protected  void release(NodeGroup group, boolean remove)
           
 void release(ResourceSet r)
           
protected  void releaseClosed(Node node)
           
protected  void releaseMigrated(Node node)
           
protected  void releaseResized(Node node)
           
protected  void releaseSaved(Node node)
           
protected  boolean reserveHostSharesRevisit(Machine host, Node node)
           
 void reset(java.util.Properties properties)
          De-serializes the object from the given properties list.
 void revisit(IActor actor, java.util.Properties properties)
          Recovers state of the component using a previously saved properties list and a references to the actor this component belongs to.
 void revisit(ResourceReservation r)
           
protected  void revisitModify(Node n)
           
 java.util.Properties save()
          Serializes the object into a properties list.
 void save(java.util.Properties properties)
          Serializes the object into the given properties list.
protected  NodeGroup selectExtract(NodeSet inList, NodeSet notInList, int count, java.util.Properties p)
          Removes count nodes from the given set and places them in a nodegroup.
 NodeGroup selectExtract(java.util.Vector<ID> ids, IConcreteSet current)
          For use in selecting victims from a shrinking cluster.
 void setActor(IActor actor)
           
protected  void setShares(NodeGroup group, long[] shares)
          Sets the shares for all nodes in this group
protected  void setShares(Node node, long[] shares)
          Sets the shares for the given node
 void setType(ResourceType type)
           
protected  long[] subtract(long[] a, long[] b)
          Subtracts a from b
 int unavailable(ResourceSet set)
           
protected  boolean zero(long[] shares)
          Checks if the array contains only zero entries
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PropertyResourceType

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

IndexMemory

public static final int IndexMemory
See Also:
Constant Field Values

IndexCpu

public static final int IndexCpu
See Also:
Constant Field Values

IndexBandwidth

public static final int IndexBandwidth
See Also:
Constant Field Values

IndexStorage

public static final int IndexStorage
See Also:
Constant Field Values

PropertyMemory

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

PropertyCpu

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

PropertyBandwidth

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

PropertyStorage

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

PropertyDimensions

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

PropertyNamePrefix

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

PropertyMaxPrefix

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

PropertyGuid

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

inplace

protected long inplace

restores

protected long restores

migrations

protected long migrations

saves

protected long saves

lazyClose

protected boolean lazyClose
True if we are using lazy revocation of leased resources


guid

protected ID guid

machines

protected java.util.HashMap<NodeID,Machine> machines
Set of all donated machines. Used to detect multiple donations of the same machines.


identifiers

protected java.util.Hashtable<ID,Machine> identifiers
Mapping of logical identifiers to machines


machinesHosting

protected java.util.ArrayList<Machine> machinesHosting
Physical machines currently in use


machinesFree

protected java.util.ArrayList<Machine> machinesFree
Machines not in use


machinesFailed

protected java.util.ArrayList<Machine> machinesFailed
Machines that host un-released/failed resources


actor

protected IActor actor
The actor this control belongs to


authority

protected IAuthority authority
The actor, cast to a SlottedAuthority (for convenience)


calendar

protected AuthorityCalendar calendar
The actor calendar


logger

protected LoggingTool logger

type

protected ResourceType type

nodes

protected java.util.Hashtable<NodeID,Node> nodes
Constructor Detail

IdControlChange

public IdControlChange()
Method Detail

initialize

public void initialize()
                throws java.lang.Exception
Description copied from interface: IInitialize
Initializes the object.

Specified by:
initialize in interface IInitialize
Throws:
java.lang.Exception

getDb

protected AuthorityCodDatabase getDb()

getState

public IdControlChange.ControlState getState()

donate

public void donate(ResourceSet set)
            throws java.lang.Exception
Note: must be able to handle multiple donates of the same resources

Specified by:
donate in interface IResourceControl
Throws:
java.lang.Exception

findIndex

protected int findIndex(java.util.ArrayList<Machine> machines,
                        Node n)

eject

public void eject(ResourceSet set)
           throws java.lang.Exception
Specified by:
eject in interface IResourceControl
Throws:
java.lang.Exception

unavailable

public int unavailable(ResourceSet set)
                throws java.lang.Exception
Specified by:
unavailable in interface IResourceControl
Throws:
java.lang.Exception

available

public void available(ResourceSet set)
               throws java.lang.Exception
Specified by:
available in interface IResourceControl
Throws:
java.lang.Exception

assign

public ResourceSet assign(AuthorityReservation r)
                   throws java.lang.Exception
Specified by:
assign in interface IResourceControl
Throws:
java.lang.Exception

correctDeficit

public ResourceSet correctDeficit(AuthorityReservation r)
                           throws java.lang.Exception
Specified by:
correctDeficit in interface IResourceControl
Throws:
java.lang.Exception

freed

public void freed(ResourceSet r)
           throws java.lang.Exception
Specified by:
freed in interface IResourceControl
Throws:
java.lang.Exception

release

public void release(ResourceSet r)
             throws java.lang.Exception
Specified by:
release in interface IResourceControl
Throws:
java.lang.Exception

handleRelease

protected void handleRelease(java.util.Iterator iter)
                      throws java.lang.Exception
Throws:
java.lang.Exception

getMachine

protected Machine getMachine(ID id)
                      throws java.lang.Exception
Returns the machine associated with the given logical id

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

getReservation

protected AuthorityReservation getReservation(Node node)

isExpired

protected boolean isExpired(AuthorityReservation r,
                            long now)
Checks if the specified reservation has expired

Parameters:
r - Reservation
now - Current cycle

checkLazyClose

protected void checkLazyClose(Machine m)
Checks if this machine contains nodes from expired reservations. If so, the reservations that they belong to will be scheduled for closing.

Parameters:
m -

allocateNodes

protected NodeGroup allocateNodes(java.util.Vector<ID> ids,
                                  long[] shares,
                                  AuthorityReservation reservation)
                           throws java.lang.Exception
Allocates new nodes

Parameters:
ids - list of logical ids to use
count - number of machines to allocate (seems redundant)
shares - resource shares
reservation - for which reservation
Returns:
a node group with newly allocated nodes. null if cannot satisfy request
Throws:
java.lang.Exception - if an error occurs

zero

protected boolean zero(long[] shares)
Checks if the array contains only zero entries

Parameters:
shares -
Returns:

modify

protected NodeGroup modify(AuthorityReservation r,
                           NodeSet inList,
                           long[] capacity)
                    throws java.lang.Exception
Modify all nodes u

Parameters:
r -
nodes -
newIds -
capacity -
currentCapacity -
Returns:
Throws:
java.lang.Exception

releaseMigrated

protected void releaseMigrated(Node node)
                        throws java.lang.Exception
Throws:
java.lang.Exception

releaseSaved

protected void releaseSaved(Node node)
                     throws java.lang.Exception
Throws:
java.lang.Exception

releaseResized

protected void releaseResized(Node node)
                       throws java.lang.Exception
Throws:
java.lang.Exception

releaseClosed

protected void releaseClosed(Node node)
                      throws java.lang.Exception
Throws:
java.lang.Exception

inProgress

protected boolean inProgress(AuthorityReservation r)
Determines if there are nodes in this reservation that have pending modify/close operation


pendingRestore

protected boolean pendingRestore(AuthorityReservation r)
                          throws java.lang.Exception
Checks if nodes in this reservation need to be restored

Parameters:
r - the reservation
Returns:
true if at least one restore operation was scheduled or still has to be scheduled (insufficient capacity at the destination host)
Throws:
java.lang.Exception

forceClose

protected void forceClose(NodeGroup lost)
Forces the nodes in this group to be lost

Parameters:
lost -

getIds

protected java.util.Vector<ID> getIds(NodeGroup currentNodes)
Returns the logical ids of the nodes contained in this nodegroup

Parameters:
currentNodes -
Returns:

getNewIds

protected java.util.Vector<ID> getNewIds(java.util.Vector<ID> ids,
                                         NodeGroup currentNodes)
Returns a hashtable of the identifiers not present in the node group

Parameters:
ids -
currentNodes -
Returns:

handleChangedIds

protected boolean handleChangedIds(NodeSet nodes,
                                   java.util.Vector<ID> ids,
                                   AuthorityReservation reservation)
                            throws java.lang.Exception
Schedules migrations (saves) for the nodes that have changed their identifiers. All nodes for which there is sufficient capacity on the new destination will be migrated. All nodes for which there is insufficient capacity will be saved.

Parameters:
nodes - nodes with changed identifiers
ids - the new identifiers to use
currentShares -
Returns:
True if at least one migrate/save is scheduled
Throws:
java.lang.Exception

release

protected void release(NodeGroup group)

release

protected void release(NodeGroup group,
                       boolean remove)
                throws java.lang.Exception
Throws:
java.lang.Exception

release

protected void release(Node node,
                       boolean remove)
                throws java.lang.Exception
Throws:
java.lang.Exception

calculateChanges

public void calculateChanges(NodeGroup current,
                             java.util.Vector<ID> ids,
                             NodeSet inList,
                             NodeSet notInList,
                             java.util.Vector<ID> newIds)
This function calculates the difference between the current association of nodes and logicalIds and the new association received with the extend request.

Parameters:
current - The nodes currently assigned to the reservation
ids - The ids received with the extend list
notInList - A set of nodes whose logical id is not in ids [used output should be created (empty) by the caller]
newIds - A list of new ids (not in

selectExtract

protected NodeGroup selectExtract(NodeSet inList,
                                  NodeSet notInList,
                                  int count,
                                  java.util.Properties p)
                           throws java.lang.Exception
Removes count nodes from the given set and places them in a nodegroup. Selects victims and may cause id switches and migrations.

Parameters:
inList -
notInList -
count -
currentShares -
p -
Returns:
Throws:
java.lang.Exception

convert

protected java.lang.String convert(long[] data)
Converts and array to a string

Parameters:
data -
Returns:

hasChanged

protected boolean hasChanged(long[] current,
                             long[] requested)
Returns true if the passed resource specifications are different

Parameters:
current -
requested -
Returns:

getIdentifiers

protected java.util.Vector<ID> getIdentifiers(java.util.Properties p)
                                       throws java.lang.Exception
Extracts identifiers from the specified properties list

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

getShares

protected long[] getShares(java.util.Properties p)
                    throws java.lang.Exception
Extracts the shares from the specified properties list

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

getShares

protected long[] getShares(Node n)
Extracts the shares from the specified node

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

setShares

protected void setShares(NodeGroup group,
                         long[] shares)
                  throws java.lang.Exception
Sets the shares for all nodes in this group

Parameters:
group -
shares -
Throws:
java.lang.Exception

setShares

protected void setShares(Node node,
                         long[] shares)
Sets the shares for the given node

Parameters:
node -
shares -

subtract

protected long[] subtract(long[] a,
                          long[] b)
Subtracts a from b

Parameters:
a -
b -
Returns:

getGrowing

protected long[] getGrowing(long[] difference)
Returns max(difference[i],0)

Parameters:
difference -
Returns:

getInUse

protected int getInUse()

dumpStats

public java.lang.String dumpStats()
                           throws java.lang.Exception
Throws:
java.lang.Exception

getMachineForNodeRevisit

protected Machine getMachineForNodeRevisit(Node node)
Obtains the host machine for the given node during recovery. Attaches the node of the selected machine to node.realHost.

Parameters:
node - the node
Returns:
Machine this node is hosted on

reserveHostSharesRevisit

protected boolean reserveHostSharesRevisit(Machine host,
                                           Node node)
                                    throws java.lang.Exception
Throws:
java.lang.Exception

fail

protected void fail(Machine host)

revisitModify

protected void revisitModify(Node n)
                      throws java.lang.Exception
Throws:
java.lang.Exception

revisit

public void revisit(ResourceReservation r)
             throws java.lang.Exception
Specified by:
revisit in interface IResourceControl
Throws:
java.lang.Exception

setActor

public void setActor(IActor actor)
Specified by:
setActor in interface IResourceControl

getTypes

public ResourceType[] getTypes()
Specified by:
getTypes in interface IResourceControl

save

public java.util.Properties save()
                          throws java.lang.Exception
Description copied from interface: ISerialize
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 properties)
          throws java.lang.Exception
Description copied from interface: ISerialize
Serializes the object into the given properties list.

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

reset

public void reset(java.util.Properties properties)
           throws java.lang.Exception
Description copied from interface: ISerialize
De-serializes the object from the given properties list.

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

revisit

public void revisit(IActor actor,
                    java.util.Properties properties)
             throws java.lang.Exception
Description copied from interface: IRecover
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
properties - properties list containing configuration data about the component
Throws:
java.lang.Exception

configure

public void configure(java.util.Properties p)
               throws java.lang.Exception
Throws:
java.lang.Exception

setType

public void setType(ResourceType type)

getToModify

protected NodeSet getToModify(NodeGroup currentNodes,
                              NodeGroup lost)
                       throws java.lang.Exception
Returns the difference between currentNodes and lost

Parameters:
currentNodes -
lost -
Returns:
Throws:
java.lang.Exception

selectExtract

public NodeGroup selectExtract(java.util.Vector<ID> ids,
                               IConcreteSet current)
                        throws java.lang.Exception
For use in selecting victims from a shrinking cluster. Just extract them and quickly put them back.

Throws:
java.lang.Exception

correctFailed

public ResourceSet correctFailed(ResourceSet rset)
                          throws java.lang.Exception
Specified by:
correctFailed in interface IResourceControl
Throws:
java.lang.Exception

getGuid

public ID getGuid()
Specified by:
getGuid in interface IResourceControl


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