Skip to content

Unified --Json output#6419

Open
ArbaazKhan1 wants to merge 9 commits into
apache:mainfrom
ArbaazKhan1:accumulo-6391
Open

Unified --Json output#6419
ArbaazKhan1 wants to merge 9 commits into
apache:mainfrom
ArbaazKhan1:accumulo-6391

Conversation

@ArbaazKhan1

@ArbaazKhan1 ArbaazKhan1 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

addresses issue #6391

To make a universal --json flag I moved it from Fate and ServiceStatus and into ServerOpts so all commands inherit it. Added a new CommandOutputEnvelope class that will take accumulo JSON outputs and wraps them in an envelope for a unified output and a new CommandReport interface that report classes will inherit so they can produce both human-readable and computer readable lines. Started by wiring up fate --summary and service-status as the two proof-of-concept commands since both already have partial JSON support

@ArbaazKhan1

ArbaazKhan1 commented Jun 9, 2026

Copy link
Copy Markdown
Contributor Author

What the Json output would look like for `accumulo inst service-status --json

{
  "command": "accumulo admin service-status",
  "version": "1.0",
  "reportTime": "2026-06-09T20:20:01Z",
  "status": "OK",
  "data": {
    "reportTime": "2026-06-09T20:20:01.889Z",
    "zkReadErrors": 0,
    "showHosts": false,
    "summaries": {
      "COMPACTOR": {
        "resourceGroups": {
          "default": 1
        },
        "serviceByGroups": {
          "default": [
            "localhost:9600"
          ]
        },
        "serviceCount": 1,
        "errorCount": 0
      },
      "GC": {
        "resourceGroups": {
          "default": 1
        },
        "serviceByGroups": {
          "default": [
            "localhost:9998"
          ]
        },
        "serviceCount": 1,
        "errorCount": 0
      },
      "MANAGER": {
        "resourceGroups": {
          "default": 1
        },
        "serviceByGroups": {
          "default": [
            "localhost:9999"
          ]
        },
        "serviceCount": 1,
        "errorCount": 0
      },
      "MONITOR": {
        "resourceGroups": {
          "default": 1
        },
        "serviceByGroups": {
          "default": [
            "localhost:9995"
          ]
        },
        "serviceCount": 1,
        "errorCount": 0
      },
      "S_SERVER": {
        "resourceGroups": {
          "default": 1
        },
        "serviceByGroups": {
          "default": [
            "localhost:9700"
          ]
        },
        "serviceCount": 1,
        "errorCount": 0
      },
      "T_SERVER": {
        "resourceGroups": {
          "default": 1
        },
        "serviceByGroups": {
          "default": [
            "localhost:9800"
          ]
        },
        "serviceCount": 1,
        "errorCount": 0
      }
    }
  }
}

@ArbaazKhan1 ArbaazKhan1 marked this pull request as ready for review June 11, 2026 16:18
@ctubbsii ctubbsii added this to the 4.0.0 milestone Jun 18, 2026
Comment thread core/src/main/java/org/apache/accumulo/core/cli/CommandOutputEnvelope.java Outdated
Comment thread core/src/main/java/org/apache/accumulo/core/cli/CommandOutputEnvelope.java Outdated
Comment thread core/src/main/java/org/apache/accumulo/core/cli/CommandOutputEnvelope.java Outdated

@DomGarguilo DomGarguilo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying out some commands and things are looking good. I did find one discrepency that I think is caused by these changes. I tried accumulo inst service-status --json and realized the serviceByGroups field is printed even though it only should be when --showHosts is provided too. I think the logic that excludes that field from the output is broken now since the new envelope code serializes the ServiceStatusReport object directly instead of using its existing toJson() method. Probably need to update ServiceStatusReport.getData()

+ " Expected format: -o <key>=<value> [-o <key>=<value>]")
private List<String> overrides = new ArrayList<>();

@Parameter(names = {"-j", "--json"},

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Searched the project and the ListCompactions command has this -j/--json option already. Should probably remove that and let it read the inherited options.json instead

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants