Class TNCCallbackHandler
java.lang.Object
com.nt.udc.testnodechain.callbacks.TNCEventSender
com.nt.udc.testnodechain.callbacks.TNCCallbackHandler
- All Implemented Interfaces:
TNCEventReceiverIfc
,TNCEventSenderIfc
,Serializable
,Remote
- Direct Known Subclasses:
AdminTNCCallbackHandler
The TNCCallbackHandler class extends TNCEventSender and implements TNCEventReceiverIfc.
This class is responsible for both receiving events and sending them to registered receivers.
It supports event buffering, where events are stored locally upon reception and sent to new subscribers
upon subscribing for events, ensuring they receive events they might have missed otherwise.
- See Also:
-
Field Summary
Fields inherited from class com.nt.udc.testnodechain.callbacks.TNCEventSender
logger, receiverManager
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
addEventToBuffer
(String testID, BaseEventIfc event) Adds a single event to the buffer associated with a specific test ID.protected void
addEventToBuffer
(String testID, List<BaseEventIfc> events) Adds events to the buffer associated with a specific test ID.boolean
This method returns a boolean indicating whether event buffering is enabled for this callback handler.void
freeUpTestResources
(String testId, boolean removeTestListeners) Frees up resources associated with a test identified by the given test ID.boolean
hasHistoricEvents
(String testId) Checks whether there are historic events associated with the specified test ID.protected void
newTestSubscriberAdded
(String recieverID, String testID) This method is called when a new test subscriber is added, providing information about the receiver ID and the associated test ID.void
onBulkEvents
(List<BaseEventIfc> events) This method is triggered when the receiver subscribes to a test for the first time, and the sender has event buffering implemented.void
onFreeUpTestResources
(String testId) Will be called when the sender is cleaning up the resources allocated for this test.void
onNodeOutputFileAvailable
(NodeOutputFileAvailableEvent nodeOutputFileAvailable) Notifies the observer when a node's output file becomes available.void
onNodeStatisticsChange
(List<NodeUpdateEvent> nodeData) The onNodeStatisticsChange method is called when there is a change in node statistics.void
onNodeStatusChange
(NodeStatusUpdateEventIfc nodeStatus) The onNodeStatusChange method is called when there is a change in the status of a node.void
onRemoveReceiver
(String receiverId) Will be called when the sender is removing this listener enttirelyvoid
onRemoveTestListener
(String testId) Will be called when the sender is removing this listener from test mapping.void
Handles the event when a test is about to timeout.void
onTestStatusChange
(TestStatusChangeEventIfc testStatus) Notifies the receivers about changes in the status of a test.segregateEvents
(List<? extends BaseEventIfc> events) Segregates events based on the associated test ID into a Map.Methods inherited from class com.nt.udc.testnodechain.callbacks.TNCEventSender
addReceiver, addReceiver, bulkEvents, clear, isReceiverValid, logDebug, logDebug, logInfo, logInfo, nodeOutputFileAvailable, nodeStatisticsChange, nodeStatusChange, removeReceiver, removeTestListener, subscribeForTest, testAboutToTimeout, testStatusChange
-
Constructor Details
-
TNCCallbackHandler
-
-
Method Details
-
onNodeStatisticsChange
The onNodeStatisticsChange method is called when there is a change in node statistics. It receives a list of NodeUpdateEvent objects containing the updated node data.- Specified by:
onNodeStatisticsChange
in interfaceTNCEventReceiverIfc
- Parameters:
nodeData
- A list of NodeUpdateEvent objects representing the updated node statistics.- Throws:
RemoteException
- If there is a communication-related exception while propogating the update to registered receivers
-
onNodeStatusChange
The onNodeStatusChange method is called when there is a change in the status of a node. It receives a NodeStatusUpdateEventIfc object representing the updated node status.- Specified by:
onNodeStatusChange
in interfaceTNCEventReceiverIfc
- Parameters:
nodeStatus
- A NodeStatusUpdateEventIfc object containing the updated node status information.- Throws:
RemoteException
- If there is a communication-related exception while propogating the update to registered receivers
-
onBulkEvents
This method is triggered when the receiver subscribes to a test for the first time, and the sender has event buffering implemented. The goal is to populate the events into the local buffer ( as a receiver ), with the actual distribution ( as as sender ) to the respective receivers being postponed and managed by the 'newTestSubscriberAdded()' method.- Specified by:
onBulkEvents
in interfaceTNCEventReceiverIfc
- Parameters:
events
-- Throws:
RemoteException
- If there is a communication-related exception while propogating the update to registered receivers
-
onTestStatusChange
Notifies the receivers about changes in the status of a test.- Specified by:
onTestStatusChange
in interfaceTNCEventReceiverIfc
- Parameters:
testStatus
- The event interface representing the change in test status.- Throws:
RemoteException
- If a communication-related exception occurs during the remote method invocation.
-
onNodeOutputFileAvailable
public void onNodeOutputFileAvailable(NodeOutputFileAvailableEvent nodeOutputFileAvailable) throws RemoteException Notifies the observer when a node's output file becomes available.- Specified by:
onNodeOutputFileAvailable
in interfaceTNCEventReceiverIfc
- Parameters:
nodeOutputFileAvailable
- The event representing the availability of the node's output file.- Throws:
RemoteException
- If a communication-related exception occurs during the remote method invocation.
-
onTestAboutToTimeout
Handles the event when a test is about to timeout.- Specified by:
onTestAboutToTimeout
in interfaceTNCEventReceiverIfc
- Parameters:
event
- The TestTimeoutReminderEvent containing information about the test about to timeout.- Throws:
RemoteException
- If a remote exception occurs during the handling of node status changes.
-
segregateEvents
Segregates events based on the associated test ID into a Map. This method takes a list of events and segregates them into a Map, where each entry in the map represents a test ID, and the corresponding value is a List of events associated with that test ID.- Parameters:
events
- A List of objects implementing the BaseEventIfc interface.- Returns:
- A Map where keys represent test IDs, and values are Lists of events for the respective test IDs.
-
newTestSubscriberAdded
This method is called when a new test subscriber is added, providing information about the receiver ID and the associated test ID.- Overrides:
newTestSubscriberAdded
in classTNCEventSender
- Parameters:
recieverID
- The identifier of the new test subscriber.testID
- The unique identifier of the test associated with the new subscriber.receiverID
- The identifier of the new test subscriber.
-
addEventToBuffer
Adds a single event to the buffer associated with a specific test ID. This method is responsible for appending a single event to the buffer corresponding to the provided test ID.- Parameters:
testID
- The unique identifier for the test to which the event will be added.event
- A BaseEventIfc object representing the event to be added to the buffer.
-
addEventToBuffer
Adds events to the buffer associated with a specific test ID. This method is responsible for appending a list of events to the buffer corresponding to the provided test ID.- Parameters:
testID
- The unique identifier for the test to which the events will be added.events
- A List of BaseEventIfc objects representing the events to be added to the buffer.
-
bufferingEnabled
public boolean bufferingEnabled()This method returns a boolean indicating whether event buffering is enabled for this callback handler.- Returns:
- true if event buffering is enabled, false otherwise.
-
hasHistoricEvents
Description copied from interface:TNCEventSenderIfc
Checks whether there are historic events associated with the specified test ID.- Specified by:
hasHistoricEvents
in interfaceTNCEventSenderIfc
- Overrides:
hasHistoricEvents
in classTNCEventSender
- Parameters:
testId
- The unique identifier of the test to check for historic events.- Returns:
true
if there are historic events for the given test ID;false
otherwise.
-
freeUpTestResources
Description copied from interface:TNCEventSenderIfc
Frees up resources associated with a test identified by the given test ID.- Specified by:
freeUpTestResources
in interfaceTNCEventSenderIfc
- Overrides:
freeUpTestResources
in classTNCEventSender
- Parameters:
testId
- The unique identifier of the test whose resources should be freed up.removeTestListeners
- A boolean flag indicating whether to remove test listeners associated with the test. If set totrue
, the test listeners will be removed; otherwise, they will be retained.
-
onFreeUpTestResources
Description copied from interface:TNCEventReceiverIfc
Will be called when the sender is cleaning up the resources allocated for this test.- Specified by:
onFreeUpTestResources
in interfaceTNCEventReceiverIfc
- Parameters:
testId
- The identifier of the test being cleaned up.- Throws:
RemoteException
- If there is a communication-related exception.
-
onRemoveTestListener
Description copied from interface:TNCEventReceiverIfc
Will be called when the sender is removing this listener from test mapping.- Specified by:
onRemoveTestListener
in interfaceTNCEventReceiverIfc
- Parameters:
testId
- The identifier of the test being cleaned up.- Throws:
RemoteException
- If there is a communication-related exception.
-
onRemoveReceiver
Description copied from interface:TNCEventReceiverIfc
Will be called when the sender is removing this listener enttirely- Specified by:
onRemoveReceiver
in interfaceTNCEventReceiverIfc
- Throws:
RemoteException
- If there is a communication-related exception.
-