package org.onap.dmaap.dbcapi.model;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.log4j.Logger;
-import org.onap.dmaap.dbcapi.logging.DmaapbcLogMessageEnum;
import org.onap.dmaap.dbcapi.service.MirrorMakerService;
+import java.util.ArrayList;
+
public class MirrorMaker extends DmaapObject {
- static final Logger logger = Logger.getLogger(MirrorMaker.class);
+
private String sourceCluster;
private String targetCluster;
public MirrorMaker(){
}
-
+ public MirrorMaker(String source, String target, int i) {
+ initMM( source, target );
+ // original mm names did not have any index, so leave off index 0 for
+ // backwards compatibility
+ if ( i != 0 ) {
+ String n = this.getMmName() + "_" + i;
+ this.setMmName(n);
+ }
+ }
public MirrorMaker(String source, String target) {
+ initMM( source, target );
+ }
+
+ private void initMM(String source, String target) {
sourceCluster = source;
targetCluster = target;
mmName = genKey(source, target);
- topics = new ArrayList<String>();
+ topics = new ArrayList<>();
}
}
}
*/
- public String updateWhiteList() {
+ public String getWhitelistUpdateJSON() {
StringBuilder str = new StringBuilder( "{ \"messageID\": \"" + MirrorMakerService.genTransactionId() + "\", \"updateWhiteList\": {" );
str.append( " \"name\": \"" + this.getMmName() + "\", \"whitelist\": \"" );
int numTargets = 0;
- //for (ReplicationVector rv: vectors) {
for (String rv: topics) {
if ( numTargets > 0 ) {
str.append( ",");
}
- //str.append( rv.getFqtn() );
str.append( rv );
numTargets++;
}
StringBuilder str = new StringBuilder( "{ \"messageID\": \"" + MirrorMakerService.genTransactionId() + "\", \"createMirrorMaker\": {" );
str.append( " \"name\": \"" + this.getMmName() + "\", " );
str.append( " \"consumer\": \"" + this.sourceCluster + ":" + consumerPort + "\", " );
- str.append( " \"producer\": \"" + this.targetCluster + ":" + producerPort + "\" ");
+ str.append( " \"producer\": \"" + this.targetCluster + ":" + producerPort + "\", ");
- str.append( " } }" );
+ str.append( " \"numStreams\": \"10\" } }" );
return str.toString();
}