orca.shirako.core
Class Broker

java.lang.Object
  extended by orca.shirako.core.Actor
      extended by orca.shirako.core.Broker
All Implemented Interfaces:
IActor, IActorIdentity, IActorPublic, IBroker, IBrokerPublic, IClientActor, IClientPublic, IInitialize, IRecover, IReservationOperations, ISerialize, IServerActor, IServerPublic, ISliceOperations, ITick

public class Broker
extends Actor
implements IBroker

Broker offers the base for all broker actors.


Field Summary
protected  PeerRegistry registry
          The peer registry.
 
Fields inherited from class orca.shirako.core.Actor
clock, currentCycle, DefaultDescription, description, firstTick, fromDB, guid, identity, kernel, logger, monitor, policy, PropertyAuthToken, PropertyDescription, PropertyManager, PropertyMapper, PropertyMapperClass, PropertyPlugin, PropertyPluginClass, PropertyType, recovered, spi, stopped, type, wrapper
 
Fields inherited from interface orca.shirako.api.IActor
PropertyClass, PropertyGuid, PropertyName, TypeAll, TypeBroker, TypeServiceManager, TypeSiteAuthority
 
Fields inherited from interface orca.shirako.api.IActor
PropertyClass, PropertyGuid, PropertyName, TypeAll, TypeBroker, TypeServiceManager, TypeSiteAuthority
 
Constructor Summary
Broker()
          Default constructor.
Broker(AuthToken identity, ActorClock clock)
          Creates a new broker with the given identity and term factory.
 
Method Summary
 void actorAdded()
          Informs the actor that it has been integrated in the container.
 void addBroker(IBrokerProxy broker)
          Registers a broker.
protected  void bid(long cycle)
          Bids for resources as dictated by the plugin bidding policy for the current cycle.
 ReservationClient claim(ReservationID reservationID, ResourceSet resources)
          Claims already exported resources from the default upstream broker.
 ReservationClient claim(ReservationID reservationID, ResourceSet resources, IBrokerProxy broker)
          Claims already exported resources from the given broker.
 ReservationClient claim(ReservationID reservationID, ResourceSet resources, Slice slice, IBrokerProxy broker)
          Claims already exported resources from the given broker.
 void claim(ResourceReservation reservation, IClientCallbackProxy callback, AuthToken caller)
          Services a request to claim a previously exported ticket.
protected  void closeExpiring(long cycle)
          Close expiring reservations
 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.
 void export(BrokerReservation reservation, AuthToken client)
          Exports the resources described by the reservation to the client.
 ReservationID export(ResourceSet resources, Term term, AuthToken client)
          Exports the specified resources for the given period of time to the client.
 void extendTicket(BrokerReservation reservation)
          Processes an extend ticket request for the reservation.
 void extendTicket(ReservationClient reservation)
          Issues a ticket extend request for the given reservation.
 void extendTicket(ReservationSet set)
          Issues a ticket request for every reservation in the set.
 void extendTicket(ResourceReservation reservation, AuthToken caller)
          Services an incoming request to extend an existing ticket.
 IBrokerProxy getBroker(java.lang.String name)
          Gets the broker proxy with the given name
 IBrokerProxy[] getBrokers()
          Returns all brokers registered with the actor.
 IBrokerProxy getDefaultBroker()
          Returns the default broker.
protected  Slice getDefaultSlice()
           
 void initialize()
          Initializes a generic actor.
 void ticket(BrokerReservation reservation)
          Processes a ticket request for the reservation.
 void ticket(ReservationClient reservation)
          Issues a ticket request for the given reservation.
 void ticket(ReservationSet set)
          Issues a ticket request for every reservation in the set.
 void ticket(ResourceReservation reservation, IClientCallbackProxy callback, AuthToken caller)
          Services an incoming request for a new ticket.
protected  void tickHandler()
          Handles a timer interrupt.
 void updateTicket(ResourceReservation reservation, UpdateData udd, AuthToken caller)
          Handles an incoming ticket update.
 
