Search in sources :

Example 16 with Response

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

the class ServerAuthenticationHandler method handleAuthFailure.

private static <S extends ServerConnection<S>, T extends EnumLite> void handleAuthFailure(final S connection, final ResponseSender sender, final Exception e, final T saslResponseType) throws RpcException {
    final String remoteAddress = connection.getRemoteAddress().toString();
    logger.debug("Authentication using mechanism {} with encryption context {} failed from client {} due to {}", connection.getSaslServer().getMechanismName(), connection.getEncryptionCtxtString(), remoteAddress, e);
    // inform the client that authentication failed, and no more
    sender.send(new Response(saslResponseType, SASL_FAILED_MESSAGE));
    // drop connection
    throw new RpcException(e);
}
Also used : Response(org.apache.drill.exec.rpc.Response) RpcException(org.apache.drill.exec.rpc.RpcException) ByteString(com.google.protobuf.ByteString)

Example 17 with Response

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

the class CustomHandlerRegistry method handle.

public Response handle(CustomMessage message, DrillBuf dBody) throws RpcException {
    final ParsingHandler<?, ?> handler;
    try (@SuppressWarnings("unused") Closeable lock = read.open()) {
        handler = handlers.get(message.getType());
    }
    if (handler == null) {
        throw new UserRpcException(endpoint, "Unable to handle message.", new IllegalStateException(String.format("Unable to handle message. The message type provided [%d] did not have a registered handler.", message.getType())));
    }
    final CustomResponse<?> customResponse = handler.onMessage(message.getMessage(), dBody);
    @SuppressWarnings("unchecked") final CustomMessage responseMessage = CustomMessage.newBuilder().setMessage(ByteString.copyFrom(((Controller.CustomSerDe<Object>) handler.getResponseSerDe()).serializeToSend(customResponse.getMessage()))).setType(message.getType()).build();
    // make sure we don't pass in a null array.
    final ByteBuf[] dBodies = customResponse.getBodies() == null ? new DrillBuf[0] : customResponse.getBodies();
    return new Response(RpcType.RESP_CUSTOM, responseMessage, dBodies);
}
Also used : Response(org.apache.drill.exec.rpc.Response) CustomResponse(org.apache.drill.exec.rpc.control.Controller.CustomResponse) UserRpcException(org.apache.drill.exec.rpc.UserRpcException) Closeable(org.apache.drill.common.AutoCloseables.Closeable) CustomMessage(org.apache.drill.exec.proto.BitControl.CustomMessage) ByteBuf(io.netty.buffer.ByteBuf)

Aggregations

Response (org.apache.drill.exec.rpc.Response)17 RpcException (org.apache.drill.exec.rpc.RpcException)9 ByteString (com.google.protobuf.ByteString)4 CustomMessage (org.apache.drill.exec.proto.BitControl.CustomMessage)4 Ack (org.apache.drill.exec.proto.GeneralRPCProtos.Ack)4 QueryId (org.apache.drill.exec.proto.UserBitShared.QueryId)4 UserRpcException (org.apache.drill.exec.rpc.UserRpcException)4 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)2 ByteBuf (io.netty.buffer.ByteBuf)2 ByteBufInputStream (io.netty.buffer.ByteBufInputStream)2 IOException (java.io.IOException)2 SaslException (javax.security.sasl.SaslException)2 Closeable (org.apache.drill.common.AutoCloseables.Closeable)2 FragmentSetupException (org.apache.drill.exec.exception.FragmentSetupException)2 FinishedReceiver (org.apache.drill.exec.proto.BitControl.FinishedReceiver)2 InitializeFragments (org.apache.drill.exec.proto.BitControl.InitializeFragments)2 BitData (org.apache.drill.exec.proto.BitData)2 FragmentRecordBatch (org.apache.drill.exec.proto.BitData.FragmentRecordBatch)2 FragmentHandle (org.apache.drill.exec.proto.ExecProtos.FragmentHandle)2 QueryProfile (org.apache.drill.exec.proto.UserBitShared.QueryProfile)2