X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cadi%2Fclient%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2Fhttp%2FHMangr.java;h=1d1f273206a3cf9445af06fd8010f48055a7ec7e;hb=refs%2Fchanges%2F24%2F97124%2F3;hp=19e40b3aa2a918cd2750569591060e768bcd11a7;hpb=bdce7667a6e272e2fa32e298d957a0d9090c5bc9;p=aaf%2Fauthz.git diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HMangr.java b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HMangr.java index 19e40b3a..1d1f2732 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/http/HMangr.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/http/HMangr.java @@ -7,9 +7,9 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. @@ -46,7 +46,7 @@ public class HMangr { private int readTimeout, connectionTimeout; public final Locator loc; private Access access; - + public HMangr(Access access, Locator loc) throws LocatorException { readTimeout = 10000; connectionTimeout=3000; @@ -58,18 +58,18 @@ public class HMangr { } /** - * Reuse the same service. This is helpful for multiple calls that change service side cached data so that + * Reuse the same service. This is helpful for multiple calls that change service side cached data so that * there is not a speed issue. - * + * * If the service goes down, another service will be substituted, if available. - * + * * @param access * @param loc * @param ss * @param item * @param retryable * @return - * @throws URISyntaxException + * @throws URISyntaxException * @throws Exception */ public RET same(SecuritySetter ss, Retryable retryable) throws APIException, CadiException, LocatorException { @@ -107,7 +107,7 @@ public class HMangr { } else { client.setSecuritySetter(ss); } - + retry = false; try { ret = retryable.code(client); @@ -118,14 +118,14 @@ public class HMangr { try { Throwable ec = e.getCause(); if (ec instanceof java.net.ConnectException) { - if (client!=null && loc.hasItems()) { + if (client!=null && loc.hasItems()) { access.log(Level.WARN,"Connection refused, trying next available service"); retry = true; } else { throw new CadiException("Connection refused, no more services to try"); } } else if (ec instanceof java.net.SocketException) { - if (client!=null && loc.hasItems()) { + if (client!=null && loc.hasItems()) { access.log(Level.WARN,"Socket prematurely closed, trying next available service"); retry = true; } else { @@ -155,8 +155,8 @@ public class HMangr { } return ret; } - - + + public RET best(SecuritySetter ss, Retryable retryable) throws LocatorException, CadiException, APIException { retryable.item(loc.best()); return same(ss,retryable); @@ -168,7 +168,7 @@ public class HMangr { public RET all(SecuritySetter ss, Retryable retryable,boolean notify) throws LocatorException, CadiException, APIException { return call(ss,retryable,notify,null); } - + public RET allExcept(SecuritySetter ss, Retryable retryable,boolean notify, String selfHost) throws LocatorException, CadiException, APIException { return call(ss,retryable,notify,selfHost); } @@ -211,12 +211,12 @@ public class HMangr { access.log(Level.ERROR,"Connection to",uri,"refused during call to all services"); } } - - if (ret == null && notify) + + if (ret == null && notify) throw new LocatorException("No available clients to call"); return ret; } - + public void close() { // TODO Anything here? @@ -230,7 +230,7 @@ public class HMangr { public int readTimeout() { return readTimeout; } - + public void connectionTimeout(int t) { connectionTimeout = t; }