Search in sources :

Example 1 with FragmentState

use of org.apache.drill.exec.proto.UserBitShared.FragmentState in project drill by apache.

the class QueryManager method updateFragmentStatus.

private boolean updateFragmentStatus(final FragmentStatus fragmentStatus) {
    final FragmentHandle fragmentHandle = fragmentStatus.getHandle();
    final int majorFragmentId = fragmentHandle.getMajorFragmentId();
    final int minorFragmentId = fragmentHandle.getMinorFragmentId();
    final FragmentData data = fragmentDataMap.get(majorFragmentId).get(minorFragmentId);
    final FragmentState oldState = data.getState();
    final boolean inTerminalState = isTerminal(oldState);
    final FragmentState currentState = fragmentStatus.getProfile().getState();
    if (inTerminalState || (oldState == FragmentState.CANCELLATION_REQUESTED && !isTerminal(currentState))) {
        // Already in a terminal state, or invalid state transition from CANCELLATION_REQUESTED. This shouldn't happen.
        logger.warn(String.format("Received status message for fragment %s after fragment was in state %s. New state was %s", QueryIdHelper.getQueryIdentifier(fragmentHandle), oldState, currentState));
        return false;
    }
    data.setStatus(fragmentStatus);
    return oldState != currentState;
}
Also used : FragmentState(org.apache.drill.exec.proto.UserBitShared.FragmentState) FragmentHandle(org.apache.drill.exec.proto.ExecProtos.FragmentHandle) DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)

Example 2 with FragmentState

use of org.apache.drill.exec.proto.UserBitShared.FragmentState in project drill by apache.

the class FragmentExecutor method sendFinalState.

private void sendFinalState() {
    final FragmentState outcome = fragmentState.get();
    if (outcome == FragmentState.FAILED) {
        final FragmentHandle handle = getContext().getHandle();
        final UserException uex = UserException.systemError(deferredException.getAndClear()).addIdentity(getContext().getIdentity()).addContext("Fragment", handle.getMajorFragmentId() + ":" + handle.getMinorFragmentId()).build(logger);
        statusReporter.fail(uex);
    } else {
        statusReporter.stateChanged(outcome);
    }
}
Also used : FragmentState(org.apache.drill.exec.proto.UserBitShared.FragmentState) FragmentHandle(org.apache.drill.exec.proto.ExecProtos.FragmentHandle) UserException(org.apache.drill.common.exceptions.UserException)

Example 3 with FragmentState

use of org.apache.drill.exec.proto.UserBitShared.FragmentState in project drill by apache.

the class FragmentExecutor method updateState.

private synchronized boolean updateState(FragmentState target) {
    final FragmentState current = fragmentState.get();
    logger.info(fragmentName + ": State change requested {} --> {}", current, target);
    switch(target) {
        case CANCELLATION_REQUESTED:
            switch(current) {
                case SENDING:
                case AWAITING_ALLOCATION:
                case RUNNING:
                    fragmentState.set(target);
                    statusReporter.stateChanged(target);
                    return true;
                default:
                    warnStateChange(current, target);
                    return false;
            }
        case FINISHED:
            if (current == FragmentState.CANCELLATION_REQUESTED) {
                target = FragmentState.CANCELLED;
            } else if (current == FragmentState.FAILED) {
                target = FragmentState.FAILED;
            }
        // fall-through
        case FAILED:
            if (!isTerminal(current)) {
                fragmentState.set(target);
                // don't notify reporter until we finalize this terminal state.
                return true;
            } else if (current == FragmentState.FAILED) {
                // no warn since we can call fail multiple times.
                return false;
            } else if (current == FragmentState.CANCELLED && target == FragmentState.FAILED) {
                fragmentState.set(FragmentState.FAILED);
                return true;
            } else {
                warnStateChange(current, target);
                return false;
            }
        case RUNNING:
            if (current == FragmentState.AWAITING_ALLOCATION) {
                fragmentState.set(target);
                statusReporter.stateChanged(target);
                return true;
            } else {
                errorStateChange(current, target);
            }
        // these should never be requested.
        case CANCELLED:
        case SENDING:
        case AWAITING_ALLOCATION:
        default:
            errorStateChange(current, target);
    }
    // errorStateChange() throw should mean this is never executed
    throw new IllegalStateException();
}
Also used : FragmentState(org.apache.drill.exec.proto.UserBitShared.FragmentState)

Aggregations

FragmentState (org.apache.drill.exec.proto.UserBitShared.FragmentState)3 FragmentHandle (org.apache.drill.exec.proto.ExecProtos.FragmentHandle)2 UserException (org.apache.drill.common.exceptions.UserException)1 DrillbitEndpoint (org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint)1