ParameterNoticeBoard
Class EventBroadcaster

java.lang.Object
  extended by java.lang.Thread
      extended by ParameterNoticeBoard.EventBroadcaster
All Implemented Interfaces:
java.lang.Runnable

 class EventBroadcaster
extends java.lang.Thread

Used to broadcast an event on a item in the parameter noticeboard to all of the listeners which have subscribed to it. It does this by creating thread for each listener in order to send the update to all of the listeners simultaneously. All of the threads are syncronised at the end of the run method. The advantage of this is that if one of the listeners has gone away and the ORB spends sometime working this out, the rest of the listeners will be updated asyncronously. If an attempt to connect to a listener fails, that listener is then removed from the list of listeners which are associated with that parameter noticeboard item.

The class makes extensive use of the new concurrency features of Java 5.0 and in particular it uses the ExecutorService in order to fire off the update listener threads and then again to syncronise when all of the threads have completed.

Version:
$Id: EventBroadcaster.java,v 1.3 2008/05/21 11:16:41 cb Exp $
Author:
Craige Bevil

Nested Class Summary
private  class EventBroadcaster.ListenerUpdaterThread
          This inner class will be used to update the listener within it's own thread by
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
private  java.util.concurrent.ExecutorService ListenerUpdateThreadService
          This is used for starting threads which will be used to update listeners when there are events on the parameters which they are subscribed to
private  java.util.concurrent.ConcurrentHashMap<java.lang.String,NonResponsiveClient> NonResponsiveClientHash
          Used to keep a track of the non-responsive clients
(package private)  java.util.concurrent.ConcurrentHashMap<iParameterNoticeBoard.ParameterNoticeBoardListener,ParameterSubscriber> ParameterListeners
          This is a hash map which contains the listeners which are subscribed to this particular parameter.
(package private)  java.lang.String ParameterName
          This is the name of the parameter which has had the update.
(package private)  org.omg.CORBA.Any ParameterValue
          This is the value of the parameter which is to be broadcast
(package private)  MessageHandler SyslogMessageHandler
          Used for interacting with the syslog
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
EventBroadcaster(java.util.concurrent.ConcurrentHashMap<java.lang.String,NonResponsiveClient> NonResponsiveClientHash, java.util.concurrent.ConcurrentHashMap<iParameterNoticeBoard.ParameterNoticeBoardListener,ParameterSubscriber> ParameterListeners, java.lang.String ParameterName, org.omg.CORBA.Any ParameterValue, MessageHandler SyslogMessageHandler)
          Constructor
 
Method Summary
 void run()
          The main method of the thread.
 
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
 

Field Detail

ListenerUpdateThreadService

private java.util.concurrent.ExecutorService ListenerUpdateThreadService
This is used for starting threads which will be used to update listeners when there are events on the parameters which they are subscribed to


NonResponsiveClientHash

private java.util.concurrent.ConcurrentHashMap<java.lang.String,NonResponsiveClient> NonResponsiveClientHash
Used to keep a track of the non-responsive clients


ParameterListeners

java.util.concurrent.ConcurrentHashMap<iParameterNoticeBoard.ParameterNoticeBoardListener,ParameterSubscriber> ParameterListeners
This is a hash map which contains the listeners which are subscribed to this particular parameter.


ParameterName

java.lang.String ParameterName
This is the name of the parameter which has had the update.


ParameterValue

org.omg.CORBA.Any ParameterValue
This is the value of the parameter which is to be broadcast


SyslogMessageHandler

MessageHandler SyslogMessageHandler
Used for interacting with the syslog

Constructor Detail

EventBroadcaster

EventBroadcaster(java.util.concurrent.ConcurrentHashMap<java.lang.String,NonResponsiveClient> NonResponsiveClientHash,
                 java.util.concurrent.ConcurrentHashMap<iParameterNoticeBoard.ParameterNoticeBoardListener,ParameterSubscriber> ParameterListeners,
                 java.lang.String ParameterName,
                 org.omg.CORBA.Any ParameterValue,
                 MessageHandler SyslogMessageHandler)
Constructor

Parameters:
NonResponsiveClientHash - This is a hash which contains a list of all of the clients which are not responsive.
ParameterListeners - This is a hash map of all of the listeners which are subscribed to this parameter noticeboard item.
ParameterName - This is the name of the item in the parameter noticeboard which these listeners are subscribed.
ParameterValue - This is the CORBA any value which contains the event which is to be redistributed.
SyslogMessageHandler - This is a object which can be used to interact with the syslog.
Method Detail

run

public void run()
The main method of the thread. Will spawn a thread for every listener which is subscribed to the parameter noticeboard and update that listener. It will then wait until all of them listener threads have completed before it itself will terminate.

Specified by:
run in interface java.lang.Runnable
Overrides:
run in class java.lang.Thread