-
Notifications
You must be signed in to change notification settings - Fork 3.4k
HBASE-25895 Implement a Cluster Metrics JSON endpoint #4177
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
HBASE-25895 Implement a Cluster Metrics JSON endpoint #4177
Conversation
This comment was marked as outdated.
This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As I mentioned on the review of your draft PR this is mostly boilerplate wiring up gson to jersey, and it looks sane to me, although I do not understand the requirements in detail.
|
||
@Override | ||
public JsonElement serialize(byte[] src, Type typeOfSrc, JsonSerializationContext context) { | ||
return new JsonPrimitive(Bytes.toString(src)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assume nonprintable characters in the string are url escaped here downstream from this call to the JsonPrimitve constructor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@apurtell I cannot tell you. Actually, I'm embarrassed to see that this commit doesn't include any tests. I've added some most basic coverage, including a test that shows the behavior of the configured Gson instance produced by the factory. Please advise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After some research, my understanding is that Gson handles escaping characters according to the JSON RFC's definition of String values. We are free, according to the RFC, to encode more aggressively than what Gson does, but it appears to implement the minimum plus some additional characters related to html. My test demonstrates that there are some binary values that are not encoded and that do not render well (at least on this machine).
We may chose to escape a wider range of code points, or we my consider some alternative encoding for binary values, such as base64 with perhaps some prefix.
I have made every effort to declare this API as IA.Private, so we are free to evolve it as we choose, so long as we can maintain a sufficient level of backward compatibility for our guarantees. Thus I would prefer to press forward with landing this initial implementation of the feature and continue this encoding discussion as a follow-on effort.
Please advise.
https://datatracker.ietf.org/doc/html/rfc4627#section-2.5
https://github.com/google/gson/blob/gson-parent-2.8.9/gson/src/main/java/com/google/gson/stream/JsonWriter.java#L133-L163
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @ndimiduk . I was mainly worried that we might break parsing.
@@ -689,9 +691,16 @@ protected MasterRpcServices createRpcServices() throws IOException { | |||
@Override | |||
protected void configureInfoServer(InfoServer infoServer) { | |||
infoServer.addUnprivilegedServlet("master-status", "/master-status", MasterStatusServlet.class); | |||
infoServer.addUnprivilegedServlet("api_v1", "/api/v1/*", buildApiV1Servlet()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is nice, something to build on
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
e50fff6
to
1c62e64
Compare
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
I'm not sure what to make of the test failure in precommit checks / yetus jdk11 hadoop3 checks / testResolvePortConflict. ZK resulted in a port conflict.
Is this somehow related to my conf customization in Ideas @busbey ? |
This failure does not reproduce locally when I run this new test and |
1c62e64
to
5446762
Compare
🎊 +1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
💔 -1 overall
This message was automatically generated. |
Publishes a set of JSON endpoints following a RESTful structure, which expose a subset of the `o.a.h.h.ClusterMetrics` object tree. The URI structure is as follows /api/v1/admin/cluster_metrics /api/v1/admin/cluster_metrics/live_servers /api/v1/admin/cluster_metrics/dead_servers Signed-off-by: Sean Busbey <busbey@apache.org> Signed-off-by: Andrew Purtell <apurtell@apache.org>
5446762
to
7b50d86
Compare
Publishes a set of JSON endpoints following a RESTful structure, which expose a subset of the
o.a.h.h.ClusterMetrics
object tree. The URI structure is as follows