trafodion-codereview mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From selvaganesang <...@git.apache.org>
Subject [GitHub] trafodion pull request #1344: TRAFODION-2844 add strategy to dcsserver for r...
Date Tue, 09 Jan 2018 16:25:26 GMT
Github user selvaganesang commented on a diff in the pull request:

    https://github.com/apache/trafodion/pull/1344#discussion_r160454737
  
    --- Diff: dcs/src/main/java/org/trafodion/dcs/util/RetryCounter.java ---
    @@ -20,54 +20,94 @@
      */
     package org.trafodion.dcs.util;
     
    +import java.util.LinkedList;
    +import java.util.Queue;
     import java.util.concurrent.TimeUnit;
     
     import org.apache.commons.logging.Log;
     import org.apache.commons.logging.LogFactory;
     
     public class RetryCounter {
    -  private static final Log LOG = LogFactory.getLog(RetryCounter.class);
    -  private final int maxRetries;
    -  private int retriesRemaining;
    -  private final int retryIntervalMillis;
    -  private final TimeUnit timeUnit;
    +    private static final Log LOG = LogFactory.getLog(RetryCounter.class);
    +    private final int maxRetries;
    +    private int retriesRemaining;
    +    private int retryInterval;
    +    private Queue<Long> queue;
    +    private TimeUnit timeUnit;
     
    -  public RetryCounter(int maxRetries, 
    -  int retryIntervalMillis, TimeUnit timeUnit) {
    -    this.maxRetries = maxRetries;
    -    this.retriesRemaining = maxRetries;
    -    this.retryIntervalMillis = retryIntervalMillis;
    -    this.timeUnit = timeUnit;
    -  }
    +    public RetryCounter(int maxRetries, int retryInterval, TimeUnit timeUnit) {
    +        this.maxRetries = maxRetries;
    +        this.retriesRemaining = maxRetries;
    +        this.retryInterval = retryInterval;
    +        this.queue = new LinkedList<Long>();
    +        this.timeUnit = timeUnit;
    +    }
     
    -  public int getMaxRetries() {
    -    return maxRetries;
    -  }
    +    public int getMaxRetries() {
    +        return maxRetries;
    +    }
     
    -  /**
    -   * Sleep for a exponentially back off time
    -   * @throws InterruptedException
    -   */
    -  public void sleepUntilNextRetry() throws InterruptedException {
    -    int attempts = getAttemptTimes();
    -    long sleepTime = (long) (retryIntervalMillis * Math.log(attempts+15));
    -    LOG.info("Sleeping " + sleepTime + "ms before retry #" + attempts + "...");
    -    timeUnit.sleep(sleepTime);
    -  }
    +    /**
    +     * Sleep for a exponentially back off time
    +     * @throws InterruptedException
    +     */
    +    public void sleepUntilNextRetry() throws InterruptedException {
    +        int attempts = getAttemptTimes();
    +        long sleepTime = (long) (retryInterval * Math.log(attempts + 15));
    +        LOG.info("Sleeping " + sleepTime + "ms before retry #" + attempts + "...");
    +        timeUnit.sleep(sleepTime);
    --- End diff --
    
    No. I meant this is a good change


---

Mime
View raw message