Search in sources :

Example 11 with FragmentExecutor

use of org.apache.drill.exec.work.fragment.FragmentExecutor in project drill by apache.

the class ControlMessageHandler method cancelFragment.

/* (non-Javadoc)
   * @see org.apache.drill.exec.work.batch.BitComHandler#cancelFragment(org.apache.drill.exec.proto.ExecProtos.FragmentHandle)
   */
public Ack cancelFragment(final FragmentHandle handle) {
    /**
     * For case 1, see {@link org.apache.drill.exec.work.foreman.QueryManager#cancelExecutingFragments}.
     * In comments below, "active" refers to fragment states: SENDING, AWAITING_ALLOCATION, RUNNING and
     * "inactive" refers to FINISHED, CANCELLATION_REQUESTED, CANCELLED, FAILED
     */
    // Case 2: Cancel active intermediate fragment. Such a fragment will be in the work bus. Delegate cancel to the
    // work bus.
    final boolean removed = bee.getContext().getWorkBus().removeFragmentManager(handle, true);
    if (removed) {
        return Acks.OK;
    }
    // Case 3: Cancel active leaf fragment. Such a fragment will be with the worker bee if and only if it is running.
    // Cancel directly in this case.
    final FragmentExecutor runner = bee.getFragmentRunner(handle);
    if (runner != null) {
        runner.cancel();
        return Acks.OK;
    }
    // Other cases: Fragment completed or does not exist. Currently known cases:
    // (1) Leaf or intermediate fragment that is inactive: although we should not receive a cancellation
    // request; it is possible that before the fragment state was updated in the QueryManager, this handler
    // received a cancel signal.
    // (2) Unknown fragment.
    logger.warn("Dropping request to cancel fragment. {} does not exist.", QueryIdHelper.getQueryIdentifier(handle));
    return Acks.OK;
}
Also used : FragmentExecutor(org.apache.drill.exec.work.fragment.FragmentExecutor)

Example 12 with FragmentExecutor

use of org.apache.drill.exec.work.fragment.FragmentExecutor in project drill by apache.

the class ControlMessageHandler method resumeFragment.

public Ack resumeFragment(final FragmentHandle handle) {
    // resume a pending fragment
    final FragmentManager manager = bee.getContext().getWorkBus().getFragmentManager(handle);
    if (manager != null) {
        manager.unpause();
        return Acks.OK;
    }
    // resume a paused fragment
    final FragmentExecutor runner = bee.getFragmentRunner(handle);
    if (runner != null) {
        runner.unpause();
        return Acks.OK;
    }
    // fragment completed or does not exist
    logger.warn("Dropping request to resume fragment. {} does not exist.", QueryIdHelper.getQueryIdentifier(handle));
    return Acks.OK;
}
Also used : FragmentManager(org.apache.drill.exec.work.fragment.FragmentManager) NonRootFragmentManager(org.apache.drill.exec.work.fragment.NonRootFragmentManager) FragmentExecutor(org.apache.drill.exec.work.fragment.FragmentExecutor)

Aggregations

FragmentExecutor (org.apache.drill.exec.work.fragment.FragmentExecutor)12 NonRootFragmentManager (org.apache.drill.exec.work.fragment.NonRootFragmentManager)8 FragmentStatusReporter (org.apache.drill.exec.work.fragment.FragmentStatusReporter)7 FragmentContextImpl (org.apache.drill.exec.ops.FragmentContextImpl)5 RpcException (org.apache.drill.exec.rpc.RpcException)3 UserRpcException (org.apache.drill.exec.rpc.UserRpcException)3 FragmentManager (org.apache.drill.exec.work.fragment.FragmentManager)3 RootFragmentManager (org.apache.drill.exec.work.fragment.RootFragmentManager)3 ExecutionSetupException (org.apache.drill.common.exceptions.ExecutionSetupException)2 FragmentContext (org.apache.drill.exec.ops.FragmentContext)2 ControlTunnel (org.apache.drill.exec.rpc.control.ControlTunnel)2 DrillbitContext (org.apache.drill.exec.server.DrillbitContext)1 IncomingBuffers (org.apache.drill.exec.work.batch.IncomingBuffers)1