handleEvent
public GenericMessagingTask<NodeIDType,?>[] handleEvent(ProtocolEvent<ReconfigurationPacket.PacketType,java.lang.String> event,
ProtocolTask<NodeIDType,ReconfigurationPacket.PacketType,java.lang.String>[] ptasks)
The action handling the event may return messaging tasks that will be
automatically handled by this interface. This interface lets the protocol
developer focus on event/action pairs without worrying about networking
or scheduling optimizations. The parameter ptasks[0] returns a single
protocol task if any spawned by this action.
We need a unique key ***that is unique across all nodes*** in order to
match incoming messages against the corresponding task. ProtocolExecutor
automatically inserts this key in every message exchanged as part of the
protocol task. The getKey method is necessitated by the Keyable
interface in this class. A simple way to choose a String key that is
unique across all nodes at a node is to use the current node's ID
concatenated with a random number and/or the current time. A protocol
task can also explicitly choose meaningful (i.e., not random or based on
timestamps) names for tasks, but they still need to be unique across all
nodes. Refer to the examples provided with the protocoltask package.
A protocol task can be canceled from within the task, if necessary, by
invoking ProtocolExecutor.cancel(this). But you probably have a bad
design if you need to rely on this.
- Specified by:
handleEvent
in interface ProtocolTask<NodeIDType,ReconfigurationPacket.PacketType,java.lang.String>
- Returns:
- Returns messaging tasks to be performed.