Methods inherited from class orca.shirako.core.Actor
close, close, close, error, extend, extend, externalTick, getActorClock, getClientSlices, getCurrentCycle, getDescription, getGuid, getIdentity, getInventorySlices, getKernel, getLogger, getName, getName, getPolicy, getReservation, getReservations, getShirakoPlugin, getSlice, getSlices, getType, getType, initializeKeyStore, internalError, isFromDatabase, isRecovered, isStopped, query, recover, register, registerSlice, removeReservation, removeReservation, removeSlice, removeSlice, reregister, reregisterSlice, reset, reset, revisit, save, save, setActorClock, setDescription, setGuid, setIdentity, setLogger, setPolicy, setRecovered, setShirakoPlugin, setStopped, start, stop, toString, unregister, unregister, unregisterSlice, unregisterSlice
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface orca.shirako.api.IActor
getActorClock, getCurrentCycle, getDescription, getLogger, getPolicy, getShirakoPlugin, getType, initializeKeyStore, isFromDatabase, isRecovered, isStopped, recover, setActorClock, setDescription, setGuid, setIdentity, setLogger, setPolicy, setRecovered, setShirakoPlugin, start, stop
 
Methods inherited from interface orca.shirako.api.ITick
externalTick
 
Methods inherited from interface orca.shirako.api.ISerialize
reset, save, save
 
Methods inherited from interface orca.shirako.api.IRecover
revisit
 
Methods inherited from interface orca.shirako.api.IActorPublic
query
 
Methods inherited from interface orca.shirako.api.IActorIdentity
getGuid, getIdentity, getName
 
Methods inherited from interface orca.shirako.api.ISliceOperations
getClientSlices, getInventorySlices, getSlice, getSlices, registerSlice, removeSlice, removeSlice, reregisterSlice, unregisterSlice, unregisterSlice
 
Methods inherited from interface orca.shirako.api.IReservationOperations
close, close, close, extend, extend, getReservation, getReservations, register, removeReservation, removeReservation, reregister, unregister, unregister
 
Methods inherited from interface orca.shirako.api.IActor
getActorClock, getCurrentCycle, getDescription, getLogger, getPolicy, getShirakoPlugin, getType, initializeKeyStore, isFromDatabase, isRecovered, isStopped, recover, setActorClock, setDescription, setGuid, setIdentity, setLogger, setPolicy, setRecovered, setShirakoPlugin, start, stop
 
Methods inherited from interface orca.shirako.api.ITick
externalTick
 
Methods inherited from interface orca.shirako.api.ISerialize
reset, save, save
 
Methods inherited from interface orca.shirako.api.IRecover
revisit
 
Methods inherited from interface orca.shirako.api.IActorPublic
query
 
Methods inherited from interface orca.shirako.api.IActorIdentity
getGuid, getIdentity, getName
 
Methods inherited from interface orca.shirako.api.ISliceOperations
getClientSlices, getInventorySlices, getSlice, getSlices, registerSlice, removeSlice, removeSlice, reregisterSlice, unregisterSlice, unregisterSlice
 
Methods inherited from interface orca.shirako.api.IReservationOperations
close, close, close, extend, extend, getReservation, getReservations, register, removeReservation, removeReservation, reregister, unregister, unregister
 

Field Detail

registry

protected PeerRegistry registry
The peer registry.

Constructor Detail

Broker

public Broker()
Default constructor.


Broker

public Broker(AuthToken identity,
              ActorClock clock)
Creates a new broker with the given identity and term factory.

Parameters:
identity - broker identity
clock - term factory
Method Detail

initialize

public void initialize()
                throws java.lang.Exception
Description copied from class: Actor
Initializes a generic actor.

Specified by:
initialize in interface IInitialize
Overrides:
initialize in class Actor
Throws:
java.lang.Exception - Throws exception of some required fields are missing.

actorAdded

public void actorAdded()
                throws java.lang.Exception
Description copied from interface: IActor
Informs the actor that it has been integrated in the container. This method should finish the initialization of the actor: some initialization steps may not be able to execute until the actor is part of the running container.

Specified by:
actorAdded in interface IActor
Overrides:
actorAdded in class Actor
Throws:
java.lang.Exception

donate

public void donate(ReservationClient reservation)
            throws java.lang.Exception
Description copied from interface: IServerActor
Accepts ticketed resources to be used for allocation of client requests.

Specified by:
donate in interface IServerActor
Throws:
java.lang.Exception

