Search in sources :

Example 1 with NonRootFragmentManager

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

the class ControlMessageHandler method startNewFragment.

/**
 * Start a new fragment on this node. These fragments can be leaf or intermediate fragments
 * which are scheduled by remote or local Foreman node.
 * @param fragment
 * @throws UserRpcException
 */
public void startNewFragment(final PlanFragment fragment, final DrillbitContext drillbitContext) throws UserRpcException {
    logger.debug("Received remote fragment start instruction: {}", fragment);
    try {
        final FragmentContextImpl fragmentContext = new FragmentContextImpl(drillbitContext, fragment, drillbitContext.getFunctionImplementationRegistry());
        final FragmentStatusReporter statusReporter = new FragmentStatusReporter(fragmentContext);
        final FragmentExecutor fragmentExecutor = new FragmentExecutor(fragmentContext, fragment, statusReporter);
        // 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()) {
            bee.addFragmentRunner(fragmentExecutor);
        } else {
            // isIntermediate, store for incoming data.
            final NonRootFragmentManager manager = new NonRootFragmentManager(fragment, fragmentExecutor, statusReporter);
            drillbitContext.getWorkBus().addFragmentManager(manager);
        }
    } catch (final ExecutionSetupException ex) {
        throw new UserRpcException(drillbitContext.getEndpoint(), "Failed to create fragment context", ex);
    } 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 : ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException) NonRootFragmentManager(org.apache.drill.exec.work.fragment.NonRootFragmentManager) UserRpcException(org.apache.drill.exec.rpc.UserRpcException) FragmentStatusReporter(org.apache.drill.exec.work.fragment.FragmentStatusReporter) FragmentContextImpl(org.apache.drill.exec.ops.FragmentContextImpl) FragmentExecutor(org.apache.drill.exec.work.fragment.FragmentExecutor) UserRpcException(org.apache.drill.exec.rpc.UserRpcException) RpcException(org.apache.drill.exec.rpc.RpcException) ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException)

Example 2 with NonRootFragmentManager

use of org.apache.drill.exec.work.fragment.NonRootFragmentManager 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 3 with NonRootFragmentManager

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

the class FragmentsRunner method startLocalFragment.

/**
 * Start the locally assigned leaf or intermediate fragment
 *
 * @param fragment fragment
 */
private void startLocalFragment(final PlanFragment fragment) throws ExecutionSetupException {
    logger.debug("Received local fragment start instruction", fragment);
    final FragmentContextImpl fragmentContext = new FragmentContextImpl(drillbitContext, fragment, drillbitContext.getFunctionImplementationRegistry());
    final FragmentStatusReporter statusReporter = new FragmentStatusReporter(fragmentContext);
    final FragmentExecutor fragmentExecutor = new FragmentExecutor(fragmentContext, fragment, statusReporter);
    // 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()) {
        bee.addFragmentRunner(fragmentExecutor);
    } else {
        // isIntermediate, store for incoming data.
        final NonRootFragmentManager manager = new NonRootFragmentManager(fragment, fragmentExecutor, statusReporter);
        drillbitContext.getWorkBus().addFragmentManager(manager);
    }
}
Also used : NonRootFragmentManager(org.apache.drill.exec.work.fragment.NonRootFragmentManager) FragmentStatusReporter(org.apache.drill.exec.work.fragment.FragmentStatusReporter) FragmentContextImpl(org.apache.drill.exec.ops.FragmentContextImpl) FragmentExecutor(org.apache.drill.exec.work.fragment.FragmentExecutor)

Example 4 with NonRootFragmentManager

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

the class ControlMessageHandler method startNewFragment.

/**
 * Start a new fragment on this node. These fragments can be leaf or intermediate fragments
 * which are scheduled by remote or local Foreman node.
 * @param fragment
 * @throws UserRpcException
 */
private void startNewFragment(final PlanFragment fragment, final DrillbitContext drillbitContext) throws UserRpcException {
    logger.debug("Received remote fragment start instruction", fragment);
    try {
        final FragmentContextImpl fragmentContext = new FragmentContextImpl(drillbitContext, fragment, drillbitContext.getFunctionImplementationRegistry());
        final FragmentStatusReporter statusReporter = new FragmentStatusReporter(fragmentContext);
        final FragmentExecutor fragmentExecutor = new FragmentExecutor(fragmentContext, fragment, statusReporter);
        // 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()) {
            bee.addFragmentRunner(fragmentExecutor);
        } else {
            // isIntermediate, store for incoming data.
            final NonRootFragmentManager manager = new NonRootFragmentManager(fragment, fragmentExecutor, statusReporter);
            drillbitContext.getWorkBus().addFragmentManager(manager);
        }
    } catch (final ExecutionSetupException ex) {
        throw new UserRpcException(drillbitContext.getEndpoint(), "Failed to create fragment context", ex);
    } 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 : ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException) NonRootFragmentManager(org.apache.drill.exec.work.fragment.NonRootFragmentManager) UserRpcException(org.apache.drill.exec.rpc.UserRpcException) FragmentStatusReporter(org.apache.drill.exec.work.fragment.FragmentStatusReporter) FragmentContextImpl(org.apache.drill.exec.ops.FragmentContextImpl) FragmentExecutor(org.apache.drill.exec.work.fragment.FragmentExecutor) UserRpcException(org.apache.drill.exec.rpc.UserRpcException) RpcException(org.apache.drill.exec.rpc.RpcException) ExecutionSetupException(org.apache.drill.common.exceptions.ExecutionSetupException)

Aggregations

FragmentExecutor (org.apache.drill.exec.work.fragment.FragmentExecutor)4 FragmentStatusReporter (org.apache.drill.exec.work.fragment.FragmentStatusReporter)4 NonRootFragmentManager (org.apache.drill.exec.work.fragment.NonRootFragmentManager)4 FragmentContextImpl (org.apache.drill.exec.ops.FragmentContextImpl)3 RpcException (org.apache.drill.exec.rpc.RpcException)3 UserRpcException (org.apache.drill.exec.rpc.UserRpcException)3 ExecutionSetupException (org.apache.drill.common.exceptions.ExecutionSetupException)2 FragmentContext (org.apache.drill.exec.ops.FragmentContext)1 ControlTunnel (org.apache.drill.exec.rpc.control.ControlTunnel)1 DrillbitContext (org.apache.drill.exec.server.DrillbitContext)1