public abstract class TargetReceiver extends java.lang.Object implements MessageReceiver
Modifier and Type | Field and Description |
---|---|
protected int |
destination
The destination
|
protected long |
groupingSize
The message grouping size
|
protected int |
highWaterMark
High water mark to keep track of objects
|
protected java.util.concurrent.locks.Lock |
lock
The lock
|
protected <any> |
messages
Lets keep track of the messages, we need to keep track of the messages for each target
and source, Map<target, Queue<messages>>
|
protected DataFlowOperation |
operation
The operations
|
protected int |
representSource
The source task connected to this partial receiver
|
protected SyncState |
syncState
The sync state
|
protected int[] |
targets
The targets
|
protected java.util.Set<java.lang.Integer> |
thisDestinations
The destinations we are sending messages to
|
protected java.util.Set<java.lang.Integer> |
thisSources
Sources we are expecting messages from
|
protected int |
workerId
The worker id this receiver is in
|
Constructor and Description |
---|
TargetReceiver() |
Modifier and Type | Method and Description |
---|---|
protected void |
addMessage(int target,
java.util.List<java.lang.Object> msgQueue,
java.lang.Object value) |
protected abstract void |
addSyncMessage(int source,
int target)
Add a sync message
|
protected abstract void |
addSyncMessageBarrier(int source,
int target,
byte[] barrier)
Add a sync message
|
protected abstract boolean |
canAcceptMessage(int source,
int target)
Check weather we can accept a message
|
protected void |
clearTarget(int target)
Clear all the buffers for the target, to ready for the next
|
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 |
isFilledToSend(int target)
Return true if we are filled to send
|
protected abstract void |
merge(int dest,
java.util.List<java.lang.Object> dests)
Swap the messages to the ready queue
|
boolean |
onMessage(int source,
int path,
int target,
int flags,
java.lang.Object object)
The actual message callback
|
protected abstract boolean |
onSyncEvent(int target,
byte[] value)
This method is called when there is a sync event on the operation
|
protected abstract boolean |
sendToTarget(int source,
int target)
Send the values to a target
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
clean, close, isComplete, onMessage, progress
protected <any> messages
protected int workerId
protected DataFlowOperation operation
protected int destination
protected int representSource
protected int highWaterMark
protected java.util.concurrent.locks.Lock lock
protected java.util.Set<java.lang.Integer> thisSources
protected java.util.Set<java.lang.Integer> thisDestinations
protected SyncState syncState
protected long groupingSize
protected int[] targets
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 messageprotected void addMessage(int target, java.util.List<java.lang.Object> msgQueue, java.lang.Object value)
protected abstract void addSyncMessage(int source, int target)
source
- sourcetarget
- targetprotected abstract void addSyncMessageBarrier(int source, int target, byte[] barrier)
source
- sourcetarget
- targetbarrier
- the barrier messageprotected abstract boolean canAcceptMessage(int source, int target)
source
- sourcetarget
- targetprotected abstract void merge(int dest, java.util.List<java.lang.Object> dests)
dest
- the targetdests
- message queue to switch to readyprotected void clearTarget(int target)
target
- targetprotected abstract boolean sendToTarget(int source, int target)
source
- the sourcestarget
- the targetprotected abstract boolean onSyncEvent(int target, byte[] value)
target
- the target to which the sync event belongvalue
- the byte value, can be nullprotected abstract boolean isFilledToSend(int target)