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
Updated the response for reload API to be pretty printed #11608
Conversation
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.
cc @jadami10 to also provide some feedback
@@ -782,7 +782,7 @@ public SuccessResponse reloadAllSegments( | |||
LOGGER.error("Failed to add reload all segments job meta into zookeeper for table: {}", tableNameWithType, e); | |||
} | |||
} | |||
return new SuccessResponse("Segment reload details: " + JsonUtils.objectToString(perTableMsgData)); | |||
return new SuccessResponse(JsonUtils.objectToPrettyString(perTableMsgData)); |
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.
It doesn't need to be a json, maybe simply
return new SuccessResponse(JsonUtils.objectToPrettyString(perTableMsgData)); | |
return new SuccessResponse("Segment reload details: " + perTableMsgData); |
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.
it doesn't need to be, but what value is Segment reload details:
to the result of an endpoint that is clearly already the reload details. The impetus for this change was to make it easier to parse the result in java/scala so you don't have to go from request -> strip the prefix -> decode the json string -> decode the json. You should be able to go from request -> json in 1 hop.
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.
For now, I've just kept the json string in the success response which makes it easier to parse/understand. Please let me know what you think Thanks!
Codecov Report
@@ Coverage Diff @@
## master #11608 +/- ##
============================================
- Coverage 66.36% 66.34% -0.03%
Complexity 207 207
============================================
Files 2350 2350
Lines 127248 127248
Branches 19593 19593
============================================
- Hits 84449 84420 -29
- Misses 36912 36935 +23
- Partials 5887 5893 +6
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 19 files with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
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.
you also need to update
const statusResponseObj = JSON.parse(result.status.replace("Segment reload details: ", "")) |
You should run this through the quickstart to make sure it's still working
@@ -782,7 +782,7 @@ public SuccessResponse reloadAllSegments( | |||
LOGGER.error("Failed to add reload all segments job meta into zookeeper for table: {}", tableNameWithType, e); | |||
} | |||
} | |||
return new SuccessResponse("Segment reload details: " + JsonUtils.objectToString(perTableMsgData)); | |||
return new SuccessResponse(JsonUtils.objectToPrettyString(perTableMsgData)); |
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.
it doesn't need to be, but what value is Segment reload details:
to the result of an endpoint that is clearly already the reload details. The impetus for this change was to make it easier to parse the result in java/scala so you don't have to go from request -> strip the prefix -> decode the json string -> decode the json. You should be able to go from request -> json in 1 hop.
Got it thanks let me do this |
fe3f7f8
to
cda8d11
Compare
looks like there's still some tests failing |
c46f1b4
to
f98781f
Compare
String tableNameWithType = TableNameBuilder.forType(tableType).tableNameWithType(tableName); | ||
JsonNode tableLevelDetails = | ||
JsonUtils.stringToJsonNode(StringEscapeUtils.unescapeJava(response.split(": ")[1])).get(tableNameWithType); | ||
JsonUtils.stringToJsonNode(response.substring( |
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 very hard to understand. I think we might need to parse twice? Something like:
JsonNode responseJson = JsonUtils.stringToJsonNode(response);
JsonNode tableLevelDetails = JsonUtils.stringToJsonNode(responseJson.get("status").asText()).get(tableNameWithType);
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.
Hi @Jackie-Jiang the the value corresponding to the "status" is another json string. So parsing it into json fails because the value is wrapped in "". I just did the substring logic to get the wrapped string. Thanks!
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.
The json string is encoded as the value field of the top level json, so parsing the json twice should be able to extract it. See the code example above
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.
Got it thanks, I did this, it seems the 6 tests fail. The result is wrapped in "", so the JsonUtils.stringToJsonNode
fails parsing it, to fix the test we would have to extract the value and then parse it. What do you think. Thanks!
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.
The problem is the unnecessary unescape. Applied a commit and let's see if it fixes the problem
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.
Oh got it thank you so much!
6245222
to
c803385
Compare
performance
fix for Reload API has a difficult response #11588