sarathsubramanian commented on a change in pull request #118:
URL: https://github.com/apache/atlas/pull/118#discussion_r564562698
##########
File path: common/src/main/java/org/apache/atlas/utils/KafkaUtils.java
##########
@@ -143,6 +135,33 @@ public Integer getPartitionCount(String topicName) throws
ExecutionException, In
return partitionCount;
}
+ public Integer getReplicationFactor(String topicName) throws
ExecutionException, InterruptedException {
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("==> KafkaUtils.getReplicationFactor({})", topicName);
+ }
+
+ Integer replicationFactor =
getPartitionList(topicName).stream().mapToInt(x ->
x.replicas().size()).max().getAsInt();
Review comment:
consider adding null check for getPartitionList(topicName)
##########
File path: common/src/main/java/org/apache/atlas/utils/KafkaUtils.java
##########
@@ -143,6 +135,33 @@ public Integer getPartitionCount(String topicName) throws
ExecutionException, In
return partitionCount;
}
+ public Integer getReplicationFactor(String topicName) throws
ExecutionException, InterruptedException {
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("==> KafkaUtils.getReplicationFactor({})", topicName);
+ }
+
+ Integer replicationFactor =
getPartitionList(topicName).stream().mapToInt(x ->
x.replicas().size()).max().getAsInt();
+
+ if(LOG.isDebugEnabled()) {
+ LOG.debug("<== KafkaUtils.getReplicationFactor returning for topic
{} with replicationFactor {}", topicName, replicationFactor);
+ }
+
+ return replicationFactor;
+ }
+
+ private List<TopicPartitionInfo> getPartitionList(String topicName) throws
ExecutionException, InterruptedException {
+ List<TopicPartitionInfo> partitionList = null;
+
+ DescribeTopicsResult describeTopicsResult =
adminClient.describeTopics(Collections.singleton(topicName));
+ Map<String, KafkaFuture<TopicDescription>> futureMap =
describeTopicsResult.values();
Review comment:
can 'describeTopicsResult' be null if no topics exist? add necessary
null check
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]