NodeIDType
- EventType
- KeyType
- This abstract class is concretized for Long keys, int node IDs,
and ProtocolPackets. Its purpose is to receive responses from a
threshold number of nodes in the specified set. To enable this,
instantiators of this abstract class must implement (1) a
"boolean handleEvent(event)" method that says whether or not the
response was valid, which helps ThresholdProtocolTask
automatically stop retrying with nodes that have already
responded; (2) a handleThresholdEvent(.) method that returns a
protocol task to be executed when the threshold is reached
(returning null automatically cancels the task as it is considered
complete).public abstract class ThresholdProtocolTask<NodeIDType,EventType,KeyType> extends java.lang.Object implements SchedulableProtocolTask<NodeIDType,EventType,KeyType>
Modifier and Type | Field and Description |
---|---|
protected Waitfor<NodeIDType> |
waitfor |
Constructor and Description |
---|
ThresholdProtocolTask(java.util.Set<NodeIDType> nodes)
Set of nodes from which we expect to hear back.
|
ThresholdProtocolTask(java.util.Set<NodeIDType> nodes,
int threshold)
Set of nodes out of which we expect to hear back from
threshold
number of nodes. |
ThresholdProtocolTask(java.util.Set<NodeIDType> nodes,
int threshold,
boolean autoCancel)
Set of nodes out of which we expect to hear back from
threshold
number of nodes. |
Modifier and Type | Method and Description |
---|---|
protected GenericMessagingTask<NodeIDType,?>[] |
fix(GenericMessagingTask<NodeIDType,?>[] mtasks) |
long |
getPeriod()
The current restart period.
|
abstract boolean |
handleEvent(ProtocolEvent<EventType,KeyType> event) |
GenericMessagingTask<NodeIDType,?>[] |
handleEvent(ProtocolEvent<EventType,KeyType> event,
ProtocolTask<NodeIDType,EventType,KeyType>[] ptasks)
This method automatically keeps track of senders from which we have
already received valid responses in order to keep track of whether the
threshold has been reached, and if so, it invokes
handleThresholdEvent |
GenericMessagingTask<NodeIDType,?>[] |
handleThresholdEvent(ProtocolTask<NodeIDType,EventType,KeyType>[] ptasks)
Default action is to cancel the protocol task when the threshold is
reached.
|
void |
setPeriod(long restartPeriod) |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
restart
getEventTypes, start
protected final Waitfor<NodeIDType> waitfor
public ThresholdProtocolTask(java.util.Set<NodeIDType> nodes)
nodes
- public ThresholdProtocolTask(java.util.Set<NodeIDType> nodes, int threshold)
threshold
number of nodes.nodes
- threshold
- public ThresholdProtocolTask(java.util.Set<NodeIDType> nodes, int threshold, boolean autoCancel)
threshold
number of nodes.nodes
- threshold
- autoCancel
- public abstract boolean handleEvent(ProtocolEvent<EventType,KeyType> event)
event
- public GenericMessagingTask<NodeIDType,?>[] handleThresholdEvent(ProtocolTask<NodeIDType,EventType,KeyType>[] ptasks)
ptasks
- public final GenericMessagingTask<NodeIDType,?>[] handleEvent(ProtocolEvent<EventType,KeyType> event, ProtocolTask<NodeIDType,EventType,KeyType>[] ptasks)
handleThresholdEvent
handleEvent
in interface ProtocolTask<NodeIDType,EventType,KeyType>
protected GenericMessagingTask<NodeIDType,?>[] fix(GenericMessagingTask<NodeIDType,?>[] mtasks)
public void setPeriod(long restartPeriod)
restartPeriod
- The period after which restart messages will be sent (only to
nodes from which valid responses have not yet been received).public long getPeriod()
getPeriod
in interface SchedulableProtocolTask<NodeIDType,EventType,KeyType>