orca.policy.core
Class BaseServiceManagerCalendarPolicy

java.lang.Object
  extended by orca.shirako.core.Policy
      extended by orca.shirako.core.ServiceManagerPolicy
          extended by orca.policy.core.BaseServiceManagerCalendarPolicy
All Implemented Interfaces:
IClientPolicy, IInitialize, IPolicy, IRecover, ISerialize, IServiceManagerPolicy
Direct Known Subclasses:
ServiceManagerSimplePolicyPlugin

public abstract class BaseServiceManagerCalendarPolicy
extends ServiceManagerPolicy

SMBasePolicyPlugin specifies and implements some of the service manager's base resource allocation and upstream bidding policy.


Field Summary
protected  ServiceManagerCalendar calendar
          The calendar of this service manager
protected  ActorClock clock
          The clock
protected  java.util.HashSet<IReservationEventHandler> events
          An event handler for upcalls
protected  boolean lazyClose
          If true, the service manager will close reservations lazily: it will not issue a close and will wait until the site terminates the lease.
protected  LoggingTool logger
          The logger
protected  ReservationSet pendingNotify
          Contains reservations for which we may have completed performing bookkeeping actions but may need to wait for some other event to take place before we raise the corresponding event.
static java.lang.String PropertyEventHandler
           
 
Fields inherited from class orca.shirako.core.ServiceManagerPolicy
recoverer
 
Fields inherited from class orca.shirako.core.Policy
actor, guid, PropertyGuid
 
Constructor Summary
BaseServiceManagerCalendarPolicy()
          Creates a "blank" instance.
 
Method Summary
 void addEventHandler(IReservationEventHandler e)
          Adds an event handler.
protected  void checkPending()
          Checks pending bids, and installs successfully completed requests in the holdings calendar.
 void close(ResourceReservation reservation)
          Notifies the policy that a reservation is about to be closed.
 void closed(ResourceReservation reservation)
          Notifies the policy that a reservation has been closed.
 void demand(ReservationClient reservation)
          Injects a new resource demand into the demand stream.
protected  void error(java.lang.String string)
          Log and throw and exception
 void extend(ResourceReservation reservation, ResourceSet resources, Term term)
          Notifies the policy that a reservation is about to be extended.
 void finish(long cycle)
          Informs the mapper that all processing for the specified cycle is complete.
protected abstract  long getClose(ReservationClient reservation, Term term)
          Get the time that a reservation closes
 ReservationSet getClosing(long cycle)
          Returns a set of reservations that must be closed.
 ReservationSet getHoldings()
          Return the holdings for the actor.
 ReservationSet getHoldings(long cycle)
          Returns the holdings for the actor at the given time instance.
 ReservationSet getPending()
          Returns all reservations with pending operations.
protected abstract  long getRedeem(ReservationClient reservation)
          Get the time when this reservation should be redeemed
 ReservationSet getRedeeming(long cycle)
          Returns a set of reservations that must be redeemed.
protected abstract  long getRenew(ReservationClient reservation)
          Get the time when this reservation should be renewed
 java.util.Iterator getTicketingReservations()
          Get the reservations that are currently requesting tickets
 int getTicketingUnits(java.lang.String slicename)
          Returns the number of units for which there is an outstanding ticket or extendTicket request
 int getTicketingUnits(java.lang.String slicename, ResourceType type)
          Returns the number of units for which there is an outstanding ticket or extendTicket request
 int getTicketingUnits(java.lang.String slicename, java.lang.String brokerName, ResourceType type)
          Ticketing units for slice/broker/type
 void initialize()
          Initializes the object.
protected  boolean isExpired(ResourceReservation r)
          Checks if the reservation has expired.
 void remove(ResourceReservation reservation)
          Notifies the policy that a reservation is about to be removed.
 void removeEventHandler(IReservationEventHandler e)
          Removes an event handler.
 void revisit(ResourceReservation reservation)
          Informs the mapper about a reservation.
 void setEventHandler(IReservationEventHandler e)
          Adds an event handler.
 
Methods inherited from class orca.shirako.core.ServiceManagerPolicy
formulateBids, leaseSatisfies, reset, revisit, ticketSatisfies, updateTicketComplete
 
Methods inherited from class orca.shirako.core.Policy
getGuid, internalError, logError, logWarn, prepare, query, reset, save, save, setActor, setLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface orca.shirako.api.IPolicy
getGuid, prepare, query, setActor, setLogger
 
