X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=restapi-call-node%2Fprovider%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fccsdk%2Fsli%2Fplugins%2Frestapicall%2FRetryPolicy.java;fp=restapi-call-node%2Fprovider%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fccsdk%2Fsli%2Fplugins%2Frestapicall%2FRetryPolicy.java;h=8d5143be373c8b21f1f25f611bd10f4de0849c22;hb=43c9e83b3cc9b3dfaf55f08fc25813a77a4f2784;hp=65684d9379383e91a9b013dc620d29422c166f60;hpb=f396b85b5815ea0cdfeed96f999ed360e2a9ee9d;p=ccsdk%2Fsli%2Fplugins.git 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]; + } + +}