public void get() throws WriteTimeoutException, WriteFailureException { long timeout = currentTimeout(); boolean success; try { success = condition.await(timeout, TimeUnit.NANOSECONDS); } catch (InterruptedException ex) { throw new AssertionError(ex); } if (!success) { int blockedFor = totalBlockFor(); int acks = ackCount(); // It's pretty unlikely, but we can race between exiting await above and here, so // that we could now have enough acks. In that case, we "lie" on the acks count to // avoid sending confusing info to the user (see CASSANDRA-6491). if (acks >= blockedFor) acks = blockedFor - 1; throw new WriteTimeoutException(writeType, consistencyLevel, acks, blockedFor); } if (totalBlockFor() + failures > totalEndpoints()) { throw new WriteFailureException(consistencyLevel, ackCount(), totalBlockFor(), writeType, failureReasonByEndpoint); } }
public void assureSufficientLiveNodes() { wrapped.assureSufficientLiveNodes(); }
public void get() throws WriteTimeoutException, WriteFailureException { wrapped.get(); }
@Override public void onFailure(InetAddress from, RequestFailureReason failureReason) { logger.trace("Got failure from {}", from); int n = waitingFor(from) ? failuresUpdater.incrementAndGet(this) : failures; failureReasonByEndpoint.put(from, failureReason); if (totalBlockFor() + n > totalEndpoints()) signal(); }
public void runMayThrow() { PaxosState.commit(message.payload); if (responseHandler != null) responseHandler.response(null); }
public void runMayThrow() { try { PaxosState.commit(message.payload); if (responseHandler != null) responseHandler.response(null); } catch (Exception ex) { if (!(ex instanceof WriteTimeoutException)) logger.error("Failed to apply paxos commit locally : {}", ex); responseHandler.onFailure(FBUtilities.getBroadcastAddress(), RequestFailureReason.UNKNOWN); } }
responseHandler.setSupportsBackPressure(false); responseHandler.get();
public void get() throws WriteTimeoutException { long requestTimeout = writeType == WriteType.COUNTER ? DatabaseDescriptor.getCounterWriteRpcTimeout() : DatabaseDescriptor.getWriteRpcTimeout(); long timeout = TimeUnit.MILLISECONDS.toNanos(requestTimeout) - (System.nanoTime() - start); boolean success; try { success = condition.await(timeout, TimeUnit.NANOSECONDS); } catch (InterruptedException ex) { throw new AssertionError(ex); } if (!success) { int acks = ackCount(); int blockedFor = totalBlockFor(); // It's pretty unlikely, but we can race between exiting await above and here, so // that we could now have enough acks. In that case, we "lie" on the acks count to // avoid sending confusing info to the user (see CASSANDRA-6491). if (acks >= blockedFor) acks = blockedFor - 1; throw new WriteTimeoutException(writeType, consistencyLevel, acks, blockedFor); } }
protected int totalBlockFor() { return wrapped.totalBlockFor(); }
protected int ackCount() { return wrapped.ackCount(); }
protected void signal() { wrapped.signal(); }
public boolean isLatencyForSnitch() { return wrapped.isLatencyForSnitch(); }
public void onFailure(InetAddress from, RequestFailureReason failureReason) { wrapped.onFailure(from, failureReason); }
MessagingService.instance().applyBackPressure(backPressureHosts, responseHandler.currentTimeout());
@Override public void onFailure(InetAddress from, RequestFailureReason failureReason) { logger.trace("Got failure from {}", from); int n = waitingFor(from) ? failuresUpdater.incrementAndGet(this) : failures; failureReasonByEndpoint.put(from, failureReason); if (totalBlockFor() + n > totalEndpoints()) signal(); }
@Override public void runMayThrow() throws OverloadedException, WriteTimeoutException { assert mutation instanceof CounterMutation; Mutation result = ((CounterMutation) mutation).applyCounterMutation(); responseHandler.response(null); Set<InetAddress> remotes = Sets.difference(ImmutableSet.copyOf(targets), ImmutableSet.of(FBUtilities.getBroadcastAddress())); if (!remotes.isEmpty()) sendToHintedEndpoints(result, remotes, responseHandler, localDataCenter, Stage.COUNTER_MUTATION); } };
public void runMayThrow() { try { PaxosState.commit(message.payload); if (responseHandler != null) responseHandler.response(null); } catch (Exception ex) { if (!(ex instanceof WriteTimeoutException)) logger.error("Failed to apply paxos commit locally : {}", ex); responseHandler.onFailure(FBUtilities.getBroadcastAddress(), RequestFailureReason.UNKNOWN); } }
responseHandler.setSupportsBackPressure(false); responseHandler.get();
protected int totalBlockFor() { return wrapped.totalBlockFor(); }
protected int ackCount() { return wrapped.ackCount(); }