Search in sources :

Example 1 with Task

use of io.dingodb.exec.base.Task in project dingo by dingodb.

the class JobImpl method getOrCreate.

@Nonnull
@Override
public Task getOrCreate(Location location) {
    for (Task task : tasks) {
        if (task.getLocation().equals(location)) {
            return task;
        }
    }
    Task task = new TaskImpl(jobId, location);
    tasks.add(task);
    return task;
}
Also used : Task(io.dingodb.exec.base.Task) Nonnull(javax.annotation.Nonnull)

Example 2 with Task

use of io.dingodb.exec.base.Task 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);
        }
    });
}
Also used : NetService(io.dingodb.net.NetService) NetError(io.dingodb.net.NetError) StoreServiceProvider(io.dingodb.store.api.StoreServiceProvider) MetaService(io.dingodb.meta.MetaService) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) SimpleTag(io.dingodb.net.SimpleTag) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) NetAddress(io.dingodb.net.NetAddress) Channel(io.dingodb.net.Channel) DingoException(io.dingodb.common.error.DingoException) StandardCharsets(java.nio.charset.StandardCharsets) Executors(java.util.concurrent.Executors) ConcurrentMap(java.util.concurrent.ConcurrentMap) Objects(java.util.Objects) SendOperator(io.dingodb.exec.operator.SendOperator) Slf4j(lombok.extern.slf4j.Slf4j) Optional(io.dingodb.common.util.Optional) StoreService(io.dingodb.store.api.StoreService) Task(io.dingodb.exec.base.Task) ExecutorService(java.util.concurrent.ExecutorService) TaskImpl(io.dingodb.exec.impl.TaskImpl) TagUtil(io.dingodb.exec.util.TagUtil) Task(io.dingodb.exec.base.Task) SendOperator(io.dingodb.exec.operator.SendOperator) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException)

Example 3 with Task

use of io.dingodb.exec.base.Task 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;
}
Also used : ReceiveOperator(io.dingodb.exec.operator.ReceiveOperator) Task(io.dingodb.exec.base.Task) Output(io.dingodb.exec.base.Output) TableId(io.dingodb.common.table.TableId) Id(io.dingodb.exec.base.Id) SendOperator(io.dingodb.exec.operator.SendOperator) LinkedList(java.util.LinkedList) TupleSchema(io.dingodb.common.table.TupleSchema) Location(io.dingodb.meta.Location)

Example 4 with Task

use of io.dingodb.exec.base.Task in project dingo by dingodb.

the class DingoJobVisitor method visit.

@Override
public Collection<Output> visit(@Nonnull DingoCoalesce rel) {
    Collection<Output> inputs = dingo(rel.getInput()).accept(this);
    int size = inputs.size();
    if (size <= 1) {
        return inputs;
    }
    Output one = inputs.iterator().next();
    boolean isToSumUp = one.isToSumUp();
    Operator operator = isToSumUp ? new SumUpOperator(size) : new CoalesceOperator(size);
    operator.setId(idGenerator.get());
    Task task = one.getTask();
    task.putOperator(operator);
    int i = 0;
    for (Output input : inputs) {
        assert input.getTask().equals(task) : "Operator linked must be in the same task.";
        assert input.isToSumUp() == isToSumUp : "All inputs must have the same \"toSumUp\" hint.";
        input.setLink(operator.getInput(i));
        ++i;
    }
    return operator.getOutputs();
}
Also used : SumUpOperator(io.dingodb.exec.operator.SumUpOperator) AggregateOperator(io.dingodb.exec.operator.AggregateOperator) SortOperator(io.dingodb.exec.operator.SortOperator) RootOperator(io.dingodb.exec.operator.RootOperator) PartScanOperator(io.dingodb.exec.operator.PartScanOperator) SendOperator(io.dingodb.exec.operator.SendOperator) ReceiveOperator(io.dingodb.exec.operator.ReceiveOperator) ProjectOperator(io.dingodb.exec.operator.ProjectOperator) ValuesOperator(io.dingodb.exec.operator.ValuesOperator) PartUpdateOperator(io.dingodb.exec.operator.PartUpdateOperator) ReduceOperator(io.dingodb.exec.operator.ReduceOperator) Operator(io.dingodb.exec.base.Operator) GetByKeysOperator(io.dingodb.exec.operator.GetByKeysOperator) PartitionOperator(io.dingodb.exec.operator.PartitionOperator) PartDeleteOperator(io.dingodb.exec.operator.PartDeleteOperator) PartInsertOperator(io.dingodb.exec.operator.PartInsertOperator) CoalesceOperator(io.dingodb.exec.operator.CoalesceOperator) Task(io.dingodb.exec.base.Task) CoalesceOperator(io.dingodb.exec.operator.CoalesceOperator) Output(io.dingodb.exec.base.Output) SumUpOperator(io.dingodb.exec.operator.SumUpOperator) OutputHint(io.dingodb.exec.base.OutputHint)

