mirror of https://github.com/apache/kafka.git
KAFKA-19109 Don't print null in kafka-metadata-quorum describe status (#19543)
If directory id is `Uuid.ZERO_UUID`, the command don't print the result. Reviewers: Ken Huang <s7133700@gmail.com>, TengYao Chi <frankvicky@apache.org>, Chia-Ping Tsai <chia7712@gmail.com>
This commit is contained in:
parent
3696c49788
commit
61cb33f347
|
@ -315,8 +315,10 @@ public class MetadataQuorumCommand {
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("{");
|
sb.append("{");
|
||||||
sb.append("\"id\": ").append(id).append(", ");
|
sb.append("\"id\": ").append(id);
|
||||||
sb.append("\"directoryId\": ").append(directoryId.equals(Uuid.ZERO_UUID) ? "null" : "\"" + directoryId + "\"");
|
if (!directoryId.equals(Uuid.ZERO_UUID)) {
|
||||||
|
sb.append(", ").append("\"directoryId\": ").append("\"").append(directoryId).append("\"");
|
||||||
|
}
|
||||||
if (!endpoints.isEmpty()) {
|
if (!endpoints.isEmpty()) {
|
||||||
sb.append(", \"endpoints\": [");
|
sb.append(", \"endpoints\": [");
|
||||||
for (RaftVoterEndpoint endpoint : endpoints) {
|
for (RaftVoterEndpoint endpoint : endpoints) {
|
||||||
|
|
|
@ -116,7 +116,7 @@ class MetadataQuorumCommandTest {
|
||||||
assertTrue(outputs[4].matches("MaxFollowerLag:\\s+\\d+"), describeOutput);
|
assertTrue(outputs[4].matches("MaxFollowerLag:\\s+\\d+"), describeOutput);
|
||||||
assertTrue(outputs[5].matches("MaxFollowerLagTimeMs:\\s+-?\\d+"), describeOutput);
|
assertTrue(outputs[5].matches("MaxFollowerLagTimeMs:\\s+-?\\d+"), describeOutput);
|
||||||
assertTrue(
|
assertTrue(
|
||||||
outputs[6].matches("CurrentVoters:\\s+\\[\\{\"id\":\\s+\\d+,\\s+\"directoryId\":\\s+\\S+,\\s+" +
|
outputs[6].matches("CurrentVoters:\\s+\\[\\{\"id\":\\s+\\d+,\\s+" +
|
||||||
"\"endpoints\":\\s+\\[\"\\S+://\\[?\\S+]?:\\d+\",?.*]"),
|
"\"endpoints\":\\s+\\[\"\\S+://\\[?\\S+]?:\\d+\",?.*]"),
|
||||||
describeOutput
|
describeOutput
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue