orca.shirako.core
Class BrokerPolicy

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

public class BrokerPolicy
extends Policy
implements IBrokerPolicy


Field Summary
protected  BrokerPolicyRecoverer recoverer
          The recoverer.
 
Fields inherited from class orca.shirako.core.Policy
actor, clock, guid, logger, PropertyGuid
 
Constructor Summary
BrokerPolicy()
          Default constructor.
BrokerPolicy(Broker actor)
          Creates a new instance.
 
Method Summary
 void allocate(long cycle)
          Allocates resources to all clients who have requested them.
 boolean bind(BrokerReservation reservation)
          Handles an incoming request to allocate resources and issue a ticket for the reservation.
 void demand(ReservationClient reservation)
          Injects a new resource demand into the demand stream.
 void donate(ReservationClient reservation)
          Accepts ticketed resources to be used for allocation of client requests.
 boolean extend(BrokerReservation reservation)
          Handles an incoming request to extend previously allocated resources and issue a ticket for the reservation.
 Bids formulateBids(long cycle)
          Formulates bids to the upstream broker(s).
 ReservationSet getHoldings()
          Return the holdings for the actor.
 ReservationSet getHoldings(long cycle)
          Returns the holdings for the actor at the given time instance.
 ReservationSet getRedeeming(long cycle)
           
 void initialize()
          Initializes the object.
 void prepareExtend(ReservationClient reservation)
           
 void prepareReserve(ReservationClient reservation)
           
 void reset()
          Post recovery entry point.
 void revisit(IActor actor, java.util.Properties p)
          Recovers state of the component using a previously saved properties list and a references to the actor this component belongs to.
 void revisit(ResourceReservation reservation)
          Informs the mapper about a reservation.
 void ticketSatisfies(ResourceSet requestedResources, ResourceSet actualResources, Term requestedTerm, Term actualTerm)
          Checks if the resources and term received in a ticket are in compliance with what was initially requested.
 void updateTicketComplete(IReservation reservation)
          Notifies the policy that a ticket update operation has completed.
 
Methods inherited from class orca.shirako.core.Policy
close, closed, error, extend, finish, getClosing, getGuid, internalError, logError, logWarn, prepare, query, remove, 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
close, closed, extend, finish, getClosing, getGuid, prepare, query, remove, setActor, setLogger
 
Methods inherited from interface orca.shirako.api.ISerialize
reset, save, save
 
Methods inherited from interface orca.shirako.api.IPolicy
close, closed, extend, finish, getClosing, getGuid, prepare, query, remove, setActor, setLogger
 
Methods inherited from interface orca.shirako.api.ISerialize
reset, save, save
 

Field Detail

recoverer

protected BrokerPolicyRecoverer recoverer
The recoverer.

Constructor Detail

BrokerPolicy

public BrokerPolicy()
Default constructor.


BrokerPolicy

public BrokerPolicy(Broker actor)
Creates a new instance.

Parameters:
actor - actor the mapper belongs to
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 Policy
Throws:
java.lang.Exception

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

prepareReserve

public void prepareReserve(ReservationClient reservation)
                    throws java.lang.Exception
Throws:
java.lang.Exception

prepareExtend

public void prepareExtend(ReservationClient reservation)
                   throws java.lang.Exception
Throws:
java.lang.Exception

updateTicketComplete

public void updateTicketComplete(IReservation reservation)
                          throws java.lang.Exception
Description copied from interface: IClientPolicy
Notifies the policy that a ticket update operation has completed. The mapper may use this upcall to update its internal state. This method is invoked with the kernel lock on.

Specified by:
updateTicketComplete in interface IClientPolicy
Parameters:
reservation - reservation for which an update ticket operation has completed
Throws:
java.lang.Exception

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
Parameters:
reservation - reservation representing resource demand
See Also:
IClientPolicy.formulateBids(long)

bind

public boolean bind(BrokerReservation reservation)
             throws java.lang.Exception
