Search in sources :

Example 1 with ControlTunnel

use of org.apache.drill.exec.rpc.control.ControlTunnel in project drill by axbaretto.

the class FragmentStatusReporter method sendStatus.

/**
 * Sends status to remote Foreman node using Control Tunnel or to Local Foreman bypassing
 * Control Tunnel and using WorkEventBus.
 *
 * @param status
 */
void sendStatus(final FragmentStatus status) {
    DrillbitEndpoint foremanNode = foremanDrillbit.get();
    if (foremanNode == null) {
        logger.warn("{}: State {} is not reported as {} is closed", QueryIdHelper.getQueryIdentifier(context.getHandle()), status.getProfile().getState(), this);
        return;
    }
    if (localDrillbit.equals(foremanNode)) {
        // Update the status locally
        context.getWorkEventbus().statusUpdate(status);
    } else {
        // Send the status via Control Tunnel to remote foreman node
        final ControlTunnel tunnel = context.getController().getTunnel(foremanNode);
        tunnel.sendFragmentStatus(status);
    }
}
Also used : ControlTunnel(org.apache.drill.exec.rpc.control.ControlTunnel) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)

Example 2 with ControlTunnel

use of org.apache.drill.exec.rpc.control.ControlTunnel in project drill by apache.

the class Foreman method setupRootFragment.

/**
   * Set up the root fragment (which will run locally), and submit it for execution.
   *
   * @param rootFragment
   * @param rootOperator
   * @throws ExecutionSetupException
   */
private void setupRootFragment(final PlanFragment rootFragment, final FragmentRoot rootOperator) throws ExecutionSetupException {
    @SuppressWarnings("resource") final FragmentContext rootContext = new FragmentContext(drillbitContext, rootFragment, queryContext, initiatingClient, drillbitContext.getFunctionImplementationRegistry());
    @SuppressWarnings("resource") final IncomingBuffers buffers = new IncomingBuffers(rootFragment, rootContext);
    rootContext.setBuffers(buffers);
    queryManager.addFragmentStatusTracker(rootFragment, true);
    final ControlTunnel tunnel = drillbitContext.getController().getTunnel(queryContext.getCurrentEndpoint());
    final FragmentExecutor rootRunner = new FragmentExecutor(rootContext, rootFragment, new FragmentStatusReporter(rootContext, tunnel), rootOperator);
    final RootFragmentManager fragmentManager = new RootFragmentManager(rootFragment.getHandle(), buffers, rootRunner);
    if (buffers.isDone()) {
        // if we don't have to wait for any incoming data, start the fragment runner.
        bee.addFragmentRunner(fragmentManager.getRunnable());
    } else {
        // if we do, record the fragment manager in the workBus.
        drillbitContext.getWorkBus().addFragmentManager(fragmentManager);
    }
}
Also used : ControlTunnel(org.apache.drill.exec.rpc.control.ControlTunnel) IncomingBuffers(org.apache.drill.exec.work.batch.IncomingBuffers) FragmentContext(org.apache.drill.exec.ops.FragmentContext) FragmentStatusReporter(org.apache.drill.exec.work.fragment.FragmentStatusReporter) RootFragmentManager(org.apache.drill.exec.work.fragment.RootFragmentManager) FragmentExecutor(org.apache.drill.exec.work.fragment.FragmentExecutor)

Example 3 with ControlTunnel

use of org.apache.drill.exec.rpc.control.ControlTunnel in project drill by apache.

the class ControlMessageHandler method startNewRemoteFragment.

private void startNewRemoteFragment(final PlanFragment fragment) throws UserRpcException {
    logger.debug("Received remote fragment start instruction", fragment);
    final DrillbitContext drillbitContext = bee.getContext();
    try {
        // we either need to start the fragment if it is a leaf fragment, or set up a fragment manager if it is non leaf.
        if (fragment.getLeafFragment()) {
            final FragmentContext context = new FragmentContext(drillbitContext, fragment, drillbitContext.getFunctionImplementationRegistry());
            final ControlTunnel tunnel = drillbitContext.getController().getTunnel(fragment.getForeman());
            final FragmentStatusReporter statusReporter = new FragmentStatusReporter(context, tunnel);
            final FragmentExecutor fr = new FragmentExecutor(context, fragment, statusReporter);
            bee.addFragmentRunner(fr);
        } else {
            // isIntermediate, store for incoming data.
            final NonRootFragmentManager manager = new NonRootFragmentManager(fragment, drillbitContext);
            drillbitContext.getWorkBus().addFragmentManager(manager);
        }
    } catch (final Exception e) {
        throw new UserRpcException(drillbitContext.getEndpoint(), "Failure while trying to start remote fragment", e);
    } catch (final OutOfMemoryError t) {
        if (t.getMessage().startsWith("Direct buffer")) {
            throw new UserRpcException(drillbitContext.getEndpoint(), "Out of direct memory while trying to start remote fragment", t);
        } else {
            throw t;
        }
    }
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext) ControlTunnel(org.apache.drill.exec.rpc.control.ControlTunnel) NonRootFragmentManager(org.apache.drill.exec.work.fragment.NonRootFragmentManager) UserRpcException(org.apache.drill.exec.rpc.UserRpcException) FragmentContext(org.apache.drill.exec.ops.FragmentContext) FragmentStatusReporter(org.apache.drill.exec.work.fragment.FragmentStatusReporter) FragmentExecutor(org.apache.drill.exec.work.fragment.FragmentExecutor) UserRpcException(org.apache.drill.exec.rpc.UserRpcException) RpcException(org.apache.drill.exec.rpc.RpcException)

Example 4 with ControlTunnel

use of org.apache.drill.exec.rpc.control.ControlTunnel in project drill by apache.

the class FragmentStatusReporter method sendStatus.

/**
 * Sends status to remote Foreman node using Control Tunnel or to Local Foreman bypassing
 * Control Tunnel and using WorkEventBus.
 *
 * @param status
 */
void sendStatus(final FragmentStatus status) {
    DrillbitEndpoint foremanNode = foremanDrillbit.get();
    if (foremanNode == null) {
        logger.warn("{}: State {} is not reported as {} is closed", QueryIdHelper.getQueryIdentifier(context.getHandle()), status.getProfile().getState(), this);
        return;
    }
    // Send status for both local and remote foreman node via Tunnel. For local there won't be any network connection
    // created and it will be submitted locally using LocalControlConnectionManager
    final ControlTunnel tunnel = context.getController().getTunnel(foremanNode);
    tunnel.sendFragmentStatus(status);
}
Also used : ControlTunnel(org.apache.drill.exec.rpc.control.ControlTunnel) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)

Aggregations

ControlTunnel (org.apache.drill.exec.rpc.control.ControlTunnel)4 FragmentContext (org.apache.drill.exec.ops.FragmentContext)2 DrillbitEndpoint (org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)2 FragmentExecutor (org.apache.drill.exec.work.fragment.FragmentExecutor)2 FragmentStatusReporter (org.apache.drill.exec.work.fragment.FragmentStatusReporter)2 RpcException (org.apache.drill.exec.rpc.RpcException)1 UserRpcException (org.apache.drill.exec.rpc.UserRpcException)1 DrillbitContext (org.apache.drill.exec.server.DrillbitContext)1 IncomingBuffers (org.apache.drill.exec.work.batch.IncomingBuffers)1 NonRootFragmentManager (org.apache.drill.exec.work.fragment.NonRootFragmentManager)1 RootFragmentManager (org.apache.drill.exec.work.fragment.RootFragmentManager)1