void notifyError(Object error) { assert error != null; Throwable cause = error instanceof Throwable ? (Throwable) error : ((ErrorResponse) error).getCause(); switch (onException(cause)) { case THROW_EXCEPTION: notifyNormalResponse(cause, 0); break; case RETRY_INVOCATION: if (invokeCount < tryCount) { // we are below the tryCount, so lets retry handleRetry(cause); } else { // we can't retry anymore, so lets send the cause to the future. notifyNormalResponse(cause, 0); } break; default: throw new IllegalStateException("Unhandled ExceptionAction"); } }
void notifyError(Object error) { assert error != null; Throwable cause = error instanceof Throwable ? (Throwable) error : ((ErrorResponse) error).getCause(); switch (onException(cause)) { case THROW_EXCEPTION: notifyNormalResponse(cause, 0); break; case RETRY_INVOCATION: if (invokeCount < tryCount) { // we are below the tryCount, so lets retry handleRetry(cause); } else { // we can't retry anymore, so lets send the cause to the future. notifyNormalResponse(cause, 0); } break; default: throw new IllegalStateException("Unhandled ExceptionAction"); } }
void notifyNormalResponse(long callId, Object value, int backupCount, Address sender) { responsesNormal.inc(); Invocation invocation = invocationRegistry.get(callId); if (invocation == null) { responsesMissing.inc(); if (nodeEngine.isRunning()) { logger.warning("No Invocation found for normal response with callId=" + callId + " sent from " + sender); } return; } invocation.notifyNormalResponse(value, backupCount); }
@Override public void sendResponse(Operation op, Object response) { if (!RESPONSE_RECEIVED.compareAndSet(this, FALSE, TRUE)) { throw new ResponseAlreadySentException("NormalResponse already responseReceived for callback: " + this + ", current-response: " + response); } if (response instanceof CallTimeoutResponse) { notifyCallTimeout(); } else if (response instanceof ErrorResponse || response instanceof Throwable) { notifyError(response); } else if (response instanceof NormalResponse) { NormalResponse normalResponse = (NormalResponse) response; notifyNormalResponse(normalResponse.getValue(), normalResponse.getBackupAcks()); } else { // there are no backups or the number of expected backups has returned; so signal the future that the result is ready complete(response); } }
void notifyNormalResponse(long callId, Object value, int backupCount, Address sender) { responsesNormal.inc(); Invocation invocation = invocationRegistry.get(callId); if (invocation == null) { responsesMissing.inc(); if (nodeEngine.isRunning()) { logger.warning("No Invocation found for normal response with callId=" + callId + " sent from " + sender); } return; } invocation.notifyNormalResponse(value, backupCount); }
@Override public void sendResponse(Operation op, Object response) { if (!RESPONSE_RECEIVED.compareAndSet(this, FALSE, TRUE)) { throw new ResponseAlreadySentException("NormalResponse already responseReceived for callback: " + this + ", current-response: " + response); } if (response instanceof CallTimeoutResponse) { notifyCallTimeout(); } else if (response instanceof ErrorResponse || response instanceof Throwable) { notifyError(response); } else if (response instanceof NormalResponse) { NormalResponse normalResponse = (NormalResponse) response; notifyNormalResponse(normalResponse.getValue(), normalResponse.getBackupAcks()); } else { // there are no backups or the number of expected backups has returned; so signal the future that the result is ready complete(response); } }