Tabnine Logo
RetryPredicate.ofAlwaysTrue
Code IndexAdd Tabnine to your IDE (free)

How to use
ofAlwaysTrue
method
in
io.sphere.sdk.retry.RetryPredicate

Best Java code snippets using io.sphere.sdk.retry.RetryPredicate.ofAlwaysTrue (Showing top 8 results out of 315)

origin: commercetools/commercetools-jvm-sdk

private RetryStrategy applyContext(final RetryContext retryContext) {
  final Optional<RetryRule> matchingRetryRuleOption = findMatchingRetryRule(retryRules, retryContext);
  final RetryRule matchingRetryRule = matchingRetryRuleOption
      .orElseGet(() -> RetryRule.of(RetryPredicate.ofAlwaysTrue(), RetryAction.ofGiveUpAndSendLatestException()));
  return matchingRetryRule.apply(retryContext);
}
origin: com.commercetools.sdk.jvm.core/commercetools-java-client-core

private List<RetryRule> createRules() {
  final Predicate<RetryContext> isFatal = r -> {
    final Throwable latestError = r.getLatestError();
    final boolean unknownHost = latestError instanceof HttpException && latestError != null && latestError instanceof UnknownHostException;
    final boolean unauthorized = latestError instanceof UnauthorizedException;
    return unknownHost || unauthorized;
  };
  final RetryRule fatalRetryRule = RetryRule.of(isFatal, RetryAction.ofShutdownServiceAndSendLatestException());
  final RetryRule retryScheduledRetryRule = RetryRule.of(RetryPredicate.ofAlwaysTrue(), RetryAction.ofScheduledRetry(2, retryContext -> Duration.ofMillis(retryContext.getAttempt() * retryContext.getAttempt() * 50)));
  return asList(fatalRetryRule, retryScheduledRetryRule);
}
origin: commercetools/commercetools-jvm-sdk

private List<RetryRule> createRules() {
  final Predicate<RetryContext> isFatal = r -> {
    final Throwable latestError = r.getLatestError();
    final boolean unknownHost = latestError instanceof HttpException && latestError != null && latestError instanceof UnknownHostException;
    final boolean unauthorized = latestError instanceof UnauthorizedException;
    return unknownHost || unauthorized;
  };
  final RetryRule fatalRetryRule = RetryRule.of(isFatal, RetryAction.ofShutdownServiceAndSendLatestException());
  final RetryRule retryScheduledRetryRule = RetryRule.of(RetryPredicate.ofAlwaysTrue(), RetryAction.ofScheduledRetry(2, retryContext -> Duration.ofMillis(retryContext.getAttempt() * retryContext.getAttempt() * 50)));
  return asList(fatalRetryRule, retryScheduledRetryRule);
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void immediateRetryRule() throws Exception {
  try (final Service service = new Failing2TimesServiceImpl()) {
    final List<RetryRule> retryRules = singletonList(RetryRule.of(RetryPredicate.ofAlwaysTrue(), RetryAction.ofImmediateRetries(3)));
    try(final AsyncRetrySupervisor supervisor = AsyncRetrySupervisor.of(retryRules)) {
      final CompletionStage<Integer> bar = supervisor.supervise(service, service::apply, "bar");
      assertThat(waitAndGet(bar)).isEqualTo(3);
      assertThat(service.isClosed()).isFalse();
    }
  }
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void immediateRetryRuleNonSufficient() throws Exception {
  try (final Service service = new Failing2TimesServiceImpl()) {
    final List<RetryRule> retryRules = singletonList(RetryRule.of(RetryPredicate.ofAlwaysTrue(), RetryAction.ofImmediateRetries(1)));
    try(final AsyncRetrySupervisor supervisor = AsyncRetrySupervisor.of(retryRules)) {
      final CompletionStage<Integer> bar = supervisor.supervise(service, service::apply, "bar");
      final Throwable throwable = catchThrowable(() -> waitAndGet(bar));
      assertThat(throwable.getCause()).hasMessage(Failing2TimesServiceImpl.ERROR_MESSAGE);
      assertThat(service.isClosed()).isFalse();
    }
  }
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void shutdownServiceAndSendFirstException() throws Exception {
  try (final Service service = new Failing2TimesServiceImpl()) {
    final List<RetryRule> retryRules = singletonList(RetryRule.of(RetryPredicate.ofAlwaysTrue(), RetryAction.ofShutdownServiceAndSendFirstException()));
    try(final AsyncRetrySupervisor supervisor = AsyncRetrySupervisor.of(retryRules)) {
      final CompletionStage<Integer> bar = supervisor.supervise(service, service::apply, "bar");
      final Throwable throwable = catchThrowable(() -> waitAndGet(bar));
      assertThat(throwable.getCause()).hasMessage(Failing2TimesServiceImpl.ERROR_MESSAGE);
      Thread.sleep(200);
      assertThat(service.isClosed()).isTrue();
    }
  }
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void giveUpAndSendFirstException() throws Exception {
  try (final Service service = new Failing2TimesServiceImpl()) {
    final List<RetryRule> retryRules = singletonList(RetryRule.of(RetryPredicate.ofAlwaysTrue(), RetryAction.ofGiveUpAndSendFirstException()));
    try(final AsyncRetrySupervisor supervisor = AsyncRetrySupervisor.of(retryRules)) {
      final CompletionStage<Integer> bar = supervisor.supervise(service, service::apply, "bar");
      final Throwable throwable = catchThrowable(() -> waitAndGet(bar));
      assertThat(throwable.getCause()).hasMessage(Failing2TimesServiceImpl.ERROR_MESSAGE);
      assertThat(service.isClosed()).isFalse();
    }
  }
}
origin: commercetools/commercetools-jvm-sdk

@Test
public void scheduledRetry() throws Exception {
  try (final Service service = new Failing2TimesServiceImpl()) {
    final RetryAction op = RetryAction.ofScheduledRetry(3, o -> Duration.ofMillis(o.getAttempt() * 100));
    final List<RetryRule> retryRules = singletonList(RetryRule.of(RetryPredicate.ofAlwaysTrue(), op));
    try(final AsyncRetrySupervisor supervisor = AsyncRetrySupervisor.of(retryRules)) {
      final CompletionStage<Integer> bar = supervisor.supervise(service, service::apply, "bar");
      assertThat(waitAndGet(bar)).isEqualTo(3);
      assertThat(service.isClosed()).isFalse();
    }
  }
}
io.sphere.sdk.retryRetryPredicateofAlwaysTrue

Javadoc

Creates a predicate that yields always true.

Popular methods of RetryPredicate

  • ofMatchingStatusCodes
    Creates a predicate which matches another predicate for status codes for SphereServiceExceptions.
  • test

Popular in Java

  • Reading from database using SQL prepared statement
  • runOnUiThread (Activity)
  • getSupportFragmentManager (FragmentActivity)
  • startActivity (Activity)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • GridLayout (java.awt)
    The GridLayout class is a layout manager that lays out a container's components in a rectangular gri
  • RandomAccessFile (java.io)
    Allows reading from and writing to a file in a random-access manner. This is different from the uni-
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • Logger (org.slf4j)
    The org.slf4j.Logger interface is the main user entry point of SLF4J API. It is expected that loggin
  • Top Sublime Text plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now