orca.policy.core
Class ServiceManagerSimplePolicyPlugin

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

public class ServiceManagerSimplePolicyPlugin
extends BaseServiceManagerCalendarPolicy

A simple implementation of a Service Manager bidding policy. This version implements a simple SM bid policy with the following assumptions:
1 broker
Always bid on only the first open auction
Never shrinks a reservation (e.g., due to budget constraints)
Extend all reservations expiring at bidding time, if renewable
Close - ADVANCE_CLOSE cycles early

Author:
grit

Field Summary
protected static long ADVANCE_CLOSE
          How far in advance a reservation should initiate the close.
static long CLOCK_SKEW
          The amount of time over specific policy decisions the SM must add when communicating with other actors (e.g.
 
Fields inherited from class orca.policy.core.BaseServiceManagerCalendarPolicy
calendar, clock, events, lazyClose, logger, pendingNotify, PropertyEventHandler
 
Fields inherited from class orca.shirako.core.ServiceManagerPolicy
recoverer
 
Fields inherited from class orca.shirako.core.Policy
actor, guid, PropertyGuid
 
Constructor Summary
ServiceManagerSimplePolicyPlugin()
           
 
Method Summary
 void demand(ResourceReservation reservation)
          
 Bids formulateBids(long cycle)
          Form bids for expiring reservations and new demands.
 long getClose(ReservationClient reservation, Term term)
          Very simple policy - based on ADVANCE_CLOSE
Get the time that a reservation closes
protected  Term getExtendTerm(Term suggestedTerm, Term currentTerm)
           
 long getRedeem(ReservationClient reservation)
          Redeem at the new start of the lease
Get the time when this reservation should be redeemed
 long getRenew(ReservationClient reservation)
          Call up to the agent to receive the advanceTime.
 void prepare(long cycle)
          Informs the policy that processing for a new cycle is about to begin.
protected  ReservationSet processDemand(long cycle)
          For each newly requested reservation, assigns a term to request, and a broker to bid from.
protected  ReservationSet processRenewing(long cycle)
          Returns a fresh ReservationSet of expiring reservations to try to renew in this bidding cycle, and suggest new terms for them.
 
Methods inherited from class orca.policy.core.BaseServiceManagerCalendarPolicy
addEventHandler, checkPending, close, closed, demand, error, extend, finish, getClosing, getHoldings, getHoldings, getPending, getRedeeming, getTicketingReservations, getTicketingUnits, getTicketingUnits, getTicketingUnits, initialize, isExpired, remove, removeEventHandler, revisit, setEventHandler
 
Methods inherited from class orca.shirako.core.ServiceManagerPolicy
leaseSatisfies, reset, revisit, ticketSatisfies, updateTicketComplete
 
Methods inherited from class orca.shirako.core.Policy
getGuid, internalError, logError, logWarn, 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, query, setActor, setLogger
 
Methods inherited from interface orca.shirako.api.ISerialize
reset, save, save
 

Field Detail

CLOCK_SKEW

public static long CLOCK_SKEW
The amount of time over specific policy decisions the SM must add when communicating with other actors (e.g. redeem() and renew()). Clock skew must be at least one if the SM is ticked after the agent and/or authority At some point in time we may want this to not be static and learn it from what we see in the system, but for now it is static.


ADVANCE_CLOSE

protected static long ADVANCE_CLOSE
How far in advance a reservation should initiate the close. This allows for the SM to property close its reservation before the authority does a close on its behalf, which would eliminate any state the SM needs to save.

Constructor Detail

ServiceManagerSimplePolicyPlugin

public ServiceManagerSimplePolicyPlugin()
Method Detail

prepare

public void prepare(long cycle)
Informs the policy that processing for a new cycle is about to begin. The policy should initialize whatever internal state is necessary to process a new cycle. 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:
prepare in interface IPolicy
Overrides:
prepare in class Policy
Parameters:
cycle - the cycle number that is about to be processed

formulateBids

public Bids formulateBids(long cycle)
Form bids for expiring reservations and new demands. Return sets of reservations for new bids and renewals.
formulateBids is unlocked on SM. Note that a bidding policy never changes the state of reservations, except to suggest terms and brokers. It just returns sets of reservations ready to bid for and extend. It also never changes the membership of any reservation sets maintained by the server, although it does walk through them.
Formulates bids to the upstream broker(s). The method should determine whether to issue bids on the current cycle. This method should consider the current demand, call broker(s) to obtain necessary information and decide how to distribute its resource demand. When deciding how to bid, also consider any expiring reservation and decide whether to renew and adjust their units. The code should only formulate the bids: the actor will then issue them. This method is invoked with the kernel lock on.

Here are some guidelines for implementing this method:


Specified by:
formulateBids in interface IClientPolicy
Overrides:
formulateBids in class ServiceManagerPolicy
Parameters:
cycle - The current time
Returns:
Two collections:
  • ticketing - set of new reservations
  • extending - set of reservations to be extended Can be null if no action should be taken

processDemand

protected ReservationSet processDemand(long cycle)
                                throws java.lang.Exception
For each newly requested reservation, assigns a term to request, and a broker to bid from.

Parameters:
demand - a set of reservations that indicate the demand for resources
pending - a set of reservations that are currently pending
Returns:
non-null set of new bids
Throws:
java.lang.Exception - rare

getExtendTerm

protected Term getExtendTerm(Term suggestedTerm,
                             Term currentTerm)
                      throws java.lang.Exception
Throws:
java.lang.Exception

processRenewing

protected ReservationSet processRenewing(long cycle)
                                  throws java.lang.Exception
Returns a fresh ReservationSet of expiring reservations to try to renew in this bidding cycle, and suggest new terms for them.

Parameters:
renewing - a set of reservations that are up for renewal
pending - a set of reservations that are pending
Returns:
non-null set of renewals
Throws:
java.lang.Exception - rare

getClose

public long getClose(ReservationClient reservation,
                     Term term)
              throws java.lang.Exception
Very simple policy - based on ADVANCE_CLOSE
Get the time that a reservation closes

Specified by:
getClose in class BaseServiceManagerCalendarPolicy
Parameters:
reservation - the reservation
term - the term
Returns:
the close time of the reservation
Throws:
java.lang.Exception

getRedeem

public long getRedeem(ReservationClient reservation)
               throws java.lang.Exception
Redeem at the new start of the lease
Get the time when this reservation should be redeemed

Specified by:
getRedeem in class BaseServiceManagerCalendarPolicy
Parameters:
reservation - the reservation
Returns:
the redeem time of the reservation
Throws:
java.lang.Exception

getRenew

public long getRenew(ReservationClient reservation)
              throws java.lang.Exception
Call up to the agent to receive the advanceTime. Do time based on newStart so that requests are aligned with
Get the time when this reservation should be renewed

Specified by:
getRenew in class BaseServiceManagerCalendarPolicy
Parameters:
reservation - the reservation
Returns:
the renew time of the reservation
Throws:
java.lang.Exception

demand

public void demand(ResourceReservation reservation)



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