/** @return true if the call is done; otherwise, return false. */ boolean isDone() { final CallReturn r = invokeOnce(); LOG.debug("#{}: {}", getCallId(), r.getState()); switch (r.getState()) { case RETURNED: case EXCEPTION: asyncCallReturn.set(r); // the async call is done return true; case RETRY: invokeOnce(); break; case WAIT_RETRY: case ASYNC_CALL_IN_PROGRESS: case ASYNC_INVOKED: // nothing to do break; default: Preconditions.checkState(false); } return false; }
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { final boolean isRpc = isRpcInvocation(proxyDescriptor.getProxy()); final int callId = isRpc? Client.nextCallId(): RpcConstants.INVALID_CALL_ID; final Call call = newCall(method, args, isRpc, callId); while (true) { final CallReturn c = call.invokeOnce(); final CallReturn.State state = c.getState(); if (state == CallReturn.State.ASYNC_INVOKED) { return null; // return null for async calls } else if (c.getState() != CallReturn.State.RETRY) { return c.getReturnValue(); } } }
/** @return true if the call is done; otherwise, return false. */ boolean isDone() { final CallReturn r = invokeOnce(); LOG.debug("#{}: {}", getCallId(), r.getState()); switch (r.getState()) { case RETURNED: case EXCEPTION: asyncCallReturn.set(r); // the async call is done return true; case RETRY: invokeOnce(); break; case WAIT_RETRY: case ASYNC_CALL_IN_PROGRESS: case ASYNC_INVOKED: // nothing to do break; default: Preconditions.checkState(false); } return false; }
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { final boolean isRpc = isRpcInvocation(proxyDescriptor.getProxy()); final int callId = isRpc? Client.nextCallId(): RpcConstants.INVALID_CALL_ID; final Call call = newCall(method, args, isRpc, callId); while (true) { final CallReturn c = call.invokeOnce(); final CallReturn.State state = c.getState(); if (state == CallReturn.State.ASYNC_INVOKED) { return null; // return null for async calls } else if (c.getState() != CallReturn.State.RETRY) { return c.getReturnValue(); } } }