@Override public void setConf(Configuration conf) { super.setConf(conf); if (conf == null) { // Configured gets passed null before real conf. Why? I don't know. return; } sshUserName = conf.get("hbase.it.clustermanager.ssh.user", ""); String extraSshOptions = conf.get("hbase.it.clustermanager.ssh.opts", ""); sshOptions = System.getenv("HBASE_SSH_OPTS"); if (!extraSshOptions.isEmpty()) { sshOptions = StringUtils.join(new Object[] { sshOptions, extraSshOptions }, " "); } sshOptions = (sshOptions == null) ? "" : sshOptions; sshUserName = (sshUserName == null) ? "" : sshUserName; tunnelCmd = conf.get("hbase.it.clustermanager.ssh.cmd", DEFAULT_TUNNEL_CMD); // Print out ssh special config if any. if ((sshUserName != null && sshUserName.length() > 0) || (sshOptions != null && sshOptions.length() > 0)) { LOG.info("Running with SSH user [" + sshUserName + "] and options [" + sshOptions + "]"); } this.retryCounterFactory = new RetryCounterFactory(new RetryConfig() .setMaxAttempts(conf.getInt(RETRY_ATTEMPTS_KEY, DEFAULT_RETRY_ATTEMPTS)) .setSleepInterval(conf.getLong(RETRY_SLEEP_INTERVAL_KEY, DEFAULT_RETRY_SLEEP_INTERVAL))); }
@Override public long getBackoffTime(RetryConfig config, int attempts) { long backoffTime = super.getBackoffTime(config, attempts); return config.getMaxSleepTime() > 0 ? Math.min(backoffTime, config.getMaxSleepTime()) : backoffTime; } }
@Override public long getBackoffTime(RetryConfig config, int attempts) { long backoffTime = (long) (config.getSleepInterval() * Math.pow(2, attempts)); return addJitter(backoffTime, config.getJitter()); } }
@Override public void setConf(Configuration conf) { super.setConf(conf); if (conf == null) { // Configured gets passed null before real conf. Why? I don't know. return; } sshUserName = conf.get("hbase.it.clustermanager.ssh.user", ""); String extraSshOptions = conf.get("hbase.it.clustermanager.ssh.opts", ""); sshOptions = System.getenv("HBASE_SSH_OPTS"); if (!extraSshOptions.isEmpty()) { sshOptions = StringUtils.join(new Object[] { sshOptions, extraSshOptions }, " "); } sshOptions = (sshOptions == null) ? "" : sshOptions; sshUserName = (sshUserName == null) ? "" : sshUserName; tunnelCmd = conf.get("hbase.it.clustermanager.ssh.cmd", DEFAULT_TUNNEL_CMD); // Print out ssh special config if any. if ((sshUserName != null && sshUserName.length() > 0) || (sshOptions != null && sshOptions.length() > 0)) { LOG.info("Running with SSH user [" + sshUserName + "] and options [" + sshOptions + "]"); } this.retryCounterFactory = new RetryCounterFactory(new RetryConfig() .setMaxAttempts(conf.getInt(RETRY_ATTEMPTS_KEY, DEFAULT_RETRY_ATTEMPTS)) .setSleepInterval(conf.getLong(RETRY_SLEEP_INTERVAL_KEY, DEFAULT_RETRY_SLEEP_INTERVAL))); }
public RetryCounter(int maxAttempts, long sleepInterval, TimeUnit timeUnit) { this(new RetryConfig(maxAttempts, sleepInterval, -1, timeUnit, new ExponentialBackoffPolicy())); }
public RetryCounter(int maxAttempts, long sleepInterval, TimeUnit timeUnit) { this(new RetryConfig(maxAttempts, sleepInterval, -1, timeUnit, new ExponentialBackoffPolicy())); }
public int getMaxAttempts() { return retryConfig.getMaxAttempts(); }
public boolean shouldRetry() { return attempts < retryConfig.getMaxAttempts(); }
public long getBackoffTime(RetryConfig config, int attempts) { return config.getSleepInterval(); } }
public int getMaxAttempts() { return retryConfig.getMaxAttempts(); }
public boolean shouldRetry() { return attempts < retryConfig.getMaxAttempts(); }
public long getBackoffTime(RetryConfig config, int attempts) { return config.getSleepInterval(); } }
/** * Sleep for a back off time as supplied by the backoff policy, and increases the attempts * @throws InterruptedException */ public void sleepUntilNextRetry() throws InterruptedException { int attempts = getAttemptTimes(); long sleepTime = retryConfig.backoffPolicy.getBackoffTime(retryConfig, attempts); if (LOG.isTraceEnabled()) { LOG.trace("Sleeping " + sleepTime + "ms before retry #" + attempts + "..."); } retryConfig.getTimeUnit().sleep(sleepTime); useRetry(); }
public boolean shouldRetry() { return attempts < retryConfig.getMaxAttempts(); }
/** * Sleep for a back off time as supplied by the backoff policy, and increases the attempts * @throws InterruptedException */ public void sleepUntilNextRetry() throws InterruptedException { int attempts = getAttemptTimes(); long sleepTime = retryConfig.backoffPolicy.getBackoffTime(retryConfig, attempts); if (LOG.isTraceEnabled()) { LOG.trace("Sleeping " + sleepTime + "ms before retry #" + attempts + "..."); } retryConfig.getTimeUnit().sleep(sleepTime); useRetry(); }
public int getMaxAttempts() { return retryConfig.getMaxAttempts(); }
public RetryCounter(int maxAttempts, long sleepInterval, TimeUnit timeUnit) { this(new RetryConfig(maxAttempts, sleepInterval, -1, timeUnit, new ExponentialBackoffPolicy())); }
public long getBackoffTime(RetryConfig config, int attempts) { return config.getSleepInterval(); } }
public RetryCounterFactory(int maxAttempts, int sleepIntervalMillis, int maxSleepTime) { this(new RetryConfig( maxAttempts, sleepIntervalMillis, maxSleepTime, TimeUnit.MILLISECONDS, new ExponentialBackoffPolicyWithLimit())); }
@Override public long getBackoffTime(RetryConfig config, int attempts) { long backoffTime = super.getBackoffTime(config, attempts); return config.getMaxSleepTime() > 0 ? Math.min(backoffTime, config.getMaxSleepTime()) : backoffTime; } }