use of org.apache.drill.exec.rpc.RpcException in project drill by apache.
the class TestCustomUserAuthenticator method negativeAuthHelper.
private static void negativeAuthHelper(final String user, final String password) throws Exception {
RpcException negativeAuthEx = null;
try {
runTest(user, password);
} catch (RpcException e) {
negativeAuthEx = e;
}
assertNotNull("Expected RpcException.", negativeAuthEx);
final String exMsg = negativeAuthEx.getMessage();
assertThat(exMsg, containsString("Authentication failed"));
assertThat(exMsg, containsString("Incorrect credentials"));
}
use of org.apache.drill.exec.rpc.RpcException 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.");
}
}
use of org.apache.drill.exec.rpc.RpcException in project drill by axbaretto.
the class JdbcConnectTriesTestEmbeddedBits method testDirectConnectionConnectTriesEqualsDrillbitCount.
@Test
public void testDirectConnectionConnectTriesEqualsDrillbitCount() throws SQLException {
Connection connection = null;
try {
connection = testDrillDriver.connect("jdbc:drill:drillbit=127.0.0.1:5000,127.0.0.1:5001;" + "tries=2", getDefaultProperties());
fail();
} catch (SQLException ex) {
assertNull(connection);
assertTrue(ex.getCause() instanceof RpcException);
assertTrue(ex.getCause().getCause() instanceof ExecutionException);
}
}
use of org.apache.drill.exec.rpc.RpcException in project drill by axbaretto.
the class DrillClient method runQuery.
/**
* Run query based on list of fragments that were supposedly produced during query planning phase. Supported
* query type is {@link QueryType#EXECUTION}
* @param type
* @param planFragments
* @param resultsListener
* @throws RpcException
*/
public void runQuery(QueryType type, List<PlanFragment> planFragments, UserResultsListener resultsListener) throws RpcException {
// QueryType can be only executional
checkArgument((QueryType.EXECUTION == type), "Only EXECUTION type query is supported with PlanFragments");
// setting Plan on RunQuery will be used for logging purposes and therefore can not be null
// since there is no Plan string provided we will create a JsonArray out of individual fragment Plans
ArrayNode jsonArray = objectMapper.createArrayNode();
for (PlanFragment fragment : planFragments) {
try {
jsonArray.add(objectMapper.readTree(fragment.getFragmentJson()));
} catch (IOException e) {
logger.error("Exception while trying to read PlanFragment JSON for %s", fragment.getHandle().getQueryId(), e);
throw new RpcException(e);
}
}
final String fragmentsToJsonString;
try {
fragmentsToJsonString = objectMapper.writeValueAsString(jsonArray);
} catch (JsonProcessingException e) {
logger.error("Exception while trying to get JSONString from Array of individual Fragments Json for %s", e);
throw new RpcException(e);
}
final UserProtos.RunQuery query = newBuilder().setType(type).addAllFragments(planFragments).setPlan(fragmentsToJsonString).setResultsMode(STREAM_FULL).build();
client.submitQuery(resultsListener, query);
}
use of org.apache.drill.exec.rpc.RpcException in project drill by axbaretto.
the class StatusHandler method success.
@Override
public void success(Ack value, ByteBuf buffer) {
sendingAccountor.decrement();
if (value.getOk()) {
return;
}
logger.error("Data not accepted downstream. Stopping future sends.");
// if we didn't get ack ok, we'll need to kill the query.
consumer.accept(new RpcException("Data not accepted downstream."));
}
Aggregations