Examples of RetryPolicy


Examples of com.datastax.driver.core.policies.RetryPolicy

public class MetricsTest extends CCMBridge.PerClassSingleNodeCluster {
    private volatile RetryDecision retryDecision;

    @Override
    protected Cluster.Builder configure(Cluster.Builder builder) {
        return builder.withRetryPolicy(new RetryPolicy() {
            @Override
            public RetryDecision onReadTimeout(Statement statement, ConsistencyLevel cl, int requiredResponses, int receivedResponses, boolean dataRetrieved, int nbRetry) {
                return retryDecision;
            }
View Full Code Here

Examples of com.microsoft.windowsazure.scheduler.models.RetryPolicy

                        actionInstance.setType(typeInstance);
                    }
                   
                    JsonNode retryPolicyValue2 = actionValue2.get("retryPolicy");
                    if (retryPolicyValue2 != null) {
                        RetryPolicy retryPolicyInstance = new RetryPolicy();
                        actionInstance.setRetryPolicy(retryPolicyInstance);
                       
                        JsonNode retryTypeValue = retryPolicyValue2.get("retryType");
                        if (retryTypeValue != null) {
                            RetryType retryTypeInstance;
                            retryTypeInstance = SchedulerClientImpl.parseRetryType(retryTypeValue.getTextValue());
                            retryPolicyInstance.setRetryType(retryTypeInstance);
                        }
                       
                        JsonNode retryIntervalValue = retryPolicyValue2.get("retryInterval");
                        if (retryIntervalValue != null) {
                            Duration retryIntervalInstance;
                            retryIntervalInstance = TimeSpan8601Converter.parse(retryIntervalValue.getTextValue());
                            retryPolicyInstance.setRetryInterval(retryIntervalInstance);
                        }
                       
                        JsonNode retryCountValue = retryPolicyValue2.get("retryCount");
                        if (retryCountValue != null) {
                            int retryCountInstance;
                            retryCountInstance = retryCountValue.getIntValue();
                            retryPolicyInstance.setRetryCount(retryCountInstance);
                        }
                    }
                   
                    JsonNode errorActionValue2 = actionValue2.get("errorAction");
                    if (errorActionValue2 != null) {
View Full Code Here

Examples of com.netflix.astyanax.retry.RetryPolicy

        for (int i = 1; i < tokens.length; i++) {
            args[i - 1] = Integer.valueOf(tokens[i]);
        }

        try {
            RetryPolicy rp = instantiate(policyClassName, args, serializedRetryPolicy);
            log.debug("Instantiated RetryPolicy object {} from config string \"{}\"", rp, serializedRetryPolicy);
            return rp;
        } catch (Exception e) {
            throw new PermanentStorageException("Failed to instantiate Astyanax Retry Policy class", e);
        }
View Full Code Here

Examples of com.netflix.curator.RetryPolicy

    String connectionString = Joiner.on(",").join(dnsNames);

    Builder builder = CuratorFrameworkFactory.builder();
    builder.connectString(connectionString);
    TimeSpan retryInterval = TimeSpan.FIVE_SECONDS;
    RetryPolicy retryPolicy = new RetryOneTime((int) retryInterval.getTotalMilliseconds());
    builder.retryPolicy(retryPolicy);

    CuratorFramework curatorFramework;
    try {
      curatorFramework = builder.build();
View Full Code Here

Examples of io.druid.indexing.common.RetryPolicy

  {
    log.info("Performing action for task[%s]: %s", task.getId(), taskAction);

    byte[] dataToSend = jsonMapper.writeValueAsBytes(new TaskActionHolder(task, taskAction));

    final RetryPolicy retryPolicy = retryPolicyFactory.makeRetryPolicy();

    while (true) {
      try {
        final Server server;
        final URI serviceUri;
        try {
          server = getServiceInstance();
          serviceUri = makeServiceUri(server);
        }
        catch (Exception e) {
          // Want to retry, so throw an IOException.
          throw new IOException("Failed to locate service uri", e);
        }

        final StatusResponseHolder response;

        log.info("Submitting action for task[%s] to overlord[%s]: %s", task.getId(), serviceUri, taskAction);

        try {
          response = httpClient.post(serviceUri.toURL())
                               .setContent("application/json", dataToSend)
                               .go(new StatusResponseHandler(Charsets.UTF_8))
                               .get();
        }
        catch (Exception e) {
          Throwables.propagateIfInstanceOf(e.getCause(), IOException.class);
          Throwables.propagateIfInstanceOf(e.getCause(), ChannelException.class);
          throw Throwables.propagate(e);
        }

        if (response.getStatus().getCode() / 200 == 1) {
          final Map<String, Object> responseDict = jsonMapper.readValue(
              response.getContent(),
              new TypeReference<Map<String, Object>>()
              {
              }
          );
          return jsonMapper.convertValue(responseDict.get("result"), taskAction.getReturnTypeReference());
        } else {
          // Want to retry, so throw an IOException.
          throw new IOException(
              String.format(
                  "Scary HTTP status returned: %s. Check your overlord[%s] logs for exceptions.",
                  response.getStatus(),
                  server.getHost()
              )
          );
        }
      }
      catch (IOException | ChannelException e) {
        log.warn(e, "Exception submitting action for task[%s]", task.getId());

        final Duration delay = retryPolicy.getAndIncrementRetryDelay();
        if (delay == null) {
          throw e;
        } else {
          try {
            final long sleepTime = delay.getMillis();
View Full Code Here

Examples of net.jodah.lyra.config.RetryPolicy

* @author Jonathan Halterman
*/
@Test
public class RecurringStatsTest {
  public void shouldAttemptForeverWithDefaultPolicy() throws Exception {
    RecurringStats stats = new RecurringStats(new RetryPolicy());
    stats.incrementAttempts();
    assertFalse(stats.isPolicyExceeded());
    Thread.sleep(50);
    stats.incrementAttempts();
    assertFalse(stats.isPolicyExceeded());
View Full Code Here

Examples of net.jodah.lyra.config.RetryPolicy

    stats.incrementAttempts();
    assertFalse(stats.isPolicyExceeded());
  }

  public void shouldNotAttemptWhenMaxAttemptsExceeded() throws Exception {
    RecurringStats stats = new RecurringStats(new RetryPolicy().withMaxAttempts(3));
    stats.incrementAttempts();
    stats.incrementAttempts();
    assertFalse(stats.isPolicyExceeded());
    stats.incrementAttempts();
    assertTrue(stats.isPolicyExceeded());
View Full Code Here

Examples of net.jodah.lyra.config.RetryPolicy

    stats.incrementAttempts();
    assertTrue(stats.isPolicyExceeded());
  }

  public void shouldNotAttemptWhenMaxDurationExceeded() throws Exception {
    RecurringStats stats = new RecurringStats(new RetryPolicy().withMaxDuration(Duration.millis(25)));
    stats.incrementTime();
    assertFalse(stats.isPolicyExceeded());
    assertFalse(stats.isPolicyExceeded());
    Thread.sleep(50);
    assertTrue(stats.isPolicyExceeded());
View Full Code Here

Examples of net.jodah.lyra.config.RetryPolicy

    Thread.sleep(50);
    assertTrue(stats.isPolicyExceeded());
  }

  public void shouldAdjustWaitTimeForMaxDuration() throws Throwable {
    RecurringStats stats = new RecurringStats(new RetryPolicy().withInterval(Duration.millis(150))
        .withMaxDuration(Duration.millis(100)));
    stats.incrementTime();
    assertFalse(stats.isPolicyExceeded());
    assertEquals(stats.getWaitTime().toMillis(), 100);
    Thread.sleep(25);
View Full Code Here

Examples of net.jodah.lyra.config.RetryPolicy

    assertFalse(stats.isPolicyExceeded());
    assertTrue(stats.getWaitTime().toMillis() < 100);
  }

  public void waitTimeShouldDefaultToZero() {
    RecurringStats stats = new RecurringStats(new RetryPolicy());
    assertEquals(stats.getWaitTime().toMillis(), 0);
    stats.incrementAttempts();
    assertEquals(stats.getWaitTime().toMillis(), 0);
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.