|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorca.shirako.core.Policy
orca.shirako.core.BrokerPolicy
orca.policy.core.BrokerBasePolicyPlugin
orca.policy.core.BrokerSimplePolicyPlugin
public class BrokerSimplePolicyPlugin
AgentSimplePolicyPlugin is a simple implementation of an
agent's plugin interface. It buffers requests for allocation periods and when
it performs allocations of resources it does so in FIFO giving preference to
extending requests.
| Field Summary | |
|---|---|
protected long |
ADVANCE_TIME
How far in the future is an Agent allocating resources (starting time). |
protected long |
CALL_INTERVAL
Number of cycles between two consecutive allocations. |
protected static long |
CLOCK_SKEW
The amount of time over specific policy decisions the agent must add when communicating with other agents as a client (e.g. |
protected long |
lastAllocation
Last time we allocated requests |
protected boolean |
ready
Indicates if the agent is ready to accept requests |
static java.lang.String |
REQUEST_TYPE
Specifies the type of ticket being requested |
| Fields inherited from class orca.policy.core.BrokerBasePolicyPlugin |
|---|
calendar, PropertyDiscoverTypes, PropertyTypeCount, PropertyTypeDescriptionPrefix, PropertyTypeNamePrefix, requireApproval |
| Fields inherited from class orca.shirako.core.BrokerPolicy |
|---|
recoverer |
| Fields inherited from class orca.shirako.core.Policy |
|---|
actor, clock, guid, logger, PropertyGuid |
| Constructor Summary | |
|---|---|
BrokerSimplePolicyPlugin()
|
|
| Method Summary | |
|---|---|
void |
allocate(long cycle)
Run an allocation of requests against all sources, given a set of pending bids by using FCFS giving extends priority. |
protected void |
allocateExtending(java.util.Iterator sources,
long startTime,
java.util.Vector<java.lang.String> requestTypes)
Iterates through all of the sources and allocates resources to their extending bids based on FIFO. |
protected void |
allocateNewBids(java.util.Iterator newBids,
java.util.Hashtable<ResourceType,ReservationClient> sourceHash,
long startTime,
java.util.Vector<java.lang.String> requestTypes)
Iterates through all of the new bids and allocates resources based on FIFO. |
boolean |
bind(BrokerReservation reservation)
Handles an incoming request to allocate resources and issue a ticket for the reservation. |
protected long |
calculateAvailable(long startTime,
ReservationClient source,
BrokerReservation reservation)
Calculate the available resources for a particular start time |
protected java.util.Hashtable<ResourceType,ReservationClient> |
createSourceHashtable(java.util.Iterator sources)
Create a Hashtable of the sources by type. |
boolean |
extend(BrokerReservation reservation)
Handles an incoming request to extend previously allocated resources and issue a ticket for the reservation. |
protected ResourceSet |
extractTicket(BrokerReservation reservation,
ReservationClient source,
Term approved,
long resourceShare)
Extract the ticket from the source and check to see if the resulting ticket satisfies the request |
Bids |
formulateBids(long cycle)
Formulate a collection of bids to extend. |
protected long |
getAllocation(BrokerReservation reservation)
Returns the allocation time for this reservation |
protected Term |
getApprovedTerm(BrokerReservation reservation)
Determine the approved term of a reservation |
protected long |
getNextAllocation(long currentCycle)
Returns the cycle of the next allocation period. |
long |
getRenew(ReservationClient reservation)
Call up to the agent to receive the advanceTime. |
protected long |
getStartForAllocation(long allocationCycle)
Returns the start time of reservations for an allocation at the given cycle. |
void |
prepare(long cycle)
Informs the policy that processing for a new cycle is about to begin. |
protected ReservationSet |
processRenewing(ReservationSet renewing,
ReservationSet pending)
Performs checks on renewing reservations. |
java.util.Properties |
query(java.util.Properties properties)
Returns the ADVANCE_TIME of an agent's allocation in the
properties. |
protected void |
satisfyAllocation(BrokerReservation reservation,
ReservationClient source,
long resourceShare,
long startResTime)
Performs all of the checks and necessary functions to allocate a ticket to a reservation from a source. |
protected void |
switchSource(java.util.Iterator sources,
long startTime,
java.util.Hashtable<ResourceType,ReservationClient> sourceHash)
Determine if a reservation has switched its source and place the request onto the correct source. |
protected boolean |
verifyWantedResources(BrokerReservation reservation,
ReservationClient source,
long startTime,
int wanted)
Ensure that there are sufficient resources to allocate the number of requested resources |
| Methods inherited from class orca.policy.core.BrokerBasePolicyPlugin |
|---|
addForApproval, addForApprovalCalendar, addToCalendar, approve, checkPending, close, closed, count, donate, finish, getClosing, getForApproval, initialize, notApprove, release, release, releaseNotApproved, remove, removeForApproval, revisit, revisitClient, revisitServer |
| Methods inherited from class orca.shirako.core.BrokerPolicy |
|---|
demand, getHoldings, getHoldings, getRedeeming, prepareExtend, prepareReserve, reset, revisit, ticketSatisfies, updateTicketComplete |
| Methods inherited from class orca.shirako.core.Policy |
|---|
error, extend, getGuid, internalError, logError, logWarn, 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, setActor, setLogger |
| Methods inherited from interface orca.shirako.api.ISerialize |
|---|
reset, save, save |
| Methods inherited from interface orca.shirako.api.IPolicy |
|---|
extend, getGuid, setActor, setLogger |
| Methods inherited from interface orca.shirako.api.ISerialize |
|---|
reset, save, save |
| Field Detail |
|---|
public static final java.lang.String REQUEST_TYPE
protected long CALL_INTERVAL
protected long ADVANCE_TIME
protected long lastAllocation
protected boolean ready
protected static long CLOCK_SKEW
| Constructor Detail |
|---|
public BrokerSimplePolicyPlugin()
| Method Detail |
|---|
public void prepare(long cycle)
Note: The cycle number parameter is redundant and is passed for
convenience. The policy can always obtain the cycle number by calling
IActor.getCurrentCycle().
prepare in interface IPolicyprepare in class Policycycle - the cycle number that is about to be processedpublic Bids formulateBids(long cycle)
Here are some guidelines for implementing this method:
formulateBids in interface IClientPolicyformulateBids in class BrokerPolicycycle - The current time
protected ReservationSet processRenewing(ReservationSet renewing,
ReservationSet pending)
renewing - collection of the renewing reservationspending - collection of reservations that are pending
java.lang.Exception - rare
public void allocate(long cycle)
throws java.lang.Exception
min(requested,available) until we run out. It gives
priority to extending requests compared to new requests. Assumes that
there is only 1 source reservation per type. Makes the assumption that we
allocate resources sequentially in time, so there are never less
resources available in the future.
allocate in interface IServerPolicyallocate in class BrokerPolicycycle - the cycle for this allocation
java.lang.Exception
protected void allocateNewBids(java.util.Iterator newBids,
java.util.Hashtable<ResourceType,ReservationClient> sourceHash,
long startTime,
java.util.Vector<java.lang.String> requestTypes)
throws java.lang.Exception
requestTypes or all requests if requestTypes
is null. Requests are associated with their appropriate source.
newBids - new bids to be allocatedsourceHash - the sources for this allocationstartTime - when the allocation beginsrequestTypes - determines which request type is being allocated. A
requestTypes of null indicates that any
requestType may be allocated.
java.lang.Exception
protected void allocateExtending(java.util.Iterator sources,
long startTime,
java.util.Vector<java.lang.String> requestTypes)
throws java.lang.Exception
requestTypes or all requests if
requestTypes is null.
sources - sources for this allocationstartTime - when the allocation beginsrequestTypes - determines which request type is being allocated. A
requestType of null indicates that any
requestType may be allocated.
java.lang.Exception
protected boolean verifyWantedResources(BrokerReservation reservation,
ReservationClient source,
long startTime,
int wanted)
throws java.lang.Exception
reservation - reservation being allocatedsource - source proposed for the requesting reservationstartTime - start of the proposed ticketwanted - number of resources being requested
true if there are sufficient resources,
false otherwise
java.lang.Exceptionprotected java.util.Hashtable<ResourceType,ReservationClient> createSourceHashtable(java.util.Iterator sources)
sources - sources for this allocation
protected void switchSource(java.util.Iterator sources,
long startTime,
java.util.Hashtable<ResourceType,ReservationClient> sourceHash)
throws java.lang.Exception
sources - sources for this allocationstartTime - start of the requested ticketssourceHash - all of the sources for this allocation sorted by type
java.lang.Exception
protected long calculateAvailable(long startTime,
ReservationClient source,
BrokerReservation reservation)
startTime - start of proposed ticketsource - source who's resources are being countedreservation - reservation associated with the counting (may be used
to get start/end times)
protected Term getApprovedTerm(BrokerReservation reservation)
reservation -
protected void satisfyAllocation(BrokerReservation reservation,
ReservationClient source,
long resourceShare,
long startResTime)
throws java.lang.Exception
reservation - request being allocated resourcessource - source request is being allocated fromresourceShare - number of resources being allocated to the requeststartResTime - when the ticket for the request starts
java.lang.Exception
protected ResourceSet extractTicket(BrokerReservation reservation,
ReservationClient source,
Term approved,
long resourceShare)
throws java.lang.Exception
reservation - reservation being requestedsource - source request is being extracted fromapproved - the approved term for this ticketresourceShare - number of resources being allocated to this ticket
java.lang.Exceptionprotected long getNextAllocation(long currentCycle)
currentCycle - the current cycle
protected long getAllocation(BrokerReservation reservation)
throws java.lang.Exception
reservation - reservation being assigned to an allocation
java.lang.Exceptionprotected long getStartForAllocation(long allocationCycle)
allocationCycle - allocation cycle
public long getRenew(ReservationClient reservation)
throws java.lang.Exception
getRenew in class BrokerBasePolicyPluginreservation - reservation to calculate renew time from
java.lang.Exception
public boolean bind(BrokerReservation reservation)
throws java.lang.Exception
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.
bind in interface IServerPolicybind in class BrokerPolicyreservation - reservation to allocate resources for.
java.lang.Exception
public boolean extend(BrokerReservation reservation)
throws java.lang.Exception
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.
extend in interface IServerPolicyextend in class BrokerPolicyjava.lang.Exceptionpublic java.util.Properties query(java.util.Properties properties)
ADVANCE_TIME of an agent's allocation in the
properties. This is used so that service managers and downstream brokers
know how early to bid. If the requested properties is null, the agent
returns all of the properties that it has defined.
query in interface IPolicyquery in class BrokerBasePolicyPlugin
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||