aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--pom.xml2
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/client/MrProvConnection.java27
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/client/MrTopicConnection.java24
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/model/MR_Cluster.java23
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/service/DmaapService.java16
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/service/MR_ClusterService.java13
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/client/MrProvConnectionTest.java4
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/client/MrTopicConnectionTest.java4
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/model/MR_ClusterTest.java6
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/service/MR_ClusterServiceTest.java2
-rw-r--r--src/test/java/org/onap/dmaap/dbcapi/testframework/DmaapObjectFactory.java6
-rw-r--r--version.properties2
12 files changed, 103 insertions, 26 deletions
diff --git a/pom.xml b/pom.xml
index 8f54863..a95b13f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -324,7 +324,7 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jettyVersion>9.3.9.v20160517</jettyVersion>
<eelf.version>0.0.1</eelf.version>
- <artifact.version>1.0.3-SNAPSHOT</artifact.version>
+ <artifact.version>1.0.4-SNAPSHOT</artifact.version>
<!-- SONAR -->
<jacoco.version>0.7.7.201606060606</jacoco.version>
<sonar-jacoco-listeners.version>3.2</sonar-jacoco-listeners.version>
diff --git a/src/main/java/org/onap/dmaap/dbcapi/client/MrProvConnection.java b/src/main/java/org/onap/dmaap/dbcapi/client/MrProvConnection.java
index 91ed1bb..a8ace78 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/client/MrProvConnection.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/client/MrProvConnection.java
@@ -26,6 +26,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.ConnectException;
+import java.net.HttpURLConnection;
import java.net.ProtocolException;
import java.net.URL;
import java.net.UnknownHostException;
@@ -49,7 +50,7 @@ public class MrProvConnection extends BaseLoggingClass{
private String provURL;
- private HttpsURLConnection uc;
+ private HttpURLConnection uc;
private String topicMgrCred;
@@ -90,10 +91,13 @@ public class MrProvConnection extends BaseLoggingClass{
provURL = cluster.getTopicProtocol() + "://" + cluster.getFqdn() + ":" + cluster.getTopicPort() + "/topics/create";
+ if ( cluster.getTopicProtocol().equals( "https" ) ) {
+ return makeSecureConnection( provURL );
+ }
return makeConnection( provURL );
}
- private boolean makeConnection( String pURL ) {
+ private boolean makeSecureConnection( String pURL ) {
logger.info( "makeConnection to " + pURL );
try {
@@ -112,6 +116,25 @@ public class MrProvConnection extends BaseLoggingClass{
}
}
+ private boolean makeConnection( String pURL ) {
+ logger.info( "makeConnection to " + pURL );
+
+ try {
+ URL u = new URL( pURL );
+ uc = (HttpURLConnection) u.openConnection();
+ uc.setInstanceFollowRedirects(false);
+ logger.info( "open connect to " + pURL );
+ return(true);
+ } catch( UnknownHostException uhe ){
+ logger.error( "Caught UnknownHostException for " + pURL);
+ return(false);
+ } catch (Exception e) {
+ logger.error("Unexpected error during openConnection of " + pURL );
+ e.printStackTrace();
+ return(false);
+ }
+
+ }
static String bodyToString( InputStream is ) {
StringBuilder sb = new StringBuilder();
diff --git a/src/main/java/org/onap/dmaap/dbcapi/client/MrTopicConnection.java b/src/main/java/org/onap/dmaap/dbcapi/client/MrTopicConnection.java
index b79b33a..e1ea955 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/client/MrTopicConnection.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/client/MrTopicConnection.java
@@ -27,6 +27,7 @@ import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.ProtocolException;
import java.net.URL;
+import java.net.HttpURLConnection;
import javax.net.ssl.HttpsURLConnection;
import javax.net.ssl.SSLException;
@@ -41,7 +42,7 @@ import org.onap.dmaap.dbcapi.util.DmaapConfig;
public class MrTopicConnection extends BaseLoggingClass {
private String topicURL;
- private HttpsURLConnection uc;
+ private HttpURLConnection uc;
private String mmProvCred;
@@ -62,10 +63,13 @@ public class MrTopicConnection extends BaseLoggingClass {
topicURL = cluster.getTopicProtocol() + "://" + fqdn + ":" + cluster.getTopicPort() + "/events/" + topic ;
+ if ( cluster.getTopicProtocol().equals( "https")) {
+ return makeSecureConnection( topicURL );
+ }
return makeConnection( topicURL );
}
- private boolean makeConnection( String pURL ) {
+ private boolean makeSecureConnection( String pURL ) {
logger.info( "makeConnection to " + pURL );
try {
@@ -81,6 +85,22 @@ public class MrTopicConnection extends BaseLoggingClass {
}
}
+ private boolean makeConnection( String pURL ) {
+ logger.info( "makeConnection to " + pURL );
+
+ try {
+ URL u = new URL( pURL );
+ uc = (HttpURLConnection) u.openConnection();
+ uc.setInstanceFollowRedirects(false);
+ logger.info( "open connection to " + pURL );
+ return(true);
+ } catch (Exception e) {
+ logger.error("Unexpected error during openConnection of " + pURL );
+ e.printStackTrace();
+ return(false);
+ }
+
+ }
static String bodyToString( InputStream is ) {
StringBuilder sb = new StringBuilder();
diff --git a/src/main/java/org/onap/dmaap/dbcapi/model/MR_Cluster.java b/src/main/java/org/onap/dmaap/dbcapi/model/MR_Cluster.java
index 79de9ba..8185083 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/model/MR_Cluster.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/model/MR_Cluster.java
@@ -55,6 +55,7 @@ public class MR_Cluster extends DmaapObject {
}
+ // Deprecate this constructor
public MR_Cluster( String dLN,
String f,
String a,
@@ -70,9 +71,27 @@ public class MR_Cluster extends DmaapObject {
this.lastMod = new DmaapTimestamp();
this.lastMod.mark();
- debugLogger.debug( "MR_Cluster constructor w initialization complete" + this.lastMod.getVal() );
+ debugLogger.debug( "depracated MR_Cluster constructor w initialization complete" + this.lastMod.getVal() );
}
-
+
+ // new style constructor
+ public MR_Cluster( String dLN,
+ String f,
+ String prot,
+ String port ) {
+ this.dcaeLocationName = dLN;
+ this.fqdn = f;
+ this.hosts = new String[3];
+ this.hosts[0] = fqdn;
+ this.hosts[1] = fqdn;
+ this.hosts[2] = fqdn;
+ this.topicProtocol = prot;
+ this.topicPort = port;
+ this.lastMod = new DmaapTimestamp();
+ this.lastMod.mark();
+
+ debugLogger.debug( "MR_Cluster constructor w initialization complete" + this.lastMod.getVal() );
+}
public String getDcaeLocationName() {
return dcaeLocationName;
}
diff --git a/src/main/java/org/onap/dmaap/dbcapi/service/DmaapService.java b/src/main/java/org/onap/dmaap/dbcapi/service/DmaapService.java
index 03410f3..e7d4e04 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/service/DmaapService.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/service/DmaapService.java
@@ -52,12 +52,11 @@ public class DmaapService extends BaseLoggingClass {
private Singleton<Dmaap> dmaapholder = DatabaseClass.getDmaap();
- // TODO put these in properties file
+
String topicFactory; // = "org.openecomp.dcae.dmaap.topicFactory";
String topicMgrRole; // = "org.openecomp.dmaapBC.TopicMgr";
-
- // TODO confirm this is equivalent to dmaap.getTopicNsRoot() so we can retire it
String dcaeTopicNs; // = "org.openecomp.dcae.dmaap";
+ private boolean multiSite;
public DmaapService() {
@@ -65,6 +64,7 @@ public class DmaapService extends BaseLoggingClass {
topicFactory = p.getProperty("MR.TopicFactoryNS", "MR.topicFactoryNS.not.set");
topicMgrRole = p.getProperty("MR.TopicMgrRole", "MR.TopicMgrRole.not.set" );
dcaeTopicNs = dmaapholder.get().getTopicNsRoot();
+ multiSite = "true".equalsIgnoreCase(p.getProperty("MR.multisite", "true"));
}
@@ -85,7 +85,11 @@ public class DmaapService extends BaseLoggingClass {
AafService aaf = new AafService( ServiceType.AAF_Admin);
ApiPerms p = new ApiPerms();
p.setEnvMap();
- boolean anythingWrong = setTopicMgtPerms( nd, aaf ) || createMmaTopic();
+ boolean anythingWrong = false;
+
+ if ( multiSite ) {
+ anythingWrong = setTopicMgtPerms( nd, aaf ) || createMmaTopic();
+ }
if ( anythingWrong ) {
dmaap.setStatus(DmaapObject_Status.INVALID);
@@ -121,7 +125,9 @@ public class DmaapService extends BaseLoggingClass {
ApiPerms p = new ApiPerms();
p.setEnvMap();
AafService aaf = new AafService( ServiceType.AAF_Admin);
- anythingWrong = setTopicMgtPerms( nd, aaf ) || createMmaTopic();
+ if ( multiSite ) {
+ anythingWrong = setTopicMgtPerms( nd, aaf ) || createMmaTopic();
+ }
}
if ( anythingWrong ) {
diff --git a/src/main/java/org/onap/dmaap/dbcapi/service/MR_ClusterService.java b/src/main/java/org/onap/dmaap/dbcapi/service/MR_ClusterService.java
index 529723e..2dae579 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/service/MR_ClusterService.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/service/MR_ClusterService.java
@@ -32,10 +32,19 @@ import org.onap.dmaap.dbcapi.model.ApiError;
import org.onap.dmaap.dbcapi.model.DcaeLocation;
import org.onap.dmaap.dbcapi.model.MR_Cluster;
import org.onap.dmaap.dbcapi.model.DmaapObject.DmaapObject_Status;
+import org.onap.dmaap.dbcapi.util.DmaapConfig;
public class MR_ClusterService extends BaseLoggingClass {
private Map<String, MR_Cluster> mr_clusters = DatabaseClass.getMr_clusters();
+ private boolean multiSite;
+
+ public MR_ClusterService() {
+ logger.info( "new ClusterService");
+ DmaapConfig p = (DmaapConfig)DmaapConfig.getConfig();
+ multiSite = "true".equalsIgnoreCase(p.getProperty("MR.multisite", "true"));
+
+ }
public Map<String, MR_Cluster> getMR_Clusters() {
return mr_clusters;
@@ -89,7 +98,7 @@ public class MR_ClusterService extends BaseLoggingClass {
mr_clusters.put( cluster.getDcaeLocationName(), cluster );
DcaeLocationService svc = new DcaeLocationService();
DcaeLocation loc = svc.getDcaeLocation( cluster.getDcaeLocationName() );
- if ( loc != null && loc.isCentral() ) {
+ if ( loc != null && loc.isCentral() && multiSite ) {
ApiError resp = TopicService.setBridgeClientPerms( cluster );
if ( ! resp.is2xx() ) {
logger.error( "Unable to provision Bridge to " + cluster.getDcaeLocationName() );
@@ -119,7 +128,7 @@ public class MR_ClusterService extends BaseLoggingClass {
cluster.setLastMod();
cluster.setStatus(DmaapObject_Status.INVALID);
mr_clusters.put( cluster.getDcaeLocationName(), cluster );
- } else if ( loc.isCentral() ) {
+ } else if ( loc.isCentral() & multiSite ) {
ApiError resp = TopicService.setBridgeClientPerms( cluster );
if ( ! resp.is2xx() ) {
logger.error( "Unable to provision Bridge to " + cluster.getDcaeLocationName() );
diff --git a/src/test/java/org/onap/dmaap/dbcapi/client/MrProvConnectionTest.java b/src/test/java/org/onap/dmaap/dbcapi/client/MrProvConnectionTest.java
index 45b2f2e..1ada720 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/client/MrProvConnectionTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/client/MrProvConnectionTest.java
@@ -81,8 +81,8 @@ public class MrProvConnectionTest {
dls.addDcaeLocation( loc );
ApiError err = new ApiError();
- String[] hl = { "host1", "host2", "host3" };
- MR_Cluster cluster = new MR_Cluster( locname, "localhost", "", hl );
+
+ MR_Cluster cluster = new MR_Cluster( locname, "localhost", "http", "3904" );
mcs.addMr_Cluster( cluster, err );
ns.makeTopicConnection( cluster );
Topic topic = new Topic();
diff --git a/src/test/java/org/onap/dmaap/dbcapi/client/MrTopicConnectionTest.java b/src/test/java/org/onap/dmaap/dbcapi/client/MrTopicConnectionTest.java
index 2163925..dfb9a3b 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/client/MrTopicConnectionTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/client/MrTopicConnectionTest.java
@@ -81,8 +81,8 @@ public class MrTopicConnectionTest {
dls.addDcaeLocation( loc );
ApiError err = new ApiError();
- String[] hl = { "host1", "host2", "host3" };
- MR_Cluster cluster = new MR_Cluster( locname, "localhost", "", hl );
+
+ MR_Cluster cluster = new MR_Cluster( locname, "localhost", "http", "3904");
mcs.addMr_Cluster( cluster, err );
ns.makeTopicConnection( cluster, "org.onap.dmaap.anInterestingTopic", "" );
String msg = "{ 'key': '1234', 'val': 'hello world' }";
diff --git a/src/test/java/org/onap/dmaap/dbcapi/model/MR_ClusterTest.java b/src/test/java/org/onap/dmaap/dbcapi/model/MR_ClusterTest.java
index 26bca4c..df102e3 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/model/MR_ClusterTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/model/MR_ClusterTest.java
@@ -30,7 +30,7 @@ import org.junit.Before;
import org.junit.Test;
import org.onap.dmaap.dbcapi.testframework.ReflectionHarness;
public class MR_ClusterTest {
- String d, fqdn, a;
+ String d, fqdn;
ReflectionHarness rh = new ReflectionHarness();
@@ -38,7 +38,6 @@ public class MR_ClusterTest {
public void setUp() throws Exception {
d = "central-onap";
fqdn = "mr.onap.org";
- a = "ignore";
}
@After
@@ -59,8 +58,7 @@ public class MR_ClusterTest {
@Test
public void testMR_ClusterClassConstructor() {
- String[] h = { "host1", "host2", "host3" };
- MR_Cluster t = new MR_Cluster( d, fqdn, a, h );
+ MR_Cluster t = new MR_Cluster( d, fqdn, "http", "3904");
t.getHosts();
diff --git a/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClusterServiceTest.java b/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClusterServiceTest.java
index 285647a..6552037 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClusterServiceTest.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/service/MR_ClusterServiceTest.java
@@ -74,7 +74,7 @@ public class MR_ClusterServiceTest {
ApiError err = new ApiError();
String[] h = { "zplvm009.onap.org", "zplvm007.onap.org", "zplvm008.onap.org" };
- MR_Cluster node = new MR_Cluster( locname, f, "ignore", h );
+ MR_Cluster node = new MR_Cluster( locname, f, "http", "3904");
MR_Cluster n2 = ns.addMr_Cluster( node, err );
if ( n2 != null ) {
diff --git a/src/test/java/org/onap/dmaap/dbcapi/testframework/DmaapObjectFactory.java b/src/test/java/org/onap/dmaap/dbcapi/testframework/DmaapObjectFactory.java
index 9d3c868..0bce106 100644
--- a/src/test/java/org/onap/dmaap/dbcapi/testframework/DmaapObjectFactory.java
+++ b/src/test/java/org/onap/dmaap/dbcapi/testframework/DmaapObjectFactory.java
@@ -71,6 +71,8 @@ public class DmaapObjectFactory {
private static final String edge_subnet = "10.10.20.0/24";
private static final String edge_cluster_fqdn = "localhost";
private static final String[]hosts = { "host1", "host2", "host3" };
+ private static final String port = "3904";
+ private static final String prot = "http";
public Dmaap genDmaap() {
return new Dmaap( dmaap_ver, dmaap_topic_root, dmaap_name, dmaap_dr, dmaap_log_url, dmaap_mm_topic, "nk", "ako" );
@@ -86,9 +88,9 @@ public class DmaapObjectFactory {
public MR_Cluster genMR_Cluster( String layer ) {
if ( layer.contains( "edge" ) ) {
- return new MR_Cluster( edge_loc, edge_cluster_fqdn, "ignore", hosts );
+ return new MR_Cluster( edge_loc, edge_cluster_fqdn, prot, port );
}
- return new MR_Cluster( central_loc, central_cluster_fqdn, "ignore", hosts );
+ return new MR_Cluster( central_loc, central_cluster_fqdn, prot, port );
}
public Topic genSimpleTopic( String tname ) {
diff --git a/version.properties b/version.properties
index 6e27268..d49958a 100644
--- a/version.properties
+++ b/version.properties
@@ -27,7 +27,7 @@
major=1
minor=0
-patch=3
+patch=4
base_version=${major}.${minor}.${patch}
# Release must be completed with git revision # in Jenkins