Example 5 with Task

use of io.dingodb.exec.base.Task in project dingo by dingodb.

the class DingoJobVisitor method visit.

@Override
public Collection<Output> visit(@Nonnull DingoReduce rel) {
    Collection<Output> inputs = dingo(rel.getInput()).accept(this);
    int size = inputs.size();
    if (size <= 1) {
        return inputs;
    }
    Operator operator;
    operator = new ReduceOperator(inputs.size(), rel.getKeyMapping(), rel.getAggList());
    operator.setId(idGenerator.get());
    Output one = inputs.iterator().next();
    Task task = one.getTask();
    task.putOperator(operator);
    int i = 0;
    for (Output input : inputs) {
        assert input.getTask().equals(task) : "Operator linked must be in the same task.";
        input.setLink(operator.getInput(i));
        ++i;
    }
    return operator.getOutputs();
}
Also used : SumUpOperator(io.dingodb.exec.operator.SumUpOperator) AggregateOperator(io.dingodb.exec.operator.AggregateOperator) SortOperator(io.dingodb.exec.operator.SortOperator) RootOperator(io.dingodb.exec.operator.RootOperator) PartScanOperator(io.dingodb.exec.operator.PartScanOperator) SendOperator(io.dingodb.exec.operator.SendOperator) ReceiveOperator(io.dingodb.exec.operator.ReceiveOperator) ProjectOperator(io.dingodb.exec.operator.ProjectOperator) ValuesOperator(io.dingodb.exec.operator.ValuesOperator) PartUpdateOperator(io.dingodb.exec.operator.PartUpdateOperator) ReduceOperator(io.dingodb.exec.operator.ReduceOperator) Operator(io.dingodb.exec.base.Operator) GetByKeysOperator(io.dingodb.exec.operator.GetByKeysOperator) PartitionOperator(io.dingodb.exec.operator.PartitionOperator) PartDeleteOperator(io.dingodb.exec.operator.PartDeleteOperator) PartInsertOperator(io.dingodb.exec.operator.PartInsertOperator) CoalesceOperator(io.dingodb.exec.operator.CoalesceOperator) Task(io.dingodb.exec.base.Task) Output(io.dingodb.exec.base.Output) ReduceOperator(io.dingodb.exec.operator.ReduceOperator) OutputHint(io.dingodb.exec.base.OutputHint)

Aggregations

Task (io.dingodb.exec.base.Task)18 Output (io.dingodb.exec.base.Output)12 ValuesOperator (io.dingodb.exec.operator.ValuesOperator)9 RootOperator (io.dingodb.exec.operator.RootOperator)8 SendOperator (io.dingodb.exec.operator.SendOperator)8 GetByKeysOperator (io.dingodb.exec.operator.GetByKeysOperator)7 PartScanOperator (io.dingodb.exec.operator.PartScanOperator)7 PartitionOperator (io.dingodb.exec.operator.PartitionOperator)7 ReceiveOperator (io.dingodb.exec.operator.ReceiveOperator)7 Location (io.dingodb.meta.Location)7 LinkedList (java.util.LinkedList)7 Operator (io.dingodb.exec.base.Operator)6 AggregateOperator (io.dingodb.exec.operator.AggregateOperator)6 CoalesceOperator (io.dingodb.exec.operator.CoalesceOperator)6 PartDeleteOperator (io.dingodb.exec.operator.PartDeleteOperator)6 PartInsertOperator (io.dingodb.exec.operator.PartInsertOperator)6 PartUpdateOperator (io.dingodb.exec.operator.PartUpdateOperator)6 ProjectOperator (io.dingodb.exec.operator.ProjectOperator)6 ReduceOperator (io.dingodb.exec.operator.ReduceOperator)6 SortOperator (io.dingodb.exec.operator.SortOperator)6