Methods inherited from interface orca.shirako.api.ISerialize
reset, save, save
 

Field Detail

PropertyEventHandler

public static java.lang.String PropertyEventHandler

logger

protected LoggingTool logger
The logger


events

protected java.util.HashSet<IReservationEventHandler> events
An event handler for upcalls


calendar

protected ServiceManagerCalendar calendar
The calendar of this service manager


clock

protected ActorClock clock
The clock


lazyClose

protected boolean lazyClose
If true, the service manager will close reservations lazily: it will not issue a close and will wait until the site terminates the lease. The major drawback is that leave actions will not be able to connect to the resources, since the resources will not exist at this time.


pendingNotify

protected ReservationSet pendingNotify
Contains reservations for which we may have completed performing bookkeeping actions but may need to wait for some other event to take place before we raise the corresponding event.

Constructor Detail

BaseServiceManagerCalendarPolicy

public BaseServiceManagerCalendarPolicy()
Creates a "blank" instance.

Method Detail

initialize

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

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

finish

public void finish(long cycle)
Description copied from interface: IPolicy
Informs the mapper that all processing for the specified cycle is complete. The mapper can safely discard any state associated with the cycle or any previous cycles. This method is invoked with the kernel lock on.

Note: The cycle number parameter is redundant and is passed for convenience. The policy can always obtain the cycle number by calling IActor.getCurrentCycle().

Specified by:
finish in interface IPolicy
Overrides:
finish in class Policy
Parameters:
cycle - the cycle number that has just passed

demand

public void demand(ReservationClient reservation)
Description copied from interface: IClientPolicy
Injects a new resource demand into the demand stream. The reservation must be pre-initialized with resource set, term, properties, etc. The policy should use this request as an indication that new resources are required. The exact mapping of the request to actual requests for resources is policy-specific. For example, the policy may choose to combine several reservation requests into one, split a reservation request onto multiple brokers, etc. This method is invoked with the kernel lock on.

Specified by:
demand in interface IClientPolicy
Overrides:
demand in class ServiceManagerPolicy
Parameters:
reservation - reservation representing resource demand
See Also:
IClientPolicy.formulateBids(long)

getClosing

public ReservationSet getClosing(long cycle)
Description copied from interface: IPolicy
Returns a set of reservations that must be closed. This method is invoked with the kernel lock on.

Specified by:
getClosing in interface IPolicy
Overrides:
getClosing in class Policy
Parameters:
cycle - the current cycle

getRedeeming

public ReservationSet getRedeeming(long cycle)
Description copied from interface: IServiceManagerPolicy
Returns a set of reservations that must be redeemed. This method is invoked with the kernel lock on.

Specified by:
getRedeeming in interface IServiceManagerPolicy
Overrides:
getRedeeming in class ServiceManagerPolicy
Parameters:
cycle - the current cycle

getTicketingReservations

public java.util.Iterator getTicketingReservations()
Get the reservations that are currently requesting tickets

Returns:
an iterator of the pending reservations

getTicketingUnits

public int getTicketingUnits(java.lang.String slicename)
Returns the number of units for which there is an outstanding ticket or extendTicket request

Parameters:
slicename - the name of the slice
Returns:
number of units from reservations that are ticketing

getTicketingUnits

public int getTicketingUnits(java.lang.String slicename,
                             ResourceType type)
Returns the number of units for which there is an outstanding ticket or extendTicket request

Parameters:
slicename - the name of the slice
type - resource type
Returns:
number of units from reservations that are ticketing of a particular type

getTicketingUnits

public int getTicketingUnits(java.lang.String slicename,
                             java.lang.String brokerName,
                             ResourceType type)
Ticketing units for slice/broker/type

Parameters:
slicename -
brokerName -
type -
Returns:

getHoldings

public ReservationSet getHoldings()
Description copied from interface: IClientPolicy
Return the holdings for the actor.

Specified by:
getHoldings in interface IClientPolicy
Overrides:
getHoldings in class ServiceManagerPolicy
Returns:
the holdings for this actor

getHoldings

public ReservationSet getHoldings(long cycle)
Description copied from interface: IClientPolicy
Returns the holdings for the actor at the given time instance.

