Search in sources :

Example 1 with RpcConnectionHandler

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

the class UserClient method connect.

private CheckedFuture<Void, RpcException> connect(final UserToBitHandshake handshake, final DrillbitEndpoint endpoint) {
    final SettableFuture<Void> connectionSettable = SettableFuture.create();
    final CheckedFuture<Void, RpcException> connectionFuture = new AbstractCheckedFuture<Void, RpcException>(connectionSettable) {

        @Override
        protected RpcException mapException(Exception e) {
            return RpcException.mapException(e);
        }
    };
    final RpcConnectionHandler<UserToBitConnection> connectionHandler = new RpcConnectionHandler<UserToBitConnection>() {

        @Override
        public void connectionSucceeded(UserToBitConnection connection) {
            connectionSettable.set(null);
        }

        @Override
        public void connectionFailed(FailureType type, Throwable t) {
            connectionSettable.setException(new RpcException(String.format("%s : %s", type.name(), t.getMessage()), t));
        }
    };
    connectAsClient(queryResultHandler.getWrappedConnectionHandler(connectionHandler), handshake, endpoint.getAddress(), endpoint.getUserPort());
    return connectionFuture;
}
Also used : RpcException(org.apache.drill.exec.rpc.RpcException) NonTransientRpcException(org.apache.drill.exec.rpc.NonTransientRpcException) AbstractCheckedFuture(com.google.common.util.concurrent.AbstractCheckedFuture) RpcConnectionHandler(org.apache.drill.exec.rpc.RpcConnectionHandler) RpcException(org.apache.drill.exec.rpc.RpcException) SaslException(javax.security.sasl.SaslException) NonTransientRpcException(org.apache.drill.exec.rpc.NonTransientRpcException) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Aggregations

AbstractCheckedFuture (com.google.common.util.concurrent.AbstractCheckedFuture)1 IOException (java.io.IOException)1 ExecutionException (java.util.concurrent.ExecutionException)1 SaslException (javax.security.sasl.SaslException)1 NonTransientRpcException (org.apache.drill.exec.rpc.NonTransientRpcException)1 RpcConnectionHandler (org.apache.drill.exec.rpc.RpcConnectionHandler)1 RpcException (org.apache.drill.exec.rpc.RpcException)1