X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cadi%2Fclient%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2Flocator%2FHotPeerLocator.java;h=93cefc58257054291cafa0c27dd17988fb228cf9;hb=refs%2Fchanges%2F87%2F65287%2F1;hp=26b8817bbfc5376900ec2ee15c297b14ca03b7ac;hpb=ead32f193586e39b59bb366bddf70e665173a52d;p=aaf%2Fauthz.git diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/HotPeerLocator.java b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/HotPeerLocator.java index 26b8817b..93cefc58 100644 --- a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/HotPeerLocator.java +++ b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/HotPeerLocator.java @@ -74,15 +74,15 @@ public abstract class HotPeerLocator implements Locator { this.invalidateTime = invalidateTime; double distance = Double.MAX_VALUE; - for(int i=0;i implements Locator { distances[i]=d; // find preferred server - if(d implements Locator { @Override public Item best() throws LocatorException { - if(failures[preferred]==0L) { + if (failures[preferred]==0L) { return new HPItem(preferred); } else { long now = System.currentTimeMillis(); @@ -125,9 +125,9 @@ public abstract class HotPeerLocator implements Locator { int best = -1; boolean tickle = false; // try for best existing client - for(int i=0;i implements Locator { } } } - if(best<0 && tickle) { + if (best<0 && tickle) { tickle=false; - if(refresh()) { + if (refresh()) { // try again - for(int i=0;i implements Locator { * If a valid client is available, but there are some that can refresh, return the client immediately * but start a Thread to do the background Client setup. */ - if(tickle) { + if (tickle) { synchronized(clients) { - if(refreshThread==null) { + if (refreshThread==null) { refreshThread = new Thread(new Runnable(){ @Override public void run() { @@ -170,7 +170,7 @@ public abstract class HotPeerLocator implements Locator { } } - if(best<0) { + if (best<0) { throw new LocatorException("No Clients available"); } @@ -183,8 +183,8 @@ public abstract class HotPeerLocator implements Locator { public CLIENT get(Item item) throws LocatorException { HPItem hpi = (HPItem)item; CLIENT c = clients[hpi.idx]; - if(c==null) { - if(failures[hpi.idx]>System.currentTimeMillis()) { + if (c==null) { + if (failures[hpi.idx]>System.currentTimeMillis()) { throw new LocatorException("Client requested is invalid"); } else { synchronized(clients) { @@ -192,7 +192,7 @@ public abstract class HotPeerLocator implements Locator { failures[hpi.idx]=0L; } } - } else if(failures[hpi.idx]>0){ + } else if (failures[hpi.idx]>0){ throw new LocatorException("Client requested is invalid"); } return c; @@ -200,7 +200,7 @@ public abstract class HotPeerLocator implements Locator { public String info(Item item) { HPItem hpi = (HPItem)item; - if(hpi!=null && hpi.idx implements Locator { @Override public boolean hasItems() { - for(int i=0;i implements Locator { @Override public Item next(Item item) throws LocatorException { HPItem hpi = (HPItem)item; - if(++hpi.idx>=clients.length) { + if (++hpi.idx>=clients.length) { return null; } return hpi; @@ -244,11 +244,11 @@ public abstract class HotPeerLocator implements Locator { boolean force = !hasItems(); // If no Items at all, reset boolean rv = true; long now = System.currentTimeMillis(); - for(int i=0;i0L && (failures[i]0L && (failures[i] implements Locator { @Override public void destroy() { - for(int i=0;i implements Locator { } public boolean invalidate(CLIENT client) throws LocatorException { - for(int i=0;i