|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.TimerTask
ParameterNoticeBoard.ParameterNoticeBoard
class ParameterNoticeBoard
This class forms the Parameter NoticeBoard which is a CORBA object that forms the central noticeboard for CORBA based instrument controllers in the WHT OCS. It allows suppliers and consumers to connect to the noticeboard and will permit the values of named status items to be stored on the noticeboard by suppliers and subsequently retrieved by consumers.
The parameter noticeboard provides a subscription service which will allow consumers to subscribe to a named parameter in the noticeboard and the parameter noticeboard will in turn inform the listener object when the value of that parameter is modified. The supply of events to consumers is buffered. The first event received on a named parameter is immediately sent on to the listeners but subsequent events on the same parameter up for a specific time window are buffered. Further events which arrive on that parameter replace the previous event in the queue and after the delay time is reached, the last object put into the event queue is then broadcast to the listeners. Currently the delay window is about 1 second. The listener is always guaranteed to get the first and the last event of a stream of events.
Each item in the notice board will be a CORBA Any object and it will be up to the consumer to extract the values which are held within a status value which is provided by the notice board.
Once the notice board starts up, it will write a reference to the parameter noticeboard CORBA servant into the naming service on the local machine which can then be used by consumers and suppliers to locate the parameter noticeboard. Note that the reference that is written to the naming service is a persistent reference and as such can be reused after the parameter noticeboard has been restarted. The name of the reference in the naming service will be ParameterNoticeBoard and will be found in the root naming context.
The parameter noticeboard offers the concept of a persistent parameter which is saved across restarts of the system providing the ParameterNoticeBoard is closed down in the appropriate manner using the closeDown() method which can be invoked from the controllerCmd(1) application which is part of the observing system.
This file will be stored in the file /wht/var/parameterNoticeBoard-< hostname>.dat
This persistent CORBA server will run on TCP port 35675.
Field Summary | |
---|---|
private java.util.concurrent.ConcurrentHashMap<java.lang.String,NoticeboardEvent> |
EventQueue
This hash will be used to buffer events before they are broadcast to the subscribed event observers. |
private java.util.List<ListenerUpdate> |
ListenersToUpdate
When a client attaches a listener to a NB item, we are unable to immediately send an update to that listener from that thread to avoid deadlock. |
private java.util.concurrent.ConcurrentHashMap<java.lang.String,java.util.concurrent.Future> |
ListenerUpdateThreads
This is a hash map of the listener update threads which have instantiated. |
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.Timer |
ListenerUpdateTimer
This is a timer object which will be used for scheduling the update of the parameter noticeboard. |
private java.util.concurrent.ConcurrentHashMap<java.lang.String,NonResponsiveClient> |
NonResponsiveClientHash
This is used to hold a list of all of the clients which are not reponsive so we can save ourselves the bother of attempting to communicate with them. |
private int |
NoOfUpdates
This is the number of updates that have been recieved in the reporting period. |
(package private) org.omg.CORBA.ORB |
Orb
This is a reference to the orb |
private java.util.concurrent.ConcurrentHashMap<java.lang.String,java.util.concurrent.ConcurrentHashMap<iParameterNoticeBoard.ParameterNoticeBoardListener,ParameterSubscriber>> |
ParameterCallbacks
This is hash of CORBA objects provided by consumers of the noticeboard which will be informed when there is an event on the parameter for which it is subscribed. |
private java.lang.String |
PersistenceObjectFile
The name of the file to write the persistence parameter data into (that is to say, parameters which are to be save across restarts of the system) |
private java.util.concurrent.ConcurrentHashMap |
PersistentParameters
This hash will be used to store the persistent parameters which are to be stored across the restarts of this parameter noticeboard |
private java.util.concurrent.ConcurrentHashMap<java.lang.String,org.omg.CORBA.Any> |
RegisteredParameters
This hash will be used to hold the values of the parameters which are currently registered in the parameter noticeboard. |
private MessageHandler |
SyslogMessageHandler
This will be used to report errors and informational messages to the syslog by the noticeboard |
private int |
TimeToReportStatisticsCounter
Whether it is time to report the usage statistics of the application |
private static int |
TIMETOREPORTSTATISTICSPERIOD
This is the period after which we should report the usage statistics in seconds |
Constructor Summary | |
---|---|
ParameterNoticeBoard(MessageHandler SyslogMessageHandler,
org.omg.CORBA.ORB Orb,
java.lang.String PersistanceDirectory)
Constructor for the class. |
Method Summary | |
---|---|
private boolean |
broadcastEvent(java.lang.String ParameterName,
org.omg.CORBA.Any ParameterValue)
Broadcast the specified event to all of the listeners which are registered to receive events on this parameter. |
void |
cancelAllEventSuscriptionForConsumer(java.lang.String ClientID)
Allows a consumer to unsubscribe to all parameters for which it is subscribed. |
void |
cancelParameterSuscriptionForConsumer(java.lang.String ClientID,
java.lang.String ParameterName)
Allows a consumer to cancel it's subscription to updates which are associated with a parameter in the parameter noticeboard by specifying the client identifier that it registered itself with initially. |
void |
closeDown(java.lang.String CloseDownMessage)
This is an obligation to the CORBA instrument controller interface which permits the application to be closed down in a controlled manner. |
boolean |
deleteParameter(java.lang.String ParameterName)
This method is part of the ParameterNoticeBoardSupplierOperations CORBA servant interface which is to be implemented as part of this class. |
iParameterNoticeBoard.ParameterStruct[] |
fetchAllNoticeboardParameters()
Returns all of the values which are currently in the noticeboard. |
java.lang.String[] |
fetchFullParameterList()
This returns as a CORBA sequence, a list of the names of all of the parameters which are currently in the parameter noticeboard |
org.omg.CORBA.Any |
fetchParameter(java.lang.String ParameterName)
Returns the value in the noticeboard which is associated with the requested parameter. |
iParameterNoticeBoard.ParameterStruct[] |
fetchParameterArray(java.lang.String[] ParametersToRetrieve)
Returns the values in the noticeboard which are associated with the requested parameters. |
int |
getNoOfUpdates()
This is part of the JMX interface to the application and returns the details of the no of updates which have been performed. |
int |
getNoOfUpdateThreads()
This is part of the JMX interface to the application and returns the details of the number of update threads which are in existence. |
boolean |
handshake()
This is an obligation to the CORBA instrument controller interface which permits a third party to ascertain if the instrument controller is responding. |
static void |
main(java.lang.String[] args)
This is the main method for this class, it will result in the parameter notice board being set up. |
int |
noOfActiveListeners(java.lang.String PNBItem)
This is part of the JMX interface to the application and returns the details of the number of active listeners for a specific parameter noticeboard item. |
private boolean |
ReadNoticeboardItemPersistenceFile()
Read in the object persistence file so restablish the items in the noticeboard. |
boolean |
registerEventListener(iParameterNoticeBoard.ParameterNoticeBoardListener EventListener,
java.lang.String ParameterName)
This method is part of the ParameterNoticeBoardSupplierOperations CORBA servant interface which is to be implemented as part of this class. |
boolean |
registerEventListenerWithID(iParameterNoticeBoard.ParameterNoticeBoardListener EventListener,
java.lang.String ParameterName,
java.lang.String ClientID)
Allows a client to register a listener on a parameter using a identifier. |
boolean |
registerParameter(java.lang.String ParameterName)
This method is part of the ParameterNoticeBoardSupplierOperations CORBA servant interface which is to be implemented as part of this class. |
boolean |
registerParameterWithExpiryTime(java.lang.String ParameterName,
int ExpiryTime)
This method is part of the ParameterNoticeBoardSupplierOperations CORBA servant interface which is to be implemented as part of this class. |
void |
run()
This is the classes obligation for the TimerTask interface and will be called each time that the timer expires. |
void |
setDebugState(boolean DebugState)
This is an obligation to the CORBA instrument controller interface which permits the debug of the application to be enabled or disabled. |
void |
setTraceLevel(double TraceLevel)
This is an obligation to the CORBA instrument controller interface which permits the trace level of the application to be set, in this application there is no different trace levels enabled. |
void |
syncUpdateParameter(java.lang.String ParameterName,
org.omg.CORBA.Any ParameterValue)
Although I did not want to do this, I need to create a method which is not a oneway so that we can update the NB from TCL as the oneways do not seem to work from COMBAT |
void |
updateParameter(java.lang.String ParameterName,
org.omg.CORBA.Any ParameterValue)
This method is part of the ParameterNoticeBoardSupplierOperations CORBA servant interface which is to be implemented as part of this class. |
void |
updatePersistentParameter(java.lang.String ParameterName,
org.omg.CORBA.Any ParameterValue)
This method is part of the ParameterNoticeBoardSupplierOperations CORBA servant interface which is to be implemented as part of this class. |
void |
updatePersistentParameterArray(java.lang.String[] ParameterName,
org.omg.CORBA.Any[] ParameterValue)
This method is part of the ParameterNoticeBoardSupplierOperations CORBA servant interface which is to be implemented as part of this class. |
Methods inherited from class java.util.TimerTask |
---|
cancel, scheduledExecutionTime |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private int NoOfUpdates
private static final int TIMETOREPORTSTATISTICSPERIOD
private java.util.concurrent.ConcurrentHashMap<java.lang.String,NonResponsiveClient> NonResponsiveClientHash
private int TimeToReportStatisticsCounter
private java.util.concurrent.ConcurrentHashMap<java.lang.String,java.util.concurrent.Future> ListenerUpdateThreads
private java.util.concurrent.ExecutorService ListenerUpdateThreadService
private java.util.List<ListenerUpdate> ListenersToUpdate
private final java.util.Timer ListenerUpdateTimer
private java.lang.String PersistenceObjectFile
private java.util.concurrent.ConcurrentHashMap<java.lang.String,org.omg.CORBA.Any> RegisteredParameters
private java.util.concurrent.ConcurrentHashMap<java.lang.String,NoticeboardEvent> EventQueue
private java.util.concurrent.ConcurrentHashMap PersistentParameters
private java.util.concurrent.ConcurrentHashMap<java.lang.String,java.util.concurrent.ConcurrentHashMap<iParameterNoticeBoard.ParameterNoticeBoardListener,ParameterSubscriber>> ParameterCallbacks
private MessageHandler SyslogMessageHandler
org.omg.CORBA.ORB Orb
Constructor Detail |
---|
ParameterNoticeBoard(MessageHandler SyslogMessageHandler, org.omg.CORBA.ORB Orb, java.lang.String PersistanceDirectory)
SyslogMessageHandler
- Used for reporting errors to syslogOrb
- PersistanceDirectory
- Dicretory into which to write the persistance dataMethod Detail |
---|
private boolean ReadNoticeboardItemPersistenceFile()
public java.lang.String[] fetchFullParameterList() throws iParameterNoticeBoard.NoticeBoardEmptyException
fetchFullParameterList
in interface iParameterNoticeBoard.ParameterNoticeBoardSupplierOperations
iParameterNoticeBoard.NoticeBoardEmptyException
- This is thrown when the notice board is empty when the call is made.
iParameterNoticeBoard.NoticeBoardEmptyException
public org.omg.CORBA.Any fetchParameter(java.lang.String ParameterName) throws iParameterNoticeBoard.ParameterNotRegisteredException, iParameterNoticeBoard.ParameterNotSetException
fetchParameter
in interface iParameterNoticeBoard.ParameterNoticeBoardSupplierOperations
ParameterName
- This is the name of the parameter that the caller is requesting the value for.
iParameterNoticeBoard.ParameterNotRegisteredException
- If the specified parameter does not exist in the noticeboard.
iParameterNoticeBoard.ParameterNotSetException
- This is raised when a client attempts to access a parameter
which has been created but has not been set.
iParameterNoticeBoard.ParameterNotRegisteredException
iParameterNoticeBoard.ParameterNotSetException
public iParameterNoticeBoard.ParameterStruct[] fetchParameterArray(java.lang.String[] ParametersToRetrieve) throws iParameterNoticeBoard.ParameterNotRegisteredException, iParameterNoticeBoard.ParameterNotSetException
This method forms part of the CORBA interface to the parameter noticeboard and will be used by CORBA clients in order to access the noticeboard.
fetchParameterArray
in interface iParameterNoticeBoard.ParameterNoticeBoardSupplierOperations
ParametersToRetrieve
- The names of the parameters that the caller is requesting the values for.
iParameterNoticeBoard.ParameterNotRegisteredException
- If the specified parameters do not exist in the noticeboard.
iParameterNoticeBoard.ParameterNotSetException
- This is raised when a client attempts to access a parameter
which has been created but has not been set.
iParameterNoticeBoard.ParameterNotRegisteredException
iParameterNoticeBoard.ParameterNotSetException
public boolean registerEventListener(iParameterNoticeBoard.ParameterNoticeBoardListener EventListener, java.lang.String ParameterName) throws iParameterNoticeBoard.ParameterNotRegisteredException
registerEventListener
in interface iParameterNoticeBoard.ParameterNoticeBoardSupplierOperations
ParameterName
- The name of the parameter for which the consumer would like to
be informed of updates for.EventListener
- This is a EventListener CORBA object which will have methods on it called when there is an
event on the parameter for which it is associated.
iParameterNoticeBoard.ParameterNotRegisteredException
- Thrown if the parameter that is specified is not registered.
iParameterNoticeBoard.ParameterNotRegisteredException
public boolean registerEventListenerWithID(iParameterNoticeBoard.ParameterNoticeBoardListener EventListener, java.lang.String ParameterName, java.lang.String ClientID) throws iParameterNoticeBoard.ParameterNotRegisteredException
registerEventListenerWithID
in interface iParameterNoticeBoard.ParameterNoticeBoardSupplierOperations
ParameterName
- The name of the parameter for which the consumer would like to
be informed of updates for.EventListener
- This is a EventListener CORBA object which will have methods on it called when there is an
event on the parameter for which it is associated.ClientID
- This is the tag which will be used to identify the parameter noticeboard consumer.
iParameterNoticeBoard.ParameterNotRegisteredException
- Thrown if the parameter that is specified is not registered.public boolean registerParameterWithExpiryTime(java.lang.String ParameterName, int ExpiryTime) throws iParameterNoticeBoard.ParameterAlreadyRegisteredException
The expiry time is how long the status value is considered value after being updated. This time is expressed in milliseconds
registerParameterWithExpiryTime
in interface iParameterNoticeBoard.ParameterNoticeBoardSupplierOperations
ParameterName
- The name of the new parameter which is to be added to the noticeboard.ExpiryTime
- Delay in milliseconds after status value has been updated before the status
value is considered out of date.
iParameterNoticeBoard.ParameterAlreadyRegisteredException
- Thrown if the parameter is already registered.
iParameterNoticeBoard.ParameterAlreadyRegisteredException
public boolean registerParameter(java.lang.String ParameterName) throws iParameterNoticeBoard.ParameterAlreadyRegisteredException
registerParameter
in interface iParameterNoticeBoard.ParameterNoticeBoardSupplierOperations
ParameterName
- The name of the new parameter which is to be added to the noticeboard
iParameterNoticeBoard.ParameterAlreadyRegisteredException
- Thrown if the parameter is already registered.
iParameterNoticeBoard.ParameterAlreadyRegisteredException
public boolean deleteParameter(java.lang.String ParameterName) throws iParameterNoticeBoard.ParameterNotRegisteredException
Note that any event listeners which are subscribed to this parameter will be removed as well. On removing an event listener, the method calls the parameterMonitorTerminated on the listener object so that the listener is aware that the subscription to the parameter has been cancelled by the noticeboard.
deleteParameter
in interface iParameterNoticeBoard.ParameterNoticeBoardSupplierOperations
ParameterName
- The name of the parameter which is to be removed from the noticeboard
iParameterNoticeBoard.ParameterNotRegisteredException
- Thrown if the parameter is not registered.
iParameterNoticeBoard.ParameterNotRegisteredException
public void syncUpdateParameter(java.lang.String ParameterName, org.omg.CORBA.Any ParameterValue)
syncUpdateParameter
in interface iParameterNoticeBoard.ParameterNoticeBoardSupplierOperations
ParameterName
- The name of the parameter which is to have it's parameter updatedParameterValue
- This is the new value of the parameter.public void updatePersistentParameter(java.lang.String ParameterName, org.omg.CORBA.Any ParameterValue)
Additionally the parameter specified will be considered persistent and as such will be stored across restarts of the parameter noticeboard.
updatePersistentParameter
in interface iParameterNoticeBoard.ParameterNoticeBoardSupplierOperations
ParameterName
- The name of the parameter which is to have it's parameter updatedParameterValue
- This is the new value of the parameter.public void updatePersistentParameterArray(java.lang.String[] ParameterName, org.omg.CORBA.Any[] ParameterValue)
Additionally the parameter specified will be considered persistent and as such will be stored across restarts of the parameter noticeboard.
updatePersistentParameterArray
in interface iParameterNoticeBoard.ParameterNoticeBoardSupplierOperations
ParameterName
- The name of the parameter which is to have it's parameter updatedParameterValue
- This is the new value of the parameter.public void updateParameter(java.lang.String ParameterName, org.omg.CORBA.Any ParameterValue)
updateParameter
in interface iParameterNoticeBoard.ParameterNoticeBoardSupplierOperations
ParameterName
- The name of the parameter which is to have it's parameter updatedParameterValue
- This is the new value of the parameter.public void setDebugState(boolean DebugState)
setDebugState
in interface iInstrumentController.InstrumentControllerOperations
setDebugState
in interface ParameterNoticeBoardMBean
DebugState
- Whether or not debug should be enabled or disabled.public void setTraceLevel(double TraceLevel)
setTraceLevel
in interface iInstrumentController.InstrumentControllerOperations
TraceLevel
- The expected trace level of the application when debug is enabled.public void closeDown(java.lang.String CloseDownMessage)
closeDown
in interface iInstrumentController.InstrumentControllerOperations
CloseDownMessage
- The text of a message which is to be put
into the syslog when the application closes downpublic boolean handshake()
handshake
in interface iInstrumentController.InstrumentControllerOperations
public void run()
run
in interface java.lang.Runnable
run
in class java.util.TimerTask
public void cancelParameterSuscriptionForConsumer(java.lang.String ClientID, java.lang.String ParameterName)
cancelParameterSuscriptionForConsumer
in interface iParameterNoticeBoard.ParameterNoticeBoardSupplierOperations
ClientID
- This is the ID with which the consumer
initially registered for updates from the parameter with.
ParameterName
- This is the name of the parameter which
the client no longer wants to be subscribed to.public void cancelAllEventSuscriptionForConsumer(java.lang.String ClientID)
cancelAllEventSuscriptionForConsumer
in interface iParameterNoticeBoard.ParameterNoticeBoardSupplierOperations
ClientID
- This is the identifier which the client used
when initially subscribing to the noticeboard.private boolean broadcastEvent(java.lang.String ParameterName, org.omg.CORBA.Any ParameterValue)
ParameterName
- This is the name of the parameter which is to be broadcast to the listenersParameterValue
- This is the value of parameter which is to be broadcast.
public iParameterNoticeBoard.ParameterStruct[] fetchAllNoticeboardParameters() throws iParameterNoticeBoard.ParameterNotRegisteredException, iParameterNoticeBoard.ParameterNotSetException
This method forms part of the CORBA interface to the parameter noticeboard and will be used by CORBA clients in order to access the noticeboard.
fetchAllNoticeboardParameters
in interface iParameterNoticeBoard.ParameterNoticeBoardSupplierOperations
iParameterNoticeBoard.ParameterNotRegisteredException
- If the specified parameters do not exist in the noticeboard.
which has been created but has not been set.
iParameterNoticeBoard.ParameterNotRegisteredException
iParameterNoticeBoard.ParameterNotSetException
public static void main(java.lang.String[] args)
One should note that the parameter noticboard uses jacorb and has it's own peculiar jacorb configuration file which is stored in ParameterNoticeboard.properties. Configuring the name of the file which is to be used is performed by setting the system property ORBid which will be used to name the ORB but also instruct jacorb to look for the properties file for that particular ORBid. This is all outlined in the jacorb documentation.
args
- public int getNoOfUpdates()
getNoOfUpdates
in interface ParameterNoticeBoardMBean
public int noOfActiveListeners(java.lang.String PNBItem)
noOfActiveListeners
in interface ParameterNoticeBoardMBean
PNBItem
- The name of the parameter noticeboard item.public int getNoOfUpdateThreads()
getNoOfUpdateThreads
in interface ParameterNoticeBoardMBean
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |