edu.cmu.cs.able.gaugeInfrastructure.Siena
Class SienaEventBus

java.lang.Object
  |
  +--edu.cmu.cs.able.gaugeInfrastructure.Siena.SienaEventBus
All Implemented Interfaces:
siena.Notifiable

public class SienaEventBus
extends java.lang.Object
implements siena.Notifiable

The wrapper around the Siena event bus. This marshals and unmarshals events, provides an announcement interface, as well as a request/response interface. Currently, this class is a little cludgy. In future versions it will be split into four classses - an abstact root class and one for the each type of bus (Gauge, GaugeMgr, GaugeConsumer) that deals with specific events.


Field Summary
protected static java.lang.String ANNOUNCE
          The tag for event direction=announce
protected static java.lang.String CONFIG
          The tag used in a Siena notification to denote the config attribute name
protected static java.lang.String CONFIGURE
          The tag for a ConfigureEvent
protected static java.lang.String CONFIGURED
          The tag for a ConfiguredEvent.
protected static java.lang.String CREATE
          The tag for a CreateEvent
protected static java.lang.String CREATED
          The tag for a CreatedEvent.
protected static java.lang.String DELETE
          The tag for a DeleteEvent
protected static java.lang.String DELETED
          The tag for a DeletedEvent.
protected static java.lang.String DIRECTION
          The tag used in a Siena notification to denote the direction attribute name
protected static java.lang.String EVENTID
          The tag used in a Siena notification to denote the event ID attribute name
protected static java.lang.String EVENTTYPE
          The tag used in a Siena notification to denote the event type attribute name
protected static java.lang.String FINDGMGR
          The tag for a FindGaugeMgrEvent
protected static java.lang.String FINISHEDCREATION
          The tag for a CreationFinishedEvent
protected static java.lang.String GAUGEINIT
          The tag for GaugeInitEvent
protected static java.lang.String GAUGEMGRID
          The tag used in a Siena notification to denote the gauge manager ID attribute name
protected static java.lang.String GMGRDELETEGAUGE
          The tag for GMgrDeleteGaugeEvent
protected static java.lang.String INITIATOR
          The tag used in a Siena notification to denote the initiator attribute name
protected static java.lang.String MAPPINGS
          The tag used in a Siena notification to denote the mappings attribute name
protected static java.lang.String METAINFO
          The tag for a QueryMetaInfoEvent
protected static java.lang.String MULTIPLEVALUES
          The tag for a MultipleValueEvent
protected static java.lang.String QUERYALLVALUES
          The tag for a QueryAllValuesEvent
protected static java.lang.String QUERYSTATE
          The tag for a QueryStateEvent
protected static java.lang.String QUERYVALUE
          The tag for a QueryValueEvent
protected static java.lang.String REQUEST
          The tag for event direction=request
protected static java.lang.String RESPONSE
          The tag for event direction=response
protected static int RETRIES
          How many times to retry a blocking wait
static java.lang.String senp
          The Siena port
protected static java.lang.String SETUP
          The tag used in a Siena notification to denote the setup attribute name
static siena.HierarchicalDispatcher siena
          The siena bus
protected static java.lang.String STATUS
          The tag used in a Siena notification to denote the status attribute name
static SienaEventBus theEventBus
          Only one event bus can be constructed.
protected static int TIMEOUT
          How long to wait for a blocking response (in milliseconds)
protected static java.lang.String VALUE
          The tag for a ValueEvent
 
Constructor Summary
SienaEventBus(java.lang.String uri)
          Creates a new event bus
 
Method Summary
static void addGaugeInfo(GaugeID event, siena.Filter f)
          Flattens all the gauge info to the filter.
