use of io.dingodb.exec.operator.SendOperator in project dingo by dingodb.
the class Services method initNetService.
public static void initNetService() {
NET.registerMessageListenerProvider(SimpleTag.RCV_READY_TAG, () -> ((message, channel) -> {
String tag = TagUtil.fromBytes(message.toBytes());
if (log.isDebugEnabled()) {
log.debug("Received RCV_READY of tag {}.", tag);
}
SendOperator so = Services.rcvReadyFlag.put(tag, SendOperator.DUMMY);
if (so != null) {
so.wakeUp();
}
}));
NET.registerMessageListenerProvider(SimpleTag.TASK_TAG, () -> (message, channel) -> {
String taskStr = new String(message.toBytes(), StandardCharsets.UTF_8);
if (log.isInfoEnabled()) {
log.info("Received task: {}", taskStr);
}
try {
Task task = TaskImpl.deserialize(taskStr);
executorService.execute(() -> {
task.init();
task.run();
});
} catch (JsonProcessingException e) {
throw new RuntimeException("Cannot deserialize received task.", e);
}
});
}
use of io.dingodb.exec.operator.SendOperator in project dingo by dingodb.
the class DingoJobVisitor method visit.
@Override
public Collection<Output> visit(@Nonnull DingoExchange rel) {
Collection<Output> inputs = dingo(rel.getInput()).accept(this);
List<Output> outputs = new LinkedList<>();
TupleSchema schema = TupleSchema.fromRelDataType(rel.getRowType());
for (Output input : inputs) {
Task task = input.getTask();
Location target = input.getTargetLocation();
if (target == null) {
target = Services.META.currentLocation();
}
if (!target.equals(task.getLocation())) {
Id id = idGenerator.get();
Id receiveId = idGenerator.get();
SendOperator send = new SendOperator(target.getHost(), target.getPort(), receiveId, schema);
send.setId(id);
task.putOperator(send);
input.setLink(send.getInput(0));
ReceiveOperator receive = new ReceiveOperator(task.getHost(), task.getLocation().getPort(), schema);
receive.setId(receiveId);
receive.getSoleOutput().copyHint(input);
Task rcvTask = job.getOrCreate(target);
rcvTask.putOperator(receive);
outputs.addAll(receive.getOutputs());
} else {
outputs.add(input);
}
}
return outputs;
}
Aggregations