This is an automated email from the ASF dual-hosted git repository.
erose pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git
The following commit(s) were added to refs/heads/master by this push:
new 1ea7d8c2522 HDDS-13593. Make container ListSubcommand use
JsonUtils#getStdoutSequenceWriter (#9017)
1ea7d8c2522 is described below
commit 1ea7d8c25229aa535c488edb648cf300682657b8
Author: sreejasahithi <[email protected]>
AuthorDate: Fri Sep 12 22:16:53 2025 +0530
HDDS-13593. Make container ListSubcommand use
JsonUtils#getStdoutSequenceWriter (#9017)
---
.../hdds/scm/cli/container/ListSubcommand.java | 40 ++--------------------
1 file changed, 2 insertions(+), 38 deletions(-)
diff --git
a/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/container/ListSubcommand.java
b/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/container/ListSubcommand.java
index 0b88cec37f9..4bc9af843a0 100644
---
a/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/container/ListSubcommand.java
+++
b/hadoop-ozone/cli-admin/src/main/java/org/apache/hadoop/hdds/scm/cli/container/ListSubcommand.java
@@ -26,7 +26,6 @@
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
import com.google.common.base.Strings;
import java.io.IOException;
-import java.io.OutputStream;
import java.util.List;
import org.apache.hadoop.hdds.cli.HddsVersionProvider;
import org.apache.hadoop.hdds.client.ReplicationConfig;
@@ -38,6 +37,7 @@
import org.apache.hadoop.hdds.scm.client.ScmClient;
import org.apache.hadoop.hdds.scm.container.ContainerInfo;
import org.apache.hadoop.hdds.scm.container.ContainerListResult;
+import org.apache.hadoop.hdds.server.JsonUtils;
import picocli.CommandLine.Command;
import picocli.CommandLine.Help.Visibility;
import picocli.CommandLine.Option;
@@ -117,8 +117,7 @@ public void execute(ScmClient scmClient) throws IOException
{
ScmConfigKeys.OZONE_SCM_CONTAINER_LIST_MAX_COUNT_DEFAULT);
// Use SequenceWriter to output JSON array format for all cases
- SequenceWriter sequenceWriter = WRITER.writeValues(new
NonClosingOutputStream(System.out));
- sequenceWriter.init(true); // Initialize as a JSON array
+ SequenceWriter sequenceWriter = JsonUtils.getStdoutSequenceWriter();
if (!all) {
// Regular listing with count limit
@@ -181,39 +180,4 @@ private void listAllContainers(ScmClient scmClient,
SequenceWriter writer,
}
} while (fetchedCount > 0);
}
-
- // TODO HDDS-13593 Remove this in favor of JsonUtils#getStdoutSequenceWriter.
- private static class NonClosingOutputStream extends OutputStream {
-
- private final OutputStream delegate;
-
- NonClosingOutputStream(OutputStream delegate) {
- this.delegate = delegate;
- }
-
- @Override
- public void write(int b) throws IOException {
- delegate.write(b);
- }
-
- @Override
- public void write(byte[] b) throws IOException {
- delegate.write(b);
- }
-
- @Override
- public void write(byte[] b, int off, int len) throws IOException {
- delegate.write(b, off, len);
- }
-
- @Override
- public void flush() throws IOException {
- delegate.flush();
- }
-
- @Override
- public void close() {
- // Ignore close to keep the underlying stream open
- }
- }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]