summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/onap/dmaap/dmf/mr/service/impl/TopicServiceImpl.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/org/onap/dmaap/dmf/mr/service/impl/TopicServiceImpl.java')
-rw-r--r--src/main/java/org/onap/dmaap/dmf/mr/service/impl/TopicServiceImpl.java17
1 files changed, 8 insertions, 9 deletions
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;
}