@Override public Promise<String> run(final Context context) throws Exception { context.createTimer(50, TimeUnit.MILLISECONDS, timerTask); return promise; } };
/** Invoke event monitors and schedule a retry if policy allows. */ private void retry(int attempt, Throwable error, ErrorClassification errorClassification, Context recoveryContext, SettablePromise<T> recoveryResult) { long backoffTime = _policy.getBackoffPolicy().nextBackoff(attempt, error); if (errorClassification == ErrorClassification.UNRECOVERABLE) { // For fatal errors there are no retries. LOGGER.debug(String.format("Attempt %s of %s interrupted: %s", attempt, _name, error.getMessage())); recoveryResult.fail(error); } else if (_policy.getTerminationPolicy().shouldTerminate(attempt, System.currentTimeMillis() - _startedAt + backoffTime)) { // Retry policy commands that no more retries should be done. LOGGER.debug(String.format("Too many exceptions after attempt %s of %s, aborting: %s", attempt, _name, error.getMessage())); recoveryResult.fail(error); } else { // Schedule a new retry task after a computed backoff timeout. LOGGER.debug(String.format("Attempt %s of %s failed and will be retried after %s millis: %s", attempt, _name, backoffTime, error.getMessage())); Task<T> retryTask = wrap(attempt); Promises.propagateResult(retryTask, recoveryResult); recoveryContext.createTimer(backoffTime, TimeUnit.MILLISECONDS, retryTask); } }
@Override public void run() throws Exception { context.createTimer(1, TimeUnit.SECONDS, TestUtil.noop()); } });
@Override public Promise<List<Integer>> run(final Context ctx) { // Save the start time so we can determine when to finish _startMillis = System.currentTimeMillis(); // Set up timeouts for responses long lastWaitTime = Integer.MAX_VALUE; for (final long waitTime : WAIT_TIMES) { if (waitTime < lastWaitTime && waitTime > 0) { ctx.createTimer(waitTime, TimeUnit.MILLISECONDS, checkDone()); lastWaitTime = waitTime; } } // Issue requests for (int i = 0; i < REQUEST_LATENCIES.length; i++) { final long requestLatency = REQUEST_LATENCIES[i]; final Task<Integer> callSvc = callService("subSearch[" + i + "]", _service, new SimpleMockRequest<Integer>(requestLatency, i)); ctx.run(seq(callSvc, addResponse(callSvc), checkDone())); } return _result; }
@Override public Promise<List<Integer>> run(final Context ctx) { // Save the start time so we can determine when to finish _startMillis = System.currentTimeMillis(); // Set up timeouts for responses long lastWaitTime = Integer.MAX_VALUE; for (final long waitTime : WAIT_TIMES) { if (waitTime < lastWaitTime && waitTime > 0) { ctx.createTimer(waitTime, TimeUnit.MILLISECONDS, checkDone()); lastWaitTime = waitTime; } } // Issue requests for (int i = 0; i < REQUEST_LATENCIES.length; i++) { final long requestLatency = REQUEST_LATENCIES[i]; final Task<Integer> callSvc = callService("subSearch[" + i + "]", _service, new SimpleMockRequest<Integer>(requestLatency, i), i); ctx.run(callSvc.andThen(addResponse(callSvc)).andThen(checkDone())); } return _result; }
ctx.createTimer(time, unit, timeoutTask); that.addListener(p -> { if (committed.compareAndSet(false, true)) {
ctx.createTimer(1, TimeUnit.SECONDS, defaultClassifier);
ctx.createTimer(1, TimeUnit.SECONDS, defaultClassifier);
/** Invoke event monitors and schedule a retry if policy allows. */ private void retry(int attempt, Throwable error, ErrorClassification errorClassification, Context recoveryContext, SettablePromise<T> recoveryResult) { long backoffTime = _policy.getBackoffPolicy().nextBackoff(attempt, error); if (errorClassification == ErrorClassification.UNRECOVERABLE) { // For fatal errors there are no retries. LOGGER.debug(String.format("Attempt %s of %s interrupted: %s", attempt, _name, error.getMessage())); recoveryResult.fail(error); } else if (_policy.getTerminationPolicy().shouldTerminate(attempt, System.currentTimeMillis() - _startedAt + backoffTime)) { // Retry policy commands that no more retries should be done. LOGGER.debug(String.format("Too many exceptions after attempt %s of %s, aborting: %s", attempt, _name, error.getMessage())); recoveryResult.fail(error); } else { // Schedule a new retry task after a computed backoff timeout. LOGGER.debug(String.format("Attempt %s of %s failed and will be retried after %s millis: %s", attempt, _name, backoffTime, error.getMessage())); Task<T> retryTask = wrap(attempt); Promises.propagateResult(retryTask, recoveryResult); recoveryContext.createTimer(backoffTime, TimeUnit.MILLISECONDS, retryTask); } }
ctx.createTimer(time, unit, timeoutTask); that.addListener(p -> { if (committed.compareAndSet(false, true)) {