use of io.trino.execution.executor.TaskHandle in project trino by trinodb.
the class SqlTaskExecution method createTaskHandle.
// this is a separate method to ensure that the `this` reference is not leaked during construction
private static TaskHandle createTaskHandle(TaskStateMachine taskStateMachine, TaskContext taskContext, OutputBuffer outputBuffer, LocalExecutionPlan localExecutionPlan, TaskExecutor taskExecutor) {
TaskHandle taskHandle = taskExecutor.addTask(taskStateMachine.getTaskId(), outputBuffer::getUtilization, getInitialSplitsPerNode(taskContext.getSession()), getSplitConcurrencyAdjustmentInterval(taskContext.getSession()), getMaxDriversPerTask(taskContext.getSession()));
taskStateMachine.addStateChangeListener(state -> {
if (state.isDone()) {
taskExecutor.removeTask(taskHandle);
for (DriverFactory factory : localExecutionPlan.getDriverFactories()) {
factory.noMoreDrivers();
}
}
});
return taskHandle;
}
Aggregations