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 voidaddEventToBuffer(String testID, BaseEventIfc event) Adds a single event to the buffer associated with a specific test ID.protected voidaddEventToBuffer(String testID, List<BaseEventIfc> events) Adds events to the buffer associated with a specific test ID.booleanThis method returns a boolean indicating whether event buffering is enabled for this callback handler.voidfreeUpTestResources(String testId, boolean removeTestListeners) Frees up resources associated with a test identified by the given test ID.booleanhasHistoricEvents(String testId) Checks whether there are historic events associated with the specified test ID.protected voidnewTestSubscriberAdded(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.voidonBulkEvents(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.voidonFreeUpTestResources(String testId) Will be called when the sender is cleaning up the resources allocated for this test.voidonNodeOutputFileAvailable(NodeOutputFileAvailableEvent nodeOutputFileAvailable) Notifies the observer when a node's output file becomes available.voidonNodeStatisticsChange(List<NodeUpdateEvent> nodeData) The onNodeStatisticsChange method is called when there is a change in node statistics.voidonNodeStatusChange(NodeStatusUpdateEventIfc nodeStatus) The onNodeStatusChange method is called when there is a change in the status of a node.voidonRemoveReceiver(String receiverId) Will be called when the sender is removing this listener enttirelyvoidonRemoveTestListener(String testId) Will be called when the sender is removing this listener from test mapping.voidHandles the event when a test is about to timeout.voidonTestStatusChange(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:
onNodeStatisticsChangein 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:
onNodeStatusChangein 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:
onBulkEventsin 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:
onTestStatusChangein 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:
onNodeOutputFileAvailablein 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:
onTestAboutToTimeoutin 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:
newTestSubscriberAddedin 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:TNCEventSenderIfcChecks whether there are historic events associated with the specified test ID.- Specified by:
hasHistoricEventsin interfaceTNCEventSenderIfc- Overrides:
hasHistoricEventsin classTNCEventSender- Parameters:
testId- The unique identifier of the test to check for historic events.- Returns:
trueif there are historic events for the given test ID;falseotherwise.
-
freeUpTestResources
Description copied from interface:TNCEventSenderIfcFrees up resources associated with a test identified by the given test ID.- Specified by:
freeUpTestResourcesin interfaceTNCEventSenderIfc- Overrides:
freeUpTestResourcesin 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:TNCEventReceiverIfcWill be called when the sender is cleaning up the resources allocated for this test.- Specified by:
onFreeUpTestResourcesin 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:TNCEventReceiverIfcWill be called when the sender is removing this listener from test mapping.- Specified by:
onRemoveTestListenerin 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:TNCEventReceiverIfcWill be called when the sender is removing this listener enttirely- Specified by:
onRemoveReceiverin interfaceTNCEventReceiverIfc- Throws:
RemoteException- If there is a communication-related exception.
-