orca.shirako.kernel
Class ReservationServer

java.lang.Object
  extended by orca.shirako.kernel.Reservation
      extended by orca.shirako.kernel.ResourceReservation
          extended by orca.shirako.kernel.ReservationServer
All Implemented Interfaces:
IRecover, IReservation, IReservationStatus, IResourceReservation, ISerialize, IServerReservation
Direct Known Subclasses:
AuthorityReservation, BrokerReservation

public class ReservationServer
extends ResourceReservation
implements IServerReservation


Nested Class Summary
 
Nested classes/interfaces inherited from class orca.shirako.kernel.Reservation
Reservation.CountHelper
 
Field Summary
protected  ICallbackProxy callback
          Callback proxy.
protected  AuthToken client
          Identity of the client actor.
protected  AuthToken owner
          Identity of the server actor.
protected  IPolicy policy
          Policy in control of the reservation.
protected  long processTime
          The cycle in which this reservation is scheduled for processing.
static java.lang.String PropertyCallback
           
static java.lang.String PropertyClient
           
static java.lang.String PropertyOwner
           
static java.lang.String PropertyProcessTime
           
static java.lang.String PropertySequenceNumberIn
           
static java.lang.String PropertySequenceNumberOut
           
static java.lang.String PropertyServicePending
           
static java.lang.String PropertyUpdateCount
           
static java.lang.String PropertyUpdateData
           
protected  int sequenceIn
          Sequence number for incoming messages.
protected  int sequenceOut
          Sequence number for outgoing messages.
protected  int servicePending
          Scratch element to trigger post-actions on a probe.
protected  UpdateData udd
          Status of the last server-side operation for the reservation.
protected  int updateCount
          How many update messages have been sent to the client.
 
Fields inherited from class orca.shirako.kernel.ResourceReservation
approved, approvedResources, approvedTerm, bidPending, ElasticSize, ElasticTime, previousResources, previousTerm, PropertyApprovedResources, PropertyApprovedTerm, PropertyBidPending, PropertyPreviousTerm, PropertyRenewable, PropertyRequestedResources, PropertyRequestedTerm, PropertyResources, PropertyTerm, renewable, requestedResources, requestedTerm, resources, term
 
Fields inherited from class orca.shirako.kernel.Reservation
actor, category, closeTime, dirty, errMsg, expired, extended, from, guard, listeners, logger, pending, PropertyCategory, PropertyCloseTime, PropertyExtended, PropertyGuard, PropertyPending, PropertySlice, PropertySliceID, PropertyState, rid, slice, sliceID, slicename, state, stateTransition
 
Fields inherited from interface orca.shirako.api.IReservation
CategoryAll, CategoryAuthority, CategoryBroker, CategoryClient, PropertyClass, PropertyID
 
Constructor Summary
protected ReservationServer()
          Creates a new blank reservation instance.
protected ReservationServer(ReservationID rid, ResourceSet resources, Term term, Slice slice)
          Creates a new reservation instance to represent a server-side request for resources.
protected ReservationServer(ResourceSet resources, Term term, Slice slice)
          Creates a new reservation instance to represent a server-side request for resources.
 
Method Summary
protected  void clearNotice()
          Clears all event notices associated with the reservation.
protected  Reservation.CountHelper count(java.util.Date when)
           
 void count(ResourceCount rc, java.util.Date when)
          Tallies up resources in the reservation.
 void fail(java.lang.String message)
          Marks an operation failure.
 void fail(java.lang.String message, java.lang.Exception e)
          Marks an operation failure.
protected  void failNotify(java.lang.String message)
          Reports an operation failure and notifies the client.
 void failWarn(java.lang.String message)
          Marks an operation failure.
 int forecastUnits(java.util.Date when)
          Estimate the resource units controlled by this reservation at some time which may be in the future.
protected  void generateUpdate()
          Generates an update to the callback object (if any) for this reservation.
 ICallbackProxy getCallback()
          Returns the callback proxy.
 AuthToken getClientAuthToken()
          Returns the identity of the client represented by the reservation.
 long getProcessTime()
          Returns the time the reservation is going to be processed.
 int getSequenceIn()
          Returns the sequence number of the last received message.
 int getSequenceOut()
          Returns the sequence number of the last sent message.
 AuthToken getServerAuthToken()
          Returns the identity of the server actor that controls the reservation.
 ResourceType getType()
          Returns the resource type allocated to the reservation.
