@Override public boolean cancel(boolean mayInterruptIfRunning) { final boolean updated = !isDone() && completeExceptionally(new CancellationException()); return updated || isCancelled(); }
@Override public String toString() { if (isDone()) { if (isCompletedExceptionally()) { return MoreObjects.toStringHelper(this) .add("cause", cause).toString(); } else { return MoreObjects.toStringHelper(this) .addValue(getNow(null)).toString(); } } final int count = getNumberOfDependents(); if (count == 0) { return MoreObjects.toStringHelper(this) .addValue("not completed").toString(); } else { return MoreObjects.toStringHelper(this) .addValue("not completed") .add("dependents", count).toString(); } } }
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); } } }); }
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 { final TBase<?, ?> result = f.getResult(impl, args); if (func.isOneWay()) { reply.complete(null); } else { reply.complete(func.getResult(result)); } } 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); } } }); }
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); } } }); }