public static ErrorMessage fromException(Throwable e) { return fromException(e, null); }
public static ErrorMessage fromException(Throwable e) { return fromException(e, null); }
public static ErrorMessage fromException(Throwable e) { return fromException(e, null); }
public static ErrorMessage fromException(Throwable e) { return fromException(e, null); }
@Override public void exceptionCaught(final ChannelHandlerContext ctx, Throwable cause) throws Exception { if (ctx.channel().isOpen()) { UnexpectedChannelExceptionHandler handler = new UnexpectedChannelExceptionHandler(ctx.channel(), false); ChannelFuture future = ctx.writeAndFlush(ErrorMessage.fromException(cause, handler)); // On protocol exception, close the channel as soon as the message have been sent if (cause instanceof ProtocolException) { future.addListener(new ChannelFutureListener() { public void operationComplete(ChannelFuture future) { ctx.close(); } }); } } } }
@Override public void exceptionCaught(final ChannelHandlerContext ctx, Throwable cause) { // Provide error message to client in case channel is still open UnexpectedChannelExceptionHandler handler = new UnexpectedChannelExceptionHandler(ctx.channel(), false); ErrorMessage errorMessage = ErrorMessage.fromException(cause, handler); if (ctx.channel().isOpen()) { ChannelFuture future = ctx.writeAndFlush(errorMessage); // On protocol exception, close the channel as soon as the message have been sent if (cause instanceof ProtocolException) { future.addListener(new ChannelFutureListener() { public void operationComplete(ChannelFuture future) { ctx.close(); } }); } } } }
@Override public void exceptionCaught(final ChannelHandlerContext ctx, Throwable cause) { // Provide error message to client in case channel is still open UnexpectedChannelExceptionHandler handler = new UnexpectedChannelExceptionHandler(ctx.channel(), false); ErrorMessage errorMessage = ErrorMessage.fromException(cause, handler); if (ctx.channel().isOpen()) { ChannelFuture future = ctx.writeAndFlush(errorMessage); // On protocol exception, close the channel as soon as the message have been sent if (cause instanceof ProtocolException) { future.addListener(new ChannelFutureListener() { public void operationComplete(ChannelFuture future) { ctx.close(); } }); } } } }
public Message.Response execute(QueryState state) { try { AuthenticatedUser user = DatabaseDescriptor.getAuthenticator().authenticate(credentials); state.getClientState().login(user); return new ReadyMessage(); } catch (AuthenticationException e) { return ErrorMessage.fromException(e); } }
public Message.Response execute(QueryState state, long queryStartNanoTime) { try { AuthenticatedUser user = DatabaseDescriptor.getAuthenticator().legacyAuthenticate(credentials); state.getClientState().login(user); AuthMetrics.instance.markSuccess(); } catch (AuthenticationException e) { AuthMetrics.instance.markFailure(); return ErrorMessage.fromException(e); } return new ReadyMessage(); }
public Message.Response execute(QueryState state, long queryStartNanoTime) { try { AuthenticatedUser user = DatabaseDescriptor.getAuthenticator().legacyAuthenticate(credentials); state.getClientState().login(user); AuthMetrics.instance.markSuccess(); } catch (AuthenticationException e) { AuthMetrics.instance.markFailure(); return ErrorMessage.fromException(e); } return new ReadyMessage(); }
public Message.Response execute(QueryState state, long queryStartNanoTime) { try { AuthenticatedUser user = DatabaseDescriptor.getAuthenticator().legacyAuthenticate(credentials); state.getClientState().login(user); AuthMetrics.instance.markSuccess(); } catch (AuthenticationException e) { AuthMetrics.instance.markFailure(); return ErrorMessage.fromException(e); } return new ReadyMessage(); }
@Override public void exceptionCaught(final ChannelHandlerContext ctx, Throwable cause) { // Provide error message to client in case channel is still open UnexpectedChannelExceptionHandler handler = new UnexpectedChannelExceptionHandler(ctx.channel(), false); ErrorMessage errorMessage = ErrorMessage.fromException(cause, handler); if (ctx.channel().isOpen()) { ChannelFuture future = ctx.writeAndFlush(errorMessage); // On protocol exception, close the channel as soon as the message have been sent if (cause instanceof ProtocolException) { future.addListener(new ChannelFutureListener() { public void operationComplete(ChannelFuture future) { ctx.close(); } }); } } } }
@Override public Response execute(QueryState queryState) { try { SaslAuthenticator authenticator = ((ServerConnection) connection).getAuthenticator(); byte[] challenge = authenticator.evaluateResponse(token == null ? new byte[0] : token); if (authenticator.isComplete()) { AuthenticatedUser user = authenticator.getAuthenticatedUser(); queryState.getClientState().login(user); // authentication is complete, send a ready message to the client return new AuthSuccess(challenge); } else { return new AuthChallenge(challenge); } } catch (AuthenticationException e) { return ErrorMessage.fromException(e); } } }
@Override public Response execute(QueryState queryState, long queryStartNanoTime) { try { IAuthenticator.SaslNegotiator negotiator = ((ServerConnection) connection).getSaslNegotiator(queryState); byte[] challenge = negotiator.evaluateResponse(token); if (negotiator.isComplete()) { AuthenticatedUser user = negotiator.getAuthenticatedUser(); queryState.getClientState().login(user); AuthMetrics.instance.markSuccess(); // authentication is complete, send a ready message to the client return new AuthSuccess(challenge); } else { return new AuthChallenge(challenge); } } catch (AuthenticationException e) { AuthMetrics.instance.markFailure(); return ErrorMessage.fromException(e); } } }
public Message.Response execute(QueryState state, long queryStartNanoTime) { try { UUID tracingId = null; if (isTracingRequested()) { tracingId = UUIDGen.getTimeUUID(); state.prepareTracingSession(tracingId); } if (state.traceNextQuery()) { state.createTracingSession(getCustomPayload()); Tracing.instance.begin("Preparing CQL3 query", state.getClientAddress(), ImmutableMap.of("query", query)); } Message.Response response = ClientState.getCQLQueryHandler().prepare(query, state, getCustomPayload()); if (tracingId != null) response.setTracingId(tracingId); return response; } catch (Exception e) { JVMStabilityInspector.inspectThrowable(e); return ErrorMessage.fromException(e); } finally { Tracing.instance.stopSession(); } }
@Override public void channelRead0(ChannelHandlerContext ctx, Request request) { final Response response; final ServerConnection connection; try { assert request.connection() instanceof ServerConnection; connection = (ServerConnection)request.connection(); QueryState qstate = connection.validateNewMessage(request.type, connection.getVersion(), request.getStreamId()); logger.debug("Received: {}, v={}", request, connection.getVersion()); response = request.execute(qstate); response.setStreamId(request.getStreamId()); response.attach(connection); connection.applyStateTransition(request.type, response.type); } catch (Throwable t) { JVMStabilityInspector.inspectThrowable(t); UnexpectedChannelExceptionHandler handler = new UnexpectedChannelExceptionHandler(ctx.channel(), true); flush(new FlushItem(ctx, ErrorMessage.fromException(t, handler).setStreamId(request.getStreamId()), request.getSourceFrame())); return; } logger.debug("Responding: {}, v={}", response, connection.getVersion()); flush(new FlushItem(ctx, response, request.getSourceFrame())); }
@Override public Response execute(QueryState queryState, long queryStartNanoTime) { try { IAuthenticator.SaslNegotiator negotiator = ((ServerConnection) connection).getSaslNegotiator(queryState); byte[] challenge = negotiator.evaluateResponse(token); if (negotiator.isComplete()) { AuthenticatedUser user = negotiator.getAuthenticatedUser(); queryState.getClientState().login(user); AuthMetrics.instance.markSuccess(); // authentication is complete, send a ready message to the client return new AuthSuccess(challenge); } else { return new AuthChallenge(challenge); } } catch (AuthenticationException e) { AuthMetrics.instance.markFailure(); return ErrorMessage.fromException(e); } } }
@Override public Response execute(QueryState queryState, long queryStartNanoTime) { try { IAuthenticator.SaslNegotiator negotiator = ((ServerConnection) connection).getSaslNegotiator(queryState); byte[] challenge = negotiator.evaluateResponse(token); if (negotiator.isComplete()) { AuthenticatedUser user = negotiator.getAuthenticatedUser(); queryState.getClientState().login(user); AuthMetrics.instance.markSuccess(); // authentication is complete, send a ready message to the client return new AuthSuccess(challenge); } else { return new AuthChallenge(challenge); } } catch (AuthenticationException e) { AuthMetrics.instance.markFailure(); return ErrorMessage.fromException(e); } } }
public Message.Response execute(QueryState state) { try { UUID tracingId = null; if (isTracingRequested()) { tracingId = UUIDGen.getTimeUUID(); state.prepareTracingSession(tracingId); } if (state.traceNextQuery()) { state.createTracingSession(); Tracing.instance.begin("Preparing CQL3 query", ImmutableMap.of("query", query)); } Message.Response response = state.getClientState().getCQLQueryHandler().prepare(query, state); if (tracingId != null) response.setTracingId(tracingId); return response; } catch (Exception e) { JVMStabilityInspector.inspectThrowable(e); return ErrorMessage.fromException(e); } finally { Tracing.instance.stopSession(); } }
public Message.Response execute(QueryState state, long queryStartNanoTime) { try { UUID tracingId = null; if (isTracingRequested()) { tracingId = UUIDGen.getTimeUUID(); state.prepareTracingSession(tracingId); } if (state.traceNextQuery()) { state.createTracingSession(getCustomPayload()); Tracing.instance.begin("Preparing CQL3 query", state.getClientAddress(), ImmutableMap.of("query", query)); } Message.Response response = ClientState.getCQLQueryHandler().prepare(query, state, getCustomPayload()); if (tracingId != null) response.setTracingId(tracingId); return response; } catch (Exception e) { JVMStabilityInspector.inspectThrowable(e); return ErrorMessage.fromException(e); } finally { Tracing.instance.stopSession(); } }