static void addGaugeInfo(GaugeID gauge, siena.Notification n)
          Flattens all the gauge info to the notification.
 siena.Filter event2Filter(GaugeEvent event)
           
 GaugeEvent notification2Event(siena.Notification e)
           
 void notify(siena.Notification e)
          Called by Siena when a matching event is published.
 void notify(siena.Notification[] e)
           
 void notifyGauge(siena.Notification e)
          Notifies a gauge of events of interest.
 void notifyGaugeConsumer(siena.Notification e)
          Notifies GaugeConsumers of an event that is of interest to them
 boolean publishAnnouncement(GaugeEvent event)
          Publishes an announcement on the bus
 GaugeEvent publishRequest(GaugeEvent event)
          Publishes a request on the bus.
 boolean publishResponse(GaugeEvent event, java.lang.String initiator)
          Publishes a response.
 boolean registerConfiguredEvents(GaugeConsumer consumer, GaugeControl gauge)
           
 boolean registerCreatedEvents(GaugeConsumer consumer, GaugeControl gauge)
           
 boolean registerDeletedEvents(GaugeConsumer consumer, GaugeControl gauge)
           
 void registerGauge(GaugeControl gauge)
           
 void registerGaugeMgr(GaugeMgr gMgr)
           
 boolean registerValueEvents(GaugeConsumer consumer, GaugeControl gauge)
           
 void unregisterGauge(GaugeControl gauge)
           
 boolean unregisterGaugeEvents(GaugeConsumer consumer, GaugeControl gauge)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONFIGURED

protected static final java.lang.String CONFIGURED
The tag for a ConfiguredEvent.

DELETED

protected static final java.lang.String DELETED
The tag for a DeletedEvent.

CREATED

protected static final java.lang.String CREATED
The tag for a CreatedEvent.

MULTIPLEVALUES

protected static final java.lang.String MULTIPLEVALUES
The tag for a MultipleValueEvent

VALUE

protected static final java.lang.String VALUE
The tag for a ValueEvent

DELETE

protected static final java.lang.String DELETE
The tag for a DeleteEvent

CONFIGURE

protected static final java.lang.String CONFIGURE
The tag for a ConfigureEvent

CREATE

protected static final java.lang.String CREATE
The tag for a CreateEvent

METAINFO

protected static final java.lang.String METAINFO
The tag for a QueryMetaInfoEvent

QUERYVALUE

protected static final java.lang.String QUERYVALUE
The tag for a QueryValueEvent

QUERYALLVALUES

protected static final java.lang.String QUERYALLVALUES
The tag for a QueryAllValuesEvent

QUERYSTATE

protected static final java.lang.String QUERYSTATE
The tag for a QueryStateEvent

FINDGMGR

protected static final java.lang.String FINDGMGR
The tag for a FindGaugeMgrEvent

REQUEST

protected static final java.lang.String REQUEST
The tag for event direction=request

ANNOUNCE

protected static final java.lang.String ANNOUNCE
The tag for event direction=announce

RESPONSE

protected static final java.lang.String RESPONSE
The tag for event direction=response

GAUGEINIT

protected static final java.lang.String GAUGEINIT
The tag for GaugeInitEvent

GMGRDELETEGAUGE

protected static final java.lang.String GMGRDELETEGAUGE
The tag for GMgrDeleteGaugeEvent

FINISHEDCREATION

protected static final java.lang.String FINISHEDCREATION
The tag for a CreationFinishedEvent

EVENTTYPE

protected static final java.lang.String EVENTTYPE
The tag used in a Siena notification to denote the event type attribute name

GAUGEMGRID

protected static final java.lang.String GAUGEMGRID
The tag used in a Siena notification to denote the gauge manager ID attribute name

SETUP

protected static final java.lang.String SETUP
The tag used in a Siena notification to denote the setup attribute name

MAPPINGS

protected static final java.lang.String MAPPINGS
The tag used in a Siena notification to denote the mappings attribute name

CONFIG

protected static final java.lang.String CONFIG
The tag used in a Siena notification to denote the config attribute name

STATUS

protected static final java.lang.String STATUS
The tag used in a Siena notification to denote the status attribute name

INITIATOR

protected static final java.lang.String INITIATOR
The tag used in a Siena notification to denote the initiator attribute name

EVENTID

protected static final java.lang.String EVENTID
The tag used in a Siena notification to denote the event ID attribute name

DIRECTION

protected static final java.lang.String DIRECTION
The tag used in a Siena notification to denote the direction attribute name

