cgl.narada.service.client.impl
Class EventConsumerImpl

java.lang.Object
  extended by cgl.narada.service.client.impl.EventConsumerImpl
All Implemented Interfaces:
EventConsumer

public class EventConsumerImpl
extends Object
implements EventConsumer

The event consumer provides a host of functions for clients to consume events. These include subscription to profiles and also the specification of QoS constraints that an event must satisfy prior to delivery. The consumer also includes several utlity functions among them are the ability to retrieve the number of events received at this consumer.


Constructor Summary
protected EventConsumerImpl(int entityId, int consumerId, QosServiceImpl qosServiceImpl)
           
 
Method Summary
 boolean canSatisfyQosRequirements(Profile profile)
          Verify if the specify QosConstraints can indeed be satisfied.
 ConsumerConstraints createConsumerConstraints(Profile profile)
          Create consumer constraints associated with a certain profile
 ConsumerConstraints getConsumerConstraints(Profile profile)
          Retrieves the QosEnablerAndSpecifer for a given profile.
 int getEntityId()
          Retrieve the entity identifier
 Profile[] getListOfManagedProfiles()
          Gets a list of profiles managed by the consumer
 NBEventListener getNBEventListener()
          Gets the event listener for the profiles managed by this consumer
 int getNumberOfEventsReceivedSoFar()
          Retrieves the number of events routed by this event consumer
 long getTimeElapsedSinceLastEvent()
          Retrieves the time elapsed (in milliseconds) since the last event was received on this consumer
 boolean hasConsumerConstraints(Profile profile)
          Checks to see if a constraint has been registered for a given profile
 void initiateReplay(ReplayRequest replayRequest, ReplayServiceListener replayListener)
          Initiate replay based on the created replay request
 void propagateRecoveryNotification(NBRecoveryNotification recoveryNotification)
           
 long recover(int templateId, NBRecoveryListener recoveryListener)
          This is called by an entity to recover from failures or prolonged disconnects
 void setNBEventListener(NBEventListener nbEventListener)
          Sets the event listener for the profiles managed by this consumer
 void setNBNotificationListener(NBNotificationListener nbNotificationListener)
          Sets the notification listener for the profiles (and the specified Qos constraints) managed by this consumer
 void subscribeTo(Profile profile)
          Subscribe to a profile and register a listener to receive events conforming to the specified constraint
 void subscribeTo(Profile profile, ConsumerConstraints consumerConstraints)
          Subscribe to a profile, but request that the event satisfies some QoS constraints prior to delivery.
 void unSubscribe(Profile profile)
          Unsubscribes a profile.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventConsumerImpl

protected EventConsumerImpl(int entityId,
                            int consumerId,
                            QosServiceImpl qosServiceImpl)
Method Detail

getEntityId

public int getEntityId()
Description copied from interface: EventConsumer
Retrieve the entity identifier

Specified by:
getEntityId in interface EventConsumer

getNumberOfEventsReceivedSoFar

public int getNumberOfEventsReceivedSoFar()
Retrieves the number of events routed by this event consumer

Specified by:
getNumberOfEventsReceivedSoFar in interface EventConsumer

getTimeElapsedSinceLastEvent

public long getTimeElapsedSinceLastEvent()
Retrieves the time elapsed (in milliseconds) since the last event was received on this consumer

Specified by:
getTimeElapsedSinceLastEvent in interface EventConsumer

hasConsumerConstraints

public boolean hasConsumerConstraints(Profile profile)
                               throws ServiceException
Checks to see if a constraint has been registered for a given profile

Specified by:
hasConsumerConstraints in interface EventConsumer
Throws:
ServiceException

canSatisfyQosRequirements

public boolean canSatisfyQosRequirements(Profile profile)
                                  throws ServiceException
Verify if the specify QosConstraints can indeed be satisfied. This method will true if there aare no specified Qos associated with the profile.

Specified by:
canSatisfyQosRequirements in interface EventConsumer
Throws:
ServiceException

getConsumerConstraints

public ConsumerConstraints getConsumerConstraints(Profile profile)
                                           throws ServiceException
Retrieves the QosEnablerAndSpecifer for a given profile. Returns null if none have been specified for the profile in question or if the profile has not yet been registered to this consumer.

Specified by:
getConsumerConstraints in interface EventConsumer
Throws:
ServiceException

getListOfManagedProfiles

public Profile[] getListOfManagedProfiles()
Gets a list of profiles managed by the consumer

Specified by:
getListOfManagedProfiles in interface EventConsumer

setNBEventListener

public void setNBEventListener(NBEventListener nbEventListener)
                        throws ServiceException
Sets the event listener for the profiles managed by this consumer

Specified by:
setNBEventListener in interface EventConsumer
Throws:
ServiceException

getNBEventListener

public NBEventListener getNBEventListener()
Gets the event listener for the profiles managed by this consumer

Specified by:
getNBEventListener in interface EventConsumer

setNBNotificationListener

public void setNBNotificationListener(NBNotificationListener nbNotificationListener)
                               throws ServiceException
Sets the notification listener for the profiles (and the specified Qos constraints) managed by this consumer

Specified by:
setNBNotificationListener in interface EventConsumer
Throws:
ServiceException

createConsumerConstraints

public ConsumerConstraints createConsumerConstraints(Profile profile)
                                              throws ServiceException
Create consumer constraints associated with a certain profile

Specified by:
createConsumerConstraints in interface EventConsumer
Throws:
ServiceException

subscribeTo

public void subscribeTo(Profile profile)
                 throws ServiceException
Subscribe to a profile and register a listener to receive events conforming to the specified constraint

Specified by:
subscribeTo in interface EventConsumer
Throws:
ServiceException

unSubscribe

public void unSubscribe(Profile profile)
                 throws ServiceException
Unsubscribes a profile. If there is a registered ConsumerConstraints for this profile, it is also disabled.

Specified by:
unSubscribe in interface EventConsumer
Throws:
ServiceException

subscribeTo

public void subscribeTo(Profile profile,
                        ConsumerConstraints consumerConstraints)
                 throws ServiceException
Subscribe to a profile, but request that the event satisfies some QoS constraints prior to delivery. This subscription may trigger a discovery request and based upon the responses or lack thereof the subscription propagation may succeed or not. This method requires that a NotificationListener be registered prior to activating the profile.

Specified by:
subscribeTo in interface EventConsumer
Throws:
ServiceException

recover

public long recover(int templateId,
                    NBRecoveryListener recoveryListener)
             throws ServiceException
This is called by an entity to recover from failures or prolonged disconnects

Specified by:
recover in interface EventConsumer
Throws:
ServiceException

propagateRecoveryNotification

public void propagateRecoveryNotification(NBRecoveryNotification recoveryNotification)

initiateReplay

public void initiateReplay(ReplayRequest replayRequest,
                           ReplayServiceListener replayListener)
                    throws ServiceException
Initiate replay based on the created replay request

Specified by:
initiateReplay in interface EventConsumer
Throws:
ServiceException


For comments and suggestions please send e-mail to The NaradaBrokering Project