1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.hadoop.hbase.util;
20
21 import java.util.concurrent.TimeUnit;
22
23 import org.apache.hadoop.hbase.classification.InterfaceAudience;
24 import org.apache.hadoop.hbase.util.RetryCounter.ExponentialBackoffPolicyWithLimit;
25 import org.apache.hadoop.hbase.util.RetryCounter.RetryConfig;
26
27 @InterfaceAudience.Private
28 public class RetryCounterFactory {
29 private final RetryConfig retryConfig;
30
31 public RetryCounterFactory(int maxAttempts, int sleepIntervalMillis) {
32 this(maxAttempts, sleepIntervalMillis, -1);
33 }
34
35 public RetryCounterFactory(int maxAttempts, int sleepIntervalMillis, int maxSleepTime) {
36 this(new RetryConfig(
37 maxAttempts,
38 sleepIntervalMillis,
39 maxSleepTime,
40 TimeUnit.MILLISECONDS,
41 new ExponentialBackoffPolicyWithLimit()));
42 }
43
44 public RetryCounterFactory(RetryConfig retryConfig) {
45 this.retryConfig = retryConfig;
46 }
47
48 public RetryCounter create() {
49 return new RetryCounter(retryConfig);
50 }
51 }