TIMEOUT

protected static final int TIMEOUT
How long to wait for a blocking response (in milliseconds)

RETRIES

protected static final int RETRIES
How many times to retry a blocking wait

siena

public static siena.HierarchicalDispatcher siena
The siena bus

theEventBus

public static SienaEventBus theEventBus
Only one event bus can be constructed. This is it.

senp

public static java.lang.String senp
The Siena port
Constructor Detail

SienaEventBus

public SienaEventBus(java.lang.String uri)
Creates a new event bus
Parameters:
uri - The Siena port to connect to
Method Detail

publishAnnouncement

public boolean publishAnnouncement(GaugeEvent event)
Publishes an announcement on the bus
Parameters:
event - The event to be announced
Returns:
Whether the announcement was publishes successfully

publishRequest

public GaugeEvent publishRequest(GaugeEvent event)
Publishes a request on the bus. Gauge consumers or managers call this when they wish to communicate directly to a gauge or gauge manager. The event must have the appropriate request side attributes filled in.
Parameters:
event - The request to publish
Returns:
Whether the event was published successfully

publishResponse

public boolean publishResponse(GaugeEvent event,
                               java.lang.String initiator)
Publishes a response. The event must have the appropriate reply side attributes filled in. This is used to reply to a request event.
Parameters:
event - The reply to be published
initiator - Who the reply should go to
Returns:
Whether the reply was published correctly

addGaugeInfo

public static void addGaugeInfo(GaugeID gauge,
                                siena.Notification n)
Flattens all the gauge info to the notification. The notification will have the attribute, value pairs:
("gaugeID", gauge.uid)
("gaugeName", gauge.gaugeName)
("gaugeType", gauge.gaugeType)
("modelName", gauge.modelName)
("modelType", gauge.modelType)
Parameters:
gauge - The ID of the gauge to turn into a notification
n - The notification to contain the flattened gauge ID

addGaugeInfo

public static void addGaugeInfo(GaugeID event,
                                siena.Filter f)
Flattens all the gauge info to the filter. The notification will have the attribute, value pairs:
("gaugeID", gauge.uid)
("gaugeName", gauge.gaugeName)
("gaugeType", gauge.gaugeType)
("modelName", gauge.modelName)
("modelType", gauge.modelType)
Parameters:
event - The gauge ID to be flattened.
f - The filter to contain the flattened GaugeID

notifyGaugeConsumer

public void notifyGaugeConsumer(siena.Notification e)
Notifies GaugeConsumers of an event that is of interest to them
Parameters:
e - The event

notifyGauge

public void notifyGauge(siena.Notification e)
Notifies a gauge of events of interest. Called by Siena when an event matching a filter is matched.
Parameters:
e - The event

notify

public void notify(siena.Notification e)
Called by Siena when a matching event is published. This works out whether the event should be sent to a gauge consumer, gauge manager, or gauge.
Specified by:
notify in interface siena.Notifiable
Parameters:
e -  

notify

public void notify(siena.Notification[] e)
Specified by:
notify in interface siena.Notifiable

registerDeletedEvents

public boolean registerDeletedEvents(GaugeConsumer consumer,
                                     GaugeControl gauge)

registerCreatedEvents

public boolean registerCreatedEvents(GaugeConsumer consumer,
                                     GaugeControl gauge)

registerConfiguredEvents

public boolean registerConfiguredEvents(GaugeConsumer consumer,
                                        GaugeControl gauge)

registerValueEvents

public boolean registerValueEvents(GaugeConsumer consumer,
                                   GaugeControl gauge)

unregisterGaugeEvents

public boolean unregisterGaugeEvents(GaugeConsumer consumer,
                                     GaugeControl gauge)

registerGauge

public void registerGauge(GaugeControl gauge)

unregisterGauge

public void unregisterGauge(GaugeControl gauge)

event2Filter

public siena.Filter event2Filter(GaugeEvent event)

notification2Event

public GaugeEvent notification2Event(siena.Notification e)

registerGaugeMgr

public void registerGaugeMgr(GaugeMgr gMgr)