Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Align output format of REST API to return JSON #16087

Merged
merged 10 commits into from Nov 27, 2019

Conversation

@mmedenjak
Copy link
Contributor

mmedenjak commented Nov 22, 2019

  • changes the output format of the healthcheck and cluster URI to return
    JSON. Previously, they were sending distinct custom formats not returned
    by any other URI. Also, many other URIs were already returning JSON
  • used the checkCredentials method in all of the POST handlers since it
    handles the case when there is no data sent and does not produce NPE
  • made all handlers to use the common prepareResponse method which now
    prepares the response for different response types appropriately
  • expanded the return value of the cluster URI to return an array with
    JSON objects for each cluster member so user does not need to parse the
    member list but kept the list as a separate value as a summary
  • remove unused methods
  • add credentials checks to WAN URI's
  • refactor credentials checks and exception handling to share code between handlers
  • in case of failed authentication, return HTTP 403 with empty response instead of HTTP 200 with JSON response

curl localhost:5701/hazelcast/rest/cluster
Previous output:

Members {size:2, ver:2} [
	Member [127.0.0.1]:5701 - 56b1b0b4-5d5f-46b9-b2f0-683e8f061e86 this
	Member [127.0.0.1]:5702 - 46a89fca-e718-416a-818c-8604f9770a68
]

ConnectionCount: 1
AllConnectionCount: 2

New output:

{
  "members": [
    {
      "address": "[127.0.0.1]:5701",
      "liteMember": false,
      "localMember": true,
      "uuid": "24434a55-6f28-49ee-9244-54615cf2c8da",
      "memberVersion": "4.0.0"
    },
    {
      "address": "[127.0.0.1]:5702",
      "liteMember": false,
      "localMember": false,
      "uuid": "338e5e45-fa5c-43b0-955d-30ea7237a3e2",
      "memberVersion": "4.0.0"
    }
  ],
  "connectionCount": 1,
  "allConnectionCount": 2
}

curl localhost:5701/hazelcast/health
Previous output:

Hazelcast::NodeState=ACTIVE
Hazelcast::ClusterState=ACTIVE
Hazelcast::ClusterSafe=TRUE
Hazelcast::MigrationQueueSize=0
Hazelcast::ClusterSize=2

New output:

{
  "nodeState": "ACTIVE",
  "clusterState": "ACTIVE",
  "clusterSafe": "TRUE",
  "migrationQueueSize": 0,
  "clusterSize": 2
}

Fixes: #10753
EE: hazelcast/hazelcast-enterprise#3383

@mmedenjak mmedenjak added this to the 4.0 milestone Nov 22, 2019
@mmedenjak mmedenjak self-assigned this Nov 22, 2019
@mmedenjak mmedenjak force-pushed the mmedenjak:4.0-rest-json branch from d748520 to 7292bb9 Nov 22, 2019
@mmedenjak mmedenjak requested review from emre-aydin and leszko Nov 22, 2019
@mmedenjak mmedenjak force-pushed the mmedenjak:4.0-rest-json branch from 7292bb9 to c3ae6b5 Nov 22, 2019
@emre-aydin

This comment has been minimized.

Copy link
Contributor

emre-aydin commented Nov 25, 2019

Note: we need to update the reference manual when this gets merged.

@mmedenjak mmedenjak force-pushed the mmedenjak:4.0-rest-json branch from ec005f5 to 9528496 Nov 25, 2019
@leszko
leszko approved these changes Nov 26, 2019
Copy link
Contributor

leszko left a comment

@mmedenjak Very good change 👍 Added a minor comment, other than that, LGTM.

@mmedenjak mmedenjak force-pushed the mmedenjak:4.0-rest-json branch from 9528496 to 0c770d2 Nov 26, 2019
Matko Medenjak added 10 commits Nov 22, 2019
- changes the output format of the healthcheck and cluster URI to return
JSON. Previously, they were sending distinct custom formats not returned
by any other URI. Also, many other URIs were already returning JSON
- used the checkCredentials method in all of the POST handlers since it
handles the case when there is no data sent and does not produce NPE
- made all handlers to use the common prepareResponse method which now
prepares the response for different response types appropriately
- expanded the return value of the cluster URI to return an array with
JSON objects for each cluster member so user does not need to parse the
member list but kept the list as a separate value as a summary
- remove unused methods

Fixes: #10753
Matko Medenjak
@mmedenjak mmedenjak force-pushed the mmedenjak:4.0-rest-json branch from e29b98e to 9b912cd Nov 27, 2019
@mmedenjak mmedenjak merged commit ff3ce46 into hazelcast:master Nov 27, 2019
1 check passed
1 check passed
default Test PASSed.
Details
@mmedenjak mmedenjak deleted the mmedenjak:4.0-rest-json branch Nov 27, 2019
@mmedenjak

This comment has been minimized.

Copy link
Contributor Author

mmedenjak commented Nov 27, 2019

Merged, finally! Thank you for the reviews, guys! 🙇
The follow-up PR with further cleanup of exception handling will come soon :)

mmedenjak pushed a commit to mmedenjak/hazelcast-reference-manual that referenced this pull request Nov 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.