com.github.rholder.retry.StopStrategy Java Examples
The following examples show how to use
com.github.rholder.retry.StopStrategy.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: Authenticator.java From styx with Apache License 2.0 | 6 votes |
Authenticator(GoogleIdTokenVerifier googleIdTokenVerifier, CloudResourceManager cloudResourceManager, Iam iam, AuthenticatorConfiguration configuration, WaitStrategy retryWaitStrategy, StopStrategy retryStopStrategy) { this.googleIdTokenVerifier = Objects.requireNonNull(googleIdTokenVerifier, "googleIdTokenVerifier"); this.cloudResourceManager = Objects.requireNonNull(cloudResourceManager, "cloudResourceManager"); this.iam = Objects.requireNonNull(iam, "iam"); this.domainWhitelist = configuration.domainWhitelist(); this.resourceWhitelist = configuration.resourceWhitelist(); this.allowedAudiences = configuration.allowedAudiences(); this.retryWaitStrategy = Objects.requireNonNull(retryWaitStrategy, "retryWaitStrategy"); this.retryStopStrategy = Objects.requireNonNull(retryStopStrategy, "retryStopStrategy"); }
Example #2
Source File: BigtableStorage.java From styx with Apache License 2.0 | 6 votes |
@VisibleForTesting BigtableStorage(Connection connection, ExecutorService executor, WaitStrategy waitStrategy, StopStrategy retryStopStrategy) { this.connection = Objects.requireNonNull(connection, "connection"); this.executor = MDCUtil.withMDC(Context.currentContextExecutor( register(closer, Objects.requireNonNull(executor, "executor"), "bigtable-storage"))); retryer = RetryerBuilder.<Void>newBuilder() .retryIfExceptionOfType(IOException.class) .withWaitStrategy(Objects.requireNonNull(waitStrategy, "waitStrategy")) .withStopStrategy(Objects.requireNonNull(retryStopStrategy, "retryStopStrategy")) .withRetryListener(BigtableStorage::onRequestAttempt) .build(); }
Example #3
Source File: RetryUtil.java From cloudbreak with Apache License 2.0 | 6 votes |
/** * Builds a retryer. * * @param actionDescription a description of the action being performed * @param waitUntilTime the latest time to wait to perform the action * @param sleepTimeMs the sleep time in millisecond for retries * @param exceptionClass the class of exception to throw * @param logger the logger * @param <T> the type of object returned * @return the retryer */ private static <T> Retryer<T> buildRetryer(String actionDescription, ZonedDateTime waitUntilTime, long sleepTimeMs, Class<? extends CcmException> exceptionClass, Logger logger) { StopStrategy stop; if (waitUntilTime != null) { // Given the time at which waiting should stop, // get the available number of millis from this instant stop = StopStrategyFactory.waitUntilDateTime(waitUntilTime); logger.info("Trying until {} to {}", waitUntilTime, actionDescription); } else { stop = StopStrategies.neverStop(); logger.warn("Unbounded wait to {}", actionDescription); } WaitStrategy wait = WaitStrategies.fixedWait(sleepTimeMs, TimeUnit.MILLISECONDS); logger.info("Checking every {} milliseconds", sleepTimeMs); return RetryerBuilder.<T>newBuilder() .retryIfException(t -> exceptionClass.isInstance(t) && ((CcmException) t).isRetryable()) .retryIfResult(Objects::isNull) .withStopStrategy(stop) .withWaitStrategy(wait) .build(); }
Example #4
Source File: ServiceAccountUsageAuthorizer.java From styx with Apache License 2.0 | 5 votes |
Impl(Iam iam, CloudResourceManager crm, Directory directory, String serviceAccountUserRole, AuthorizationPolicy authorizationPolicy, WaitStrategy waitStrategy, StopStrategy retryStopStrategy, String message, List<String> administrators, List<String> blacklist) { this.iam = Objects.requireNonNull(iam, "iam"); this.crm = Objects.requireNonNull(crm, "crm"); this.directory = Objects.requireNonNull(directory, "directory"); this.serviceAccountUserRole = Objects.requireNonNull(serviceAccountUserRole, "serviceAccountUserRole"); this.authorizationPolicy = Objects.requireNonNull(authorizationPolicy, "authorizationPolicy"); this.waitStrategy = Objects.requireNonNull(waitStrategy, "waitStrategy"); this.retryStopStrategy = Objects.requireNonNull(retryStopStrategy, "retryStopStrategy"); this.message = Objects.requireNonNull(message, "message"); this.administrators = Objects.requireNonNull(administrators, "administrators"); this.blacklist = Objects.requireNonNull(blacklist, "blacklist"); }
Example #5
Source File: StopStrategyFactory.java From cloudbreak with Apache License 2.0 | 5 votes |
/** * Returns a stop strategy that will stop retrying when the specified date and time is reached. Will always * execute the callable at least one time. * * @param stopDateTime the date and time to stop retrying * @return a stop strategy that stops at a specified date and time */ public static StopStrategy waitUntilDateTime(ZonedDateTime stopDateTime) { long millisecondsUntilStop = ChronoUnit.MILLIS.between(ZonedDateTime.now(), stopDateTime); if (millisecondsUntilStop < 0) { return STOP_IMMEDIATELY; } return StopStrategies.stopAfterDelay(millisecondsUntilStop, TimeUnit.MILLISECONDS); }
Example #6
Source File: MqttStreamer.java From ignite with Apache License 2.0 | 2 votes |
/** * Sets the strategy to determine when to stop retrying to (re-)connect. By default, we never stop. * * @param retryStopStrategy The retry stop strategy. */ public void setRetryStopStrategy(StopStrategy retryStopStrategy) { this.retryStopStrategy = retryStopStrategy; }
Example #7
Source File: MqttStreamer.java From ignite with Apache License 2.0 | 2 votes |
/** * Gets the retry stop strategy. * * @return The retry stop strategy. */ public StopStrategy getRetryStopStrategy() { return retryStopStrategy; }