protected  void incomingRequest()
          Checks reservation state prior to handling an incoming request.
protected  void prepare(ICallbackProxy srt, LoggingTool logger)
          Prepare
 void probe()
          Probes a reservation and sync with resource status and client (server only).
 void reset(java.util.Properties p)
          De-serializes the object from the given properties list.
 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 save(java.util.Properties p)
          Serializes the object into the given properties list.
 void setOwner(AuthToken owner)
          Sets the identity of the server actor that controls the reservation.
 void setProcessTime(long time)
          Sets the time the reservation is going to be processed.
 void setSequenceIn(int sequence)
          Sets the sequence number of the last received message.
protected  void setServicePending(int pending)
          sets the type of pending operation that is in progress for the reservation.
protected  void updateLease(ResourceReservation rarg, UpdateData udd)
          Update the lease
protected  void updateTicket(ResourceReservation rarg, UpdateData udd)
          Update the ticket
protected  void validateIncoming()
          Validates a reservation as it arrives to an actor
 
Methods inherited from class orca.shirako.kernel.ResourceReservation
canRedeem, canRenew, getApprovedResources, getApprovedTerm, getApprovedType, getApprovedUnits, getConfigurationProperties, getLeasedAbstractUnits, getLeasedUnits, getLocalProperties, getPreviousResources, getPreviousTerm, getRequestedResources, getRequestedTerm, getRequestedType, getRequestedUnits, getRequestProperties, getResourceProperties, getResources, getTerm, getUnits, holding, isApproved, isBidPending, isExpired, isRenewable, setApproved, setApproved, setApprovedResources, setApprovedTerm, setBidPending, setElasticSize, setElasticSize, setElasticTime, setElasticTime, toString, validate
 
Methods inherited from class orca.shirako.kernel.Reservation
awaitActive, awaitClosed, awaitTicketed, claim, clearDirty, close, createInstance, error, extendLease, extendTicket, getActor, getCategory, getCategory, getCloseTime, getGuard, getNotice, getPendingState, getPendingStateName, getPreviousReservationState, getReservationID, getReservationID, getReservationState, getSlice, getSliceID, getSliceName, getSliceName, getState, getStateName, handleDuplicateRequest, hasUncommittedTransition, internalError, isActive, isActiveTicketed, isClosed, isClosing, isDirty, isExpired, isExtended, isExtendingLease, isExtendingTicket, isFailed, isNascent, isNoPending, isPriming, isRedeeming, isTerminal, isTicketed, isTicketing, logError, logException, logRemoteError, logTransition, logWarning, nothingPending, notifyListeners, notifyListeners, prepareProbe, probePending, ready, registerListener, reserve, save, saveID, serviceClaim, serviceClose, serviceExtendLease, serviceExtendTicket, serviceProbe, serviceReserve, serviceUpdateLease, serviceUpdateTicket, setActor, setCloseTime, setDirty, setExpired, setLogger, setSlice, transition, unregisterListener, validateOutgoing
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface orca.shirako.api.IResourceReservation
getApprovedResources, getApprovedTerm, getApprovedType, getApprovedUnits, getLeasedAbstractUnits, getLeasedUnits, getPreviousResources, getPreviousTerm, getRequestedResources, getRequestedTerm, getRequestedType, getRequestedUnits, getResources, getTerm, getUnits, holding, isApproved, isBidPending, isRenewable, setApproved, setApproved, setApprovedResources, setApprovedTerm, setBidPending
 
Methods inherited from interface orca.shirako.api.IReservation
awaitActive, awaitClosed, awaitTicketed, clearDirty, getActor, getCategory, getCloseTime, getPendingState, getPendingStateName, getPreviousReservationState, getReservationID, getReservationState, getSlice, getState, getStateName, hasUncommittedTransition, isDirty, registerListener, setCloseTime, setDirty, setSlice, unregisterListener
 
Methods inherited from interface orca.shirako.api.ISerialize
save
 
Methods inherited from interface orca.shirako.api.IReservationStatus
isActive, isActiveTicketed, isClosed, isClosing, isExpired, isExpired, isExtended, isExtendingLease, isExtendingTicket, isFailed, isNascent, isNoPending, isPriming, isRedeeming, isTerminal, isTicketed, isTicketing, setExpired
 

Field Detail

PropertyCallback

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

PropertyOwner

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

PropertyClient

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

PropertyUpdateData

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

