Search in sources :

Example 1 with InitializeFragments

use of org.apache.drill.exec.proto.BitControl.InitializeFragments in project drill by apache.

the class Foreman method sendRemoteFragments.

/**
   * Send all the remote fragments belonging to a single target drillbit in one request.
   *
   * @param assignment the drillbit assigned to these fragments
   * @param fragments the set of fragments
   * @param latch the countdown latch used to track the requests to all endpoints
   * @param fragmentSubmitFailures the submission failure counter used to track the requests to all endpoints
   */
private void sendRemoteFragments(final DrillbitEndpoint assignment, final Collection<PlanFragment> fragments, final CountDownLatch latch, final FragmentSubmitFailures fragmentSubmitFailures) {
    @SuppressWarnings("resource") final Controller controller = drillbitContext.getController();
    final InitializeFragments.Builder fb = InitializeFragments.newBuilder();
    for (final PlanFragment planFragment : fragments) {
        fb.addFragment(planFragment);
    }
    final InitializeFragments initFrags = fb.build();
    logger.debug("Sending remote fragments to \nNode:\n{} \n\nData:\n{}", assignment, initFrags);
    final FragmentSubmitListener listener = new FragmentSubmitListener(assignment, initFrags, latch, fragmentSubmitFailures);
    controller.getTunnel(assignment).sendFragments(listener, initFrags);
}
Also used : InitializeFragments(org.apache.drill.exec.proto.BitControl.InitializeFragments) Controller(org.apache.drill.exec.rpc.control.Controller) PlanFragment(org.apache.drill.exec.proto.BitControl.PlanFragment)

Example 2 with InitializeFragments

use of org.apache.drill.exec.proto.BitControl.InitializeFragments in project drill by axbaretto.

the class FragmentsRunner method sendRemoteFragments.

/**
 * Send all the remote fragments belonging to a single target drillbit in one request.
 *
 * @param assignment the drillbit assigned to these fragments
 * @param fragments the set of fragments
 * @param latch the countdown latch used to track the requests to all endpoints
 * @param fragmentSubmitFailures the submission failure counter used to track the requests to all endpoints
 */
private void sendRemoteFragments(final DrillbitEndpoint assignment, final Collection<PlanFragment> fragments, final CountDownLatch latch, final FragmentSubmitFailures fragmentSubmitFailures) {
    @SuppressWarnings("resource") final Controller controller = drillbitContext.getController();
    final InitializeFragments.Builder fb = InitializeFragments.newBuilder();
    for (final PlanFragment planFragment : fragments) {
        fb.addFragment(planFragment);
    }
    final InitializeFragments initFrags = fb.build();
    logger.debug("Sending remote fragments to node: {}\nData: {}", assignment, initFrags);
    final FragmentSubmitListener listener = new FragmentSubmitListener(assignment, initFrags, latch, fragmentSubmitFailures);
    controller.getTunnel(assignment).sendFragments(listener, initFrags);
}
Also used : InitializeFragments(org.apache.drill.exec.proto.BitControl.InitializeFragments) Controller(org.apache.drill.exec.rpc.control.Controller) PlanFragment(org.apache.drill.exec.proto.BitControl.PlanFragment)

Example 3 with InitializeFragments

use of org.apache.drill.exec.proto.BitControl.InitializeFragments in project drill by axbaretto.

the class ControlMessageHandler method handle.

