Search in sources :

Example 1 with UserRpcException

use of org.apache.drill.exec.rpc.UserRpcException 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 2 with UserRpcException

use of org.apache.drill.exec.rpc.UserRpcException in project drill by apache.

the class CustomHandlerRegistry method handle.

public Response handle(CustomMessage message, DrillBuf dBody) throws RpcException {
    final ParsingHandler<?, ?> handler;
    try (AutoCloseableLock lock = read.open()) {
        handler = handlers.get(message.getType());
    }
    if (handler == null) {
        throw new UserRpcException(endpoint, "Unable to handle message.", new IllegalStateException(String.format("Unable to handle message. The message type provided [%d] did not have a registered handler.", message.getType())));
    }
    final CustomResponse<?> customResponse = handler.onMessage(message.getMessage(), dBody);
    @SuppressWarnings("unchecked") final CustomMessage responseMessage = CustomMessage.newBuilder().setMessage(ByteString.copyFrom(((Controller.CustomSerDe<Object>) handler.getResponseSerDe()).serializeToSend(customResponse.getMessage()))).setType(message.getType()).build();
    // make sure we don't pass in a null array.
    final ByteBuf[] dBodies = customResponse.getBodies() == null ? new DrillBuf[0] : customResponse.getBodies();
    return new Response(RpcType.RESP_CUSTOM, responseMessage, dBodies);
}
Also used : Response(org.apache.drill.exec.rpc.Response) CustomResponse(org.apache.drill.exec.rpc.control.Controller.CustomResponse) UserRpcException(org.apache.drill.exec.rpc.UserRpcException) AutoCloseableLock(org.apache.drill.common.concurrent.AutoCloseableLock) CustomMessage(org.apache.drill.exec.proto.BitControl.CustomMessage) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

UserRpcException (org.apache.drill.exec.rpc.UserRpcException)2 ByteBuf (io.netty.buffer.ByteBuf)1 AutoCloseableLock (org.apache.drill.common.concurrent.AutoCloseableLock)1 FragmentContext (org.apache.drill.exec.ops.FragmentContext)1 CustomMessage (org.apache.drill.exec.proto.BitControl.CustomMessage)1 Response (org.apache.drill.exec.rpc.Response)1 RpcException (org.apache.drill.exec.rpc.RpcException)1 ControlTunnel (org.apache.drill.exec.rpc.control.ControlTunnel)1 CustomResponse (org.apache.drill.exec.rpc.control.Controller.CustomResponse)1 DrillbitContext (org.apache.drill.exec.server.DrillbitContext)1 FragmentExecutor (org.apache.drill.exec.work.fragment.FragmentExecutor)1 FragmentStatusReporter (org.apache.drill.exec.work.fragment.FragmentStatusReporter)1 NonRootFragmentManager (org.apache.drill.exec.work.fragment.NonRootFragmentManager)1