aboutsummaryrefslogtreecommitdiffstats
path: root/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java
diff options
context:
space:
mode:
Diffstat (limited to 'restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java')
-rw-r--r--restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java43
1 files changed, 23 insertions, 20 deletions
diff --git a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java
index 65684d93..8d5143be 100644
--- a/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java
+++ b/restapi-call-node/provider/src/main/java/org/onap/ccsdk/sli/plugins/restapicall/RetryPolicy.java
@@ -21,41 +21,44 @@
*/
package org.onap.ccsdk.sli.plugins.restapicall;
+
public class RetryPolicy {
private String[] hostnames;
private Integer maximumRetries;
-
private int position;
-
private int retryCount;
+
public RetryPolicy(String[] hostnames, Integer maximumRetries) {
- this.hostnames = hostnames;
- this.maximumRetries = maximumRetries;
-
- this.position = 0;
-
- this.retryCount = 0;
+ this.hostnames = hostnames;
+ this.maximumRetries = maximumRetries;
+ this.position = 0;
+ this.retryCount = 0;
+
}
+
public Integer getMaximumRetries() {
- return maximumRetries;
+ return maximumRetries;
}
+
public int getRetryCount() {
- return retryCount;
+ return retryCount;
}
+
public Boolean shouldRetry() {
- return retryCount < maximumRetries + 1;
+ return retryCount < maximumRetries + 1;
}
+
public String getRetryMessage() {
- return retryCount + " retry attempts were made out of " + maximumRetries + " maximum retry attempts.";
+ return retryCount + " retry attempts were made out of " + maximumRetries + " maximum retry attempts.";
}
public String getNextHostName() throws RetryException {
- retryCount++;
- position++;
-
- if (position > hostnames.length - 1) {
- position = 0;
- }
- return hostnames[position];
+ retryCount++;
+ position++;
+ if (position > hostnames.length - 1) {
+ position = 0;
}
-} \ No newline at end of file
+ return hostnames[position];
+ }
+
+}