PropertyUpdateCount

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

PropertyServicePending

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

PropertySequenceNumberIn

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

PropertySequenceNumberOut

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

PropertyProcessTime

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

sequenceIn

protected int sequenceIn
Sequence number for incoming messages.


sequenceOut

protected int sequenceOut
Sequence number for outgoing messages.


callback

protected ICallbackProxy callback
Callback proxy.


udd

protected UpdateData udd
Status of the last server-side operation for the reservation.


updateCount

protected int updateCount
How many update messages have been sent to the client.


servicePending

protected int servicePending
Scratch element to trigger post-actions on a probe.


owner

protected AuthToken owner
Identity of the server actor.


client

protected AuthToken client
Identity of the client actor.


processTime

protected long processTime
The cycle in which this reservation is scheduled for processing. Does not have to be persisted.


policy

protected IPolicy policy
Policy in control of the reservation.

Constructor Detail

ReservationServer

protected ReservationServer()
Creates a new blank reservation instance. This method should be used only for recovery purposes.


ReservationServer

protected ReservationServer(ResourceSet resources,
                            Term term,
                            Slice slice)
Creates a new reservation instance to represent a server-side request for resources.

This method will generate a new reservation identifier.

Parameters:
resources - requested resources
term - requested term
slice - slice for the reservation

ReservationServer

protected ReservationServer(ReservationID rid,
                            ResourceSet resources,
                            Term term,
                            Slice slice)
Creates a new reservation instance to represent a server-side request for resources.

Parameters:
rid - reservation identifier
resources - requested resources
term - requested term
slice - slice for the reservation
Method Detail

save

public void save(java.util.Properties p)
          throws java.lang.Exception
Description copied from interface: ISerialize
Serializes the object into the given properties list.

Specified by:
save in interface ISerialize
Overrides:
save in class ResourceReservation
Parameters:
p - properties list to serialize the object into
Throws:
java.lang.Exception

reset

public void reset(java.util.Properties p)
           throws java.lang.Exception
Description copied from interface: ISerialize
De-serializes the object from the given properties list.

Specified by:
reset in interface ISerialize
Overrides:
reset in class ResourceReservation
Parameters:
p - properties list containing the serialized version of the object
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 ResourceReservation
Parameters:
actor - actor object the component belongs to
p - properties list containing configuration data about the component
Throws:
java.lang.Exception

validateIncoming

protected void validateIncoming()
                         throws java.lang.Exception
Description copied from class: Reservation
Validates a reservation as it arrives to an actor

Overrides:
validateIncoming in class Reservation
Throws:
java.lang.Exception

generateUpdate

protected void generateUpdate()
Generates an update to the callback object (if any) for this reservation.

Parameters:
udd - status information

fail

public void fail(java.lang.String message)
Marks an operation failure. It is the caller's responsibility to generate an update. Policy implementations may use this method to report a failure: the ReservationServer subclass sends the update after the policy completes its execution. Marks an operation failure. Transitions the reservation to the failed state and logs the message as an error.
NoteDoes not throw exception.

Specified by:
fail in interface IResourceReservation
Overrides:
fail in class ResourceReservation
Parameters:
message - the error message

fail

public void fail(java.lang.String message,
                 java.lang.Exception e)
Description copied from interface: IResourceReservation
Marks an operation failure. Transitions the reservation to the failed state and logs the message as an error.
NoteDoes not throw exception.

Specified by:
fail in interface IResourceReservation
Overrides:
fail in class ResourceReservation
Parameters:
message - the error message
e - The exception

failWarn

public void failWarn(java.lang.String message)
Description copied from interface: IResourceReservation
Marks an operation failure. Transitions the reservation to the failed state and logs the message as an error.
NoteDoes not throw exception.

Specified by:
failWarn in interface IResourceReservation
Overrides:
failWarn in class ResourceReservation
Parameters:
message - the error message

failNotify

protected void failNotify(java.lang.String message)
Reports an operation failure and notifies the client. If this is an extend, then the resources in the update may be a copy of the previous ticket or lease, which may still be valid. In any case, there is no need to close: the client will do it, or the reservation expires normally.

Parameters:
message - the error message

probe

public void probe()
           throws java.lang.Exception
Probes a reservation and sync with resource status and client (server only). Generates an update to sync with the client.

Overrides:
probe in class Reservation
Throws:
java.lang.Exception

prepare

