Skip to content

Commit

Permalink
KAFKA-4108; Improve DumpLogSegments offsets-decoder output format
Browse files Browse the repository at this point in the history
This PR improves the output format of DumpLogSegments when the `--offset-decoder` option is used for consuming `__consumer_offsets`, especially when it comes to group metadata.

An example of the partial output with existing formatting:

```
key: metadata::console-consumer-40190 payload: consumer:range:1:{consumer-1-20240b92-fbf4-44d5-bf8c-66b6d70c9948=[foo-0]}
```

An example of the same output with suggested formatting:

```
key: {"metadata":"console-consumer-40190"} payload: {"protocolType":"consumer","protocol":"range","generationId":1,"assignment":"{consumer-1-20240b92-fbf4-44d5-bf8c-66b6d70c9948=[foo-0]}"}
```

Author: Vahid Hashemian <[email protected]>

Reviewers: Jason Gustafson <[email protected]>

Closes apache#1937 from vahidhashemian/KAFKA-4108
  • Loading branch information
vahidhashemian authored and hachikuji committed Oct 3, 2017
1 parent 9e35a2a commit 5663f51
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions core/src/main/scala/kafka/tools/DumpLogSegments.scala
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,12 @@ object DumpLogSegments {
}
}.mkString("{", ",", "}")

val keyString = s"metadata::$groupId"
val valueString = s"$protocolType:${group.protocol}:${group.generationId}:$assignment"
val keyString = Json.encode(Map("metadata" -> groupId))
val valueString = Json.encode(Map(
"protocolType" -> protocolType,
"protocol" -> group.protocol,
"generationId" -> group.generationId,
"assignment" -> assignment))

(Some(keyString), Some(valueString))
}
Expand Down

0 comments on commit 5663f51

Please sign in to comment.