summaryrefslogtreecommitdiffstats
path: root/cadi/client
diff options
context:
space:
mode:
authorInstrumental <jonathan.gathman@att.com>2019-09-04 19:41:24 -0500
committerInstrumental <jonathan.gathman@att.com>2019-09-04 19:41:51 -0500
commitc5aaaeeb8a4c008fa4a576c55da4c3bf703acdac (patch)
treedf48d917f868dc110734afc48c50478b58c697ad /cadi/client
parent4fbae1b6a5de191a9e26361ce6d1b8958be53f9e (diff)
K8s doesn't necessarily support DNS
Issue-ID: AAF-963 Change-Id: I65248837fc217b0ccc09f2afe02e14c716ca5bcc Signed-off-by: Instrumental <jonathan.gathman@att.com>
Diffstat (limited to 'cadi/client')
-rw-r--r--cadi/client/src/main/java/org/onap/aaf/cadi/locator/DNSLocator.java9
-rw-r--r--cadi/client/src/main/java/org/onap/aaf/cadi/locator/SingleEndpointLocator.java16
-rw-r--r--cadi/client/src/main/java/org/onap/aaf/cadi/locator/SizedLocator.java28
-rw-r--r--cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_DNSLocator.java31
4 files changed, 65 insertions, 19 deletions
diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/DNSLocator.java b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/DNSLocator.java
index d64de699..8053dabf 100644
--- a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/DNSLocator.java
+++ b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/DNSLocator.java
@@ -27,11 +27,10 @@ import java.net.URI;
import java.net.URISyntaxException;
import org.onap.aaf.cadi.Access;
-import org.onap.aaf.cadi.Locator;
-import org.onap.aaf.cadi.LocatorException;
import org.onap.aaf.cadi.Access.Level;
+import org.onap.aaf.cadi.LocatorException;
-public class DNSLocator implements Locator<URI> {
+public class DNSLocator implements SizedLocator<URI> {
private static enum Status {UNTRIED, OK, INVALID, SLOW};
private static final int CHECK_TIME = 3000;
@@ -63,11 +62,11 @@ public class DNSLocator implements Locator<URI> {
throw new LocatorException("Null passed into DNSLocator constructor");
}
int start, defPort;
- if (aaf_locate.startsWith("https:")) {
+ if (aaf_locate.startsWith("https://")) {
protocol = "https";
start = 8; // https://
defPort = 443;
- } else if (aaf_locate.startsWith("http:")) {
+ } else if (aaf_locate.startsWith("http://")) {
protocol = "http";
start = 7; // http://
defPort = 80;
diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/SingleEndpointLocator.java b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/SingleEndpointLocator.java
index 3b79dba5..b0654cfa 100644
--- a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/SingleEndpointLocator.java
+++ b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/SingleEndpointLocator.java
@@ -24,10 +24,9 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.util.Date;
-import org.onap.aaf.cadi.Locator;
import org.onap.aaf.cadi.LocatorException;
-public class SingleEndpointLocator implements Locator<URI> {
+public class SingleEndpointLocator implements SizedLocator<URI> {
private final URI uri;
private final static Item item = new Item() {};
private Date noRetryUntil;
@@ -36,8 +35,12 @@ public class SingleEndpointLocator implements Locator<URI> {
this.uri = uri;
}
- public SingleEndpointLocator(final String endpoint) throws URISyntaxException {
- this.uri = new URI(endpoint);
+ public SingleEndpointLocator(final String endpoint) throws LocatorException {
+ try {
+ this.uri = new URI(endpoint);
+ } catch (URISyntaxException e) {
+ throw new LocatorException(e);
+ }
}
@Override
@@ -84,6 +87,11 @@ public class SingleEndpointLocator implements Locator<URI> {
// Never refreshed
return true;
}
+
+ @Override
+ public int size() {
+ return 1;
+ }
@Override
public void destroy() {
diff --git a/cadi/client/src/main/java/org/onap/aaf/cadi/locator/SizedLocator.java b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/SizedLocator.java
new file mode 100644
index 00000000..65a34738
--- /dev/null
+++ b/cadi/client/src/main/java/org/onap/aaf/cadi/locator/SizedLocator.java
@@ -0,0 +1,28 @@
+/**
+ * ============LICENSE_START====================================================
+ * org.onap.aaf
+ * ===========================================================================
+ * Copyright (c) 2018 AT&T Intellectual Property. All rights reserved.
+ * ===========================================================================
+ * 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END====================================================
+ *
+ */
+
+package org.onap.aaf.cadi.locator;
+
+import org.onap.aaf.cadi.Locator;
+
+public interface SizedLocator<T> extends Locator<T> {
+ public abstract int size();
+}
diff --git a/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_DNSLocator.java b/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_DNSLocator.java
index dfc7142a..b786cf68 100644
--- a/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_DNSLocator.java
+++ b/cadi/client/src/test/java/org/onap/aaf/cadi/locator/test/JU_DNSLocator.java
@@ -21,17 +21,20 @@
package org.onap.aaf.cadi.locator.test;
-import static org.junit.Assert.*;
-import static org.hamcrest.CoreMatchers.*;
-import org.junit.*;
+import static org.hamcrest.CoreMatchers.is;
+import static org.junit.Assert.assertThat;
+import static org.junit.Assert.fail;
import java.io.ByteArrayOutputStream;
import java.io.PrintStream;
import java.net.URI;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.aaf.cadi.Access.Level;
+import org.onap.aaf.cadi.Locator.Item;
import org.onap.aaf.cadi.LocatorException;
import org.onap.aaf.cadi.PropAccess;
-import org.onap.aaf.cadi.Locator.Item;
import org.onap.aaf.cadi.locator.DNSLocator;
public class JU_DNSLocator {
@@ -73,12 +76,20 @@ public class JU_DNSLocator {
new DNSLocator(access, "https", "localhost", "8100");
new DNSLocator(access, "https", "localhost", "8100-8101");
- new DNSLocator(access, "http:localhost");
- new DNSLocator(access, "https:localhost");
- new DNSLocator(access, "https:localhost:8100");
- new DNSLocator(access, "https:localhost:[8100]");
- new DNSLocator(access, "https:localhost:[8100-8101]");
- new DNSLocator(access, "https:localhost:8000/");
+ new DNSLocator(access, "http://localhost");
+ new DNSLocator(access, "https://localhost");
+ new DNSLocator(access, "https://localhost:8100");
+ new DNSLocator(access, "https://localhost:[8100]");
+ new DNSLocator(access, "https://localhost:[8100-8101]");
+ new DNSLocator(access, "https://localhost:8000/");
+ new DNSLocator(access, "https://aaf-locatexx.onapxxx:8095/locate");
+ try {
+ new DNSLocator(access, "https:localhost:8000");
+ fail("Invalid URL should not pass");
+ } catch (LocatorException e) {
+ access.log(Level.DEBUG, "Valid Exception");
+
+ }
}
@Test