Search in sources :

Example 31 with RpcException

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"));
}
Also used : RpcException(org.apache.drill.exec.rpc.RpcException) StringContains.containsString(org.hamcrest.core.StringContains.containsString)

Example 32 with RpcException

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.");
    }
}
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 33 with RpcException

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);
    }
}
Also used : SQLException(java.sql.SQLException) RpcException(org.apache.drill.exec.rpc.RpcException) Connection(java.sql.Connection) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test) JdbcTest(org.apache.drill.categories.JdbcTest)

Example 34 with RpcException

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);
}
Also used : RunQuery(org.apache.drill.exec.proto.UserProtos.RunQuery) RpcException(org.apache.drill.exec.rpc.RpcException) NonTransientRpcException(org.apache.drill.exec.rpc.NonTransientRpcException) ArrayNode(com.fasterxml.jackson.databind.node.ArrayNode) IOException(java.io.IOException) JsonProcessingException(com.fasterxml.jackson.core.JsonProcessingException) UserProtos(org.apache.drill.exec.proto.UserProtos) PlanFragment(org.apache.drill.exec.proto.BitControl.PlanFragment)

Example 35 with RpcException

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."));
}
Also used : RpcException(org.apache.drill.exec.rpc.RpcException)

Aggregations

RpcException (org.apache.drill.exec.rpc.RpcException)56 Test (org.junit.Test)22 ExecutionException (java.util.concurrent.ExecutionException)18 IOException (java.io.IOException)15 NonTransientRpcException (org.apache.drill.exec.rpc.NonTransientRpcException)12 Connection (java.sql.Connection)10 SQLException (java.sql.SQLException)10 JdbcTest (org.apache.drill.categories.JdbcTest)10 Response (org.apache.drill.exec.rpc.Response)9 Properties (java.util.Properties)8 SaslException (javax.security.sasl.SaslException)8 QueryId (org.apache.drill.exec.proto.UserBitShared.QueryId)8 UserException (org.apache.drill.common.exceptions.UserException)6 DrillBuf (io.netty.buffer.DrillBuf)5 JsonProcessingException (com.fasterxml.jackson.core.JsonProcessingException)4 ByteString (com.google.protobuf.ByteString)4 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)4 ByteBufInputStream (io.netty.buffer.ByteBufInputStream)4 DrillException (org.apache.drill.common.exceptions.DrillException)4 UserRemoteException (org.apache.drill.common.exceptions.UserRemoteException)4