orca.policy.core
Class BrokerBasePolicyPlugin

java.lang.Object
  extended by orca.shirako.core.Policy
      extended by orca.shirako.core.BrokerPolicy
          extended by orca.policy.core.BrokerBasePolicyPlugin
All Implemented Interfaces:
IBrokerPolicy, IClientPolicy, IInitialize, IPolicy, IRecover, ISerialize, IServerPolicy
Direct Known Subclasses:
BrokerSimplePolicyPlugin

public abstract class BrokerBasePolicyPlugin
extends BrokerPolicy

BrokerBasePolicyPlugin specifies and implements some of the broker's base resource allocation and upstream bidding policy.


Field Summary
protected  BrokerCalendar calendar
          The broker calendar: list of client requests, source reservations, and allocated reservations.
static java.lang.String PropertyDiscoverTypes
           
static java.lang.String PropertyTypeCount
           
static java.lang.String PropertyTypeDescriptionPrefix
           
static java.lang.String PropertyTypeNamePrefix
           
protected  boolean requireApproval
          If true, every allocated ticket will require administrative approval before being sent back.
 
Fields inherited from class orca.shirako.core.BrokerPolicy
recoverer
 
Fields inherited from class orca.shirako.core.Policy
actor, clock, guid, logger, PropertyGuid
 
Constructor Summary
BrokerBasePolicyPlugin()
          Creates a "blank" instance.
 
Method Summary
protected  void addForApproval(BrokerReservation r)
          Add a reservation to the approval list
protected  void addForApprovalCalendar(BrokerReservation r)
          Adds the reservation to the approval list and removes the reservation from the closing calendar (if it belongs to it).
protected  void addToCalendar(ResourceSet mine, BrokerReservation reservation, ReservationClient source, Term approved)
          Record the new reservation in the agent's calendar
 void approve(BrokerReservation r)
          Approve a reservation.
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.
protected  ResourceCount count(ReservationSet set, java.util.Date when)
          Return a counter for the ReservationSet
 void donate(ReservationClient reservation)
          Accepts ticketed resources to be used for allocation of client requests.
 void finish(long cycle)
          Informs the mapper that all processing for the specified cycle is complete.
 ReservationSet getClosing(long cycle)
          Returns a set of reservations that must be closed.
 ReservationSet getForApproval()
          Return a list of all reservations that require approval
protected abstract  long getRenew(ReservationClient reservation)
          Returns the renew time of a given reservation
 void initialize()
          Initializes the object.
 void notApprove(BrokerReservation r)
          Do not approve a reservation.
 java.util.Properties query(java.util.Properties properties)
          Answers a query from another actor.
protected  void release(BrokerReservation r)
          Release resources associated with a client reservation.
protected  void release(ReservationClient r)
          Release resources associated with a source reservation.
protected  void releaseNotApproved(BrokerReservation r)
          Release the resources for a reservation that is not approved.
 void remove(ResourceReservation reservation)
          Notifies the policy that a reservation is about to be removed.
protected  void removeForApproval(BrokerReservation r)
          Remove a reservation from the approval list
 void revisit(ResourceReservation reservation)
          Informs the mapper about a reservation.
protected  void revisitClient(ReservationClient r)
          Recovers a source reservation.
protected  void revisitServer(BrokerReservation r)
          Recovers a client reservation.
 
Methods inherited from class orca.shirako.core.BrokerPolicy
allocate, bind, demand, extend, formulateBids, getHoldings, getHoldings, getRedeeming, prepareExtend, prepareReserve, reset, revisit, ticketSatisfies, updateTicketComplete
 
Methods inherited from class orca.shirako.core.Policy
error, extend, getGuid, internalError, logError, logWarn, prepare, 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
extend, getGuid, prepare, setActor, setLogger
 
Methods inherited from interface orca.shirako.api.ISerialize
reset, save, save
 
Methods inherited from interface orca.shirako.api.IPolicy
extend, getGuid, prepare, setActor, setLogger
 
Methods inherited from interface orca.shirako.api.ISerialize
reset, save, save
 

Field Detail

PropertyTypeNamePrefix

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

PropertyTypeDescriptionPrefix

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

PropertyTypeCount

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

PropertyDiscoverTypes

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

calendar

protected BrokerCalendar calendar
The broker calendar: list of client requests, source reservations, and allocated reservations.


