X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cadi%2Fclient%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2Flocator%2FPropertyLocator.java;h=bccb81160968098f363e31e0234e8c986cba5709;hb=12414fe43077e12d7ef711951b1633ad31d73573;hp=c10733158507480d8f39bef19060725156eb40dd;hpb=4b5a7d721d994a49057e9bfb403c7bff1b376660;p=aaf%2Fauthz.git diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/PropertyLocator.java b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/PropertyLocator.java index c1073315..bccb8116 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/PropertyLocator.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/PropertyLocator.java @@ -36,6 +36,7 @@ import java.util.TimerTask; import org.onap.aaf.cadi.Locator; import org.onap.aaf.cadi.LocatorException; +import org.onap.aaf.cadi.util.FixURIinfo; import org.onap.aaf.misc.env.util.Split; public class PropertyLocator implements Locator { @@ -61,7 +62,7 @@ public class PropertyLocator implements Locator { minRefresh = minRefreshMillis; backgroundRefresh = backgroundRefreshMillis; lastRefreshed=0L; - if(locList==null) { + if (locList==null) { throw new LocatorException("No Location List given for PropertyLocator"); } String[] locarray = Split.split(',',locList); @@ -69,10 +70,10 @@ public class PropertyLocator implements Locator { random = new SecureRandom(); - for(int i=0;i { int slash = locarray[i].indexOf('/',brac); int start = Integer.parseInt(locarray[i].substring(range+2, dash)); int end = Integer.parseInt(locarray[i].substring(dash+1, brac)); - for(int port=start;port<=end;++port) { + for (int port=start;port<=end;++port) { uriList.add(new URI(mach_colon+port + (slash>=0?locarray[i].substring(slash):""))); } } @@ -106,7 +107,7 @@ public class PropertyLocator implements Locator { @Override public URI get(Item item) throws LocatorException { synchronized(orig) { - if(item==null) { + if (item==null) { return null; } else { return resolved[((PLItem)item).idx]; @@ -126,31 +127,31 @@ public class PropertyLocator implements Locator { @Override public Item next(Item item) throws LocatorException { - if(item==null) { + if (item==null) { return null; } else { int spot; - if((spot=(((PLItem)item).order+1))>=end)return null; + if ((spot=(((PLItem)item).order+1))>=end)return null; return current[spot]; } } @Override public synchronized void invalidate(Item item) throws LocatorException { - if(--end<0) { + if (--end<0) { refresh(); return; } - if(item==null) { + if (item==null) { return; } PLItem pli = (PLItem)item; int i,order; - for(i=0;i { @Override public Item best() throws LocatorException { - if(current.length==0) { + if (current.length==0) { refresh(); } switch(current.length) { @@ -175,27 +176,28 @@ public class PropertyLocator implements Locator { @Override public synchronized boolean refresh() { - if(System.currentTimeMillis()>lastRefreshed) { + if (System.currentTimeMillis()>lastRefreshed) { // Build up list List resolve = new ArrayList<>(); String realname; - for(int i = 0; i < orig.length ; ++i) { + for (int i = 0; i < orig.length ; ++i) { try { - InetAddress ia[] = InetAddress.getAllByName(orig[i].getHost()); + FixURIinfo fui = new FixURIinfo(orig[i]); + InetAddress ia[] = InetAddress.getAllByName(fui.getHost()); URI o,n; - for(int j=0;j { } } catch (IOException e) { } finally { - if(!socket.isClosed()) { + if (!socket.isClosed()) { try { socket.close(); } catch (IOException e) { @@ -227,14 +229,14 @@ public class PropertyLocator implements Locator { } end=resolve.size(); PLItem[] newCurrent; - if(current==null || current.length!=end) { + if (current==null || current.length!=end) { newCurrent = new PLItem[end]; } else { newCurrent = current; } - for(int i=0; i< end; ++i) { - if(newCurrent[i]==null){ + for (int i=0; i< end; ++i) { + if (newCurrent[i]==null){ newCurrent[i]=new PLItem(i); } else { newCurrent[i].idx=newCurrent[i].order=i; @@ -271,18 +273,18 @@ public class PropertyLocator implements Locator { public String toString() { StringBuilder sb = new StringBuilder(); boolean first = true; - for(URI uri : orig) { + for (URI uri : orig) { boolean isResolved=false; - if(uri!=null) { - if(first) { + if (uri!=null) { + if (first) { first = false; } else { sb.append(", "); } sb.append(uri.toString()); sb.append(" ["); - for(URI u2 : resolved) { - if(uri.equals(u2)) { + for (URI u2 : resolved) { + if (uri.equals(u2)) { isResolved = true; break; }