Specified by:
getHoldings in interface IClientPolicy
Overrides:
getHoldings in class ServiceManagerPolicy
Returns:

getPending

public ReservationSet getPending()
Returns all reservations with pending operations.

Returns:
set of pending reservations

checkPending

protected void checkPending()
                     throws java.lang.Exception
Checks pending bids, and installs successfully completed requests in the holdings calendar. Note that the policy module must add bids to the pending set, or they may not install in the calendar.

Throws:
java.lang.Exception

getClose

protected abstract long getClose(ReservationClient reservation,
                                 Term term)
                          throws java.lang.Exception
Get the time that a reservation closes

Parameters:
reservation - the reservation
term - the term
Returns:
the close time of the reservation
Throws:
java.lang.Exception

getRedeem

protected abstract long getRedeem(ReservationClient reservation)
                           throws java.lang.Exception
Get the time when this reservation should be redeemed

Parameters:
reservation - the reservation
Returns:
the redeem time of the reservation
Throws:
java.lang.Exception

getRenew

protected abstract long getRenew(ReservationClient reservation)
                          throws java.lang.Exception
Get the time when this reservation should be renewed

Parameters:
reservation - the reservation
Returns:
the renew time of the reservation
Throws:
java.lang.Exception

error

protected void error(java.lang.String string)
              throws java.lang.Exception
Log and throw and exception

Overrides:
error in class Policy
Parameters:
string - the exception
Throws:
java.lang.Exception

isExpired

protected boolean isExpired(ResourceReservation r)
Checks if the reservation has expired.

Parameters:
r - reservation to check
Returns:

revisit

public void revisit(ResourceReservation reservation)
             throws java.lang.Exception
Description copied from interface: IPolicy
Informs the mapper about a reservation. Called during recovery/startup. The mapper must re-establish any state required for the management of the reservation.

Specified by:
revisit in interface IPolicy
Overrides:
revisit in class ServiceManagerPolicy
Throws:
java.lang.Exception

close

public void close(ResourceReservation reservation)
Notifies the policy that a reservation is about to be closed. This method will be invoked for every reservation that is about to be closed, even if the close was triggered by the policy itself. The policy should update its internal state/cancel pending operations associated with the reservation. This method is invoked with the kernel lock on.

Specified by:
close in interface IPolicy
Overrides:
close in class Policy
Parameters:
reservation - reservation about to close

closed

public void closed(ResourceReservation reservation)
Notifies the policy that a reservation has been closed. This method will be invoked for every reservation that closes successfully. The policy must uncommit any resources associated with the reservation, e.g, physical machines, currency, etc. This method is invoked with the kernel lock on.

Note: For an authority resources are released using the #IAuthorityPolicy.release(ResourceSet) method. Authority policy implementations should not consider the resources of the passed reservation as released. The release will take place once all configuration actions complete.

Specified by:
closed in interface IPolicy
Overrides:
closed in class Policy
Parameters:
reservation - closed reservation
See Also:
IAuthorityPolicy.release(ResourceSet)

remove

public void remove(ResourceReservation reservation)
Notifies the policy that a reservation is about to be removed. This method will be invoked for each reservation that is to be removed from the system. The policy should remove any state that it maintains for the reservation. This method is invoked with the kernel lock on.

Note: Only failed and closed reservations can be removed. The system will not invoke this method if the reservation is not closed or failed.

Specified by:
remove in interface IPolicy
Overrides:
remove in class Policy
Parameters:
reservation - reservation to be removed

extend

public void extend(ResourceReservation reservation,
                   ResourceSet resources,
                   Term term)
Notifies the policy that a reservation is about to be extended. This method will be invoked only for reservations, whose extensions have not been triggered by the policy, e.g, from the management interface. The policy should update its state to reflect the extend request. This method is invoked with the kernel lock on.

Specified by:
extend in interface IPolicy
Overrides:
extend in class Policy
Parameters:
reservation - reservation to be extended
resources - resource set used for the extension
term - term used for the extension

setEventHandler

public void setEventHandler(IReservationEventHandler e)
Adds an event handler.

Parameters:
e - event handler

addEventHandler

public void addEventHandler(IReservationEventHandler e)
Adds an event handler.

Parameters:
e - event handler

removeEventHandler

public void removeEventHandler(IReservationEventHandler e)
Removes an event handler.

Parameters:
e - event handler


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