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));
}
}
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));
}
}
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);
}
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.");
}
}
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);
}
Aggregations