-
Notifications
You must be signed in to change notification settings - Fork 1.5k
[#10884][feature] add requestId for BrokerResponse in pinot-broker and java-client #10943
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| /** | ||
| * Licensed to the Apache Software Foundation (ASF) under one | ||
| * or more contributor license agreements. See the NOTICE file | ||
| * distributed with this work for additional information | ||
| * regarding copyright ownership. The ASF licenses this file | ||
| * to you under the Apache License, Version 2.0 (the | ||
| * "License"); you may not use this file except in compliance | ||
| * with the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, | ||
| * software distributed under the License is distributed on an | ||
| * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY | ||
| * KIND, either express or implied. See the License for the | ||
| * specific language governing permissions and limitations | ||
| * under the License. | ||
| */ | ||
| package org.apache.pinot.client; | ||
|
|
||
| import com.fasterxml.jackson.core.JsonProcessingException; | ||
| import com.fasterxml.jackson.databind.ObjectReader; | ||
| import org.apache.pinot.spi.utils.JsonUtils; | ||
| import org.testng.Assert; | ||
| import org.testng.annotations.Test; | ||
|
|
||
|
|
||
| public class BrokerResponseTest { | ||
| private static final ObjectReader OBJECT_READER = JsonUtils.DEFAULT_READER; | ||
|
|
||
| @Test | ||
| public void parseResultWithRequestId() | ||
| throws JsonProcessingException { | ||
| String responseJson = "{\"requestId\":\"1\",\"traceInfo\":{},\"numDocsScanned\":36542," | ||
| + "\"aggregationResults\":[{\"function\":\"count_star\",\"value\":\"36542\"}],\"timeUsedMs\":30," | ||
| + "\"segmentStatistics\":[],\"exceptions\":[],\"totalDocs\":115545}"; | ||
| BrokerResponse brokerResponse = BrokerResponse.fromJson(OBJECT_READER.readTree(responseJson)); | ||
| Assert.assertEquals("1", brokerResponse.getRequestId()); | ||
| Assert.assertTrue(!brokerResponse.hasExceptions()); | ||
| } | ||
|
|
||
| @Test | ||
| public void parseResultWithoutRequestId() | ||
| throws JsonProcessingException { | ||
| String responseJson = "{\"traceInfo\":{},\"numDocsScanned\":36542," | ||
| + "\"aggregationResults\":[{\"function\":\"count_star\",\"value\":\"36542\"}],\"timeUsedMs\":30," | ||
| + "\"segmentStatistics\":[],\"exceptions\":[],\"totalDocs\":115545}"; | ||
| BrokerResponse brokerResponse = BrokerResponse.fromJson(OBJECT_READER.readTree(responseJson)); | ||
| Assert.assertEquals("unknown", brokerResponse.getRequestId()); | ||
| Assert.assertTrue(!brokerResponse.hasExceptions()); | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| { | ||
| "requestId": "1", | ||
| "traceInfo": {}, | ||
| "numDocsScanned": 36542, | ||
| "aggregationResults": [ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| { | ||
| "requestId": "1", | ||
| "traceInfo": {}, | ||
| "numDocsScanned": 22598, | ||
| "aggregationResults": [ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| { | ||
| "requestId": "1", | ||
| "traceInfo": {}, | ||
| "numDocsScanned": 0, | ||
| "aggregationResults": [], | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| { | ||
| "requestId": "1", | ||
| "selectionResults": { | ||
| "columns": [ | ||
| "ActualElapsedTime", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -41,7 +41,7 @@ | |
| * Supports serialization via JSON. | ||
| */ | ||
| @JsonPropertyOrder({ | ||
| "resultTable", "exceptions", "numServersQueried", "numServersResponded", "numSegmentsQueried", | ||
| "resultTable", "requestId", "exceptions", "numServersQueried", "numServersResponded", "numSegmentsQueried", | ||
| "numSegmentsProcessed", "numSegmentsMatched", "numConsumingSegmentsQueried", "numConsumingSegmentsProcessed", | ||
| "numConsumingSegmentsMatched", "numDocsScanned", "numEntriesScannedInFilter", "numEntriesScannedPostFilter", | ||
| "numGroupsLimitReached", "totalDocs", "timeUsedMs", "offlineThreadCpuTimeNs", "realtimeThreadCpuTimeNs", | ||
|
|
@@ -57,6 +57,7 @@ public class BrokerResponseNative implements BrokerResponse { | |
| new BrokerResponseNative(QueryException.TABLE_DOES_NOT_EXIST_ERROR); | ||
| public static final BrokerResponseNative BROKER_ONLY_EXPLAIN_PLAN_OUTPUT = getBrokerResponseExplainPlanOutput(); | ||
|
|
||
| private String _requestId; | ||
| private int _numServersQueried = 0; | ||
| private int _numServersResponded = 0; | ||
| private long _numDocsScanned = 0L; | ||
|
|
@@ -557,4 +558,16 @@ public void addToExceptions(QueryProcessingException processingException) { | |
| public int getExceptionsSize() { | ||
| return _processingExceptions.size(); | ||
| } | ||
|
|
||
| @JsonProperty("requestId") | ||
| @Override | ||
| public String getRequestId() { | ||
| return _requestId; | ||
| } | ||
|
|
||
| @JsonProperty("requestId") | ||
| @Override | ||
|
||
| public void setRequestId(String requestId) { | ||
| _requestId = requestId; | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -33,7 +33,7 @@ | |
| // same metadataKey | ||
| // TODO: Replace member fields with a simple map of <MetadataKey, Object> | ||
| // TODO: Add a subStat field, stage level subStats will contain each operator stats | ||
| @JsonPropertyOrder({"exceptions", "numBlocks", "numRows", "stageExecutionTimeMs", "stageExecutionUnit", | ||
| @JsonPropertyOrder({"requestId", "exceptions", "numBlocks", "numRows", "stageExecutionTimeMs", "stageExecutionUnit", | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. requestID generated in v1 engine doesn't include a hashed encoding of the broker address. so essentially this could cause confusion (e.g. requestID starts with 0 from one broker, but you might get another 0 when hitting a different broker a bit later) see: #10789 for more info
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah that's a problem, I'll submit another PR to reuse |
||
| "stageExecWallTimeMs", "stageExecEndTimeMs", "numServersQueried", "numServersResponded", "numSegmentsQueried", | ||
| "numSegmentsProcessed", "numSegmentsMatched", "numConsumingSegmentsQueried", "numConsumingSegmentsProcessed", | ||
| "numConsumingSegmentsMatched", "numDocsScanned", "numEntriesScannedInFilter", "numEntriesScannedPostFilter", | ||
|
|
||
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.
(nit) Extra empty line