Search in sources :

Example 1 with FragmentStatus

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

the class FragmentStatusReporter method stateChanged.

/**
 * Reports the state change to the Foreman. The state is wrapped in a {@link FragmentStatus} that has additional
 * information like metrics, etc. This additional information is gathered from the {@link ExecutorFragmentContext}.
 * NOTE: Use {@link #fail} to report state change to {@link FragmentState#FAILED}.
 *
 * @param newState the new state
 */
void stateChanged(final FragmentState newState) {
    final FragmentStatus status = getStatus(newState, null);
    logger.info("{}: State to report: {}", QueryIdHelper.getQueryIdentifier(context.getHandle()), newState);
    switch(newState) {
        case AWAITING_ALLOCATION:
        case CANCELLATION_REQUESTED:
        case CANCELLED:
        case FINISHED:
        case RUNNING:
            sendStatus(status);
            break;
        case SENDING:
            // no op.
            break;
        case FAILED:
        // shouldn't get here since fail() should be called.
        default:
            throw new IllegalStateException(String.format("Received state changed event for unexpected state of %s.", newState));
    }
}
Also used : FragmentStatus(org.apache.drill.exec.proto.BitControl.FragmentStatus)

Example 2 with FragmentStatus

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

the class FragmentStatusReporter method stateChanged.

/**
 * Reports the state change to the Foreman. The state is wrapped in a {@link FragmentStatus} that has additional
 * information like metrics, etc. This additional information is gathered from the {@link ExecutorFragmentContext}.
 * NOTE: Use {@link #fail} to report state change to {@link FragmentState#FAILED}.
 *
 * @param newState the new state
 */
void stateChanged(final FragmentState newState) {
    final FragmentStatus status = getStatus(newState, null);
    logger.info("{}: State to report: {}", QueryIdHelper.getQueryIdentifier(context.getHandle()), newState);
    switch(newState) {
        case AWAITING_ALLOCATION:
        case CANCELLATION_REQUESTED:
        case CANCELLED:
        case FINISHED:
        case RUNNING:
            sendStatus(status);
            break;
        case SENDING:
            // no op.
            break;
        case FAILED:
        // shouldn't get here since fail() should be called.
        default:
            throw new IllegalStateException(String.format("Received state changed event for unexpected state of %s.", newState));
    }
}
Also used : FragmentStatus(org.apache.drill.exec.proto.BitControl.FragmentStatus)

Example 3 with FragmentStatus

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

the class FragmentStatusReporter method fail.

/**
 * {@link FragmentStatus} with the {@link FragmentState#FAILED} state is reported to the Foreman. The
 * {@link FragmentStatus} has additional information like metrics, etc. that is gathered from the
 * {@link ExecutorFragmentContext}.
 *
 * @param ex the exception related to the failure
 */
void fail(final UserException ex) {
    final FragmentStatus status = getStatus(FragmentState.FAILED, ex);
    sendStatus(status);
}
Also used : FragmentStatus(org.apache.drill.exec.proto.BitControl.FragmentStatus)

Example 4 with FragmentStatus

use of org.apache.drill.exec.proto.BitControl.FragmentStatus 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 FragmentStatus

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

the class FragmentStatusReporter method fail.

/**
 * {@link FragmentStatus} with the {@link FragmentState#FAILED} state is reported to the Foreman. The
 * {@link FragmentStatus} has additional information like metrics, etc. that is gathered from the
 * {@link ExecutorFragmentContext}.
 *
 * @param ex the exception related to the failure
 */
void fail(final UserException ex) {
    final FragmentStatus status = getStatus(FragmentState.FAILED, ex);
    sendStatus(status);
}
Also used : FragmentStatus(org.apache.drill.exec.proto.BitControl.FragmentStatus)

Aggregations

FragmentStatus (org.apache.drill.exec.proto.BitControl.FragmentStatus)5 CustomMessage (org.apache.drill.exec.proto.BitControl.CustomMessage)1 FinishedReceiver (org.apache.drill.exec.proto.BitControl.FinishedReceiver)1 InitializeFragments (org.apache.drill.exec.proto.BitControl.InitializeFragments)1 FragmentHandle (org.apache.drill.exec.proto.ExecProtos.FragmentHandle)1 Ack (org.apache.drill.exec.proto.GeneralRPCProtos.Ack)1 QueryId (org.apache.drill.exec.proto.UserBitShared.QueryId)1 QueryProfile (org.apache.drill.exec.proto.UserBitShared.QueryProfile)1 Response (org.apache.drill.exec.rpc.Response)1 RpcException (org.apache.drill.exec.rpc.RpcException)1 UserRpcException (org.apache.drill.exec.rpc.UserRpcException)1