public abstract class KeyedReceiver extends java.lang.Object implements MessageReceiver
| Modifier and Type | Field and Description |
|---|---|
protected java.util.Map<java.lang.Integer,java.lang.Boolean> |
batchDone
Tracks if the partial receiver has completed processing for a given target
|
protected DataFlowOperation |
dataFlowOperation
The dataflow operation that is related to the class instance.
|
protected int |
destination
The destination identifier that defines the next destination for this receiver
|
protected int |
executor
Id of the current executor
|
protected java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,java.lang.Boolean>> |
finishedSources
Map that keeps track of which sources have sent an finished signal.
|
protected java.util.Map<java.lang.Integer,java.lang.Boolean> |
isEmptySent
Tracks if the empty message has been sent for each target
|
protected boolean |
isFinalBatchReceiver
Indicates whether the receiver instance is a final batch receiver or not.
|
protected int |
keyLimit
The number of keys buffered in this receiver before keys are flushed
|
protected int |
limitPerKey
The buffer limit for single key.
|
protected java.util.Map<java.lang.Integer,java.util.Map<java.lang.Object,java.util.Queue<java.lang.Object>>> |
messages
Map that keeps all the incoming messages to this receiver.
|
protected int |
representSource |
protected boolean |
representSourceSet |
protected java.util.Map<java.lang.Integer,java.util.Queue<java.lang.Object>> |
sendQueue
Objects that are inserted into this queue are objects that can be sent out from the receiver
the progress method removes items from this queue and sends them.
|
protected java.util.Set<java.lang.Integer> |
thisSources |
| Constructor and Description |
|---|
KeyedReceiver() |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
checkIfEmptyIsSent(int target)
checks if the Empty message was sent for this target and sends it if not sent and possible to
send
|
protected boolean |
finishProgress(boolean needsFurtherProgress,
int target)
Performs the final steps of the progress method in the receiver.
|
void |
init(Config cfg,
DataFlowOperation op,
java.util.Map<java.lang.Integer,java.util.List<java.lang.Integer>> expectedIds)
Initialize the message receiver with tasks from which messages are expected
For each sub edge in graph, for each path, gives the expected task ids
|
protected boolean |
isAllQueuesEmpty(java.util.Queue<java.lang.Object> targetSendQueue)
checks if the queue structures used to send data is empty.
|
boolean |
isComplete()
Weather we are complete a set of messages
|
protected boolean |
isSourcesFinished(int target)
checks if the sources have finished for a given target.
|
protected boolean |
moveMessagesToSendQueue(int target,
java.util.Map<java.lang.Object,java.util.Queue<java.lang.Object>> messagesPerTarget)
moves all the buffered messages into the sendQueue for the given target
|
protected boolean |
moveMessageToSendQueue(int target,
java.util.Map<java.lang.Object,java.util.Queue<java.lang.Object>> messagesPerTarget,
java.lang.Object key)
Moves all the buffered messages for the given key into the sendQueue and removes the
entry in the messages data structure if all the messages are moved
|
protected boolean |
offerMessage(int target,
java.lang.Object object)
saves the given message (or messages if the object is a list) into the messages data structure
if possible and rejects the message if the whole message cannot be added to the messages
data structure.
|
void |
onFinish(int source)
Once called this method will update the finishedSources data structure so that the given
source is marked as finished for each target that is present.
|
boolean |
onMessage(int src,
int path,
int target,
int flags,
java.lang.Object object)
The actual message callback
|
boolean |
progress()
Default progress method for keyed receivers.
|
protected boolean |
sendToTarget(boolean needsFurtherProgress,
boolean sourcesFinished,
int target,
java.util.Queue<java.lang.Object> targetSendQueue)
Called from the progress method to perform the communication calls to send the queued messages
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitclean, close, onMessageprotected int executor
protected int limitPerKey
protected int keyLimit
protected DataFlowOperation dataFlowOperation
protected int destination
protected java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,java.lang.Boolean>> finishedSources
protected java.util.Map<java.lang.Integer,java.util.Map<java.lang.Object,java.util.Queue<java.lang.Object>>> messages
protected java.util.Map<java.lang.Integer,java.util.Queue<java.lang.Object>> sendQueue
protected java.util.Map<java.lang.Integer,java.lang.Boolean> batchDone
protected java.util.Map<java.lang.Integer,java.lang.Boolean> isEmptySent
protected boolean isFinalBatchReceiver
protected int representSource
protected java.util.Set<java.lang.Integer> thisSources
protected boolean representSourceSet
public void init(Config cfg, DataFlowOperation op, java.util.Map<java.lang.Integer,java.util.List<java.lang.Integer>> expectedIds)
MessageReceivertarget -> source tasks
init in interface MessageReceiverexpectedIds - expected task idspublic boolean onMessage(int src,
int path,
int target,
int flags,
java.lang.Object object)
MessageReceiveronMessage in interface MessageReceiversrc - the source taskpath - the path that is taken by the message, that is intermediate targetstarget - the target of this receiverflags - the communication flagsobject - the actual messageprotected boolean offerMessage(int target,
java.lang.Object object)
target - target for which the messages are to be addedobject - the message/messages to be addedpublic void onFinish(int source)
source - the task id of the source that has finishedprotected boolean moveMessagesToSendQueue(int target,
java.util.Map<java.lang.Object,java.util.Queue<java.lang.Object>> messagesPerTarget)
target - target for which the move needs to be donemessagesPerTarget - messages for given targetprotected boolean moveMessageToSendQueue(int target,
java.util.Map<java.lang.Object,java.util.Queue<java.lang.Object>> messagesPerTarget,
java.lang.Object key)
target - target for which the move needs to be donemessagesPerTarget - messages for given targetkey - the key to be movedprotected boolean isSourcesFinished(int target)
target - the target to be checkedprotected boolean checkIfEmptyIsSent(int target)
target - target for which the check is donepublic boolean progress()
progress in interface MessageReceiverpublic boolean isComplete()
MessageReceiverisComplete in interface MessageReceiverprotected boolean finishProgress(boolean needsFurtherProgress,
int target)
needsFurtherProgress - current state of needsFurtherProgress valuetarget - the target(which is a source in this instance) from which the messages are sentprotected boolean isAllQueuesEmpty(java.util.Queue<java.lang.Object> targetSendQueue)
targetSendQueue - message queue for the current targetprotected boolean sendToTarget(boolean needsFurtherProgress,
boolean sourcesFinished,
int target,
java.util.Queue<java.lang.Object> targetSendQueue)
needsFurtherProgress - current state of needsFurtherProgress valuesourcesFinished - specifies if the sources have completedtarget - the target(which is a source in this instance) from which the messages are senttargetSendQueue - the data structure that contains all the message data