summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java138
-rw-r--r--datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/IsFrom.java11
-rw-r--r--datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeMain.java2
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java4
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Main.java2
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedAuthorization.java6
-rw-r--r--datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedLinks.java6
-rw-r--r--datarouter-prov/src/main/resources/docker-compose/prov_data/provserver.properties4
-rw-r--r--datarouter-prov/src/main/resources/provserver.properties4
-rw-r--r--datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestInternalMisc.java2
-rwxr-xr-xdatarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscribeServletTest.java1
-rwxr-xr-x[-rw-r--r--]docs/data-router/data-router.rst2
-rwxr-xr-xpom.xml4
13 files changed, 105 insertions, 81 deletions
diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java
index 76bf04e2..c28827a0 100644
--- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java
+++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/DeliveryTask.java
@@ -38,7 +38,7 @@ import org.apache.log4j.Logger;
* the file and its delivery data as well as to attempt delivery.
*/
public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
- private static Logger logger = Logger.getLogger("org.onap.dmaap.datarouter.node.DeliveryTask");
+ private static Logger loggerDeliveryTask = Logger.getLogger("org.onap.dmaap.datarouter.node.DeliveryTask");
private DeliveryTaskHelper dth;
private String pubid;
private DestInfo di;
@@ -56,36 +56,6 @@ public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
private int attempts;
private String[][] hdrs;
- /**
- * Is the object a DeliveryTask with the same publication ID?
- */
- public boolean equals(Object o) {
- if (!(o instanceof DeliveryTask)) {
- return (false);
- }
- return (pubid.equals(((DeliveryTask) o).pubid));
- }
-
- /**
- * Compare the publication IDs.
- */
- public int compareTo(DeliveryTask o) {
- return (pubid.compareTo(o.pubid));
- }
-
- /**
- * Get the hash code of the publication ID.
- */
- public int hashCode() {
- return (pubid.hashCode());
- }
-
- /**
- * Return the publication ID.
- */
- public String toString() {
- return (pubid);
- }
/**
* Create a delivery task for a given delivery queue and pub ID
@@ -110,38 +80,69 @@ public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
date = Long.parseLong(pubid.substring(0, pubid.indexOf('.')));
Vector<String[]> hdrv = new Vector<String[]>();
try {
- BufferedReader br = new BufferedReader(new FileReader(metafile));
- String s = br.readLine();
- int i = s.indexOf('\t');
- method = s.substring(0, i);
- if (!"DELETE".equals(method) && !monly) {
- length = datafile.length();
- }
- fileid = s.substring(i + 1);
- while ((s = br.readLine()) != null) {
- i = s.indexOf('\t');
- String h = s.substring(0, i);
- String v = s.substring(i + 1);
- if ("x-att-dr-routing".equalsIgnoreCase(h)) {
- subid = v.replaceAll("[^ ]*/", "");
- feedid = dth.getFeedId(subid.replaceAll(" .*", ""));
+ try(BufferedReader br = new BufferedReader(new FileReader(metafile))){
+ String s = br.readLine();
+ int i = s.indexOf('\t');
+ method = s.substring(0, i);
+ if (!"DELETE".equals(method) && !monly) {
+ length = datafile.length();
}
- if (length == 0 && h.toLowerCase().startsWith("content-")) {
- continue;
- }
- if (h.equalsIgnoreCase("content-type")) {
- ctype = v;
+ fileid = s.substring(i + 1);
+ while ((s = br.readLine()) != null) {
+ i = s.indexOf('\t');
+ String h = s.substring(0, i);
+ String v = s.substring(i + 1);
+ if ("x-att-dr-routing".equalsIgnoreCase(h)) {
+ subid = v.replaceAll("[^ ]*/", "");
+ feedid = dth.getFeedId(subid.replaceAll(" .*", ""));
+ }
+ if (length == 0 && h.toLowerCase().startsWith("content-")) {
+ continue;
+ }
+ if (h.equalsIgnoreCase("content-type")) {
+ ctype = v;
+ }
+ hdrv.add(new String[]{h, v});
}
- hdrv.add(new String[]{h, v});
}
- br.close();
+
} catch (Exception e) {
+ loggerDeliveryTask.error("Exception "+e.getStackTrace(),e);
}
hdrs = hdrv.toArray(new String[hdrv.size()][]);
url = dth.getDestURL(fileid);
}
+ /**
+ * Is the object a DeliveryTask with the same publication ID?
+ */
+ public boolean equals(Object o) {
+ if (!(o instanceof DeliveryTask)) {
+ return (false);
+ }
+ return (pubid.equals(((DeliveryTask) o).pubid));
+ }
/**
+ * Compare the publication IDs.
+ */
+ public int compareTo(DeliveryTask o) {
+ return (pubid.compareTo(o.pubid));
+ }
+
+ /**
+ * Get the hash code of the publication ID.
+ */
+ public int hashCode() {
+ return (pubid.hashCode());
+ }
+
+ /**
+ * Return the publication ID.
+ */
+ public String toString() {
+ return (pubid);
+ }
+ /**
* Get the publish ID
*/
public String getPublishId() {
@@ -186,29 +187,33 @@ public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
} catch (ProtocolException pe) {
dth.reportDeliveryExtra(this, -1L);
// Rcvd error instead of 100-continue
+ loggerDeliveryTask.error("Exception "+pe.getStackTrace(),pe);
}
if (os != null) {
long sofar = 0;
try {
byte[] buf = new byte[1024 * 1024];
- InputStream is = new FileInputStream(datafile);
- while (sofar < length) {
- int i = buf.length;
- if (sofar + i > length) {
- i = (int) (length - sofar);
- }
- i = is.read(buf, 0, i);
- if (i <= 0) {
- throw new IOException("Unexpected problem reading data file " + datafile);
+ try(InputStream is = new FileInputStream(datafile)){
+ while (sofar < length) {
+ int i = buf.length;
+ if (sofar + i > length) {
+ i = (int) (length - sofar);
+ }
+ i = is.read(buf, 0, i);
+ if (i <= 0) {
+ throw new IOException("Unexpected problem reading data file " + datafile);
+ }
+ sofar += i;
+ os.write(buf, 0, i);
}
- sofar += i;
- os.write(buf, 0, i);
+ is.close();
+ os.close();
}
- is.close();
- os.close();
+
} catch (IOException ioe) {
dth.reportDeliveryExtra(this, sofar);
throw ioe;
+
}
}
}
@@ -243,6 +248,7 @@ public class DeliveryTask implements Runnable, Comparable<DeliveryTask> {
}
dth.reportStatus(this, rc, xpubid, rmsg);
} catch (Exception e) {
+ loggerDeliveryTask.error("Exception "+e.getStackTrace(),e);
dth.reportException(this, e);
}
}
diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/IsFrom.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/IsFrom.java
index 7e3b4bff..35ba0951 100644
--- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/IsFrom.java
+++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/IsFrom.java
@@ -24,6 +24,8 @@
package org.onap.dmaap.datarouter.node;
+import org.apache.log4j.Logger;
+
import java.util.*;
import java.net.*;
@@ -34,6 +36,7 @@ public class IsFrom {
private long nextcheck;
private String[] ips;
private String fqdn;
+ private static Logger logger = Logger.getLogger("org.onap.dmaap.datarouter.node.IsFrom");
/**
* Configure the JVM DNS cache to have a 10 second TTL. This needs to be called very very early or it won't have any effect.
@@ -59,18 +62,20 @@ public class IsFrom {
long now = System.currentTimeMillis();
if (now > nextcheck) {
nextcheck = now + 10000;
- Vector<String> v = new Vector<String>();
+ Vector<String> v = new Vector<>();
try {
InetAddress[] addrs = InetAddress.getAllByName(fqdn);
for (InetAddress a : addrs) {
v.add(a.getHostAddress());
}
- } catch (Exception e) {
+ } catch (UnknownHostException e) {
+ logger.debug("IsFrom: UnknownHostEx: " + e.toString(), e);
}
ips = v.toArray(new String[v.size()]);
+ logger.info("IsFrom: DNS ENTRIES FOR FQDN " + fqdn + " : " + Arrays.toString(ips));
}
for (String s : ips) {
- if (s.equals(ip)) {
+ if (s.equals(ip) || s.equals(System.getenv("DMAAP_DR_PROV_SERVICE_HOST"))) {
return (true);
}
}
diff --git a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeMain.java b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeMain.java
index 006dc88c..c6b16822 100644
--- a/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeMain.java
+++ b/datarouter-node/src/main/java/org/onap/dmaap/datarouter/node/NodeMain.java
@@ -94,7 +94,6 @@ public class NodeMain {
Server server = new Server();
// HTTP configuration
HttpConfiguration httpConfiguration = new HttpConfiguration();
- httpConfiguration.setIdleTimeout(2000);
httpConfiguration.setRequestHeaderSize(2048);
// HTTP connector
@@ -102,6 +101,7 @@ public class NodeMain {
try (ServerConnector httpServerConnector = new ServerConnector(server,
new HttpConnectionFactory(httpConfiguration))) {
httpServerConnector.setPort(nodeConfigManager.getHttpPort());
+ httpServerConnector.setIdleTimeout(2000);
// HTTPS configuration
SslContextFactory sslContextFactory = new SslContextFactory();
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java
index 6ed5d8b6..412e1322 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/BaseServlet.java
@@ -273,7 +273,7 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
try {
thishost = InetAddress.getLocalHost();
loopback = InetAddress.getLoopbackAddress();
- checkHttpsRelaxation(); //Data Router Subscriber HTTPS Relaxation feature USERSTORYID:US674047.
+ //checkHttpsRelaxation(); //Data Router Subscriber HTTPS Relaxation feature USERSTORYID:US674047.
} catch (UnknownHostException e) {
// ignore
}
@@ -575,7 +575,7 @@ public class BaseServlet extends HttpServlet implements ProvDataProvider {
private void checkHttpsRelaxation() {
if (!mailSendFlag) {
Properties p = (new DB()).getProperties();
- intlogger.info("HTTPS relaxatio: " + p.get("org.onap.dmaap.datarouter.provserver.https.relaxation"));
+ intlogger.info("HTTPS relaxation: " + p.get("org.onap.dmaap.datarouter.provserver.https.relaxation"));
if (p.get("org.onap.dmaap.datarouter.provserver.https.relaxation").equals("true")) {
try {
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Main.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Main.java
index 3afce990..87979be6 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Main.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/Main.java
@@ -127,7 +127,6 @@ public class Main {
httpConfiguration.setSecurePort(httpsPort);
httpConfiguration.setOutputBufferSize(32768);
httpConfiguration.setRequestHeaderSize(2048);
- httpConfiguration.setIdleTimeout(300000);
httpConfiguration.setSendServerVersion(true);
httpConfiguration.setSendDateHeader(false);
@@ -146,6 +145,7 @@ public class Main {
new HttpConnectionFactory(httpConfiguration))) {
httpServerConnector.setPort(httpPort);
httpServerConnector.setAcceptQueueSize(2);
+ httpServerConnector.setIdleTimeout(300000);
// HTTPS configuration
HttpConfiguration httpsConfiguration = new HttpConfiguration(httpConfiguration);
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedAuthorization.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedAuthorization.java
index 16512d9f..a7213e09 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedAuthorization.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedAuthorization.java
@@ -25,6 +25,7 @@
package org.onap.dmaap.datarouter.provisioning.beans;
import java.util.HashSet;
+import java.util.Objects;
import java.util.Set;
import org.json.JSONArray;
@@ -101,4 +102,9 @@ public class FeedAuthorization implements JSONable {
return false;
return true;
}
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(classification, endpoint_ids, endpoint_addrs);
+ }
}
diff --git a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedLinks.java b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedLinks.java
index 261e2741..77726bb4 100644
--- a/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedLinks.java
+++ b/datarouter-prov/src/main/java/org/onap/dmaap/datarouter/provisioning/beans/FeedLinks.java
@@ -25,6 +25,7 @@
package org.onap.dmaap.datarouter.provisioning.beans;
import java.io.InvalidObjectException;
+import java.util.Objects;
import org.json.JSONObject;
@@ -109,4 +110,9 @@ public class FeedLinks implements JSONable {
return false;
return true;
}
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(self, publish, subscribe, log);
+ }
}
diff --git a/datarouter-prov/src/main/resources/docker-compose/prov_data/provserver.properties b/datarouter-prov/src/main/resources/docker-compose/prov_data/provserver.properties
index 10bb5eba..7758a64d 100644
--- a/datarouter-prov/src/main/resources/docker-compose/prov_data/provserver.properties
+++ b/datarouter-prov/src/main/resources/docker-compose/prov_data/provserver.properties
@@ -24,7 +24,7 @@
#Jetty Server properties
org.onap.dmaap.datarouter.provserver.http.port = 8080
org.onap.dmaap.datarouter.provserver.https.port = 8443
-org.onap.dmaap.datarouter.provserver.https.relaxation = false
+org.onap.dmaap.datarouter.provserver.https.relaxation = true
org.onap.dmaap.datarouter.provserver.keystore.type = jks
org.onap.dmaap.datarouter.provserver.keymanager.password = changeit
@@ -40,7 +40,7 @@ org.onap.dmaap.datarouter.provserver.logretention = 30
#DMAAP-597 (Tech Dept) REST request source IP auth
# relaxation to accommodate OOM kubernetes deploy
-org.onap.dmaap.datarouter.provserver.isaddressauthenabled = true
+org.onap.dmaap.datarouter.provserver.isaddressauthenabled = false
# Database access
org.onap.dmaap.datarouter.db.driver = org.mariadb.jdbc.Driver
diff --git a/datarouter-prov/src/main/resources/provserver.properties b/datarouter-prov/src/main/resources/provserver.properties
index 10bb5eba..7758a64d 100644
--- a/datarouter-prov/src/main/resources/provserver.properties
+++ b/datarouter-prov/src/main/resources/provserver.properties
@@ -24,7 +24,7 @@
#Jetty Server properties
org.onap.dmaap.datarouter.provserver.http.port = 8080
org.onap.dmaap.datarouter.provserver.https.port = 8443
-org.onap.dmaap.datarouter.provserver.https.relaxation = false
+org.onap.dmaap.datarouter.provserver.https.relaxation = true
org.onap.dmaap.datarouter.provserver.keystore.type = jks
org.onap.dmaap.datarouter.provserver.keymanager.password = changeit
@@ -40,7 +40,7 @@ org.onap.dmaap.datarouter.provserver.logretention = 30
#DMAAP-597 (Tech Dept) REST request source IP auth
# relaxation to accommodate OOM kubernetes deploy
-org.onap.dmaap.datarouter.provserver.isaddressauthenabled = true
+org.onap.dmaap.datarouter.provserver.isaddressauthenabled = false
# Database access
org.onap.dmaap.datarouter.db.driver = org.mariadb.jdbc.Driver
diff --git a/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestInternalMisc.java b/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestInternalMisc.java
index fd00ea51..bc724079 100644
--- a/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestInternalMisc.java
+++ b/datarouter-prov/src/test/java/datarouter/provisioning/IntegrationTestInternalMisc.java
@@ -69,7 +69,7 @@ public class IntegrationTestInternalMisc extends IntegrationTestBase {
@Test
public void testInternalHalt() {
- String url = props.getProperty("test.host") + "/internal/halt";
+ String url = props.getProperty("test.host") + "/halt";
HttpGet httpPost = new HttpGet(url);
try {
httpPost.addHeader(FeedServlet.BEHALF_HEADER, "JUnit");
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscribeServletTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscribeServletTest.java
index 9009b976..cdf96ba6 100755
--- a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscribeServletTest.java
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/SubscribeServletTest.java
@@ -201,6 +201,7 @@ public class SubscribeServletTest extends DrServletTestBase {
public void Given_Request_Is_HTTP_POST_And_POST_Fails_Bad_Request_Response_Is_Generated() throws Exception {
PowerMockito.mockStatic(Subscription.class);
PowerMockito.when(Subscription.getSubscriptionMatching(mock(Subscription.class))).thenReturn(null);
+ PowerMockito.when(Subscription.countActiveSubscriptions()).thenReturn(0);
JSONObject JSObject = buildRequestJsonObject();
SubscribeServlet subscribeServlet = new SubscribeServlet() {
protected JSONObject getJSONfromInput(HttpServletRequest req) {
diff --git a/docs/data-router/data-router.rst b/docs/data-router/data-router.rst
index 33ae1682..ecce2096 100644..100755
--- a/docs/data-router/data-router.rst
+++ b/docs/data-router/data-router.rst
@@ -807,7 +807,7 @@ Response/Error Codes
Sample Request
==============
-curl -v -X PUT --user {user}:{password} -H "Content-Type: application/octet-stream" --data-binary @/opt/app/datartr/sampleFile.txt --location-trusted -k https://{host}:{port}/publish/{feedId}/sampleFile.txt
+curl -v -X PUT --user {user}:{password} -H "Content-Type: application/octet-stream" --data-binary @/opt/app/datartr/sampleFile.txt --post301 --location-trusted -k https://{host}:{port}/publish/{feedId}/sampleFile.txt
Delete a Published file
-----------------------
diff --git a/pom.xml b/pom.xml
index 0fe61c02..d3327ba9 100755
--- a/pom.xml
+++ b/pom.xml
@@ -41,11 +41,11 @@
<sonar.skip>false</sonar.skip>
<sonar.java.coveragePlugin>jacoco</sonar.java.coveragePlugin>
<sonar.surefire.reportsPath>${project.build.directory}/surefire-reports</sonar.surefire.reportsPath>
- <sonar.jacoco.reportPath>${project.build.directory}/coverage-reports/jacoco.exec</sonar.jacoco.reportPath>
+ <sonar.jacoco.reportPaths>${project.build.directory}/coverage-reports/jacoco.exec</sonar.jacoco.reportPaths>
<sonar.jacoco.itReportPath>${project.build.directory}/coverage-reports/jacoco-it.exec</sonar.jacoco.itReportPath>
<sonar.jacoco.reportMissing.force.zero>true</sonar.jacoco.reportMissing.force.zero>
<sonar.projectVersion>${project.version}</sonar.projectVersion>
- <jetty.version>9.4.12.RC2</jetty.version>
+ <jetty.version>9.3.8.RC0</jetty.version>
<jetty.websocket.version>8.2.0.v20160908</jetty.websocket.version>
<thoughtworks.version>1.4.10</thoughtworks.version>
<snapshotNexusPath>/content/repositories/snapshots/</snapshotNexusPath>