cgl.narada.service.reliable.impl
Class ReliableDeliveryServiceImpl

java.lang.Object
  extended by java.lang.Thread
      extended by cgl.narada.service.reliable.impl.ReliableDeliveryServiceImpl
All Implemented Interfaces:
NBEventListener, Runnable

public class ReliableDeliveryServiceImpl
extends Thread
implements NBEventListener

This class provides a set of core functions that service implementations need to satisfy. All services within the system need to conform to this interface. This class pertains to the reliable delivery service being provided to entities within the system. The service is responsible for among other things (a) Maintain the list of registered entities (b) Load the appropriate matching engines, depending upon the type of templates being managed. (c) Store events received onto stable storage. (d) Manage invoice events and ensure efficient negotiations with publishing entities.


Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
Thread.State, Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
ReliableDeliveryServiceImpl(int rdsEntityId, StorageService storageService, Properties props, String commType)
           
 
Method Summary
 void addProfile(int templateId, Profile profile)
           
 void addTemplateManagement(TemplateInfo templateInfo)
           
 TemplateInfo createTemplateInfo(int templateId, int templateType, Object template)
           
 void deRegisterEntity(int entityId)
          Removes an entity from the list of registered entities.
 void deregisterEntityFromTemplate(int entityId, int templateId)
          Deregister's an entity from a managed template
 void deregisterSubscriptionsForTemplate(int templateId)
           
 boolean entityExists(int entityId)
           
 void eventReadyForStorage()
           
 CompanionDbInfo getCompanionDbInfo(int templateId)
           
 int getEntityId()
           
 TemplateInfo[] getListOfManagedTemplates()
          Returns a array containing the list of managed templates
static void main(String[] args)
           
 void onEvent(NBEvent nbEvent)
          Upon the receipt of an event which has satisfied all the constraints, if any were provided, that needed to be satisfied prior to delivery
 void processAckInvoiceEvent(RdAckInvoiceEntityEvent ackInvoiceEvent)
          Processes an ACK invoice event received from an entity
 void processCompanionEvent(RdCompanionEntityEvent companionEvent)
          Processes a companion event received for a previously published event
 void processDiscoveryRequest()
           
 void processEntityRecoveryRequest(RdRecoveryEntityRequest recoveryRequest)
           
 void processNakInvoiceEvent(RdNakInvoiceEntityEvent nakInvoiceEvent)
          Processes an nak invoice event received from an entity
 void processProfileUpdateRequest(RdProfileUpdateRequest profileUpdateRequest)
           
 void processPublishedEvent(NBEvent nbEvent)
          Processes a published event received from an entity
 void processRepublishedEvent(RdRepublishedEntityEvent republishedEvent)
           
 void recoverFromFailure()
          This method is invoked the first time a stable storage starts up, which might be after a failure or after a prolonged shutdown.
 void registerEntity(int entityId)
           
 void registerEntityForTemplate(int entityId, int templateId)
          Registers an entity with a managed template.
 void registerSubscriptionsForTemplate(int templateId)
          end onEvent()
 void removeProfile(int templateId, Profile profile)
           
 void removeTemplateManagement(int templateId)
           
 void run()
           
 void storeEventToStorage(CompanionDbInfo companionDbInfo, NBEvent nbEvent)
           
 boolean templateExists(int templateId)
           
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ReliableDeliveryServiceImpl

public ReliableDeliveryServiceImpl(int rdsEntityId,
                                   StorageService storageService,
                                   Properties props,
                                   String commType)
                            throws ServiceException
Throws:
ServiceException
Method Detail

createTemplateInfo

public TemplateInfo createTemplateInfo(int templateId,
                                       int templateType,
                                       Object template)
                                throws ServiceException
Throws:
ServiceException

getEntityId

public int getEntityId()

registerEntity

public void registerEntity(int entityId)
                    throws ServiceException
Throws:
ServiceException

deRegisterEntity

public void deRegisterEntity(int entityId)
                      throws ServiceException
Removes an entity from the list of registered entities. Also for every template id cycle through the entity list and remove the entity if present

Throws:
ServiceException

registerEntityForTemplate

public void registerEntityForTemplate(int entityId,
                                      int templateId)
                               throws ServiceException
Registers an entity with a managed template.

Throws:
ServiceException

deregisterEntityFromTemplate

public void deregisterEntityFromTemplate(int entityId,
                                         int templateId)
                                  throws ServiceException
Deregister's an entity from a managed template

Throws:
ServiceException

addTemplateManagement

public void addTemplateManagement(TemplateInfo templateInfo)
                           throws ServiceException
Throws:
ServiceException

removeTemplateManagement

public void removeTemplateManagement(int templateId)
                              throws ServiceException
Throws:
ServiceException

getListOfManagedTemplates

public TemplateInfo[] getListOfManagedTemplates()
Returns a array containing the list of managed templates


processProfileUpdateRequest

public void processProfileUpdateRequest(RdProfileUpdateRequest profileUpdateRequest)
                                 throws ServiceException
Throws:
ServiceException

addProfile

public void addProfile(int templateId,
                       Profile profile)
                throws ServiceException
Throws:
ServiceException

removeProfile

public void removeProfile(int templateId,
                          Profile profile)
                   throws ServiceException
Throws:
ServiceException

processAckInvoiceEvent

public void processAckInvoiceEvent(RdAckInvoiceEntityEvent ackInvoiceEvent)
                            throws ServiceException
Processes an ACK invoice event received from an entity

Throws:
ServiceException

processNakInvoiceEvent

public void processNakInvoiceEvent(RdNakInvoiceEntityEvent nakInvoiceEvent)
                            throws ServiceException
Processes an nak invoice event received from an entity

Throws:
ServiceException

processPublishedEvent

public void processPublishedEvent(NBEvent nbEvent)
Processes a published event received from an entity


processCompanionEvent

public void processCompanionEvent(RdCompanionEntityEvent companionEvent)
Processes a companion event received for a previously published event


processRepublishedEvent

public void processRepublishedEvent(RdRepublishedEntityEvent republishedEvent)

processEntityRecoveryRequest

public void processEntityRecoveryRequest(RdRecoveryEntityRequest recoveryRequest)
                                  throws ServiceException
Throws:
ServiceException

processDiscoveryRequest

public void processDiscoveryRequest()

onEvent

public void onEvent(NBEvent nbEvent)
Description copied from interface: NBEventListener
Upon the receipt of an event which has satisfied all the constraints, if any were provided, that needed to be satisfied prior to delivery

Specified by:
onEvent in interface NBEventListener

registerSubscriptionsForTemplate

public void registerSubscriptionsForTemplate(int templateId)
                                      throws ServiceException
end onEvent()

Throws:
ServiceException

deregisterSubscriptionsForTemplate

public void deregisterSubscriptionsForTemplate(int templateId)
                                        throws ServiceException
Throws:
ServiceException

eventReadyForStorage

public void eventReadyForStorage()

getCompanionDbInfo

public CompanionDbInfo getCompanionDbInfo(int templateId)

run

public void run()
Specified by:
run in interface Runnable
Overrides:
run in class Thread

storeEventToStorage

public void storeEventToStorage(CompanionDbInfo companionDbInfo,
                                NBEvent nbEvent)
                         throws ServiceException
Throws:
ServiceException

recoverFromFailure

public void recoverFromFailure()
                        throws ServiceException
This method is invoked the first time a stable storage starts up, which might be after a failure or after a prolonged shutdown. This method enables the storage to recover from failures etc.

Throws:
ServiceException

templateExists

public boolean templateExists(int templateId)

entityExists

public boolean entityExists(int entityId)

main

public static void main(String[] args)


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