Catch topic already assigned to mmagent 34/72434/1
authordglFromAtt <dgl@research.att.com>
Sat, 10 Nov 2018 19:23:57 +0000 (14:23 -0500)
committerdglFromAtt <dgl@research.att.com>
Sat, 10 Nov 2018 19:24:09 +0000 (14:24 -0500)
Change-Id: I75c9fffc2785cb59bac9e7ccaddebfec72b4c6e1
Signed-off-by: dglFromAtt <dgl@research.att.com>
Issue-ID: DMAAP-880

src/main/java/org/onap/dmaap/dbcapi/service/MirrorMakerService.java
src/main/java/org/onap/dmaap/dbcapi/service/TopicService.java

index 8acc4f3..382e536 100644 (file)
@@ -155,7 +155,7 @@ public class MirrorMakerService extends BaseLoggingClass {
                return ret;
        }
        
-       public MirrorMaker getNextMM( String source, String target ) {
+       public MirrorMaker getNextMM( String source, String target, String fqtn ) {
                int i = 0;
                MirrorMaker mm = null;
                while( mm == null ) {
@@ -164,6 +164,9 @@ public class MirrorMakerService extends BaseLoggingClass {
                        if ( mm == null ) {
                                mm = new MirrorMaker(source, target, i);
                        }
+                       if ( mm.getTopics().contains(fqtn) ) {
+                               break;
+                       }
                        if ( mm.getTopicCount() >= maxTopicsPerMM ) {
                                logger.info( "getNextMM: MM " + mm.getMmName() + " has " + mm.getTopicCount() + " topics.  Moving to next MM");
                                i++;
@@ -177,17 +180,17 @@ public class MirrorMakerService extends BaseLoggingClass {
 
        public MirrorMaker splitMM( MirrorMaker orig ) {
                
-               int index = 1;
                String source = orig.getSourceCluster();
                String target = orig.getTargetCluster();
                
                
                ArrayList<String> whitelist = orig.getTopics();
                while( whitelist.size() > maxTopicsPerMM ) {
-                       MirrorMaker mm = this.getNextMM( source, target );
+                       
                        int last = whitelist.size() - 1;
                        String topic = whitelist.get(last);
                        whitelist.remove(last);
+                       MirrorMaker mm = this.getNextMM( source, target, topic );
                        mm.addTopic(topic);     
                        this.updateMirrorMaker(mm);
                }
index a633982..56ed967 100644 (file)
@@ -433,7 +433,7 @@ public class TopicService extends BaseLoggingClass {
                        if ( source != null && target != null ) {
                                try { 
                                        logger.info( "Create a MM from " + source + " to " + target );
-                                       MirrorMaker mm = bridge.getNextMM( source, target);
+                                       MirrorMaker mm = bridge.getNextMM( source, target, topic.getFqtn());
                                        mm.addTopic(topic.getFqtn());
                                        bridge.updateMirrorMaker(mm);
                                } catch ( Exception ex ) {