aboutsummaryrefslogtreecommitdiffstats
path: root/src/main
diff options
context:
space:
mode:
authordglFromAtt <dgl@research.att.com>2018-11-08 16:19:31 -0500
committerdglFromAtt <dgl@research.att.com>2018-11-08 16:19:37 -0500
commit0e39c2d9a88a26693de1cd522766df5894917b3f (patch)
tree46cd34f95b171ffb0ce1487a0aeb56d773ae6f8c /src/main
parent87bf9245434ad317ea39a84a0099233197f3d7c2 (diff)
Provision topics on mr_clusters
Change-Id: I3f6bb1c46ea77bf5c4cd1ad2ed6339adb25fb0d0 Signed-off-by: dglFromAtt <dgl@research.att.com> Issue-ID: DMAAP-879
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/service/MR_ClusterService.java25
-rw-r--r--src/main/java/org/onap/dmaap/dbcapi/service/TopicService.java13
2 files changed, 34 insertions, 4 deletions
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 e2c661b..dea5d83 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
@@ -28,11 +28,13 @@ import java.util.Set;
import javax.ws.rs.core.Response.Status;
+import org.onap.dmaap.dbcapi.client.MrProvConnection;
import org.onap.dmaap.dbcapi.database.DatabaseClass;
import org.onap.dmaap.dbcapi.logging.BaseLoggingClass;
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.Topic;
import org.onap.dmaap.dbcapi.model.DmaapObject.DmaapObject_Status;
import org.onap.dmaap.dbcapi.service.DcaeLocationService;
import org.onap.dmaap.dbcapi.util.DmaapConfig;
@@ -119,7 +121,7 @@ public class MR_ClusterService extends BaseLoggingClass {
return null;
}
cluster.setLastMod();
- cluster.setStatus(DmaapObject_Status.VALID);
+ cluster.setStatus( addTopicsToCluster( cluster, apiError ) );
mr_clusters.put( cluster.getDcaeLocationName(), cluster );
DcaeLocationService svc = new DcaeLocationService();
DcaeLocation loc = svc.getDcaeLocation( cluster.getDcaeLocationName() );
@@ -145,6 +147,7 @@ public class MR_ClusterService extends BaseLoggingClass {
return null;
}
cluster.setLastMod();
+ cluster.setStatus( addTopicsToCluster( cluster, apiError ) );
mr_clusters.put( cluster.getDcaeLocationName(), cluster );
DcaeLocationService svc = new DcaeLocationService();
DcaeLocation loc = svc.getDcaeLocation( cluster.getDcaeLocationName() );
@@ -162,6 +165,7 @@ public class MR_ClusterService extends BaseLoggingClass {
mr_clusters.put( cluster.getDcaeLocationName(), cluster );
}
}
+
apiError.setCode(200);
return cluster;
}
@@ -178,5 +182,22 @@ public class MR_ClusterService extends BaseLoggingClass {
return mr_clusters.remove(key);
}
-
+ private DmaapObject_Status addTopicsToCluster( MR_Cluster cluster, ApiError err ){
+
+ TopicService ts = new TopicService();
+ MrProvConnection prov = new MrProvConnection();
+ List<Topic> topics = ts.getAllTopicsWithoutClients();
+ for( Topic topic: topics ) {
+ logger.info( "POST topic " + topic.getFqtn() + " to cluster " + cluster.getFqdn() + " in loc " + cluster.getDcaeLocationName());
+ if ( prov.makeTopicConnection(cluster)) {
+ String resp = prov.doPostTopic(topic, err);
+ logger.info( "response code: " + err.getCode() );
+ if ( ! err.is2xx() && ! (err.getCode() == 409) ) {
+ return DmaapObject_Status.INVALID;
+ }
+ }
+ }
+
+ return DmaapObject_Status.VALID;
+ }
}
diff --git a/src/main/java/org/onap/dmaap/dbcapi/service/TopicService.java b/src/main/java/org/onap/dmaap/dbcapi/service/TopicService.java
index 6a93a21..e4bc96c 100644
--- a/src/main/java/org/onap/dmaap/dbcapi/service/TopicService.java
+++ b/src/main/java/org/onap/dmaap/dbcapi/service/TopicService.java
@@ -80,9 +80,18 @@ public class TopicService extends BaseLoggingClass {
}
public List<Topic> getAllTopics() {
+ return getAllTopics( true );
+ }
+ public List<Topic> getAllTopicsWithoutClients() {
+ return getAllTopics(false);
+ }
+
+ private List<Topic> getAllTopics( Boolean withClients ) {
ArrayList<Topic> topics = new ArrayList<Topic>(mr_topics.values());
- for( Topic topic: topics ) {
- topic.setClients( clientService.getAllMrClients(topic.getFqtn()));
+ if ( withClients ) {
+ for( Topic topic: topics ) {
+ topic.setClients( clientService.getAllMrClients(topic.getFqtn()));
+ }
}
return topics;
}