Examples of RetryPolicy


Examples of net.jodah.lyra.config.RetryPolicy

    stats.incrementAttempts();
    assertEquals(stats.getWaitTime().toMillis(), 0);
  }

  public void waitTimeShouldBeConstant() {
    RecurringStats stats = new RecurringStats(new RetryPolicy().withInterval(Duration.millis(5)));
    assertEquals(stats.getWaitTime().toMillis(), 5);
    stats.incrementAttempts();
    assertEquals(stats.getWaitTime().toMillis(), 5);
  }
View Full Code Here

Examples of net.jodah.lyra.config.RetryPolicy

    stats.incrementAttempts();
    assertEquals(stats.getWaitTime().toMillis(), 5);
  }

  public void waitTimeShouldIncreaseExponentially() throws Exception {
    RecurringStats stats = new RecurringStats(new RetryPolicy().withBackoff(Duration.millis(1),
        Duration.millis(5)));
    stats.incrementTime();
    assertEquals(stats.getWaitTime().toMillis(), 1);
    stats.incrementTime();
    assertEquals(stats.getWaitTime().toMillis(), 2);
View Full Code Here

Examples of net.jodah.lyra.retry.RetryPolicy

    final StringInputRowParser stringParser = firehoseParser;

    ConnectionOptions lyraOptions = new ConnectionOptions(this.connectionFactory);
    Config lyraConfig = new Config()
        .withRecoveryPolicy(
            new RetryPolicy()
                .withMaxRetries(config.getMaxRetries())
                .withRetryInterval(Duration.seconds(config.getRetryIntervalSeconds()))
                .withMaxDuration(Duration.seconds(config.getMaxDurationSeconds()))
        );
View Full Code Here

Examples of org.apache.curator.RetryPolicy

        {
            final AtomicInteger retries = new AtomicInteger(0);
            final Semaphore semaphore = new Semaphore(0);
            client.getZookeeperClient().setRetryPolicy
                (
                    new RetryPolicy()
                    {
                        @Override
                        public boolean allowRetry(int retryCount, long elapsedTimeMs, RetrySleeper sleeper)
                        {
                            semaphore.release();
View Full Code Here

Examples of org.apache.curator.RetryPolicy

        throws InterruptedException {
        Validate.notEmpty(connectionString);
        Validate.notEmpty(sampleRateZNode);
        this.sampleRateZNode = sampleRateZNode;

        final RetryPolicy retryPolicy = new ExponentialBackoffRetry(1000, 3);
        zkCurator = CuratorFrameworkFactory.newClient(connectionString, retryPolicy);
        final ConnectionStateListener initialConnectionState = new InitialConnectionStateListener();
        zkCurator.getConnectionStateListenable().addListener(initialConnectionState);
        zkCurator.start();
View Full Code Here

Examples of org.apache.curator.RetryPolicy

        LOGGER.debug("user session counter for %s is now %d", userId, count);
        return count;
    }

    private int adjustAndGet(String userId, Direction direction) {
        RetryPolicy retryPolicy = new BoundedExponentialBackoffRetry(BASE_SLEEP_TIME_MS, MAX_SLEEP_TIME_MS, MAX_RETRIES);
        DistributedAtomicInteger distributedAtomicInteger = new DistributedAtomicInteger(curatorFramework, counterPath(userId), retryPolicy);

        try {
            distributedAtomicInteger.initialize(0); // this will respect an existing value but set uninitialized values to 0
        } catch (Exception e) {
View Full Code Here

Examples of org.apache.curator.RetryPolicy

        {
            final AtomicInteger retries = new AtomicInteger(0);
            final Semaphore semaphore = new Semaphore(0);
            client.getZookeeperClient().setRetryPolicy
                (
                    new RetryPolicy()
                    {
                        @Override
                        public boolean allowRetry(int retryCount, long elapsedTimeMs, RetrySleeper sleeper)
                        {
                            semaphore.release();
View Full Code Here

Examples of org.apache.hadoop.io.retry.RetryPolicy

                                            ) throws IOException {
    JobSubmissionProtocol raw =
        (JobSubmissionProtocol) RPC.getProxy(JobSubmissionProtocol.class,
            JobSubmissionProtocol.versionID, addr, conf, NetUtils
                .getSocketFactory(conf, JobSubmissionProtocol.class));
    RetryPolicy backoffPolicy =
      RetryPolicies.retryUpToMaximumCountWithProportionalSleep
      (5, 10, java.util.concurrent.TimeUnit.SECONDS);
    Map<Class<? extends Exception>, RetryPolicy> handlers =
      new HashMap<Class<? extends Exception>, RetryPolicy>();
    handlers.put(SocketTimeoutException.class, backoffPolicy);
    RetryPolicy backoffTimeOuts =
      RetryPolicies.retryByException(RetryPolicies.TRY_ONCE_THEN_FAIL,handlers);
    return (JobSubmissionProtocol)
      RetryProxy.create(JobSubmissionProtocol.class, raw, backoffTimeOuts);
  }
View Full Code Here

Examples of org.apache.hadoop.io.retry.RetryPolicy

    new TreeMap<String, OutputStream>();
   
  static ClientProtocol createNamenode(
      InetSocketAddress nameNodeAddr, Configuration conf)
    throws IOException {
    RetryPolicy timeoutPolicy = RetryPolicies.exponentialBackoffRetry(
        5, 200, TimeUnit.MILLISECONDS);
    RetryPolicy createPolicy = RetryPolicies.retryUpToMaximumCountWithFixedSleep(
        5, LEASE_SOFTLIMIT_PERIOD, TimeUnit.MILLISECONDS);
   
    Map<Class<? extends Exception>,RetryPolicy> remoteExceptionToPolicyMap =
      new HashMap<Class<? extends Exception>, RetryPolicy>();
    remoteExceptionToPolicyMap.put(AlreadyBeingCreatedException.class, createPolicy);

    Map<Class<? extends Exception>,RetryPolicy> exceptionToPolicyMap =
      new HashMap<Class<? extends Exception>, RetryPolicy>();
    exceptionToPolicyMap.put(RemoteException.class,
        RetryPolicies.retryByRemoteException(
            RetryPolicies.TRY_ONCE_THEN_FAIL, remoteExceptionToPolicyMap));
    exceptionToPolicyMap.put(SocketTimeoutException.class, timeoutPolicy);
    RetryPolicy methodPolicy = RetryPolicies.retryByException(
        RetryPolicies.TRY_ONCE_THEN_FAIL, exceptionToPolicyMap);
    Map<String,RetryPolicy> methodNameToPolicyMap = new HashMap<String,RetryPolicy>();
   
    methodNameToPolicyMap.put("open", methodPolicy);
    methodNameToPolicyMap.put("setReplication", methodPolicy);
View Full Code Here

Examples of org.apache.hadoop.io.retry.RetryPolicy

  /* Build a NamenodeProtocol connection to the namenode and
   * set up the retry policy */
  private static NamenodeProtocol createNamenode(Configuration conf)
    throws IOException {
    InetSocketAddress nameNodeAddr = NameNode.getAddress(conf);
    RetryPolicy timeoutPolicy = RetryPolicies.exponentialBackoffRetry(
        5, 200, TimeUnit.MILLISECONDS);
    Map<Class<? extends Exception>,RetryPolicy> exceptionToPolicyMap =
      new HashMap<Class<? extends Exception>, RetryPolicy>();
    RetryPolicy methodPolicy = RetryPolicies.retryByException(
        timeoutPolicy, exceptionToPolicyMap);
    Map<String,RetryPolicy> methodNameToPolicyMap =
        new HashMap<String, RetryPolicy>();
    methodNameToPolicyMap.put("getBlocks", methodPolicy);
    methodNameToPolicyMap.put("getAccessKeys", methodPolicy);
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.