2  * ============LICENSE_START=======================================================
 
   4  * ================================================================================
 
   5  * * Copyright (C) 2017 AT&T Intellectual Property.
 
   6  * ================================================================================
 
   7  * Copyright (C) 2018 Samsung Electronics. All rights
 
   9  * ================================================================================
 
  10  * Licensed under the Apache License, Version 2.0 (the "License");
 
  11  * you may not use this file except in compliance with the License.
 
  12  * You may obtain a copy of the License at
 
  14  *      http://www.apache.org/licenses/LICENSE-2.0
 
  16  * Unless required by applicable law or agreed to in writing, software
 
  17  * distributed under the License is distributed on an "AS IS" BASIS,
 
  18  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 
  19  * See the License for the specific language governing permissions and
 
  20  * limitations under the License.
 
  21  * ============LICENSE_END=========================================================
 
  24 package org.onap.ccsdk.sli.plugins.sshapicall.model;
 
  26 public class RetryPolicy {
 
  27     private String[] hostnames;
 
  28     private Integer maximumRetries;  
 
  30     public Integer getMaximumRetries() {
 
  31         return maximumRetries;
 
  34     public String getNextHostName(String uri) throws RetryException {
 
  35         Integer position = null;
 
  37         for (int i = 0; i < hostnames.length; i++) {
 
  38             if (uri.contains(hostnames[i])) {
 
  45             throw new RetryException("No match found for the provided uri[" + uri + "] " +
 
  46                     "so the next host name could not be retreived");
 
  50         if (position > hostnames.length - 1) {
 
  53         return hostnames[position];
 
  56     public RetryPolicy(String[] hostnames, Integer maximumRetries){
 
  57         this.hostnames = hostnames;
 
  58         this.maximumRetries = maximumRetries;