Skip to content

Unified --Json output#6419

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

Unified --Json output#6419
ArbaazKhan1 wants to merge 8 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
* "reportTime": "2026-06-04T12:00:00Z",
* "status": "OK",
* "message": null,
* "data": { ...command-specific payload... }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if the command output should be it's own top level element instead. For example,

{
  "status": {
    "command": "accumulo admin fate --summary",
    "version": "1",
    "reportTime": "2026-06-04T12:00:00Z",
    "status": "OK",
    "message": ""
  },
  "output": {
  }
}

Comment on lines +78 to +79
this.status = status;
this.message = message;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Might be able to combine these two fields into one. For success the value could be OK. For a failure the value could be ERROR: <message>

Comment on lines +59 to +60
private static final DateTimeFormatter ISO_FMT =
DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss'Z'");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I wonder if it would be more user friendly to use the hosts timezone.


if (options.json) {
System.out.println(report.toJson());
System.out.println(report.toEnvelopedJson("accumulo admin service-status"));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It might make sense to add a method to ServerKeywordExecutable that returns the invoked command. This would make this more flexible if the command group or command name changes in the future.

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.

3 participants