Search in sources :

Example 46 with RpcException

use of org.apache.drill.exec.rpc.RpcException in project drill by apache.

the class JdbcConnectTriesTestEmbeddedBits method testDirectConnectionConnectTriesLessThanDrillbitCount.

@Test
public void testDirectConnectionConnectTriesLessThanDrillbitCount() throws SQLException {
    Connection connection = null;
    try {
        connection = testDrillDriver.connect("jdbc:drill:drillbit=127.0.0.1:5000,127.0.0.1:5001;tries=1", 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 47 with RpcException

use of org.apache.drill.exec.rpc.RpcException 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 48 with RpcException

use of org.apache.drill.exec.rpc.RpcException in project drill by apache.

the class RuntimeFilterSink method route.

private void route(RuntimeFilterWritable srcRuntimeFilterWritable) {
    BitData.RuntimeFilterBDef runtimeFilterB = srcRuntimeFilterWritable.getRuntimeFilterBDef();
    int joinMajorId = runtimeFilterB.getMajorFragmentId();
    UserBitShared.QueryId queryId = runtimeFilterB.getQueryId();
    List<String> probeFields = runtimeFilterB.getProbeFieldsList();
    List<Integer> sizeInBytes = runtimeFilterB.getBloomFilterSizeInBytesList();
    long rfIdentifier = runtimeFilterB.getRfIdentifier();
    DrillBuf[] data = srcRuntimeFilterWritable.getData();
    List<CoordinationProtos.DrillbitEndpoint> scanNodeEps = joinMjId2probeScanEps.get(joinMajorId);
    int scanNodeSize = scanNodeEps.size();
    srcRuntimeFilterWritable.retainBuffers(scanNodeSize - 1);
    int scanNodeMjId = joinMjId2ScanMjId.get(joinMajorId);
    for (int minorId = 0; minorId < scanNodeEps.size(); minorId++) {
        BitData.RuntimeFilterBDef.Builder builder = BitData.RuntimeFilterBDef.newBuilder();
        for (String probeField : probeFields) {
            builder.addProbeFields(probeField);
        }
        BitData.RuntimeFilterBDef runtimeFilterBDef = builder.setQueryId(queryId).setMajorFragmentId(scanNodeMjId).setMinorFragmentId(minorId).setToForeman(false).setRfIdentifier(rfIdentifier).addAllBloomFilterSizeInBytes(sizeInBytes).build();
        RuntimeFilterWritable runtimeFilterWritable = new RuntimeFilterWritable(runtimeFilterBDef, data);
        CoordinationProtos.DrillbitEndpoint drillbitEndpoint = scanNodeEps.get(minorId);
        DataTunnel dataTunnel = drillbitContext.getDataConnectionsPool().getTunnel(drillbitEndpoint);
        Consumer<RpcException> exceptionConsumer = new Consumer<RpcException>() {

            @Override
            public void accept(final RpcException e) {
                logger.warn("fail to broadcast a runtime filter to the probe side scan node", e);
            }

            @Override
            public void interrupt(final InterruptedException e) {
                logger.warn("fail to broadcast a runtime filter to the probe side scan node", e);
            }
        };
        RpcOutcomeListener<BitData.AckWithCredit> statusHandler = new DataTunnelStatusHandler(exceptionConsumer, sendingAccountor);
        AccountingDataTunnel accountingDataTunnel = new AccountingDataTunnel(dataTunnel, sendingAccountor, statusHandler);
        accountingDataTunnel.sendRuntimeFilter(runtimeFilterWritable);
    }
}
Also used : AccountingDataTunnel(org.apache.drill.exec.ops.AccountingDataTunnel) Consumer(org.apache.drill.exec.ops.Consumer) RpcException(org.apache.drill.exec.rpc.RpcException) DrillBuf(io.netty.buffer.DrillBuf) AccountingDataTunnel(org.apache.drill.exec.ops.AccountingDataTunnel) DataTunnel(org.apache.drill.exec.rpc.data.DataTunnel) CoordinationProtos(org.apache.drill.exec.proto.CoordinationProtos) DataTunnelStatusHandler(org.apache.drill.exec.ops.DataTunnelStatusHandler) BitData(org.apache.drill.exec.proto.BitData) UserBitShared(org.apache.drill.exec.proto.UserBitShared)

Example 49 with RpcException

use of org.apache.drill.exec.rpc.RpcException in project drill by apache.

the class ConnectTriesPropertyTestClusterBits method testConnectFailureUsingZKWithOnlyFakeBits.

@Test
public void testConnectFailureUsingZKWithOnlyFakeBits() throws Exception {
    Properties props = new Properties();
    props.setProperty("tries", "3");
    // Test with Cluster Coordinator connection
    RemoteServiceSet localServiceSet = RemoteServiceSet.getLocalServiceSet();
    DrillClient client = new DrillClient(drillConfig, localServiceSet.getCoordinator());
    // Create couple of fake drillbit endpoints and register with cluster coordinator
    DrillbitEndpoint fakeEndPoint1 = DrillbitEndpoint.newBuilder().setAddress("127.0.0.1").setUserPort(5000).build();
    DrillbitEndpoint fakeEndPoint2 = DrillbitEndpoint.newBuilder().setAddress("127.0.0.1").setUserPort(5001).build();
    ClusterCoordinator.RegistrationHandle fakeEndPoint1Handle = localServiceSet.getCoordinator().register(fakeEndPoint1);
    ClusterCoordinator.RegistrationHandle fakeEndPoint2Handle = localServiceSet.getCoordinator().register(fakeEndPoint2);
    try {
        client.connect(props);
        fail();
    } catch (RpcException ex) {
        assertTrue(ex.getCause() instanceof ExecutionException);
        client.close();
    } finally {
        // Remove the fake drillbits from local cluster cordinator
        localServiceSet.getCoordinator().unregister(fakeEndPoint1Handle);
        localServiceSet.getCoordinator().unregister(fakeEndPoint2Handle);
    }
}
Also used : DrillbitEndpoint(org.apache.drill.exec.proto.CoordinationProtos.DrillbitEndpoint) RemoteServiceSet(org.apache.drill.exec.server.RemoteServiceSet) RpcException(org.apache.drill.exec.rpc.RpcException) ClusterCoordinator(org.apache.drill.exec.coord.ClusterCoordinator) Properties(java.util.Properties) ExecutionException(java.util.concurrent.ExecutionException) Test(org.junit.Test) BaseTest(org.apache.drill.test.BaseTest)

Example 50 with RpcException

use of org.apache.drill.exec.rpc.RpcException in project drill by apache.

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 {}", 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)

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