demand

public void demand(ReservationClient reservation)
Description copied from interface: IClientActor
Injects a new resource demand into the demand stream. Reservation must be pre-initialized with resource set, term, properties, etc. The actor policy periodically examines the demand stream and determines what resources must be obtained and how. For example, the policy may choose to combine several reservation requests into one, split a reservation request onto multiple brokers, etc.

Specified by:
demand in interface IClientActor
Parameters:
reservation - reservation representing resource demand

ticket

public void ticket(ReservationClient reservation)
            throws java.lang.Exception
Description copied from interface: IClientActor
Issues a ticket request for the given reservation. Note: the reservation must have already been registered with the actor.

Specified by:
ticket in interface IClientActor
Parameters:
reservation - reservation to obtain a ticket for
Throws:
java.lang.Exception
See Also:
IReservationOperations#register(orca.shirako.kernel.Reservation)

ticket

public void ticket(BrokerReservation reservation)
            throws java.lang.Exception
Description copied from interface: IBroker
Processes a ticket request for the reservation.

Specified by:
ticket in interface IBroker
Parameters:
reservation - reservation representing a request for a new ticket
Throws:
java.lang.Exception

ticket

public void ticket(ReservationSet set)
Description copied from interface: IClientActor
Issues a ticket request for every reservation in the set. All exceptions are caught and logged but no exception is propagated. No information will be delivered to indicate that some failure has taken place, e.g., failure to communicate with a broker. Inspect the state of individual reservations to determine whether/what failures have taken place.

Specified by:
ticket in interface IClientActor
Parameters:
set - set of reservations to obtain tickets for

extendTicket

public void extendTicket(ReservationClient reservation)
                  throws java.lang.Exception
Description copied from interface: IClientActor
Issues a ticket extend request for the given reservation. Note: the reservation must have already been registered with the actor.

Specified by:
extendTicket in interface IClientActor
Parameters:
reservation - reservation to extend the ticket for
Throws:
java.lang.Exception
See Also:
IReservationOperations#register(orca.shirako.kernel.Reservation)

extendTicket

public void extendTicket(BrokerReservation reservation)
                  throws java.lang.Exception
Description copied from interface: IBroker
Processes an extend ticket request for the reservation.

Specified by:
extendTicket in interface IBroker
Parameters:
reservation - reservation representing a request for a ticket extension
Throws:
java.lang.Exception

extendTicket

public void extendTicket(ReservationSet set)
Description copied from interface: IClientActor
Issues a ticket request for every reservation in the set. All exceptions are caught and logged but no exception is propagated. No information will be delivered to indicate that some failure has taken place, e.g., failure to communicate with a broker. Inspect the state of individual reservations to determine whether/what failures have taken place.

Specified by:
extendTicket in interface IClientActor
Parameters:
set - set of reservations to extend tickets for

export

public ReservationID export(ResourceSet resources,
                            Term term,
                            AuthToken client)
                     throws java.lang.Exception
Description copied from interface: IServerActor
Exports the specified resources for the given period of time to the client.

Specified by:
export in interface IServerActor
Parameters:
resources - resources to export
term - period the export will be valid
client - identity of the client resources will be exported to
Throws:
java.lang.Exception

export

public void export(BrokerReservation reservation,
                   AuthToken client)
            throws java.lang.Exception
Description copied from interface: IServerActor
Exports the resources described by the reservation to the client.

Specified by:
export in interface IServerActor
Parameters:
reservation - reservation describing resources to export
client - identity of the client resources will be exported to
Throws:
java.lang.Exception

claim

public ReservationClient claim(ReservationID reservationID,
                               ResourceSet resources)
                        throws java.lang.Exception
Description copied from interface: IClientActor
Claims already exported resources from the default upstream broker. The reservation will be stored in the default slice.

Specified by:
claim in interface IClientActor
Parameters:
reservationID - reservation identifier of the exported reservation
resources - resource set describing the resources to claim
Throws:
java.lang.Exception

getDefaultSlice

protected Slice getDefaultSlice()
                         throws java.lang.Exception
Throws:
java.lang.Exception

claim

public ReservationClient claim(ReservationID reservationID,
                               ResourceSet resources,
                               IBrokerProxy broker)
                        throws java.lang.Exception
