X-Git-Url: https://gerrit.onap.org/r/gitweb?p=dmaap%2Fmessagerouter%2Fmessageservice.git;a=blobdiff_plain;f=src%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdmf%2Fmr%2Fservice%2Fimpl%2FTopicServiceImpl.java;fp=src%2Fmain%2Fjava%2Forg%2Fonap%2Fdmaap%2Fdmf%2Fmr%2Fservice%2Fimpl%2FTopicServiceImpl.java;h=69c1414a5670004a38ae4e60c899259d7f21959e;hp=386fb97cabe51abe421b55a5d6518844fe2cbbbe;hb=45fe8aec27a65fb4ce38bd71698b1dc2db904aa4;hpb=89701dc6483800daef21eac3feafd4f74553f238 diff --git a/src/main/java/org/onap/dmaap/dmf/mr/service/impl/TopicServiceImpl.java b/src/main/java/org/onap/dmaap/dmf/mr/service/impl/TopicServiceImpl.java index 386fb97..69c1414 100644 --- a/src/main/java/org/onap/dmaap/dmf/mr/service/impl/TopicServiceImpl.java +++ b/src/main/java/org/onap/dmaap/dmf/mr/service/impl/TopicServiceImpl.java @@ -198,8 +198,9 @@ public class TopicServiceImpl implements TopicService { LOGGER.info("Creating topic {}",topicName); String key = authorizeClient(dmaapContext, topicName, TOPIC_CREATE_OP); try { - final int partitions = getValueOrDefault(topicBean.getPartitionCount(), "default.partitions"); - final int replicas = getValueOrDefault(topicBean.getReplicationCount(), "default.replicas"); + final int partitions = getIntValueOrDefault("default.partitions"); + final int replicas = getIntValueOrDefault("default.replicas"); + LOGGER.info("Attempting to create topic {} with replicas={}, partitions={}", topicName, replicas, partitions); final Topic t = getMetaBroker(dmaapContext).createTopic(topicName, topicBean.getTopicDescription(), key, partitions, replicas, topicBean.isTransactionEnabled()); LOGGER.info("Topic {} created successfully. Sending response", topicName); @@ -258,13 +259,11 @@ public class TopicServiceImpl implements TopicService { return enfTopicNamespace != null && topicName.startsWith(enfTopicNamespace); } - int getValueOrDefault(int value, String defaultProperty) { - int returnValue = value; - if (returnValue <= 0) { - String defaultValue = getPropertyFromAJSCmap(defaultProperty); - returnValue = StringUtils.isNotEmpty(defaultValue) ? NumberUtils.toInt(defaultValue) : 1; - returnValue = (returnValue <= 0) ? 1 : returnValue; - } + int getIntValueOrDefault(String defaultProperty) { + int returnValue; + String defaultValue = getPropertyFromAJSCmap(defaultProperty); + returnValue = StringUtils.isNotEmpty(defaultValue) ? NumberUtils.toInt(defaultValue) : 1; + returnValue = (returnValue <= 0) ? 1 : returnValue; return returnValue; }