@Override protected void onComplete() { callIdSequence.complete(); }
@Override protected void onComplete() { callIdSequence.complete(); }
@Override public void onFailure(Throwable t) { try { callback.onFailure(t); } finally { callIdSequence.complete(); } } }
@Override public void onResponse(ClientMessage message) { try { callback.onResponse(message); } finally { callIdSequence.complete(); } }
@Override public void onResponse(ClientMessage message) { try { callback.onResponse(message); } finally { callIdSequence.complete(); } }
@Override public void onFailure(Throwable t) { try { callback.onFailure(t); } finally { callIdSequence.complete(); } } }
/** * Deregisters an invocation. If the associated operation is inactive, takes no action and returns {@code false}. * This ensures the idempotency of deregistration. * * @param invocation The Invocation to deregister. * @return {@code true} if this call deregistered the invocation; {@code false} if the invocation wasn't registered */ public boolean deregister(Invocation invocation) { if (!deactivate(invocation.op)) { return false; } invocations.remove(invocation.op.getCallId()); callIdSequence.complete(); return true; }
/** * Deregisters an invocation. If the associated operation is inactive, takes no action and returns {@code false}. * This ensures the idempotency of deregistration. * * @param invocation The Invocation to deregister. * @return {@code true} if this call deregistered the invocation; {@code false} if the invocation wasn't registered */ public boolean deregister(Invocation invocation) { if (!deactivate(invocation.op)) { return false; } invocations.remove(invocation.op.getCallId()); callIdSequence.complete(); return true; }
private void retry() { // retry modifies the client message and should not reuse the client message. // It could be the case that it is in write queue of the connection. clientMessage = clientMessage.copy(); // first we force a new invocation slot because we are going to return our old invocation slot immediately after // It is important that we first 'force' taking a new slot; otherwise it could be that a sneaky invocation gets // through that takes our slot! clientMessage.setCorrelationId(callIdSequence.forceNext()); //we release the old slot callIdSequence.complete(); try { invokeOnSelection(); } catch (Throwable e) { clientInvocationFuture.complete(e); } }
private void retry() { // retry modifies the client message and should not reuse the client message. // It could be the case that it is in write queue of the connection. clientMessage = clientMessage.copy(); // first we force a new invocation slot because we are going to return our old invocation slot immediately after // It is important that we first 'force' taking a new slot; otherwise it could be that a sneaky invocation gets // through that takes our slot! clientMessage.setCorrelationId(callIdSequence.forceNext()); //we release the old slot callIdSequence.complete(); try { invokeOnSelection(); } catch (Throwable e) { clientInvocationFuture.complete(e); } }
/** * Registers an invocation. * * @param invocation The invocation to register. * @return {@code false} when InvocationRegistry is not alive and registration is not successful, {@code true} otherwise */ public boolean register(Invocation invocation) { final long callId; boolean force = invocation.op.isUrgent() || invocation.isRetryCandidate(); try { callId = force ? callIdSequence.forceNext() : callIdSequence.next(); } catch (HazelcastOverloadException e) { throw new HazelcastOverloadException("Failed to start invocation due to overload: " + invocation, e); } try { // fails with IllegalStateException if the operation is already active setCallId(invocation.op, callId); } catch (IllegalStateException e) { callIdSequence.complete(); throw e; } invocations.put(callId, invocation); if (!alive) { invocation.notifyError(new HazelcastInstanceNotActiveException()); return false; } return true; }
/** * Registers an invocation. * * @param invocation The invocation to register. * @return {@code false} when InvocationRegistry is not alive and registration is not successful, {@code true} otherwise */ public boolean register(Invocation invocation) { final long callId; boolean force = invocation.op.isUrgent() || invocation.isRetryCandidate(); try { callId = force ? callIdSequence.forceNext() : callIdSequence.next(); } catch (HazelcastOverloadException e) { throw new HazelcastOverloadException("Failed to start invocation due to overload: " + invocation, e); } try { // fails with IllegalStateException if the operation is already active setCallId(invocation.op, callId); } catch (IllegalStateException e) { callIdSequence.complete(); throw e; } invocations.put(callId, invocation); if (!alive) { invocation.notifyError(new HazelcastInstanceNotActiveException()); return false; } return true; }