|
||||||||||
| 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.AuthorityPolicy
orca.policy.core.AuthorityBasePolicyPlugin
public class AuthorityBasePolicyPlugin
The base for authority policy implementations
| Field Summary | |
|---|---|
protected AuthorityCalendar |
calendar
The authority's calendar. |
protected java.util.Hashtable<java.lang.String,IResourceControl> |
controls
ResourceControl objects indexed by resource type. |
protected java.util.Hashtable<java.lang.String,IResourceControl> |
controlsByGuid
Resource control objects indexed by guid. |
protected boolean |
lazyClose
If true, we will use lazy revocation. |
static java.lang.String |
PropertyResourceControlClassPrefix
|
static java.lang.String |
PropertyResourceControlPrefix
|
static java.lang.String |
PropertyResourceControlsCount
|
static java.lang.String |
PropertyResourceControlTypesPrefix
|
protected java.util.Hashtable<IResourceControl,java.util.Properties> |
tempProperties
The important properties for persistence |
| Fields inherited from class orca.shirako.core.AuthorityPolicy |
|---|
PropertySourceTicket, recoverer, tickets |
| Fields inherited from class orca.shirako.core.Policy |
|---|
actor, clock, guid, logger, PropertyGuid |
| Constructor Summary | |
|---|---|
AuthorityBasePolicyPlugin()
Creates a new instance. |
|
| Method Summary | |
|---|---|
protected ResourceSet |
assign(AuthorityReservation reservation)
Assign resources for the given reservation |
void |
assign(long cycle)
Assigns leases to incoming tickets. |
void |
available(ResourceSet rset)
Informs the policy that concrete resources previously marked as unavailable are now available. |
boolean |
bind(AuthorityReservation r)
Handles a requests to allocate resources for a ticketed reservation. |
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 |
correctDeficit(AuthorityReservation reservation)
|
ResourceSet |
correctFailed(ResourceSet rset)
Incorporates fixed, but previously failed, resources back to the policy |
void |
donate(ResourceSet rset)
Accepts concrete resources to be used for allocation of client requests. |
void |
eject(ResourceSet rset)
Ejects concrete resources from the inventory. |
protected void |
error(java.lang.String string)
Log and report an error |
boolean |
extend(AuthorityReservation reservation)
Handles a requests to extend the allocation of previously allocated resources. |
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. |
void |
freed(ResourceSet rset)
Informs the policy that a set of resources can be considered as free. |
AuthorityCalendar |
getCalendar()
Returns the calendar used by this policy |
protected long |
getClose(Term term)
Return the cycle when a term closes |
ReservationSet |
getClosing(long cycle)
Returns a set of reservations that must be closed. |
IResourceControl |
getControl(ID guid)
|
protected IResourceControl |
getControl(ResourceType type)
Obtains the control object for the given resource type |
java.util.Hashtable<IResourceControl,java.util.List<java.lang.String>> |
getControlTypes()
Returns a reverse map of resource control to resource types. |
ReservationSet |
getRequests(long cycle)
|
protected java.lang.String |
getTypes(java.util.Hashtable<IResourceControl,java.util.List<java.lang.String>> types,
IResourceControl c)
Returns a comma-separated strings of all resource types the given resource control is registered to serve. |
void |
initialize()
Initializes the object. |
protected void |
initializeControls()
Initializes all registered controls. |
protected boolean |
isExpired(ResourceReservation r)
See if a reservation has expired |
protected void |
map(AuthorityReservation r)
Maps a reservation. |
protected void |
mapForCycle(ReservationSet requests,
long cycle)
Orders mapper request processing for this cycle. |
protected void |
mapGrowing(ReservationSet bids)
Maps reservations that are growing in this cycle (redeems or expanding extends), and removes them from the bid set. |
protected void |
mapShrinking(ReservationSet bids)
Maps reservations that are shrinking or staying the same (extending with no flex) in this cycle, and removes them from the bid set. |
protected void |
registerAndRevisit(AuthorityReservation r)
Registers the reservation in the calendar and performs revisit with the control. |
void |
registerControl(ResourceType type,
IResourceControl control)
Registers the given control for the specified resource type. |
void |
registerControl(java.lang.String types,
IResourceControl control)
Registers the given control for all of the specified types. |
void |
release(ResourceSet rset)
Releases concrete resources that are no longer in use. |
void |
remove(ResourceReservation reservation)
Notifies the policy that a reservation is about to be removed. |
protected void |
reschedule(AuthorityReservation r)
Reschedule a reservation into the calendar |
void |
reset(java.util.Properties p)
De-serializes the object from the given properties list. |
protected void |
resetControls(java.util.Properties p)
|
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 r)
Informs the mapper about a reservation. |
protected void |
revisitAuthority(AuthorityReservation r)
|
protected void |
revisitControls(IActor actor)
Initiates recovery for controls. |
void |
save(java.util.Properties p)
Serializes the object into the given properties list. |
protected void |
saveControls(java.util.Properties p)
Serializes all registered controls |
void |
setResourceControl(IResourceControl control)
Registers the control. NOTE: reserved only to be called from ContainerIntializer. |
int |
unavailable(ResourceSet rset)
Informs the policy that concrete resources are about to become unavailable. |
| Methods inherited from class orca.shirako.core.AuthorityPolicy |
|---|
allocate, bind, donate, exportResources, extend, finishCorrectDeficit, reset |
| Methods inherited from class orca.shirako.core.Policy |
|---|
getGuid, internalError, logError, logWarn, prepare, query, 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 |
|---|
save |
| Field Detail |
|---|
public static final java.lang.String PropertyResourceControlsCount
public static final java.lang.String PropertyResourceControlTypesPrefix
public static final java.lang.String PropertyResourceControlClassPrefix
public static final java.lang.String PropertyResourceControlPrefix
protected AuthorityCalendar calendar
protected java.util.Hashtable<java.lang.String,IResourceControl> controls
protected java.util.Hashtable<java.lang.String,IResourceControl> controlsByGuid
protected java.util.Hashtable<IResourceControl,java.util.Properties> tempProperties
protected boolean lazyClose
| Constructor Detail |
|---|
public AuthorityBasePolicyPlugin()
| Method Detail |
|---|
public void initialize()
throws java.lang.Exception
IInitialize
initialize in interface IInitializeinitialize in class AuthorityPolicyjava.lang.Exception
protected void initializeControls()
throws java.lang.Exception
java.lang.Exception
public void save(java.util.Properties p)
throws java.lang.Exception
ISerialize
save in interface ISerializesave in class Policyp - properties list to serialize the object into
java.lang.Exception
public void reset(java.util.Properties p)
throws java.lang.Exception
ISerialize
reset in interface ISerializereset in class Policyp - properties list containing the serialized version of
the object
java.lang.Exceptionpublic java.util.Hashtable<IResourceControl,java.util.List<java.lang.String>> getControlTypes()
protected java.lang.String getTypes(java.util.Hashtable<IResourceControl,java.util.List<java.lang.String>> types,
IResourceControl c)
throws java.lang.Exception
types - the control typesc - a control
java.lang.Exception
protected void saveControls(java.util.Properties p)
throws java.lang.Exception
p - properties
java.lang.Exception
protected void resetControls(java.util.Properties p)
throws java.lang.Exception
java.lang.Exception
protected void registerAndRevisit(AuthorityReservation r)
throws java.lang.Exception
r - reservation to register
java.lang.Exception - if the control responsible for this reservation is
missing
public void revisit(ResourceReservation r)
throws java.lang.Exception
IPolicy
revisit in interface IPolicyrevisit in class AuthorityPolicyjava.lang.Exception
protected void revisitAuthority(AuthorityReservation r)
throws java.lang.Exception
java.lang.Exception
public void revisit(IActor actor,
java.util.Properties p)
throws java.lang.Exception
IRecover
revisit in interface IRecoverrevisit in class AuthorityPolicyactor - actor object the component belongs top - properties list containing configuration data about the
component
java.lang.Exception
protected void revisitControls(IActor actor)
throws java.lang.Exception
actor -
java.lang.Exception
public void registerControl(ResourceType type,
IResourceControl control)
type - resource typecontrol - the control
public void registerControl(java.lang.String types,
IResourceControl control)
throws java.lang.Exception
types - set of resource typescontrol - the control
java.lang.Exception
public void setResourceControl(IResourceControl control)
throws java.lang.Exception
registerControl instead.
control - the control
java.lang.Exceptionprotected IResourceControl getControl(ResourceType type)
type - resource type
java.lang.Exceptionpublic IResourceControl getControl(ID guid)
public void donate(ResourceSet rset)
throws java.lang.Exception
IAuthorityPolicy
donate in interface IAuthorityPolicydonate in class AuthorityPolicyrset - resource set representing resources to be used for
allocation
java.lang.Exception
public void eject(ResourceSet rset)
throws java.lang.Exception
IAuthorityPolicy
eject in interface IAuthorityPolicyeject in class AuthorityPolicyjava.lang.Exception
public void available(ResourceSet rset)
throws java.lang.Exception
IAuthorityPolicy
available in interface IAuthorityPolicyavailable in class AuthorityPolicyjava.lang.Exception
public int unavailable(ResourceSet rset)
throws java.lang.Exception
IAuthorityPolicy
unavailable in interface IAuthorityPolicyunavailable in class AuthorityPolicyjava.lang.Exceptionpublic void finish(long cycle)
IPolicy
Note: The cycle number parameter is redundant and is passed for
convenience. The policy can always obtain the cycle number by calling
IActor.getCurrentCycle().
finish in interface IPolicyfinish in class Policycycle - the cycle number that has just passed
public boolean bind(AuthorityReservation r)
throws java.lang.Exception
IAuthorityPolicyreservation.getRequestedResources(). The requested lease
term can be obtained by calling
reservation.getRequestedTerm(). Properties specific to
the lease protocol can be obtained by calling
reservation.getRequestedResources().getConfigurationProperties().
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 IAuthorityPolicybind in class AuthorityPolicyr - reservation to allocate resources for.
java.lang.Exception
public boolean extend(AuthorityReservation reservation)
throws java.lang.Exception
IAuthorityPolicyreservation.getRequestedResources(). The requested lease
term can be obtained by calling
reservation.getRequestedTerm(). Properties specific to
the lease protocol can be obtained by calling
reservation.getRequestedResources().getConfigurationProperties().
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.
extend in interface IAuthorityPolicyextend in class AuthorityPolicyreservation - reservation to allocate resources for.
java.lang.Exception
protected ResourceSet assign(AuthorityReservation reservation)
throws java.lang.Exception
reservation - the request
java.lang.Exception
public void correctDeficit(AuthorityReservation reservation)
throws java.lang.Exception
correctDeficit in interface IAuthorityPolicycorrectDeficit in class AuthorityPolicyjava.lang.Exception
public void assign(long cycle)
throws java.lang.Exception
IAuthorityPolicy
assign in interface IAuthorityPolicyassign in class AuthorityPolicycycle - the cycle the authority is making assignment for
java.lang.Exception
protected void mapForCycle(ReservationSet requests,
long cycle)
throws java.lang.Exception
requests - The requests for this cyclecycle - The cycle
java.lang.Exception
protected void mapShrinking(ReservationSet bids)
throws java.lang.Exception
bids - set of deferred operations for this cycle (non-null)
java.lang.Exception
protected void mapGrowing(ReservationSet bids)
throws java.lang.Exception
bids - set of deferred operations for this cycle (non-null)
java.lang.Exception
protected void map(AuthorityReservation r)
throws java.lang.Exception
bind or
extend above, which will release the request to the
associated mapper.
r - the reservation
java.lang.Exceptionprotected void reschedule(AuthorityReservation r)
r - the reservationprotected long getClose(Term term)
term - the term
public ResourceSet correctFailed(ResourceSet rset)
throws java.lang.Exception
IAuthorityPolicy
correctFailed in interface IAuthorityPolicycorrectFailed in class AuthorityPolicyrset - the resources
java.lang.Exceptionpublic void release(ResourceSet rset)
IAuthorityPolicyIAuthorityPolicy.freed(ResourceSet), which is
used to free resources unconditionally.
release in interface IAuthorityPolicyrelease in class AuthorityPolicyrset - the resource set to be released#closed(ResourceReservation)}public void freed(ResourceSet rset)
IAuthorityPolicy
freed in interface IAuthorityPolicyfreed in class AuthorityPolicypublic void close(ResourceReservation reservation)
close in interface IPolicyclose in class Policyreservation - reservation about to closepublic void closed(ResourceReservation reservation)
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.
closed in interface IPolicyclosed in class Policyreservation - closed reservationIAuthorityPolicy.release(ResourceSet)public void remove(ResourceReservation reservation)
Note: Only failed and closed reservations can be removed. The system will not invoke this method if the reservation is not closed or failed.
remove in interface IPolicyremove in class Policyreservation - reservation to be removed
public void extend(ResourceReservation reservation,
ResourceSet resources,
Term term)
extend in interface IPolicyextend in class Policyreservation - reservation to be extendedresources - resource set used for the extensionterm - term used for the extension
protected void error(java.lang.String string)
throws java.lang.Exception
error in class Policystring - the error
java.lang.Exception
protected boolean isExpired(ResourceReservation r)
throws java.lang.Exception
r - reservation
true if the reservation expired; otherwise, return
false
java.lang.Exceptionpublic AuthorityCalendar getCalendar()
public ReservationSet getRequests(long cycle)
getRequests in class AuthorityPolicypublic ReservationSet getClosing(long cycle)
getClosing in interface IPolicygetClosing in class Policycycle - the current cycle
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||