Description copied from interface: IClientActor
Claims already exported resources from the given broker. The reservation will be stored in the default slice.

Specified by:
claim in interface IClientActor
Parameters:
reservationID - reservation identifier of the exported reservation
resources - resource set describing the resources to claim
broker - broker proxy
Throws:
java.lang.Exception

claim

public ReservationClient claim(ReservationID reservationID,
                               ResourceSet resources,
                               Slice slice,
                               IBrokerProxy broker)
                        throws java.lang.Exception
Description copied from interface: IClientActor
Claims already exported resources from the given broker.

Specified by:
claim in interface IClientActor
Parameters:
reservationID - reservation identifier of the exported reservation
resources - resource set describing the resources to claim
slice - slice in which to store the claimed reservation. As of now, it is assumed that the exported reservation is stored under a slice with the same name in the upstream broker.
Throws:
java.lang.Exception

updateTicket

public void updateTicket(ResourceReservation reservation,
                         UpdateData udd,
                         AuthToken caller)
                  throws java.lang.Exception
Description copied from interface: IClientPublic
Handles an incoming ticket update.

Specified by:
updateTicket in interface IClientPublic
Parameters:
reservation - reservation represented by this update. The reservation object will contain the ticket (if any) as well information about the actually allocated resources.
udd - status of the remote operation.
caller - identity of the caller
Throws:
java.lang.Exception

ticket

public void ticket(ResourceReservation reservation,
                   IClientCallbackProxy callback,
                   AuthToken caller)
            throws java.lang.Exception
Description copied from interface: IBrokerPublic
Services an incoming request for a new ticket.

Specified by:
ticket in interface IBrokerPublic
Parameters:
reservation - reservation object describing the requested resources
callback - callback to use for sending the result
caller - caller credentials
Throws:
java.lang.Exception

extendTicket

public void extendTicket(ResourceReservation reservation,
                         AuthToken caller)
                  throws java.lang.Exception
Description copied from interface: IBrokerPublic
Services an incoming request to extend an existing ticket.

Specified by:
extendTicket in interface IBrokerPublic
Parameters:
reservation - reservation object describing the reservation to extend
caller - caller credentials
Throws:
java.lang.Exception

claim

public void claim(ResourceReservation reservation,
                  IClientCallbackProxy callback,
                  AuthToken caller)
           throws java.lang.Exception
Description copied from interface: IBrokerPublic
Services a request to claim a previously exported ticket.

Specified by:
claim in interface IBrokerPublic
Parameters:
reservation - reservation object describing the exported resources
callback - callback to use for sending the result
caller - caller credentials
Throws:
java.lang.Exception

addBroker

public void addBroker(IBrokerProxy broker)
Description copied from interface: IClientActor
Registers a broker. If this is the first broker to be registered, it is set as the default broker.

Specified by:
addBroker in interface IClientActor
Parameters:
broker - broker to register

getBroker

public IBrokerProxy getBroker(java.lang.String name)
Description copied from interface: IClientActor
Gets the broker proxy with the given name

Specified by:
getBroker in interface IClientActor
Parameters:
name - broker name
Returns:
requested broker

getDefaultBroker

public IBrokerProxy getDefaultBroker()
Description copied from interface: IClientActor
Returns the default broker.

Specified by:
getDefaultBroker in interface IClientActor
Returns:
the default broker

getBrokers

public IBrokerProxy[] getBrokers()
Description copied from interface: IClientActor
Returns all brokers registered with the actor.

Specified by:
getBrokers in interface IClientActor
Returns:
an array of brokers

tickHandler

protected void tickHandler()
                    throws java.lang.Exception
Handles a timer interrupt. This is the main actor loop. Add here any code that should be invoked for each passed cycle. The current cycle is in Actor.currentCycle and is guaranteed not to change until the handle invocation completes.

Overrides:
tickHandler in class Actor
Throws:
java.lang.Exception

closeExpiring

protected void closeExpiring(long cycle)
Close expiring reservations


bid

protected void bid(long cycle)
            throws java.lang.Exception
Bids for resources as dictated by the plugin bidding policy for the current cycle.

Throws:
java.lang.Exception


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