<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>
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;
private String provURL;
- private HttpsURLConnection uc;
+ private HttpURLConnection uc;
private String topicMgrCred;
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 {
return(false);
}
+ }
+ 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 ) {
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;
public class MrTopicConnection extends BaseLoggingClass {
private String topicURL;
- private HttpsURLConnection uc;
+ private HttpURLConnection uc;
private String mmProvCred;
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 {
return(false);
}
+ }
+ 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 ) {
}
+ // Deprecate this constructor
public MR_Cluster( String dLN,
String f,
String a,
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;
}
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() {
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"));
}
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);
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 ) {
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;
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() );
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() );
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();
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' }";
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();
public void setUp() throws Exception {
d = "central-onap";
fqdn = "mr.onap.org";
- a = "ignore";
}
@After
@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();
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 ) {
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" );
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 ) {
major=1
minor=0
-patch=3
+patch=4
base_version=${major}.${minor}.${patch}
# Release must be completed with git revision # in Jenkins