public abstract class SourceReceiver extends java.lang.Object implements MessageReceiver
Modifier and Type | Field and Description |
---|---|
protected java.util.Map<java.lang.Integer,byte[]> |
barriers
The barriers for each target
|
protected int |
destination
The destination
|
protected java.util.Map<java.lang.Integer,java.lang.Boolean> |
isSyncSent
Weather sync messages are forwarded from the partial receivers
|
protected java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,java.util.Queue<java.lang.Object>>> |
messages
Lets keep track of the messages, we need to keep track of the messages for each target
and source, Map<target, map<source, Queue<messages>>
|
protected DataFlowOperation |
operation
The operations
|
protected int |
sendPendingMax
The pending max per source
|
protected java.util.Map<java.lang.Integer,java.lang.Integer> |
sourcesOfTarget
Number of sources per target
|
protected java.util.Map<java.lang.Integer,java.util.Set<java.lang.Integer>> |
syncReceived
Keep weather we have received a sync from a source
|
protected SyncState |
syncState
The sync state
|
protected java.util.Map<java.lang.Integer,ReceiverState> |
targetStates
Keep state about the targets
|
protected int |
workerId
The worker id this receiver is in
|
Constructor and Description |
---|
SourceReceiver() |
Modifier and Type | Method and Description |
---|---|
protected abstract boolean |
aggregate(int target,
boolean sync,
boolean allValuesFound)
Aggregate values from sources for a target, assumes every source has a value
|
protected boolean |
allQueuesEmpty(java.util.Map<java.lang.Integer,java.util.Queue<java.lang.Object>> messagePerTarget)
Check weather there is nothing left in the queues
|
protected boolean |
allSyncsPresent(int target)
Checks weather all syncs are present
|
void |
clean()
Clean any state associated with the receiver and go to initial state
|
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 abstract boolean |
isAllEmpty(int target)
Check weather all the other information is flushed
|
boolean |
isComplete()
Weather we are complete a set of messages
|
protected abstract boolean |
isFilledToSend(int target,
boolean sync)
Return true if we are filled to send
|
protected void |
onFinish(int source) |
boolean |
onMessage(int source,
int path,
int target,
int flags,
java.lang.Object object)
The actual message callback
|
protected abstract void |
onSyncEvent(int target,
byte[] value)
This method is called when there is a sync event on the operation
|
boolean |
progress()
This method will be called by the communicationProgress
|
protected abstract boolean |
sendSyncForward(int target)
Handle the sync
|
protected abstract boolean |
sendToTarget(int target,
boolean sync)
Send the values to a target
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
close, onMessage
protected java.util.Map<java.lang.Integer,java.util.Map<java.lang.Integer,java.util.Queue<java.lang.Object>>> messages
protected int workerId
protected DataFlowOperation operation
protected int sendPendingMax
protected int destination
protected java.util.Map<java.lang.Integer,java.util.Set<java.lang.Integer>> syncReceived
protected java.util.Map<java.lang.Integer,java.lang.Integer> sourcesOfTarget
protected java.util.Map<java.lang.Integer,java.lang.Boolean> isSyncSent
protected java.util.Map<java.lang.Integer,ReceiverState> targetStates
protected java.util.Map<java.lang.Integer,byte[]> barriers
protected SyncState syncState
public void init(Config cfg, DataFlowOperation op, java.util.Map<java.lang.Integer,java.util.List<java.lang.Integer>> expectedIds)
MessageReceiver
target -> source tasks
init
in interface MessageReceiver
expectedIds
- expected task idspublic boolean onMessage(int source, int path, int target, int flags, java.lang.Object object)
MessageReceiver
onMessage
in interface MessageReceiver
source
- 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 messagepublic boolean progress()
MessageReceiver
progress
in interface MessageReceiver
public boolean isComplete()
MessageReceiver
isComplete
in interface MessageReceiver
protected abstract boolean isAllEmpty(int target)
target
- targetprotected abstract boolean sendSyncForward(int target)
target
- targetprotected abstract boolean sendToTarget(int target, boolean sync)
target
- the targetprotected abstract boolean aggregate(int target, boolean sync, boolean allValuesFound)
target
- targetsync
- true if all the syncs are presentprotected abstract boolean isFilledToSend(int target, boolean sync)
protected boolean allQueuesEmpty(java.util.Map<java.lang.Integer,java.util.Queue<java.lang.Object>> messagePerTarget)
messagePerTarget
- the queues for the targetprotected boolean allSyncsPresent(int target)
protected void onFinish(int source)
public void clean()
MessageReceiver
clean
in interface MessageReceiver
protected abstract void onSyncEvent(int target, byte[] value)
target
- the target to which the sync event belongvalue
- the byte value, can be null