@Override
public void sendDownstream(Tuple message)
throws NoSuchLocationException {
if (withinTaskDownstreamNeighbors.isEmpty()
&& crossTaskDownstreamNeighbors.isEmpty())
throw new NoSuchLocationException("Line "
+ logicalLocation.logId()
+ " has no downstream neighbor.");
for (String neighbor : withinTaskDownstreamNeighbors) {
sendWithinTaskMessage(neighbor, new Message(location,
new LogicalLocation(neighbor), message));
}
for (String neighbor : crossTaskDownstreamNeighbors) {
senderReceiver
.sendAsync(new Message(location,
new LogicalLocation(neighbor), message));
}
}
@Override
public void sendUpstream(Tuple message)
throws NoSuchLocationException {
if (withinTaskUpstreamNeighbors.isEmpty())
throw new NoSuchLocationException("Line "
+ logicalLocation.logId()
+ " has no within-task upstream neighbor.");
for (String neighbor : withinTaskUpstreamNeighbors) {
sendWithinTaskMessage(neighbor, new Message(location,
new LogicalLocation(neighbor), message));
}
}
@Override
public void sendToAgents(LogicalLocation destination, Tuple tuple)
throws NoSuchLocationException {
if (!logicalIds.contains(destination.logId()))
throw new NoSuchLocationException("Logical location "
+ destination + " does not exist.");
senderReceiver.sendAsync(new Message(location, destination, tuple));
}
};