You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/12/09 10:11:49 UTC

[GitHub] [kafka] showuon commented on a change in pull request #11584: MINOR: improve logging

showuon commented on a change in pull request #11584:
URL: https://github.com/apache/kafka/pull/11584#discussion_r765638758



##########
File path: clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinator.java
##########
@@ -288,7 +288,7 @@ private Exception invokeOnAssignment(final ConsumerPartitionAssignor assignor, f
     }
 
     private Exception invokePartitionsAssigned(final Set<TopicPartition> assignedPartitions) {
-        log.info("Adding newly assigned partitions: {}", Utils.join(assignedPartitions, ", "));
+        log.info("Adding newly assigned partitions: {}", Utils.join(assignedPartitions.stream().sorted().toArray(), ", "));

Review comment:
       Good point!

##########
File path: clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinator.java
##########
@@ -397,10 +397,10 @@ protected void onJoinComplete(int generation,
                     "\tCurrent owned partitions:                  {}\n" +
                     "\tAdded partitions (assigned - owned):       {}\n" +
                     "\tRevoked partitions (owned - assigned):     {}\n",
-                assignedPartitions,
-                ownedPartitions,
-                addedPartitions,
-                revokedPartitions
+                Utils.join(assignedPartitions.stream().sorted().toArray(), ", "),
+                Utils.join(ownedPartitions.stream().sorted().toArray(), ", "),
+                Utils.join(addedPartitions.stream().sorted().toArray(), ", "),
+                Utils.join(revokedPartitions.stream().sorted().toArray(), ", ")

Review comment:
       Actually, the `assignedPartitions`, `addedPartitions`, and `revokedPartitions`, and the following `invokePartitionsRevoked`, `invokePartitionsAssigned` are coming from the `assignment.partitions()`(or the `assignedPartitions`). We can sort it first, and the rest of the partitions will be sorted.
   
   Just the `ownedPartitions` might still need to sort itself.




-- 
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.

To unsubscribe, e-mail: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org