KKcorps commented on code in PR #10326:
URL: https://github.com/apache/pinot/pull/10326#discussion_r1117408073
##########
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/JsonAsyncHttpPinotClientTransport.java:
##########
@@ -134,11 +137,23 @@ public Future<BrokerResponse> executeQueryAsync(String
brokerAddress, String que
if (_headers != null) {
_headers.forEach((k, v) -> requestBuilder.addHeader(k, v));
}
+ LOGGER.debug("Sending query {} to {}", query, url);
+ return requestBuilder.addHeader("Content-Type", "application/json;
charset=utf-8").setBody(json.toString())
+ .execute().toCompletableFuture().thenApply(httpResponse -> {
+ LOGGER.debug("Completed query, HTTP status is {}",
httpResponse.getStatusCode());
+
+ if (httpResponse.getStatusCode() != 200) {
+ throw new PinotClientException(
+ "Pinot returned HTTP status " + httpResponse.getStatusCode()
+ ", expected 200");
+ }
- Future<Response> response =
- requestBuilder.addHeader("Content-Type", "application/json;
charset=utf-8").setBody(json.toString())
- .execute();
- return new BrokerResponseFuture(response, query, url,
_brokerReadTimeout);
+ String responseBody =
httpResponse.getResponseBody(StandardCharsets.UTF_8);
+ try {
+ return BrokerResponse.fromJson(OBJECT_READER.readTree(responseBody));
+ } catch (JsonProcessingException e) {
+ throw new CompletionException(e);
Review Comment:
Is this correct exception to throw. Earlier we were throwing
`ExecutionException` in this scenario.
##########
pinot-clients/pinot-java-client/src/main/java/org/apache/pinot/client/JsonAsyncHttpPinotClientTransport.java:
##########
@@ -134,11 +137,23 @@ public Future<BrokerResponse> executeQueryAsync(String
brokerAddress, String que
if (_headers != null) {
_headers.forEach((k, v) -> requestBuilder.addHeader(k, v));
}
+ LOGGER.debug("Sending query {} to {}", query, url);
+ return requestBuilder.addHeader("Content-Type", "application/json;
charset=utf-8").setBody(json.toString())
+ .execute().toCompletableFuture().thenApply(httpResponse -> {
+ LOGGER.debug("Completed query, HTTP status is {}",
httpResponse.getStatusCode());
+
+ if (httpResponse.getStatusCode() != 200) {
+ throw new PinotClientException(
+ "Pinot returned HTTP status " + httpResponse.getStatusCode()
+ ", expected 200");
+ }
- Future<Response> response =
- requestBuilder.addHeader("Content-Type", "application/json;
charset=utf-8").setBody(json.toString())
- .execute();
- return new BrokerResponseFuture(response, query, url,
_brokerReadTimeout);
+ String responseBody =
httpResponse.getResponseBody(StandardCharsets.UTF_8);
+ try {
+ return BrokerResponse.fromJson(OBJECT_READER.readTree(responseBody));
+ } catch (JsonProcessingException e) {
+ throw new CompletionException(e);
Review Comment:
Is this correct exception to throw? Earlier we were throwing
`ExecutionException` in this scenario.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]