@Override
public void handle(ControlConnection connection, int rpcType, ByteBuf pBody, ByteBuf dBody, ResponseSender sender) throws RpcException {
    if (RpcConstants.EXTRA_DEBUGGING) {
        logger.debug("Received bit com message of type {}", rpcType);
    }
    switch(rpcType) {
        case RpcType.REQ_CANCEL_FRAGMENT_VALUE:
            {
                final FragmentHandle handle = get(pBody, FragmentHandle.PARSER);
                cancelFragment(handle);
                sender.send(ControlRpcConfig.OK);
                break;
            }
        case RpcType.REQ_CUSTOM_VALUE:
            {
                final CustomMessage customMessage = get(pBody, CustomMessage.PARSER);
                sender.send(handlerRegistry.handle(customMessage, (DrillBuf) dBody));
                break;
            }
        case RpcType.REQ_RECEIVER_FINISHED_VALUE:
            {
                final FinishedReceiver finishedReceiver = get(pBody, FinishedReceiver.PARSER);
                receivingFragmentFinished(finishedReceiver);
                sender.send(ControlRpcConfig.OK);
                break;
            }
        case RpcType.REQ_FRAGMENT_STATUS_VALUE:
            bee.getContext().getWorkBus().statusUpdate(get(pBody, FragmentStatus.PARSER));
            // TODO: Support a type of message that has no response.
            sender.send(ControlRpcConfig.OK);
            break;
        case RpcType.REQ_QUERY_CANCEL_VALUE:
            {
                final QueryId queryId = get(pBody, QueryId.PARSER);
                if (bee.cancelForeman(queryId, null)) {
                    sender.send(ControlRpcConfig.OK);
                } else {
                    sender.send(ControlRpcConfig.FAIL);
                }
                break;
            }
        case RpcType.REQ_INITIALIZE_FRAGMENTS_VALUE:
            {
                final InitializeFragments fragments = get(pBody, InitializeFragments.PARSER);
                final DrillbitContext drillbitContext = bee.getContext();
                for (int i = 0; i < fragments.getFragmentCount(); i++) {
                    startNewFragment(fragments.getFragment(i), drillbitContext);
                }
                sender.send(ControlRpcConfig.OK);
                break;
            }
        case RpcType.REQ_QUERY_STATUS_VALUE:
            {
                final QueryId queryId = get(pBody, QueryId.PARSER);
                final Foreman foreman = bee.getForemanForQueryId(queryId);
                if (foreman == null) {
                    throw new RpcException("Query not running on node.");
                }
                final QueryProfile profile = foreman.getQueryManager().getQueryProfile();
                sender.send(new Response(RpcType.RESP_QUERY_STATUS, profile));
                break;
            }
        case RpcType.REQ_UNPAUSE_FRAGMENT_VALUE:
            {
                final FragmentHandle handle = get(pBody, FragmentHandle.PARSER);
                resumeFragment(handle);
                sender.send(ControlRpcConfig.OK);
                break;
            }
        default:
            throw new RpcException("Not yet supported.");
    }
}
Also used : DrillbitContext(org.apache.drill.exec.server.DrillbitContext) Response(org.apache.drill.exec.rpc.Response) QueryProfile(org.apache.drill.exec.proto.UserBitShared.QueryProfile) InitializeFragments(org.apache.drill.exec.proto.BitControl.InitializeFragments) QueryId(org.apache.drill.exec.proto.UserBitShared.QueryId) UserRpcException(org.apache.drill.exec.rpc.UserRpcException) RpcException(org.apache.drill.exec.rpc.RpcException) CustomMessage(org.apache.drill.exec.proto.BitControl.CustomMessage) FragmentHandle(org.apache.drill.exec.proto.ExecProtos.FragmentHandle) Foreman(org.apache.drill.exec.work.foreman.Foreman) FinishedReceiver(org.apache.drill.exec.proto.BitControl.FinishedReceiver)

Example 4 with InitializeFragments

use of org.apache.drill.exec.proto.BitControl.InitializeFragments in project drill by apache.

the class ControlMessageHandler method handle.

@Override
public void handle(ControlConnection connection, int rpcType, ByteBuf pBody, ByteBuf dBody, ResponseSender sender) throws RpcException {
    if (RpcConstants.EXTRA_DEBUGGING) {
        logger.debug("Received bit com message of type {}", rpcType);
    }
    switch(rpcType) {
        case RpcType.REQ_CANCEL_FRAGMENT_VALUE:
            {
                final FragmentHandle handle = get(pBody, FragmentHandle.PARSER);
                cancelFragment(handle);
                sender.send(ControlRpcConfig.OK);
                break;
            }
        case RpcType.REQ_CUSTOM_VALUE:
            {
                final CustomMessage customMessage = get(pBody, CustomMessage.PARSER);
                sender.send(handlerRegistry.handle(customMessage, (DrillBuf) dBody));
                break;
            }
        case RpcType.REQ_RECEIVER_FINISHED_VALUE:
            {
                final FinishedReceiver finishedReceiver = get(pBody, FinishedReceiver.PARSER);
                receivingFragmentFinished(finishedReceiver);
                sender.send(ControlRpcConfig.OK);
                break;
            }
        case RpcType.REQ_FRAGMENT_STATUS_VALUE:
            final FragmentStatus status = get(pBody, FragmentStatus.PARSER);
            requestFragmentStatus(status);
            // TODO: Support a type of message that has no response.
            sender.send(ControlRpcConfig.OK);
            break;
        case RpcType.REQ_QUERY_CANCEL_VALUE:
            {
                final QueryId queryId = get(pBody, QueryId.PARSER);
                final Ack cancelStatus = requestQueryCancel(queryId);
                if (cancelStatus.getOk()) {
                    sender.send(ControlRpcConfig.OK);
                } else {
                    sender.send(ControlRpcConfig.FAIL);
                }
                break;
            }
        case RpcType.REQ_INITIALIZE_FRAGMENTS_VALUE:
            {
                final InitializeFragments fragments = get(pBody, InitializeFragments.PARSER);
                initializeFragment(fragments);
                sender.send(ControlRpcConfig.OK);
                break;
            }
        case RpcType.REQ_QUERY_STATUS_VALUE:
            {
                final QueryId queryId = get(pBody, QueryId.PARSER);
                final QueryProfile profile = requestQueryStatus(queryId);
                sender.send(new Response(RpcType.RESP_QUERY_STATUS, profile));
                break;
            }
        case RpcType.REQ_UNPAUSE_FRAGMENT_VALUE:
            {
                final FragmentHandle handle = get(pBody, FragmentHandle.PARSER);
                resumeFragment(handle);
                sender.send(ControlRpcConfig.OK);
                break;
            }
        default:
            throw new RpcException("Not yet supported.");
    }
}
Also used : Response(org.apache.drill.exec.rpc.Response) QueryProfile(org.apache.drill.exec.proto.UserBitShared.QueryProfile) InitializeFragments(org.apache.drill.exec.proto.BitControl.InitializeFragments) QueryId(org.apache.drill.exec.proto.UserBitShared.QueryId) UserRpcException(org.apache.drill.exec.rpc.UserRpcException) RpcException(org.apache.drill.exec.rpc.RpcException) CustomMessage(org.apache.drill.exec.proto.BitControl.CustomMessage) Ack(org.apache.drill.exec.proto.GeneralRPCProtos.Ack) FragmentHandle(org.apache.drill.exec.proto.ExecProtos.FragmentHandle) FinishedReceiver(org.apache.drill.exec.proto.BitControl.FinishedReceiver) FragmentStatus(org.apache.drill.exec.proto.BitControl.FragmentStatus)

