@Override public void onError(Exception e) { reply.completeExceptionally(e); } });
/** * Creates a new exceptionally complete response. * * @param cause the cause of failure */ public DefaultRpcResponse(Throwable cause) { requireNonNull(cause, "cause"); completeExceptionally(cause); }
@Override public boolean cancel(boolean mayInterruptIfRunning) { final boolean updated = !isDone() && completeExceptionally(new CancellationException()); return updated || isCancelled(); }
private static void handleException(ClientRequestContext ctx, DefaultRpcResponse reply, @Nullable ThriftReply rawResponseContent, Exception cause) { reply.completeExceptionally(cause); ctx.logBuilder().responseContent(reply, rawResponseContent); }
/** * Creates a new {@link RpcResponse} that is completed successfully or exceptionally based on the * completion of the specified {@link CompletionStage}. */ static RpcResponse from(CompletionStage<?> stage) { requireNonNull(stage, "stage"); final DefaultRpcResponse res = new DefaultRpcResponse(); stage.handle((value, cause) -> { if (cause != null) { res.completeExceptionally(cause); } else if (value instanceof RpcResponse) { ((RpcResponse) value).handle((rpcResponseResult, rpcResponseCause) -> { if (rpcResponseCause != null) { res.completeExceptionally(Exceptions.peel(rpcResponseCause)); } else { res.complete(rpcResponseResult); } return null; }); } else { res.complete(value); } return null; }); return res; }
private static void invoke( ServiceRequestContext ctx, Object impl, ThriftFunction func, List<Object> args, DefaultRpcResponse reply) { try { final TBase<?, ?> tArgs = func.newArgs(args); if (func.isAsync()) { invokeAsynchronously(impl, func, tArgs, reply); } else { invokeSynchronously(ctx, impl, func, tArgs, reply); } } catch (Throwable t) { reply.completeExceptionally(t); } }
private static void invokeSynchronously( ServiceRequestContext ctx, Object impl, ThriftFunction func, TBase<?, ?> args, DefaultRpcResponse reply) { final ProcessFunction<Object, TBase<?, ?>> f = func.syncFunc(); ctx.blockingTaskExecutor().execute(() -> { if (reply.isDone()) { // Closed already most likely due to timeout. return; } try { if (func.isOneWay()) { reply.complete(null); f.getResult(impl, args); } else { final TBase<?, ?> result = f.getResult(impl, args); reply.complete(func.getResult(result)); } } catch (Throwable t) { if (func.isOneWay()) { reply.complete(null); logOneWayFunctionFailure(ctx, t); } else { reply.completeExceptionally(t); } } }); }
reply.completeExceptionally(cause); return reply;
@Override public void onError(Exception e) { reply.completeExceptionally(e); } });
@Override public void onError(Exception e) { reply.completeExceptionally(e); } });
@Override public void onError(Exception e) { reply.completeExceptionally(e); } });
private static void handleException(ClientRequestContext ctx, DefaultRpcResponse reply, @Nullable ThriftReply rawResponseContent, Exception cause) { reply.completeExceptionally(cause); ctx.logBuilder().responseContent(reply, rawResponseContent); }
private static void handleException(ClientRequestContext ctx, DefaultRpcResponse reply, @Nullable ThriftReply rawResponseContent, Exception cause) { reply.completeExceptionally(cause); ctx.logBuilder().responseContent(reply, rawResponseContent); }
private static void handleException(ClientRequestContext ctx, DefaultRpcResponse reply, @Nullable ThriftReply rawResponseContent, Exception cause) { reply.completeExceptionally(cause); ctx.logBuilder().responseContent(reply, rawResponseContent); }
private static void handleException(RpcRequest req, DefaultRpcResponse res, Throwable cause) { final CentralDogmaException convertedCause = Converter.convert(cause); CentralDogmaExceptions.log(req.method(), convertedCause); res.completeExceptionally(convertedCause); } }
private static void handleException(RpcRequest req, DefaultRpcResponse res, Throwable cause) { final CentralDogmaException convertedCause = Converter.convert(cause); CentralDogmaExceptions.log(req.method(), convertedCause); res.completeExceptionally(convertedCause); } }
private static void handleException(RpcRequest req, DefaultRpcResponse res, Throwable cause) { final CentralDogmaException convertedCause = Converter.convert(cause); CentralDogmaExceptions.log(req.method(), convertedCause); res.completeExceptionally(convertedCause); } }
private static void invoke( ServiceRequestContext ctx, Object impl, ThriftFunction func, List<Object> args, DefaultRpcResponse reply) { try { final TBase<?, ?> tArgs = func.newArgs(args); if (func.isAsync()) { invokeAsynchronously(impl, func, tArgs, reply); } else { invokeSynchronously(ctx, impl, func, tArgs, reply); } } catch (Throwable t) { reply.completeExceptionally(t); } }
private static void invoke( ServiceRequestContext ctx, Object impl, ThriftFunction func, List<Object> args, DefaultRpcResponse reply) { try { final TBase<?, ?> tArgs = func.newArgs(args); if (func.isAsync()) { invokeAsynchronously(impl, func, tArgs, reply); } else { invokeSynchronously(ctx, impl, func, tArgs, reply); } } catch (Throwable t) { reply.completeExceptionally(t); } }
private static void invoke( ServiceRequestContext ctx, Object impl, ThriftFunction func, List<Object> args, DefaultRpcResponse reply) { try { final TBase<?, ?> tArgs = func.newArgs(args); if (func.isAsync()) { invokeAsynchronously(impl, func, tArgs, reply); } else { invokeSynchronously(ctx, impl, func, tArgs, reply); } } catch (Throwable t) { reply.completeExceptionally(t); } }