protected void prepare(ICallbackProxy srt,
                       LoggingTool logger)
                throws java.lang.Exception
Prepare

Parameters:
srt - the slices return
logger - for diagnostic logging
Throws:
java.lang.Exception

incomingRequest

protected void incomingRequest()
                        throws java.lang.Exception
Checks reservation state prior to handling an incoming request. These checks are not applied to probes or closes.

Throws:
java.lang.Exception

updateTicket

protected void updateTicket(ResourceReservation rarg,
                            UpdateData udd)
                     throws java.lang.Exception
Update the ticket

Overrides:
updateTicket in class Reservation
Parameters:
rarg - the reservation
udd - the update data
Throws:
java.lang.Exception - thrown when method is called

updateLease

protected void updateLease(ResourceReservation rarg,
                           UpdateData udd)
                    throws java.lang.Exception
Update the lease

Overrides:
updateLease in class Reservation
Parameters:
rarg - the reservation
udd - the update data
Throws:
java.lang.Exception - thrown when method is called

forecastUnits

public int forecastUnits(java.util.Date when)
Estimate the resource units controlled by this reservation at some time which may be in the future. In this case, the "forecast" is only what this agent has already committed to the reservation.

Specified by:
forecastUnits in interface IResourceReservation
Overrides:
forecastUnits in class ResourceReservation
Parameters:
then - the date to forecast
Returns:
unit forecast

count

public void count(ResourceCount rc,
                  java.util.Date when)
Description copied from interface: IResourceReservation
Tallies up resources in the reservation.

Note: "just a hint" unless the kernel lock is held. An exception to our rule of not touching ResourceSet fields. Determines count based on time.

Specified by:
count in interface IResourceReservation
Overrides:
count in class ResourceReservation

count

protected Reservation.CountHelper count(java.util.Date when)

clearNotice

protected void clearNotice()
Description copied from class: Reservation
Clears all event notices associated with the reservation.

Overrides:
clearNotice in class Reservation

setOwner

public void setOwner(AuthToken owner)
Description copied from interface: IServerReservation
Sets the identity of the server actor that controls the reservation.

Specified by:
setOwner in interface IServerReservation
Parameters:
owner - identity of server actor

getServerAuthToken

public AuthToken getServerAuthToken()
Description copied from interface: IServerReservation
Returns the identity of the server actor that controls the reservation.

Specified by:
getServerAuthToken in interface IServerReservation
Returns:
identity of server actor

getClientAuthToken

public AuthToken getClientAuthToken()
Description copied from interface: IServerReservation
Returns the identity of the client represented by the reservation.

Specified by:
getClientAuthToken in interface IServerReservation
Returns:
identity of client actor

getCallback

public ICallbackProxy getCallback()
Description copied from interface: IServerReservation
Returns the callback proxy.

Specified by:
getCallback in interface IServerReservation
Returns:
callback proxy.

getSequenceIn

public int getSequenceIn()
Description copied from interface: IServerReservation
Returns the sequence number of the last received message.

Specified by:
getSequenceIn in interface IServerReservation
Returns:
sequence number of the last received message

setSequenceIn

public void setSequenceIn(int sequence)
Description copied from interface: IServerReservation
Sets the sequence number of the last received message.

Specified by:
setSequenceIn in interface IServerReservation

getSequenceOut

public int getSequenceOut()
Description copied from interface: IServerReservation
Returns the sequence number of the last sent message.

Specified by:
getSequenceOut in interface IServerReservation
Returns:
sequence number of the last sent message

setServicePending

protected void setServicePending(int pending)
sets the type of pending operation that is in progress for the reservation.

Parameters:
pending - operation type code

getType

public ResourceType getType()
Description copied from interface: IResourceReservation
Returns the resource type allocated to the reservation. If no resources have yet been allocated to the reservation, this method will return null.

Specified by:
getType in interface IResourceReservation
Overrides:
getType in class ResourceReservation
Returns:
resource type allocated to the reservation. null if no resources have been allocated to the reservation.

getProcessTime

public long getProcessTime()
Description copied from interface: IServerReservation
Returns the time the reservation is going to be processed.

Specified by:
getProcessTime in interface IServerReservation
Returns:
time the reservation is going to be processed

setProcessTime

public void setProcessTime(long time)
Description copied from interface: IServerReservation
Sets the time the reservation is going to be processed.

Specified by:
setProcessTime in interface IServerReservation
Parameters:
time - time the reservation is going to be processed


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