requireApproval

protected boolean requireApproval
If true, every allocated ticket will require administrative approval before being sent back.

Constructor Detail

BrokerBasePolicyPlugin

public BrokerBasePolicyPlugin()
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 BrokerPolicy
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

donate

public void donate(ReservationClient reservation)
            throws java.lang.Exception
Description copied from interface: IServerPolicy
Accepts ticketed resources to be used for allocation of client requests. The policy should add the resources represented by this reservation to its inventory. This method is invoked with the kernel lock on.

Note: This method will be invoked only for resources not directly requested by the policy. For example, exported resources claimed manually by an administrator. The policy is itself responsible to "donate" resources to its inventory when resources it requests become available.

Specified by:
donate in interface IServerPolicy
Overrides:
donate in class BrokerPolicy
Throws:
java.lang.Exception

close

public void close(ResourceReservation reservation)
Description copied from interface: IPolicy
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)
Description copied from interface: IPolicy
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)

release

protected void release(ReservationClient r)
Release resources associated with a source reservation.

Parameters:
r - source reservation

release

protected void release(BrokerReservation r)
Release resources associated with a client reservation.

Parameters:
r - client reservation

releaseNotApproved

protected void releaseNotApproved(BrokerReservation r)
Release the resources for a reservation that is not approved.

Parameters:
r -

remove

public void remove(ResourceReservation reservation)
Description copied from interface: IPolicy
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

getForApproval

public ReservationSet getForApproval()
Return a list of all reservations that require approval


addForApproval

protected void addForApproval(BrokerReservation r)
Add a reservation to the approval list

Parameters:
r -

addForApprovalCalendar

protected void addForApprovalCalendar(BrokerReservation r)
                               throws java.lang.Exception
Adds the reservation to the approval list and removes the reservation from the closing calendar (if it belongs to it).

Parameters:
r -
Throws:
java.lang.Exception

removeForApproval

protected void removeForApproval(BrokerReservation r)
Remove a reservation from the approval list

Parameters:
r -

approve

public void approve(BrokerReservation r)
Approve a reservation. To be used by policies that require administrative intervention. Override to provide your own approval policy

Parameters:
r -

notApprove

public void notApprove(BrokerReservation r)
Do not approve a reservation. To be used by policies that require administrative approval. Override to provide your own polcy for dealing with reservations that are not approved.

Parameters:
r -

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

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 BrokerPolicy
Throws:
java.lang.Exception

revisitClient

protected void revisitClient(ReservationClient r)
                      throws java.lang.Exception
Recovers a source reservation.

Parameters:
r - reservation to recover
Throws:
java.lang.Exception

revisitServer

protected void revisitServer(BrokerReservation r)
                      throws java.lang.Exception
Recovers a client reservation.

Parameters:
r - reservation to recover
Throws:
java.lang.Exception

query

public java.util.Properties query(java.util.Properties properties)
Description copied from interface: IPolicy
Answers a query from another actor. This method is intended to be used to obtain policy-specific parameters and information. This method should be used when writing more complex policies requiring additional interaction among actors. Instead of extending the proxies to support passing/obtaining the required information, policy code can use the query interface to request/obtain such information. This method is invoked with the kernel lock on: the implementation should not block for prolonged periods of time. If necessary, future versions will update this interface two allow query responses to be delivered using callbacks.

Specified by:
query in interface IPolicy
Overrides:
query in class Policy
Returns:
a properties list of outgoing values. If the incoming properties collection is null or empty, should return all possible properties that can be relevant to the caller.

addToCalendar

protected void addToCalendar(ResourceSet mine,
                             BrokerReservation reservation,
                             ReservationClient source,
                             Term approved)
Record the new reservation in the agent's calendar

Parameters:
mine - new ticket
reservation - request
source - source assigned to this request
approved - approved term
Throws:
java.lang.Exception

count

protected ResourceCount count(ReservationSet set,
                              java.util.Date when)
Return a counter for the ReservationSet

Parameters:
set - the set of reservations being counted
when - the date when to count the resources
Returns:
counter

getRenew

protected abstract long getRenew(ReservationClient reservation)
                          throws java.lang.Exception
Returns the renew time of a given reservation

Parameters:
reservation - reservation to calculate renew time from
Throws:
java.lang.Exception

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


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