orca.shirako.common
Class ResourceCount

java.lang.Object
  extended by orca.shirako.common.ResourceCount

public class ResourceCount
extends java.lang.Object

ResourceCount is a utility class used to count reservations in a ReservationSet based on the reservation state and resource type. An instance of this class is used as an argument to the "tally" methods in ReservationSet.

Note: no internal locking.

See Also:
ReservationSet

Nested Class Summary
protected  class ResourceCount.CountsPerType
          Inner class representing counts for a given resource type.
 
Field Summary
protected  java.util.HashMap<java.lang.String,ResourceCount.CountsPerType> map
          Counts per resource type.
 
Constructor Summary
ResourceCount()
          Creates a new instance.
 
Method Summary
 long countActive(ResourceType type)
          Returns the number of active units from the given resource type.
 long countClose(ResourceType type)
          Returns the number of closed units from the given resource type.
 long countExpired(ResourceType type)
          Returns the number of expired units from the given resource type.
 long countFailed(ResourceType type)
          Returns the number of failed units from the given resource type.
 long countPending(ResourceType type)
          Returns the number of pending units from the given resource type.
protected  ResourceCount.CountsPerType getCounts(ResourceType type)
          Returns the count entry for the given resource type.
protected  ResourceCount.CountsPerType getOrCreateCounts(ResourceType type)
          Returns or creates a new count entry for the given resource type.
 void tallyActive(ResourceType type, long count)
          Increments with count the internal counter for active units of the specified type.
 void tallyClose(ResourceType type, long count)
          Increments with count the internal counter for closed units of the specified type.
 void tallyExpired(ResourceType type, long count)
          Increments with count the internal counter for expired units of the specified type.
 void tallyFailed(ResourceType type, long count)
          Increments with count the internal counter for failed units of the specified type.
 void tallyPending(ResourceType type, long count)
          Increments with count the internal counter for pending units of the specified type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

map

protected java.util.HashMap<java.lang.String,ResourceCount.CountsPerType> map
Counts per resource type.

Constructor Detail

ResourceCount

public ResourceCount()
Creates a new instance.

Method Detail

getCounts

protected ResourceCount.CountsPerType getCounts(ResourceType type)
Returns the count entry for the given resource type.

Parameters:
type - resource type
Returns:

getOrCreateCounts

protected ResourceCount.CountsPerType getOrCreateCounts(ResourceType type)
Returns or creates a new count entry for the given resource type.

Parameters:
type - resource type
Returns:

countActive

public long countActive(ResourceType type)
Returns the number of active units from the given resource type.

Parameters:
type - resource type
Returns:
number of active units

countPending

public long countPending(ResourceType type)
Returns the number of pending units from the given resource type.

Parameters:
type - resource type
Returns:
number of pending units

countExpired

public long countExpired(ResourceType type)
Returns the number of expired units from the given resource type.

Parameters:
type - resource type
Returns:
number of expired units

countFailed

public long countFailed(ResourceType type)
Returns the number of failed units from the given resource type.

Parameters:
type - resource type
Returns:
number of failed units

countClose

public long countClose(ResourceType type)
Returns the number of closed units from the given resource type.

Parameters:
type - resource type
Returns:
number of closed units

tallyActive

public void tallyActive(ResourceType type,
                        long count)
Increments with count the internal counter for active units of the specified type.

Parameters:
type - resource type

tallyPending

public void tallyPending(ResourceType type,
                         long count)
Increments with count the internal counter for pending units of the specified type.

Parameters:
type - resource type

tallyExpired

public void tallyExpired(ResourceType type,
                         long count)
Increments with count the internal counter for expired units of the specified type.

Parameters:
type - resource type

tallyFailed

public void tallyFailed(ResourceType type,
                        long count)
Increments with count the internal counter for failed units of the specified type.

Parameters:
type - resource type

tallyClose

public void tallyClose(ResourceType type,
                       long count)
Increments with count the internal counter for closed units of the specified type.

Parameters:
type - resource type


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