Description copied from interface: IServerPolicy
Handles an incoming request to allocate resources and issue a ticket for the reservation. The requested resources can be obtained by calling reservation.getRequestedResources(). The requested lease term can be obtained by calling reservation.getRequestedTerm(). Properties specific to the allocation protocol can be obtained by calling reservation.getRequestedResources().getRequestProperties(). This method is invoked with the kernel lock on.

If the policy completed processing this request, the functions should return true. If no further intervention is required, e.g., approval by an administrator, the policy should also clear the bidPending flag.

The policy may decide to defer the request for a later time. In this case the function should return false and the bidPending flag should remain unchanged.

This method may be invoked multiple times for a given reservation, i.e., if the policy delays the allocation, the system will continue invoking this method at later times until the policy completes processing this request.

Specified by:
bind in interface IServerPolicy
Parameters:
reservation - reservation to allocate resources for.
Returns:
true, if the request has been fulfilled, false, if the allocation of resources will be delayed until a later time.
Throws:
java.lang.Exception

extend

public boolean extend(BrokerReservation reservation)
               throws java.lang.Exception
Description copied from interface: IServerPolicy
Handles an incoming request to extend previously allocated resources and issue a ticket for the reservation. The requested resources can be obtained by calling reservation.getRequestedResources(). Properties specific to the allocation protocol can be obtained by calling reservation.getRequestedResources().getRequestProperties(). The requested lease term can be obtained by calling reservation.getRequestedTerm(). The new term must extend the currently allocated term. This method is invoked with the kernel lock on.

If the policy completed processing this request, the functions should return true. If no further intervention is required, e.g., approval by an administrator, the policy should also clear the bidPending flag.

The policy may decide to defer the request for a later time. In this case the function should return false and the bidPending flag should remain unchanged.

This method may be invoked multiple times for a given reservation, i.e., if the policy delays the allocation, the system will continue invoking this method at later times until the policy completes processing this request.

While the policy is free to modify the term as it wishes, care must be taken that the client reservation is not closed before the extension is actually granted.

Specified by:
extend in interface IServerPolicy
Returns:
true, if the request has been fulfilled, false, if the allocation of resources will be delayed until a later time.
Throws:
java.lang.Exception

allocate

public void allocate(long cycle)
              throws java.lang.Exception
Description copied from interface: IServerPolicy
Allocates resources to all clients who have requested them. This method is called by the policy once per cycle. The method should determine whether to perform resource allocation on the given cycle and what requests to consider in that process. This method is invoked with the kernel lock on.

Specified by:
allocate in interface IServerPolicy
Parameters:
cycle - the cycle for this allocation
Throws:
java.lang.Exception

formulateBids

public Bids formulateBids(long cycle)
Description copied from interface: IClientPolicy
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
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

getRedeeming

public ReservationSet getRedeeming(long cycle)

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
Returns:

getHoldings

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

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

ticketSatisfies

public void ticketSatisfies(ResourceSet requestedResources,
                            ResourceSet actualResources,
                            Term requestedTerm,
                            Term actualTerm)
                     throws java.lang.Exception
Description copied from interface: IClientPolicy
Checks if the resources and term received in a ticket are in compliance with what was initially requested. The policy can prevent the application of the incoming update if it disagrees with it. This method is invoked with the kernel lock on.

Specified by:
ticketSatisfies in interface IClientPolicy
Parameters:
requestedResources - resources requested from broker
actualResources - resources received from broker
requestedTerm - term requested from broker
actualTerm - term received from broker
Throws:
java.lang.Exception

revisit

public void revisit(IActor actor,
                    java.util.Properties p)
             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
Overrides:
revisit in class Policy
Parameters:
actor - actor object the component belongs to
p - properties list containing configuration data about the component
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 Policy
Throws:
java.lang.Exception

reset

public void reset()
           throws java.lang.Exception
Description copied from interface: IPolicy
Post recovery entry point. This method will be invoked once all revisit operations are complete and the actor is ready to operate normally.

Specified by:
reset in interface IPolicy
Overrides:
reset in class Policy
Throws:
java.lang.Exception


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