<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<jettyVersion>9.3.8.RC0</jettyVersion>
<eelf.version>1.0.0</eelf.version>
- <artifact.version>1.0.18-SNAPSHOT</artifact.version>
+ <artifact.version>1.0.19-SNAPSHOT</artifact.version>
<!-- SONAR -->
<jacoco.version>0.7.7.201606060606</jacoco.version>
<sonar-jacoco-listeners.version>3.2</sonar-jacoco-listeners.version>
import org.onap.dmaap.dbcapi.util.DmaapConfig;
import org.onap.dmaap.dbcapi.service.DmaapService;
+import org.onap.dmaap.dbcapi.service.TopicService;
@XmlRootElement
private ReplicationType replicationCase;
private String globalMrURL; // optional: URL of global MR to replicate to/from
private FqtnType fqtnStyle;
- private String version;
+ private String version;
+ private String partitionCount;
+ private String replicationCount;
+
private ArrayList<MR_Client> clients;
private static Dmaap dmaap = new DmaapService().getDmaap();
-
+
+ private static String defaultPartitionCount;
+ private static String defaultReplicationCount;
+
// during unit testing, discovered that presence of dots in some values
// creates an unplanned topic namespace as we compose the FQTN.
// this may create sensitivity (i.e. 403) for subsequent creation of AAF perms, so best to not allow it
//this.dcaeLocationName = dcaeLocationName;
this.tnxEnabled = tnxEnabled;
this.owner = owner;
+ this.init();
this.setLastMod();
+ logger.debug( "Topic constructor w args " + this.getLastMod() );
+ }
+
+ public Topic init() {
+ DmaapConfig p = (DmaapConfig)DmaapConfig.getConfig();
+
+ defaultPartitionCount = p.getProperty( "MR.partitionCount", "2");
+ defaultReplicationCount = p.getProperty( "MR.replicationCount", "1");
+
this.setStatus( DmaapObject_Status.NEW );
this.replicationCase = ReplicationType.Validator("none");
this.fqtnStyle = FqtnType.Validator("none");
- logger.debug( "Topic constructor " + this.getLastMod() );
+ this.setPartitionCount( defaultPartitionCount );
+ this.setReplicationCount( defaultReplicationCount );
+
+ return this;
}
// expects a String in JSON format, with known fields to populate Topic object
this.setStatus( (String) jsonObj.get( "status" ) );
this.setReplicationCase( ReplicationType.Validator( (String) jsonObj.get( "replicationCase" ) ));
this.setFqtnStyle( FqtnType.Validator( (String) jsonObj.get( "fqtnStyle" ) ) );
+ this.setPartitionCount( (String) jsonObj.get("partitionCount"));
}
public String getFqtn() {
public void setOwner(String owner) {
this.owner = owner;
}
+ public String getPartitionCount() {
+ return partitionCount;
+ }
+ public void setPartitionCount(String partitions) {
+ this.partitionCount = partitions;
+ }
+ public String getReplicationCount() {
+ return replicationCount;
+ }
+ public void setReplicationCount(String replicationCount) {
+ this.replicationCount = replicationCount;
+ }
public void setClients(ArrayList<MR_Client> clients) {
return replicationCase;
}
-
-
- /*
- public void setReplicationCase(String val) {
- this.replicationCase = ReplicationType.Validator(val);
- }
- */
public void setReplicationCase(ReplicationType t) {
this.replicationCase = t;
str.append( this.getFqtn() );
str.append( "\", \"topicDescription\": \"");
str.append( this.getTopicDescription());
- str.append( "\", \"partitionCount\": \"2\", \"replicationCount\": \"1\" } ");
+ str.append( "\", \"partitionCount\": \"");
+ str.append( this.getPartitionCount());
+ str.append( "\", \"replicationCount\": \"");
+ str.append( this.getReplicationCount());
+ str.append( "\" } ");
+
logger.info( str.toString() );
return str.toString();
}
@Authorization
public class TopicResource extends BaseLoggingClass {
private static FqtnType defaultTopicStyle;
+ private static String defaultPartitionCount;
+ private static String defaultReplicationCount;
TopicService mr_topicService = new TopicService();
public TopicResource() {
DmaapConfig p = (DmaapConfig)DmaapConfig.getConfig();
- defaultTopicStyle = FqtnType.Validator( p.getProperty("MR.topicStyle", "FQTN_LEGACY_FORMAT"));
+ defaultTopicStyle = FqtnType.Validator( p.getProperty("MR.topicStyle", "FQTN_LEGACY_FORMAT"));
+ defaultPartitionCount = p.getProperty( "MR.partitionCount", "2");
+ defaultReplicationCount = p.getProperty( "MR.replicationCount", "1");
+
logger.info( "Setting defaultTopicStyle=" + defaultTopicStyle );
}
logger.info( "setting defaultTopicStyle=" + defaultTopicStyle + " for topic " + topic.getTopicName() );
topic.setFqtnStyle( defaultTopicStyle );
}
+ String pc = topic.getPartitionCount();
+ if ( pc == null ) {
+ topic.setPartitionCount(defaultPartitionCount);
+ }
+ String rc = topic.getReplicationCount();
+ if ( rc == null ) {
+ topic.setReplicationCount(defaultReplicationCount);
+ }
topic.setLastMod();
Boolean flag = false;
if (useExisting != null) {
import org.onap.dmaap.dbcapi.model.ApiError;
import org.onap.dmaap.dbcapi.model.Dmaap;
import org.onap.dmaap.dbcapi.model.MR_Client;
+import org.onap.dmaap.dbcapi.model.ReplicationType;
import org.onap.dmaap.dbcapi.model.Topic;
import org.onap.dmaap.dbcapi.model.DmaapObject.DmaapObject_Status;
import org.onap.dmaap.dbcapi.util.DmaapConfig;
if ( ! dmaap.isStatusValid() || ! nd.getDmaapName().equals(dmaap.getDmaapName()) || dmaap.getVersion().equals( "0") ) {
nd.setLastMod();
dmaapholder.update(nd); //need to set this so the following perms will pick up any new vals.
+ dcaeTopicNs = dmaapholder.get().getTopicNsRoot();
ApiPolicy apiPolicy = new ApiPolicy();
if ( apiPolicy.getUseAuthClass()) {
ApiPerms p = new ApiPerms();
clients.add( nClient );
// initialize Topic
- Topic mmaTopic = new Topic();
+ Topic mmaTopic = new Topic().init();
mmaTopic.setTopicName(dmaap.getBridgeAdminTopic());
mmaTopic.setClients(clients);
mmaTopic.setOwner("BusController");
mmaTopic.setTopicDescription("topic reserved for MirrorMaker Administration");
mmaTopic.setTnxEnabled("false");
+ mmaTopic.setPartitionCount("1"); // a single partition should guarantee message order
+
ApiError err = new ApiError();
TopicService svc = new TopicService();
String mmAgentRole = p.getProperty("MM.AgentRole");
String[] Roles = { mmProvRole, mmAgentRole };
String[] actions = { "view", "pub", "sub" };
- Topic bridgeAdminTopic = new Topic();
+ Topic bridgeAdminTopic = new Topic().init();
bridgeAdminTopic.setTopicName( dmaapSvc.getBridgeAdminFqtn() );
bridgeAdminTopic.setTopicDescription( "RESERVED topic for MirroMaker Provisioning");
bridgeAdminTopic.setOwner( "DBC" );
+
ArrayList<MR_Client> clients = new ArrayList<MR_Client>();
for( String role: Roles ) {
MR_Client client = new MR_Client();
--- /dev/null
+---
+-- ============LICENSE_START=======================================================
+-- OpenECOMP - org.onap.dbcapi
+-- ================================================================================
+-- Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+-- ================================================================================
+-- Licensed under the Apache License, Version 2.0 (the "License");
+-- you may not use this file except in compliance with the License.
+-- You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+-- ============LICENSE_END=========================================================
+---
+
+
+@alter table topic
+ add column partition_count varchar(10),
+ add column replication_count varchar(10)
+;
+
+-- set existing topics to have old default values, for display purposes
+update topic
+set partition_count = '2', replication_count = '1';
+
+
+update dmaapbc_sch_ver set version = 10 where version = 9;
import static org.junit.Assert.*;
-import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Type;
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
-
import static java.lang.System.out;
import static java.lang.System.err;
major=1
minor=0
-patch=18
+patch=19
base_version=${major}.${minor}.${patch}
# Release must be completed with git revision # in Jenkins