Example 5 with InitializeFragments

use of org.apache.drill.exec.proto.BitControl.InitializeFragments in project drill by apache.

the class FragmentsRunner method sendRemoteFragments.

/**
 * Send all the remote fragments belonging to a single target drillbit in one request. If the assignment
 * DrillbitEndpoint is local Drillbit then {@link Controller#getTunnel(DrillbitEndpoint)} takes care of submitting it
 * locally without actually creating a Control Connection to itself.
 *
 * @param assignment the drillbit assigned to these fragments
 * @param fragments the set of fragments
 * @param latch the countdown latch used to track the requests to all endpoints
 * @param fragmentSubmitFailures the submission failure counter used to track the requests to all endpoints
 */
private void sendRemoteFragments(final DrillbitEndpoint assignment, final Collection<PlanFragment> fragments, final CountDownLatch latch, final FragmentSubmitFailures fragmentSubmitFailures) {
    final Controller controller = drillbitContext.getController();
    final InitializeFragments.Builder fb = InitializeFragments.newBuilder();
    for (final PlanFragment planFragment : fragments) {
        fb.addFragment(planFragment);
    }
    final InitializeFragments initFrags = fb.build();
    logger.debug("Sending remote fragments to node: {}\nData: {}", assignment, initFrags);
    final FragmentSubmitListener listener = new FragmentSubmitListener(assignment, initFrags, latch, fragmentSubmitFailures);
    controller.getTunnel(assignment).sendFragments(listener, initFrags);
}
Also used : InitializeFragments(org.apache.drill.exec.proto.BitControl.InitializeFragments) Controller(org.apache.drill.exec.rpc.control.Controller) PlanFragment(org.apache.drill.exec.proto.BitControl.PlanFragment)

Aggregations

InitializeFragments (org.apache.drill.exec.proto.BitControl.InitializeFragments)5 PlanFragment (org.apache.drill.exec.proto.BitControl.PlanFragment)3 Controller (org.apache.drill.exec.rpc.control.Controller)3 CustomMessage (org.apache.drill.exec.proto.BitControl.CustomMessage)2 FinishedReceiver (org.apache.drill.exec.proto.BitControl.FinishedReceiver)2 FragmentHandle (org.apache.drill.exec.proto.ExecProtos.FragmentHandle)2 QueryId (org.apache.drill.exec.proto.UserBitShared.QueryId)2 QueryProfile (org.apache.drill.exec.proto.UserBitShared.QueryProfile)2 Response (org.apache.drill.exec.rpc.Response)2 RpcException (org.apache.drill.exec.rpc.RpcException)2 UserRpcException (org.apache.drill.exec.rpc.UserRpcException)2 FragmentStatus (org.apache.drill.exec.proto.BitControl.FragmentStatus)1 Ack (org.apache.drill.exec.proto.GeneralRPCProtos.Ack)1 DrillbitContext (org.apache.drill.exec.server.DrillbitContext)1 Foreman (org.apache.drill.exec.work.foreman.Foreman)1