X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=cadi%2Faaf%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Faaf%2Fcadi%2Faaf%2Fv2_0%2FAbsAAFLocator.java;h=06e2c62d27701b27ccb76eaf20648391707825a4;hb=1296352d8eafee57f982a4342ad79ada4aa56d28;hp=a654e6f6b7817c6883395d77a5412c2c166ac578;hpb=4f6c7c053681e93478e2a115714d369b8a998a11;p=aaf%2Fauthz.git diff --git a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java index a654e6f6..06e2c62d 100644 --- a/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.java +++ b/cadi/aaf/src/main/java/org/onap/aaf/cadi/aaf/v2_0/AbsAAFLocator.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. @@ -111,15 +111,15 @@ public abstract class AbsAAFLocator implements Locator this.version = (split.length > 1) ? split[1] : access.getProperty(Config.AAF_API_VERSION,Config.AAF_DEFAULT_API_VERSION); } } - + /** * This is the way to setup specialized AAFLocators ahead of time. * @param preload */ public static void setCreator(LocatorCreator lc) { - locatorCreator = lc; + locatorCreator = lc; } - + public static Locator create(final String name, final String version) throws LocatorException { if(locatorCreator==null) { throw new LocatorException("LocatorCreator is not set"); @@ -142,9 +142,9 @@ public abstract class AbsAAFLocator implements Locator return locatorURI.toString(); } } - + /** - * Setting "self" excludes this service from the list. Critical for contacting peers. + * Setting "self" excludes this service from the list. Critical for contacting peers. */ public void setSelf(final String hostname, final int port) { myhostname=hostname; @@ -161,10 +161,10 @@ public abstract class AbsAAFLocator implements Locator protected final synchronized void replace(List list) { epList = list; } - + /** * Call _refresh as needed during calls, but actual refresh will not occur if there - * are existing entities or if it has been called in the last 10 (settable) seconds. + * are existing entities or if it has been called in the last 10 (settable) seconds. * Timed Refreshes happen by Scheduled Thread */ private final boolean _refresh() { @@ -220,7 +220,7 @@ public abstract class AbsAAFLocator implements Locator public void invalidate(Item item) throws LocatorException { if (item!=null) { if (item instanceof AAFLItem) { - AAFLItem ali =(AAFLItem)item; + AAFLItem ali =(AAFLItem)item; EP ep = ali.ep; synchronized(epList) { epList.remove(ep); @@ -237,9 +237,9 @@ public abstract class AbsAAFLocator implements Locator public Item best() throws LocatorException { if (!hasItems()) { throw new LocatorException(String.format("No Entries found for '%s/%s:%s'", - (aaf_locator_uri==null?aaf_locator_host:aaf_locator_uri.toString()), - name, - version)); + (aaf_locator_uri==null?aaf_locator_host:aaf_locator_uri.toString()), + name, + version)); } List lep = new ArrayList<>(); EP first = null; @@ -274,7 +274,7 @@ public abstract class AbsAAFLocator implements Locator } else { return new AAFLItem(iter,lep.get(i)); } - + } } @@ -291,7 +291,7 @@ public abstract class AbsAAFLocator implements Locator private final Object[] epa; private final List epList; private int idx; - + public EPIterator(Object[] epa, List epList) { this.epa = epa; this.epList = epList; @@ -332,7 +332,7 @@ public abstract class AbsAAFLocator implements Locator } } } - + @Override public Item first() { Iterator iter = getIterator(); @@ -370,18 +370,18 @@ public abstract class AbsAAFLocator implements Locator } return null; } - + protected static class AAFLItem implements Item { private Iterator iter; private URI uri; private EP ep; - + public AAFLItem(Iterator iter, EP ep) { this.iter = iter; this.ep = ep; uri = ep.uri; } - + private static EP next(Iterator iter) { EP ep=null; while (iter.hasNext() && (ep==null || !ep.valid)) { @@ -389,7 +389,7 @@ public abstract class AbsAAFLocator implements Locator } return ep; } - + public String toString() { return ep==null?"Locator Item Invalid":ep.toString(); } @@ -399,7 +399,7 @@ public abstract class AbsAAFLocator implements Locator private URI uri; private final double distance; private boolean valid; - + public EP(final Endpoint ep, double latitude, double longitude) throws URISyntaxException { uri = new URI(ep.getProtocol(),null,ep.getHostname(),ep.getPort(),null,null,null); distance = GreatCircle.calc(latitude, longitude, ep.getLatitude(), ep.getLongitude()); @@ -420,13 +420,13 @@ public abstract class AbsAAFLocator implements Locator return 0; } } - + @Override public String toString() { return distance + ": " + uri + (valid?" valid":" invalidate"); } } - + /* (non-Javadoc) * @see org.onap.aaf.cadi.Locator#destroy() */ @@ -434,7 +434,7 @@ public abstract class AbsAAFLocator implements Locator public void destroy() { // Nothing to do } - + @Override public String toString() { return "AAFLocator for " + name + " on " + getURI();