You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pinot.apache.org by GitBox <gi...@apache.org> on 2021/05/09 22:10:50 UTC

[GitHub] [incubator-pinot] mayankshriv opened a new pull request #6897: Add debug endpoint for tables.

mayankshriv opened a new pull request #6897:
URL: https://github.com/apache/incubator-pinot/pull/6897


   When debugging issues in production, there's a list of commonly used debugging steps
   to indentify the issue. In this PR, we add an endpoint which automates this process
   and provides a summary of possible issues.
   
   - Endpoint added on controller: `debug/tables/{tableName}?type={offline|realtime}
   - Enhancements to add:
     - Add ingestions status for realtime tables (reusing #6890, when merged).
     - Error surfacing
   - Sample JSON output:
   
   ```
   [ {
     "tableName" : "airlineStats_OFFLINE",
     "numSegments" : 31,
     "numServers" : 1,
     "numBrokers" : 1,
     "segmentDebugInfos" : [ {
       "segmentName" : "airlineStats_OFFLINE_16071_16071_0",
       "segmentStateInServer" : [ {
         "serverName" : "Server_192.168.1.90_7000",
         "idealStateStatus" : "ONLINE",
         "externalViewStatus" : "ERROR"
       } ]
     }, {
       "segmentName" : "airlineStats_OFFLINE_16095_16095_0",
       "segmentStateInServer" : [ {
         "serverName" : "Server_192.168.1.90_7000",
         "idealStateStatus" : "ONLINE",
         "externalViewStatus" : "ERROR"
       } ]
     }, {
       "segmentName" : "airlineStats_OFFLINE_16100_16100_0",
       "segmentStateInServer" : [ {
         "serverName" : "Server_192.168.1.90_7000",
         "idealStateStatus" : "ONLINE",
         "externalViewStatus" : "ERROR"
       } ]
     } ],
     "serverDebugInfos" : [ {
       "errors" : 31,
       "serverName" : "Server_192.168.1.90_7000",
       "numReadMessages" : 0,
       "numNewMessages" : 0
     } ],
     "brokerDebugInfos" : [ ],
     "tableSize" : {
       "reportedSize" : "3 MB",
       "estimatedSize" : "3 MB"
     }
   }, {
     "tableName" : "airlineStats_REALTIME",
     "numSegments" : 1,
     "numServers" : 1,
     "numBrokers" : 1,
     "segmentDebugInfos" : [ ],
     "serverDebugInfos" : [ {
       "errors" : 0,
       "serverName" : "Server_192.168.1.90_7000",
       "numReadMessages" : 0,
       "numNewMessages" : 0
     } ],
     "brokerDebugInfos" : [ ],
     "tableSize" : {
       "reportedSize" : "1 MB",
       "estimatedSize" : "1 MB"
     }
   } ]
   ```
   
   ## Description
   <!-- Add a description of your PR here.
   A good description should include pointers to an issue or design document, etc.
   -->
   ## Upgrade Notes
   Does this PR prevent a zero down-time upgrade? (Assume upgrade order: Controller, Broker, Server, Minion)
   * [ ] Yes (Please label as **<code>backward-incompat</code>**, and complete the section below on Release Notes)
   
   Does this PR fix a zero-downtime upgrade introduced earlier?
   * [ ] Yes (Please label this as **<code>backward-incompat</code>**, and complete the section below on Release Notes)
   
   Does this PR otherwise need attention when creating release notes? Things to consider:
   - New configuration options
   - Deprecation of configurations
   - Signature changes to public methods/interfaces
   - New plugins added or old plugins removed
   * [ ] Yes (Please label this PR as **<code>release-notes</code>** and complete the section on Release Notes)
   ## Release Notes
   <!-- If you have tagged this as either backward-incompat or release-notes,
   you MUST add text here that you would like to see appear in release notes of the
   next release. -->
   
   <!-- If you have a series of commits adding or enabling a feature, then
   add this section only in final commit that marks the feature completed.
   Refer to earlier release notes to see examples of text.
   -->
   ## Documentation
   <!-- If you have introduced a new feature or configuration, please add it to the documentation as well.
   See https://docs.pinot.apache.org/developers/developers-and-contributors/update-document
   -->
   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] codecov-commenter edited a comment on pull request #6897: Add debug endpoint for tables.

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #6897:
URL: https://github.com/apache/incubator-pinot/pull/6897#issuecomment-835921970


   # [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#6897](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a2f734e) into [master](https://codecov.io/gh/apache/incubator-pinot/commit/bd4239fc6908096f60ead9f1ee2c3576f256618b?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (bd4239f) will **decrease** coverage by `8.14%`.
   > The diff coverage is `0.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-pinot/pull/6897/graphs/tree.svg?width=650&height=150&src=pr&token=4ibza2ugkz&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #6897      +/-   ##
   ============================================
   - Coverage     73.56%   65.42%   -8.15%     
     Complexity       12       12              
   ============================================
     Files          1423     1425       +2     
     Lines         70064    70210     +146     
     Branches      10120    10140      +20     
   ============================================
   - Hits          51546    45933    -5613     
   - Misses        15109    21001    +5892     
   + Partials       3409     3276     -133     
   ```
   
   | Flag | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | integration | `?` | `?` | |
   | unittests | `65.42% <0.00%> (-0.09%)` | `12.00 <0.00> (ø)` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | [...che/pinot/controller/api/debug/TableDebugInfo.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9hcGkvZGVidWcvVGFibGVEZWJ1Z0luZm8uamF2YQ==) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
   | [...t/controller/api/resources/TableDebugResource.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9hcGkvcmVzb3VyY2VzL1RhYmxlRGVidWdSZXNvdXJjZS5qYXZh) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
   | [...a/org/apache/pinot/minion/metrics/MinionMeter.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtbWluaW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9taW5pb24vbWV0cmljcy9NaW5pb25NZXRlci5qYXZh) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (ø%)` | |
   | [.../apache/pinot/common/metrics/BrokerQueryPhase.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0cmljcy9Ccm9rZXJRdWVyeVBoYXNlLmphdmE=) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (ø%)` | |
   | [.../apache/pinot/minion/metrics/MinionQueryPhase.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtbWluaW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9taW5pb24vbWV0cmljcy9NaW5pb25RdWVyeVBoYXNlLmphdmE=) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (ø%)` | |
   | [...pache/pinot/common/utils/grpc/GrpcQueryClient.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vdXRpbHMvZ3JwYy9HcnBjUXVlcnlDbGllbnQuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (ø%)` | |
   | [...pinot/minion/exception/TaskCancelledException.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtbWluaW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9taW5pb24vZXhjZXB0aW9uL1Rhc2tDYW5jZWxsZWRFeGNlcHRpb24uamF2YQ==) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (ø%)` | |
   | [...t/core/startree/plan/StarTreeDocIdSetPlanNode.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9zdGFydHJlZS9wbGFuL1N0YXJUcmVlRG9jSWRTZXRQbGFuTm9kZS5qYXZh) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (ø%)` | |
   | [.../core/startree/plan/StarTreeTransformPlanNode.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9zdGFydHJlZS9wbGFuL1N0YXJUcmVlVHJhbnNmb3JtUGxhbk5vZGUuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (ø%)` | |
   | [...core/startree/plan/StarTreeProjectionPlanNode.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9zdGFydHJlZS9wbGFuL1N0YXJUcmVlUHJvamVjdGlvblBsYW5Ob2RlLmphdmE=) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (ø%)` | |
   | ... and [340 more](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [bd4239f...a2f734e](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] codecov-commenter edited a comment on pull request #6897: Add debug endpoint for tables.

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #6897:
URL: https://github.com/apache/incubator-pinot/pull/6897#issuecomment-835921970


   # [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#6897](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (dd526bc) into [master](https://codecov.io/gh/apache/incubator-pinot/commit/bd4239fc6908096f60ead9f1ee2c3576f256618b?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (bd4239f) will **decrease** coverage by `0.07%`.
   > The diff coverage is `0.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-pinot/pull/6897/graphs/tree.svg?width=650&height=150&src=pr&token=4ibza2ugkz&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #6897      +/-   ##
   ============================================
   - Coverage     73.56%   73.49%   -0.08%     
     Complexity       12       12              
   ============================================
     Files          1423     1425       +2     
     Lines         70064    70210     +146     
     Branches      10120    10141      +21     
   ============================================
   + Hits          51546    51602      +56     
   - Misses        15109    15196      +87     
   - Partials       3409     3412       +3     
   ```
   
   | Flag | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | integration | `43.39% <0.00%> (+0.10%)` | `7.00 <0.00> (ø)` | |
   | unittests | `65.36% <0.00%> (-0.15%)` | `12.00 <0.00> (ø)` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | [...che/pinot/controller/api/debug/TableDebugInfo.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9hcGkvZGVidWcvVGFibGVEZWJ1Z0luZm8uamF2YQ==) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
   | [...t/controller/api/resources/TableDebugResource.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9hcGkvcmVzb3VyY2VzL1RhYmxlRGVidWdSZXNvdXJjZS5qYXZh) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
   | [...impl/dictionary/DoubleOnHeapMutableDictionary.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc2VnbWVudC1sb2NhbC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3Qvc2VnbWVudC9sb2NhbC9yZWFsdGltZS9pbXBsL2RpY3Rpb25hcnkvRG91YmxlT25IZWFwTXV0YWJsZURpY3Rpb25hcnkuamF2YQ==) | `46.98% <0.00%> (-19.28%)` | `0.00% <0.00%> (ø%)` | |
   | [.../helix/core/minion/MinionInstancesCleanupTask.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9oZWxpeC9jb3JlL21pbmlvbi9NaW5pb25JbnN0YW5jZXNDbGVhbnVwVGFzay5qYXZh) | `57.14% <0.00%> (-14.29%)` | `0.00% <0.00%> (ø%)` | |
   | [...operator/filter/RangeIndexBasedFilterOperator.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci9maWx0ZXIvUmFuZ2VJbmRleEJhc2VkRmlsdGVyT3BlcmF0b3IuamF2YQ==) | `40.42% <0.00%> (-4.26%)` | `0.00% <0.00%> (ø%)` | |
   | [...lix/core/realtime/PinotRealtimeSegmentManager.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9oZWxpeC9jb3JlL3JlYWx0aW1lL1Bpbm90UmVhbHRpbWVTZWdtZW50TWFuYWdlci5qYXZh) | `78.97% <0.00%> (-4.11%)` | `0.00% <0.00%> (ø%)` | |
   | [.../java/org/apache/pinot/spi/data/TimeFieldSpec.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvZGF0YS9UaW1lRmllbGRTcGVjLmphdmE=) | `88.63% <0.00%> (-2.28%)` | `0.00% <0.00%> (ø%)` | |
   | [...mpl/dictionary/DoubleOffHeapMutableDictionary.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc2VnbWVudC1sb2NhbC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3Qvc2VnbWVudC9sb2NhbC9yZWFsdGltZS9pbXBsL2RpY3Rpb25hcnkvRG91YmxlT2ZmSGVhcE11dGFibGVEaWN0aW9uYXJ5LmphdmE=) | `57.44% <0.00%> (-2.13%)` | `0.00% <0.00%> (ø%)` | |
   | [...e/pinot/controller/helix/SegmentStatusChecker.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9oZWxpeC9TZWdtZW50U3RhdHVzQ2hlY2tlci5qYXZh) | `88.37% <0.00%> (-0.78%)` | `0.00% <0.00%> (ø%)` | |
   | [...nMaxValueBasedSelectionOrderByCombineOperator.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci9jb21iaW5lL01pbk1heFZhbHVlQmFzZWRTZWxlY3Rpb25PcmRlckJ5Q29tYmluZU9wZXJhdG9yLmphdmE=) | `70.14% <0.00%> (-0.75%)` | `0.00% <0.00%> (ø%)` | |
   | ... and [20 more](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [bd4239f...dd526bc](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #6897: Add debug endpoint for tables.

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #6897:
URL: https://github.com/apache/incubator-pinot/pull/6897#discussion_r629546398



##########
File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/debug/TableDebugInfo.java
##########
@@ -0,0 +1,212 @@
+/**
+ * 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.controller.api.debug;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import java.util.List;
+import org.apache.commons.io.FileUtils;
+
+
+@JsonPropertyOrder({"tableName", "numSegments", "numServers", "numBrokers", "segmentDebugInfos", "serverDebugInfos", "brokerDebugInfos"})
+@JsonIgnoreProperties(ignoreUnknown = true)
+@SuppressWarnings("unused")
+public class TableDebugInfo {
+  @JsonProperty("tableName")
+  private final String _tableName;
+
+  @JsonProperty("tableSize")
+  private final TableSizeSummary _tableSizeSummary;
+
+  @JsonProperty("numSegments")
+  private final int _numSegments;
+
+  @JsonProperty("numServers")
+  private final int _numServers;
+
+  @JsonProperty("numBrokers")
+  private final int _numBrokers;
+
+  @JsonProperty("segmentDebugInfos")
+  private final List<SegmentDebugInfo> _segmentDebugInfos;
+
+  @JsonProperty("serverDebugInfos")
+  private final List<ServerDebugInfo> _serverDebugInfos;
+
+  @JsonProperty("brokerDebugInfos")
+  private final List<BrokerDebugInfo> _brokerDebugInfos;
+
+  @JsonCreator
+  public TableDebugInfo(String tableName, TableSizeSummary tableSizeSummary, List<SegmentDebugInfo> segmentDebugInfos,

Review comment:
       (nit) Use the same order as the property declaration

##########
File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/TableDebugResource.java
##########
@@ -0,0 +1,267 @@
+/**
+ * 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.controller.api.resources;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executor;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import org.apache.commons.httpclient.HttpConnectionManager;
+import org.apache.helix.HelixDataAccessor;
+import org.apache.helix.HelixProperty;
+import org.apache.helix.PropertyKey;
+import org.apache.helix.model.ExternalView;
+import org.apache.helix.model.IdealState;
+import org.apache.helix.model.Message;
+import org.apache.pinot.common.metrics.ControllerMetrics;
+import org.apache.pinot.controller.ControllerConf;
+import org.apache.pinot.controller.api.debug.TableDebugInfo;
+import org.apache.pinot.controller.helix.core.PinotHelixResourceManager;
+import org.apache.pinot.controller.util.TableSizeReader;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.utils.JsonUtils;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+
+import static org.apache.pinot.spi.utils.CommonConstants.Helix.BROKER_RESOURCE_INSTANCE;
+
+
+/**
+ * This class implements the debugging endpoints.
+ */
+@Api(tags = Constants.CLUSTER_TAG)
+@Path("/")
+public class TableDebugResource {
+  @Inject
+  PinotHelixResourceManager _pinotHelixResourceManager;
+
+  @Inject
+  Executor _executor;
+  @Inject
+  HttpConnectionManager _connectionManager;
+
+  @Inject
+  ControllerMetrics _controllerMetrics;
+
+  @Inject
+  ControllerConf _controllerConf;
+
+  @GET
+  @Path("/debug/tables/{tableName}")
+  @Produces(MediaType.APPLICATION_JSON)
+  @ApiOperation(value = "Get debug information for table.", notes = "Debug information for table.")
+  @ApiResponses(value = {@ApiResponse(code = 200, message = "Success"), @ApiResponse(code = 500, message = "Internal server error")})
+  public String getClusterInfo(
+      @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName,
+      @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String tableTypeStr)
+      throws JsonProcessingException {
+    ObjectNode root = JsonUtils.newObjectNode();
+    root.put("clusterName", _pinotHelixResourceManager.getHelixClusterName());
+
+    TableType tableType = Constants.validateTableType(tableTypeStr);
+    List<TableType> tableTypes = (tableType == null) ? Arrays.asList(TableType.OFFLINE, TableType.REALTIME)
+        : Collections.singletonList(tableType);
+
+    List<TableDebugInfo> tableDebugInfos = new ArrayList<>();
+    for (TableType type : tableTypes) {
+      tableDebugInfos.add(debugTable(_pinotHelixResourceManager, tableName, type));
+    }
+    return new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(tableDebugInfos);
+  }
+
+  /**
+   * Helper method to colelct debug information about the table.
+   *
+   * @param pinotHelixResourceManager Helix Resource Manager for the cluster
+   * @param tableName Name of the table
+   * @param tableType Type of the table (offline|realtime)
+   * @return TableDebugInfo
+   */
+  private TableDebugInfo debugTable(PinotHelixResourceManager pinotHelixResourceManager, String tableName,
+      TableType tableType) {
+    String tableNameWithType = TableNameBuilder.forType(tableType).tableNameWithType(tableName);
+
+    // Debug information for segments of the table.
+    List<TableDebugInfo.SegmentDebugInfo> segmentDebugInfos =
+        debugSegments(pinotHelixResourceManager, tableNameWithType);
+
+    // Debug information from brokers of the table.
+    List<TableDebugInfo.BrokerDebugInfo> brokerDebugInfos = debugBrokers(tableNameWithType);
+
+    // Debug information from servers of the table.
+    List<TableDebugInfo.ServerDebugInfo> serverDebugInfos =
+        debugServers(pinotHelixResourceManager, tableName, tableType);
+
+    // Table size summary.
+    TableDebugInfo.TableSizeSummary tableSizeSummary = getTableSize(tableNameWithType);
+
+    // Number of segments in the table.
+    IdealState idealState = _pinotHelixResourceManager.getTableIdealState(tableNameWithType);
+    int numSegments = (idealState != null) ? idealState.getPartitionSet().size() : 0;
+
+    return new TableDebugInfo(tableNameWithType, tableSizeSummary, segmentDebugInfos, serverDebugInfos,
+        brokerDebugInfos, _pinotHelixResourceManager.getServerInstancesForTable(tableName, tableType).size(),
+        _pinotHelixResourceManager.getBrokerInstancesForTable(tableName, tableType).size(), numSegments);
+  }
+
+  private TableDebugInfo.TableSizeSummary getTableSize(String tableNameWithType) {
+    TableSizeReader tableSizeReader =
+        new TableSizeReader(_executor, _connectionManager, _controllerMetrics, _pinotHelixResourceManager);
+    TableSizeReader.TableSizeDetails tableSizeDetails;
+    try {
+      tableSizeDetails = tableSizeReader
+          .getTableSizeDetails(tableNameWithType, _controllerConf.getServerAdminRequestTimeoutSeconds() * 1000);
+    } catch (Throwable t) {
+      tableSizeDetails = null;
+    }
+
+    return (tableSizeDetails != null) ? new TableDebugInfo.TableSizeSummary(tableSizeDetails.reportedSizeInBytes,
+        tableSizeDetails.estimatedSizeInBytes) : new TableDebugInfo.TableSizeSummary(-1, -1);
+  }
+
+  /**
+   * Helper method to debug segments. Computes differences between ideal state and external view for each segment.
+   *
+   * @param pinotHelixResourceManager Helix Resource Manager
+   * @param tableNameWithType Name of table with type
+   * @return Debug information for segments
+   */
+  private List<TableDebugInfo.SegmentDebugInfo> debugSegments(PinotHelixResourceManager pinotHelixResourceManager,
+      String tableNameWithType) {
+    ExternalView externalView = pinotHelixResourceManager.getTableExternalView(tableNameWithType);
+    IdealState idealState = pinotHelixResourceManager.getTableIdealState(tableNameWithType);
+
+    List<TableDebugInfo.SegmentDebugInfo> segmentDebugInfos = new ArrayList<>();
+    if (idealState == null) {
+      return segmentDebugInfos;
+    }
+
+    for (String segment : idealState.getPartitionSet()) {

Review comment:
       Use map entry to iterate to avoid unnecessary map lookups

##########
File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/debug/TableDebugInfo.java
##########
@@ -0,0 +1,212 @@
+/**
+ * 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.controller.api.debug;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import java.util.List;
+import org.apache.commons.io.FileUtils;
+
+
+@JsonPropertyOrder({"tableName", "numSegments", "numServers", "numBrokers", "segmentDebugInfos", "serverDebugInfos", "brokerDebugInfos"})
+@JsonIgnoreProperties(ignoreUnknown = true)
+@SuppressWarnings("unused")
+public class TableDebugInfo {
+  @JsonProperty("tableName")
+  private final String _tableName;
+
+  @JsonProperty("tableSize")
+  private final TableSizeSummary _tableSizeSummary;
+
+  @JsonProperty("numSegments")
+  private final int _numSegments;
+
+  @JsonProperty("numServers")
+  private final int _numServers;
+
+  @JsonProperty("numBrokers")
+  private final int _numBrokers;
+
+  @JsonProperty("segmentDebugInfos")
+  private final List<SegmentDebugInfo> _segmentDebugInfos;
+
+  @JsonProperty("serverDebugInfos")
+  private final List<ServerDebugInfo> _serverDebugInfos;
+
+  @JsonProperty("brokerDebugInfos")
+  private final List<BrokerDebugInfo> _brokerDebugInfos;
+
+  @JsonCreator
+  public TableDebugInfo(String tableName, TableSizeSummary tableSizeSummary, List<SegmentDebugInfo> segmentDebugInfos,
+      List<ServerDebugInfo> serverDebugInfos, List<BrokerDebugInfo> brokerDebugInfos, int numBrokers, int numServers,
+      int numSegments) {
+    _tableName = tableName;
+    _tableSizeSummary = tableSizeSummary;
+    _segmentDebugInfos = segmentDebugInfos;
+    _serverDebugInfos = serverDebugInfos;
+    _brokerDebugInfos = brokerDebugInfos;
+
+    _numBrokers = numBrokers;
+    _numServers = numServers;
+    _numSegments = numSegments;
+  }
+
+  public String getTableName() {
+    return _tableName;
+  }
+
+  public TableSizeSummary getTableSize() {
+    return _tableSizeSummary;
+  }
+
+  public int getNumSegments() {
+    return _numSegments;
+  }
+
+  public int getNumServers() {
+    return _numServers;
+  }
+
+  public int getNumBrokers() {
+    return _numBrokers;
+  }
+
+  public List<SegmentDebugInfo> getSegmentDebugInfos() {
+    return _segmentDebugInfos;
+  }
+
+  public List<ServerDebugInfo> getServerDebugInfos() {
+    return _serverDebugInfos;
+  }
+
+  public List<BrokerDebugInfo> getBrokerDebugInfos() {
+    return _brokerDebugInfos;
+  }
+
+  public static class SegmentDebugInfo {
+    private final String _segmentName;
+    private final List<IsEvState> _iSEvStates;

Review comment:
       (nit) `_states`

##########
File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/TableDebugResource.java
##########
@@ -0,0 +1,267 @@
+/**
+ * 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.controller.api.resources;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executor;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import org.apache.commons.httpclient.HttpConnectionManager;
+import org.apache.helix.HelixDataAccessor;
+import org.apache.helix.HelixProperty;
+import org.apache.helix.PropertyKey;
+import org.apache.helix.model.ExternalView;
+import org.apache.helix.model.IdealState;
+import org.apache.helix.model.Message;
+import org.apache.pinot.common.metrics.ControllerMetrics;
+import org.apache.pinot.controller.ControllerConf;
+import org.apache.pinot.controller.api.debug.TableDebugInfo;
+import org.apache.pinot.controller.helix.core.PinotHelixResourceManager;
+import org.apache.pinot.controller.util.TableSizeReader;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.utils.JsonUtils;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+
+import static org.apache.pinot.spi.utils.CommonConstants.Helix.BROKER_RESOURCE_INSTANCE;
+
+
+/**
+ * This class implements the debugging endpoints.
+ */
+@Api(tags = Constants.CLUSTER_TAG)
+@Path("/")
+public class TableDebugResource {
+  @Inject
+  PinotHelixResourceManager _pinotHelixResourceManager;
+
+  @Inject
+  Executor _executor;
+  @Inject
+  HttpConnectionManager _connectionManager;
+
+  @Inject
+  ControllerMetrics _controllerMetrics;
+
+  @Inject
+  ControllerConf _controllerConf;
+
+  @GET
+  @Path("/debug/tables/{tableName}")
+  @Produces(MediaType.APPLICATION_JSON)
+  @ApiOperation(value = "Get debug information for table.", notes = "Debug information for table.")
+  @ApiResponses(value = {@ApiResponse(code = 200, message = "Success"), @ApiResponse(code = 500, message = "Internal server error")})
+  public String getClusterInfo(
+      @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName,
+      @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String tableTypeStr)
+      throws JsonProcessingException {
+    ObjectNode root = JsonUtils.newObjectNode();
+    root.put("clusterName", _pinotHelixResourceManager.getHelixClusterName());
+
+    TableType tableType = Constants.validateTableType(tableTypeStr);
+    List<TableType> tableTypes = (tableType == null) ? Arrays.asList(TableType.OFFLINE, TableType.REALTIME)
+        : Collections.singletonList(tableType);
+
+    List<TableDebugInfo> tableDebugInfos = new ArrayList<>();
+    for (TableType type : tableTypes) {
+      tableDebugInfos.add(debugTable(_pinotHelixResourceManager, tableName, type));
+    }
+    return new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(tableDebugInfos);
+  }
+
+  /**
+   * Helper method to colelct debug information about the table.
+   *
+   * @param pinotHelixResourceManager Helix Resource Manager for the cluster
+   * @param tableName Name of the table
+   * @param tableType Type of the table (offline|realtime)
+   * @return TableDebugInfo
+   */
+  private TableDebugInfo debugTable(PinotHelixResourceManager pinotHelixResourceManager, String tableName,
+      TableType tableType) {
+    String tableNameWithType = TableNameBuilder.forType(tableType).tableNameWithType(tableName);
+
+    // Debug information for segments of the table.
+    List<TableDebugInfo.SegmentDebugInfo> segmentDebugInfos =
+        debugSegments(pinotHelixResourceManager, tableNameWithType);
+
+    // Debug information from brokers of the table.
+    List<TableDebugInfo.BrokerDebugInfo> brokerDebugInfos = debugBrokers(tableNameWithType);
+
+    // Debug information from servers of the table.
+    List<TableDebugInfo.ServerDebugInfo> serverDebugInfos =
+        debugServers(pinotHelixResourceManager, tableName, tableType);
+
+    // Table size summary.
+    TableDebugInfo.TableSizeSummary tableSizeSummary = getTableSize(tableNameWithType);
+
+    // Number of segments in the table.
+    IdealState idealState = _pinotHelixResourceManager.getTableIdealState(tableNameWithType);
+    int numSegments = (idealState != null) ? idealState.getPartitionSet().size() : 0;
+
+    return new TableDebugInfo(tableNameWithType, tableSizeSummary, segmentDebugInfos, serverDebugInfos,
+        brokerDebugInfos, _pinotHelixResourceManager.getServerInstancesForTable(tableName, tableType).size(),
+        _pinotHelixResourceManager.getBrokerInstancesForTable(tableName, tableType).size(), numSegments);
+  }
+
+  private TableDebugInfo.TableSizeSummary getTableSize(String tableNameWithType) {
+    TableSizeReader tableSizeReader =
+        new TableSizeReader(_executor, _connectionManager, _controllerMetrics, _pinotHelixResourceManager);
+    TableSizeReader.TableSizeDetails tableSizeDetails;
+    try {
+      tableSizeDetails = tableSizeReader
+          .getTableSizeDetails(tableNameWithType, _controllerConf.getServerAdminRequestTimeoutSeconds() * 1000);
+    } catch (Throwable t) {
+      tableSizeDetails = null;
+    }
+
+    return (tableSizeDetails != null) ? new TableDebugInfo.TableSizeSummary(tableSizeDetails.reportedSizeInBytes,
+        tableSizeDetails.estimatedSizeInBytes) : new TableDebugInfo.TableSizeSummary(-1, -1);
+  }
+
+  /**
+   * Helper method to debug segments. Computes differences between ideal state and external view for each segment.
+   *
+   * @param pinotHelixResourceManager Helix Resource Manager
+   * @param tableNameWithType Name of table with type
+   * @return Debug information for segments
+   */
+  private List<TableDebugInfo.SegmentDebugInfo> debugSegments(PinotHelixResourceManager pinotHelixResourceManager,
+      String tableNameWithType) {
+    ExternalView externalView = pinotHelixResourceManager.getTableExternalView(tableNameWithType);
+    IdealState idealState = pinotHelixResourceManager.getTableIdealState(tableNameWithType);
+
+    List<TableDebugInfo.SegmentDebugInfo> segmentDebugInfos = new ArrayList<>();
+    if (idealState == null) {
+      return segmentDebugInfos;
+    }
+
+    for (String segment : idealState.getPartitionSet()) {
+      List<TableDebugInfo.IsEvState> isEvStates = new ArrayList<>();
+      for (Map.Entry<String, String> entry : idealState.getInstanceStateMap(segment).entrySet()) {
+        String serverName = entry.getKey();
+        String isState = entry.getValue();
+
+        String evState = (externalView != null) ? externalView.getStateMap(segment).get(serverName) : "null";
+        if (!isState.equals(evState)) {
+          isEvStates.add(new TableDebugInfo.IsEvState(serverName, isState, evState));
+        }
+      }
+
+      if (isEvStates.size() > 0) {
+        segmentDebugInfos.add(new TableDebugInfo.SegmentDebugInfo(segment, isEvStates));
+      }
+    }
+    return segmentDebugInfos;
+  }
+
+  /**
+   * Computes debug information for brokers. Identifies differences in ideal state and external view
+   * for the broker resource.
+   *
+   * @param tableNameWithType Name of table with type suffix
+   * @return Debug information for brokers of the table
+   */
+  private List<TableDebugInfo.BrokerDebugInfo> debugBrokers(String tableNameWithType) {
+    List<TableDebugInfo.BrokerDebugInfo> brokerDebugInfos = new ArrayList<>();
+    HelixDataAccessor helixDataAccessor = _pinotHelixResourceManager.getHelixZkManager().getHelixDataAccessor();
+    IdealState idealState =
+        helixDataAccessor.getProperty(helixDataAccessor.keyBuilder().idealStates(BROKER_RESOURCE_INSTANCE));
+    ExternalView externalView =
+        helixDataAccessor.getProperty(helixDataAccessor.keyBuilder().externalView(BROKER_RESOURCE_INSTANCE));
+
+    for (Map.Entry<String, String> entry : idealState.getInstanceStateMap(tableNameWithType).entrySet()) {
+      String brokerName = entry.getKey();
+      String isState = entry.getValue();
+      String evState = externalView.getStateMap(tableNameWithType).get(brokerName);
+      if (!isState.equals(evState)) {
+        brokerDebugInfos.add(
+            new TableDebugInfo.BrokerDebugInfo(brokerName, new TableDebugInfo.IsEvState(brokerName, isState, evState)));
+      }
+    }
+    return brokerDebugInfos;
+  }
+
+  /**
+   * Computes debug information for servers.
+   *
+   * @param pinotHelixResourceManager Helix Resource Manager
+   * @param tableName Name of table
+   * @param tableType Type of table (offline|realtime)
+   * @return Debug information for servers of the table
+   */
+  private List<TableDebugInfo.ServerDebugInfo> debugServers(PinotHelixResourceManager pinotHelixResourceManager,
+      String tableName, TableType tableType) {
+    HelixDataAccessor accessor = _pinotHelixResourceManager.getHelixZkManager().getHelixDataAccessor();
+    List<TableDebugInfo.ServerDebugInfo> serverDebugInfos = new ArrayList<>();
+
+    for (String instanceName : pinotHelixResourceManager.getServerInstancesForTable(tableName, tableType)) {
+      PropertyKey.Builder keyBuilder = accessor.keyBuilder();
+      List<String> sessionIds = accessor.getChildNames(keyBuilder.errors(instanceName));
+
+      if (sessionIds == null || sessionIds.size() == 0) {
+        return serverDebugInfos;
+      }
+
+      String tableNameWithType = TableNameBuilder.forType(tableType).tableNameWithType(tableName);
+      int numErrors = 0;
+      for (String sessionId : sessionIds) {
+        List<HelixProperty> childValues =
+            accessor.getChildValues(keyBuilder.errors(instanceName, sessionId, tableNameWithType), false);
+        numErrors = (childValues != null) ? childValues.size() : 0;
+      }
+
+      List<String> messageNames = accessor.getChildNames(accessor.keyBuilder().messages(instanceName));
+      int numNewMessages = 0;
+      int numReadMessages = 0;
+      if (messageNames != null) {
+        for (String messageName : messageNames) {
+          Message message = accessor.getProperty(accessor.keyBuilder().message(instanceName, messageName));

Review comment:
       This might be very costly, especially when there are lots of messages stuck in the queue. Maybe just log the `numMessages`?

##########
File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/TableDebugResource.java
##########
@@ -0,0 +1,267 @@
+/**
+ * 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.controller.api.resources;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executor;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import org.apache.commons.httpclient.HttpConnectionManager;
+import org.apache.helix.HelixDataAccessor;
+import org.apache.helix.HelixProperty;
+import org.apache.helix.PropertyKey;
+import org.apache.helix.model.ExternalView;
+import org.apache.helix.model.IdealState;
+import org.apache.helix.model.Message;
+import org.apache.pinot.common.metrics.ControllerMetrics;
+import org.apache.pinot.controller.ControllerConf;
+import org.apache.pinot.controller.api.debug.TableDebugInfo;
+import org.apache.pinot.controller.helix.core.PinotHelixResourceManager;
+import org.apache.pinot.controller.util.TableSizeReader;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.utils.JsonUtils;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+
+import static org.apache.pinot.spi.utils.CommonConstants.Helix.BROKER_RESOURCE_INSTANCE;
+
+
+/**
+ * This class implements the debugging endpoints.
+ */
+@Api(tags = Constants.CLUSTER_TAG)
+@Path("/")
+public class TableDebugResource {
+  @Inject
+  PinotHelixResourceManager _pinotHelixResourceManager;
+
+  @Inject
+  Executor _executor;
+  @Inject
+  HttpConnectionManager _connectionManager;
+
+  @Inject
+  ControllerMetrics _controllerMetrics;
+
+  @Inject
+  ControllerConf _controllerConf;
+
+  @GET
+  @Path("/debug/tables/{tableName}")
+  @Produces(MediaType.APPLICATION_JSON)
+  @ApiOperation(value = "Get debug information for table.", notes = "Debug information for table.")
+  @ApiResponses(value = {@ApiResponse(code = 200, message = "Success"), @ApiResponse(code = 500, message = "Internal server error")})
+  public String getClusterInfo(
+      @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName,
+      @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String tableTypeStr)
+      throws JsonProcessingException {
+    ObjectNode root = JsonUtils.newObjectNode();
+    root.put("clusterName", _pinotHelixResourceManager.getHelixClusterName());
+
+    TableType tableType = Constants.validateTableType(tableTypeStr);
+    List<TableType> tableTypes = (tableType == null) ? Arrays.asList(TableType.OFFLINE, TableType.REALTIME)
+        : Collections.singletonList(tableType);
+
+    List<TableDebugInfo> tableDebugInfos = new ArrayList<>();
+    for (TableType type : tableTypes) {
+      tableDebugInfos.add(debugTable(_pinotHelixResourceManager, tableName, type));
+    }
+    return new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(tableDebugInfos);
+  }
+
+  /**
+   * Helper method to colelct debug information about the table.
+   *
+   * @param pinotHelixResourceManager Helix Resource Manager for the cluster
+   * @param tableName Name of the table
+   * @param tableType Type of the table (offline|realtime)
+   * @return TableDebugInfo
+   */
+  private TableDebugInfo debugTable(PinotHelixResourceManager pinotHelixResourceManager, String tableName,
+      TableType tableType) {
+    String tableNameWithType = TableNameBuilder.forType(tableType).tableNameWithType(tableName);
+
+    // Debug information for segments of the table.
+    List<TableDebugInfo.SegmentDebugInfo> segmentDebugInfos =
+        debugSegments(pinotHelixResourceManager, tableNameWithType);
+
+    // Debug information from brokers of the table.
+    List<TableDebugInfo.BrokerDebugInfo> brokerDebugInfos = debugBrokers(tableNameWithType);
+
+    // Debug information from servers of the table.
+    List<TableDebugInfo.ServerDebugInfo> serverDebugInfos =
+        debugServers(pinotHelixResourceManager, tableName, tableType);
+
+    // Table size summary.
+    TableDebugInfo.TableSizeSummary tableSizeSummary = getTableSize(tableNameWithType);
+
+    // Number of segments in the table.
+    IdealState idealState = _pinotHelixResourceManager.getTableIdealState(tableNameWithType);
+    int numSegments = (idealState != null) ? idealState.getPartitionSet().size() : 0;
+
+    return new TableDebugInfo(tableNameWithType, tableSizeSummary, segmentDebugInfos, serverDebugInfos,
+        brokerDebugInfos, _pinotHelixResourceManager.getServerInstancesForTable(tableName, tableType).size(),
+        _pinotHelixResourceManager.getBrokerInstancesForTable(tableName, tableType).size(), numSegments);
+  }
+
+  private TableDebugInfo.TableSizeSummary getTableSize(String tableNameWithType) {
+    TableSizeReader tableSizeReader =
+        new TableSizeReader(_executor, _connectionManager, _controllerMetrics, _pinotHelixResourceManager);
+    TableSizeReader.TableSizeDetails tableSizeDetails;
+    try {
+      tableSizeDetails = tableSizeReader
+          .getTableSizeDetails(tableNameWithType, _controllerConf.getServerAdminRequestTimeoutSeconds() * 1000);
+    } catch (Throwable t) {
+      tableSizeDetails = null;
+    }
+
+    return (tableSizeDetails != null) ? new TableDebugInfo.TableSizeSummary(tableSizeDetails.reportedSizeInBytes,
+        tableSizeDetails.estimatedSizeInBytes) : new TableDebugInfo.TableSizeSummary(-1, -1);
+  }
+
+  /**
+   * Helper method to debug segments. Computes differences between ideal state and external view for each segment.
+   *
+   * @param pinotHelixResourceManager Helix Resource Manager
+   * @param tableNameWithType Name of table with type
+   * @return Debug information for segments
+   */
+  private List<TableDebugInfo.SegmentDebugInfo> debugSegments(PinotHelixResourceManager pinotHelixResourceManager,
+      String tableNameWithType) {
+    ExternalView externalView = pinotHelixResourceManager.getTableExternalView(tableNameWithType);
+    IdealState idealState = pinotHelixResourceManager.getTableIdealState(tableNameWithType);
+
+    List<TableDebugInfo.SegmentDebugInfo> segmentDebugInfos = new ArrayList<>();
+    if (idealState == null) {
+      return segmentDebugInfos;
+    }
+
+    for (String segment : idealState.getPartitionSet()) {
+      List<TableDebugInfo.IsEvState> isEvStates = new ArrayList<>();
+      for (Map.Entry<String, String> entry : idealState.getInstanceStateMap(segment).entrySet()) {
+        String serverName = entry.getKey();
+        String isState = entry.getValue();
+
+        String evState = (externalView != null) ? externalView.getStateMap(segment).get(serverName) : "null";
+        if (!isState.equals(evState)) {
+          isEvStates.add(new TableDebugInfo.IsEvState(serverName, isState, evState));
+        }
+      }
+
+      if (isEvStates.size() > 0) {
+        segmentDebugInfos.add(new TableDebugInfo.SegmentDebugInfo(segment, isEvStates));
+      }
+    }
+    return segmentDebugInfos;
+  }
+
+  /**
+   * Computes debug information for brokers. Identifies differences in ideal state and external view
+   * for the broker resource.
+   *
+   * @param tableNameWithType Name of table with type suffix
+   * @return Debug information for brokers of the table
+   */
+  private List<TableDebugInfo.BrokerDebugInfo> debugBrokers(String tableNameWithType) {
+    List<TableDebugInfo.BrokerDebugInfo> brokerDebugInfos = new ArrayList<>();
+    HelixDataAccessor helixDataAccessor = _pinotHelixResourceManager.getHelixZkManager().getHelixDataAccessor();
+    IdealState idealState =
+        helixDataAccessor.getProperty(helixDataAccessor.keyBuilder().idealStates(BROKER_RESOURCE_INSTANCE));
+    ExternalView externalView =
+        helixDataAccessor.getProperty(helixDataAccessor.keyBuilder().externalView(BROKER_RESOURCE_INSTANCE));
+
+    for (Map.Entry<String, String> entry : idealState.getInstanceStateMap(tableNameWithType).entrySet()) {
+      String brokerName = entry.getKey();
+      String isState = entry.getValue();
+      String evState = externalView.getStateMap(tableNameWithType).get(brokerName);
+      if (!isState.equals(evState)) {
+        brokerDebugInfos.add(
+            new TableDebugInfo.BrokerDebugInfo(brokerName, new TableDebugInfo.IsEvState(brokerName, isState, evState)));
+      }
+    }
+    return brokerDebugInfos;
+  }
+
+  /**
+   * Computes debug information for servers.
+   *
+   * @param pinotHelixResourceManager Helix Resource Manager
+   * @param tableName Name of table
+   * @param tableType Type of table (offline|realtime)
+   * @return Debug information for servers of the table
+   */
+  private List<TableDebugInfo.ServerDebugInfo> debugServers(PinotHelixResourceManager pinotHelixResourceManager,
+      String tableName, TableType tableType) {
+    HelixDataAccessor accessor = _pinotHelixResourceManager.getHelixZkManager().getHelixDataAccessor();
+    List<TableDebugInfo.ServerDebugInfo> serverDebugInfos = new ArrayList<>();
+
+    for (String instanceName : pinotHelixResourceManager.getServerInstancesForTable(tableName, tableType)) {
+      PropertyKey.Builder keyBuilder = accessor.keyBuilder();
+      List<String> sessionIds = accessor.getChildNames(keyBuilder.errors(instanceName));
+
+      if (sessionIds == null || sessionIds.size() == 0) {
+        return serverDebugInfos;
+      }
+
+      String tableNameWithType = TableNameBuilder.forType(tableType).tableNameWithType(tableName);
+      int numErrors = 0;
+      for (String sessionId : sessionIds) {

Review comment:
       We want to track only the current `sessionId`. Currently the `numErrors` will be only for the last `sessionId`, which might not be the current

##########
File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/TableDebugResource.java
##########
@@ -0,0 +1,267 @@
+/**
+ * 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.controller.api.resources;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executor;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import org.apache.commons.httpclient.HttpConnectionManager;
+import org.apache.helix.HelixDataAccessor;
+import org.apache.helix.HelixProperty;
+import org.apache.helix.PropertyKey;
+import org.apache.helix.model.ExternalView;
+import org.apache.helix.model.IdealState;
+import org.apache.helix.model.Message;
+import org.apache.pinot.common.metrics.ControllerMetrics;
+import org.apache.pinot.controller.ControllerConf;
+import org.apache.pinot.controller.api.debug.TableDebugInfo;
+import org.apache.pinot.controller.helix.core.PinotHelixResourceManager;
+import org.apache.pinot.controller.util.TableSizeReader;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.utils.JsonUtils;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+
+import static org.apache.pinot.spi.utils.CommonConstants.Helix.BROKER_RESOURCE_INSTANCE;
+
+
+/**
+ * This class implements the debugging endpoints.
+ */
+@Api(tags = Constants.CLUSTER_TAG)
+@Path("/")
+public class TableDebugResource {
+  @Inject
+  PinotHelixResourceManager _pinotHelixResourceManager;
+
+  @Inject
+  Executor _executor;
+  @Inject
+  HttpConnectionManager _connectionManager;
+
+  @Inject
+  ControllerMetrics _controllerMetrics;
+
+  @Inject
+  ControllerConf _controllerConf;
+
+  @GET
+  @Path("/debug/tables/{tableName}")
+  @Produces(MediaType.APPLICATION_JSON)
+  @ApiOperation(value = "Get debug information for table.", notes = "Debug information for table.")
+  @ApiResponses(value = {@ApiResponse(code = 200, message = "Success"), @ApiResponse(code = 500, message = "Internal server error")})
+  public String getClusterInfo(
+      @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName,
+      @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String tableTypeStr)
+      throws JsonProcessingException {
+    ObjectNode root = JsonUtils.newObjectNode();
+    root.put("clusterName", _pinotHelixResourceManager.getHelixClusterName());
+
+    TableType tableType = Constants.validateTableType(tableTypeStr);
+    List<TableType> tableTypes = (tableType == null) ? Arrays.asList(TableType.OFFLINE, TableType.REALTIME)
+        : Collections.singletonList(tableType);
+
+    List<TableDebugInfo> tableDebugInfos = new ArrayList<>();
+    for (TableType type : tableTypes) {
+      tableDebugInfos.add(debugTable(_pinotHelixResourceManager, tableName, type));
+    }
+    return new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(tableDebugInfos);
+  }
+
+  /**
+   * Helper method to colelct debug information about the table.
+   *
+   * @param pinotHelixResourceManager Helix Resource Manager for the cluster
+   * @param tableName Name of the table
+   * @param tableType Type of the table (offline|realtime)
+   * @return TableDebugInfo
+   */
+  private TableDebugInfo debugTable(PinotHelixResourceManager pinotHelixResourceManager, String tableName,
+      TableType tableType) {
+    String tableNameWithType = TableNameBuilder.forType(tableType).tableNameWithType(tableName);
+
+    // Debug information for segments of the table.
+    List<TableDebugInfo.SegmentDebugInfo> segmentDebugInfos =
+        debugSegments(pinotHelixResourceManager, tableNameWithType);
+
+    // Debug information from brokers of the table.
+    List<TableDebugInfo.BrokerDebugInfo> brokerDebugInfos = debugBrokers(tableNameWithType);
+
+    // Debug information from servers of the table.
+    List<TableDebugInfo.ServerDebugInfo> serverDebugInfos =
+        debugServers(pinotHelixResourceManager, tableName, tableType);
+
+    // Table size summary.
+    TableDebugInfo.TableSizeSummary tableSizeSummary = getTableSize(tableNameWithType);
+
+    // Number of segments in the table.
+    IdealState idealState = _pinotHelixResourceManager.getTableIdealState(tableNameWithType);
+    int numSegments = (idealState != null) ? idealState.getPartitionSet().size() : 0;
+
+    return new TableDebugInfo(tableNameWithType, tableSizeSummary, segmentDebugInfos, serverDebugInfos,
+        brokerDebugInfos, _pinotHelixResourceManager.getServerInstancesForTable(tableName, tableType).size(),
+        _pinotHelixResourceManager.getBrokerInstancesForTable(tableName, tableType).size(), numSegments);
+  }
+
+  private TableDebugInfo.TableSizeSummary getTableSize(String tableNameWithType) {
+    TableSizeReader tableSizeReader =
+        new TableSizeReader(_executor, _connectionManager, _controllerMetrics, _pinotHelixResourceManager);
+    TableSizeReader.TableSizeDetails tableSizeDetails;
+    try {
+      tableSizeDetails = tableSizeReader
+          .getTableSizeDetails(tableNameWithType, _controllerConf.getServerAdminRequestTimeoutSeconds() * 1000);
+    } catch (Throwable t) {
+      tableSizeDetails = null;
+    }
+
+    return (tableSizeDetails != null) ? new TableDebugInfo.TableSizeSummary(tableSizeDetails.reportedSizeInBytes,
+        tableSizeDetails.estimatedSizeInBytes) : new TableDebugInfo.TableSizeSummary(-1, -1);
+  }
+
+  /**
+   * Helper method to debug segments. Computes differences between ideal state and external view for each segment.
+   *
+   * @param pinotHelixResourceManager Helix Resource Manager
+   * @param tableNameWithType Name of table with type
+   * @return Debug information for segments
+   */
+  private List<TableDebugInfo.SegmentDebugInfo> debugSegments(PinotHelixResourceManager pinotHelixResourceManager,
+      String tableNameWithType) {
+    ExternalView externalView = pinotHelixResourceManager.getTableExternalView(tableNameWithType);

Review comment:
       How about the segments in EV but not in IS?

##########
File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/debug/TableDebugInfo.java
##########
@@ -0,0 +1,212 @@
+/**
+ * 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.controller.api.debug;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.annotation.JsonPropertyOrder;
+import java.util.List;
+import org.apache.commons.io.FileUtils;
+
+
+@JsonPropertyOrder({"tableName", "numSegments", "numServers", "numBrokers", "segmentDebugInfos", "serverDebugInfos", "brokerDebugInfos"})
+@JsonIgnoreProperties(ignoreUnknown = true)
+@SuppressWarnings("unused")
+public class TableDebugInfo {
+  @JsonProperty("tableName")
+  private final String _tableName;
+
+  @JsonProperty("tableSize")
+  private final TableSizeSummary _tableSizeSummary;
+
+  @JsonProperty("numSegments")
+  private final int _numSegments;
+
+  @JsonProperty("numServers")
+  private final int _numServers;
+
+  @JsonProperty("numBrokers")
+  private final int _numBrokers;
+
+  @JsonProperty("segmentDebugInfos")
+  private final List<SegmentDebugInfo> _segmentDebugInfos;
+
+  @JsonProperty("serverDebugInfos")
+  private final List<ServerDebugInfo> _serverDebugInfos;
+
+  @JsonProperty("brokerDebugInfos")
+  private final List<BrokerDebugInfo> _brokerDebugInfos;
+
+  @JsonCreator
+  public TableDebugInfo(String tableName, TableSizeSummary tableSizeSummary, List<SegmentDebugInfo> segmentDebugInfos,
+      List<ServerDebugInfo> serverDebugInfos, List<BrokerDebugInfo> brokerDebugInfos, int numBrokers, int numServers,
+      int numSegments) {
+    _tableName = tableName;
+    _tableSizeSummary = tableSizeSummary;
+    _segmentDebugInfos = segmentDebugInfos;
+    _serverDebugInfos = serverDebugInfos;
+    _brokerDebugInfos = brokerDebugInfos;
+
+    _numBrokers = numBrokers;
+    _numServers = numServers;
+    _numSegments = numSegments;
+  }
+
+  public String getTableName() {
+    return _tableName;
+  }
+
+  public TableSizeSummary getTableSize() {
+    return _tableSizeSummary;
+  }
+
+  public int getNumSegments() {
+    return _numSegments;
+  }
+
+  public int getNumServers() {
+    return _numServers;
+  }
+
+  public int getNumBrokers() {
+    return _numBrokers;
+  }
+
+  public List<SegmentDebugInfo> getSegmentDebugInfos() {
+    return _segmentDebugInfos;
+  }
+
+  public List<ServerDebugInfo> getServerDebugInfos() {
+    return _serverDebugInfos;
+  }
+
+  public List<BrokerDebugInfo> getBrokerDebugInfos() {
+    return _brokerDebugInfos;
+  }
+
+  public static class SegmentDebugInfo {
+    private final String _segmentName;
+    private final List<IsEvState> _iSEvStates;
+
+    public SegmentDebugInfo(String name, List<IsEvState> iSEvStates) {
+      _segmentName = name;
+      _iSEvStates = iSEvStates;
+    }
+
+    public String getSegmentName() {
+      return _segmentName;
+    }
+
+    public List<IsEvState> getSegmentStateInServer() {
+      return _iSEvStates;
+    }
+  }
+
+  public static class IsEvState {
+    private final String _serverName;
+    private final String _idealStateStatus;
+    private final String _externalViewStatus;
+
+    public IsEvState(String name, String idealStateStatus, String externalViewStatus) {
+      _serverName = name;
+      _idealStateStatus = idealStateStatus;
+      _externalViewStatus = externalViewStatus;
+    }
+
+    public String getServerName() {
+      return _serverName;
+    }
+
+    public String getIdealStateStatus() {
+      return _idealStateStatus;
+    }
+
+    public String getExternalViewStatus() {
+      return _externalViewStatus;
+    }
+  }
+
+  public static class ServerDebugInfo {
+    private final int _numErrors;
+    private final int _numNewMessages;
+    private final int _numReadMessages;
+    private final String _serverName;
+
+    public ServerDebugInfo(String serverName, int numErrors, int numNewMessages, int numReadMessages) {
+      _serverName = serverName;
+      _numErrors = numErrors;
+      _numNewMessages = numNewMessages;

Review comment:
       What's the difference between new and read messages? Some documentations would be good




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] mayankshriv commented on a change in pull request #6897: Add debug endpoint for tables.

Posted by GitBox <gi...@apache.org>.
mayankshriv commented on a change in pull request #6897:
URL: https://github.com/apache/incubator-pinot/pull/6897#discussion_r629578230



##########
File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/TableDebugResource.java
##########
@@ -0,0 +1,267 @@
+/**
+ * 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.controller.api.resources;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executor;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import org.apache.commons.httpclient.HttpConnectionManager;
+import org.apache.helix.HelixDataAccessor;
+import org.apache.helix.HelixProperty;
+import org.apache.helix.PropertyKey;
+import org.apache.helix.model.ExternalView;
+import org.apache.helix.model.IdealState;
+import org.apache.helix.model.Message;
+import org.apache.pinot.common.metrics.ControllerMetrics;
+import org.apache.pinot.controller.ControllerConf;
+import org.apache.pinot.controller.api.debug.TableDebugInfo;
+import org.apache.pinot.controller.helix.core.PinotHelixResourceManager;
+import org.apache.pinot.controller.util.TableSizeReader;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.utils.JsonUtils;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+
+import static org.apache.pinot.spi.utils.CommonConstants.Helix.BROKER_RESOURCE_INSTANCE;
+
+
+/**
+ * This class implements the debugging endpoints.
+ */
+@Api(tags = Constants.CLUSTER_TAG)
+@Path("/")
+public class TableDebugResource {
+  @Inject
+  PinotHelixResourceManager _pinotHelixResourceManager;
+
+  @Inject
+  Executor _executor;
+  @Inject
+  HttpConnectionManager _connectionManager;
+
+  @Inject
+  ControllerMetrics _controllerMetrics;
+
+  @Inject
+  ControllerConf _controllerConf;
+
+  @GET
+  @Path("/debug/tables/{tableName}")
+  @Produces(MediaType.APPLICATION_JSON)
+  @ApiOperation(value = "Get debug information for table.", notes = "Debug information for table.")
+  @ApiResponses(value = {@ApiResponse(code = 200, message = "Success"), @ApiResponse(code = 500, message = "Internal server error")})
+  public String getClusterInfo(
+      @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName,
+      @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String tableTypeStr)
+      throws JsonProcessingException {
+    ObjectNode root = JsonUtils.newObjectNode();
+    root.put("clusterName", _pinotHelixResourceManager.getHelixClusterName());
+
+    TableType tableType = Constants.validateTableType(tableTypeStr);
+    List<TableType> tableTypes = (tableType == null) ? Arrays.asList(TableType.OFFLINE, TableType.REALTIME)
+        : Collections.singletonList(tableType);
+
+    List<TableDebugInfo> tableDebugInfos = new ArrayList<>();
+    for (TableType type : tableTypes) {
+      tableDebugInfos.add(debugTable(_pinotHelixResourceManager, tableName, type));
+    }
+    return new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(tableDebugInfos);
+  }
+
+  /**
+   * Helper method to colelct debug information about the table.
+   *
+   * @param pinotHelixResourceManager Helix Resource Manager for the cluster
+   * @param tableName Name of the table
+   * @param tableType Type of the table (offline|realtime)
+   * @return TableDebugInfo
+   */
+  private TableDebugInfo debugTable(PinotHelixResourceManager pinotHelixResourceManager, String tableName,
+      TableType tableType) {
+    String tableNameWithType = TableNameBuilder.forType(tableType).tableNameWithType(tableName);
+
+    // Debug information for segments of the table.
+    List<TableDebugInfo.SegmentDebugInfo> segmentDebugInfos =
+        debugSegments(pinotHelixResourceManager, tableNameWithType);
+
+    // Debug information from brokers of the table.
+    List<TableDebugInfo.BrokerDebugInfo> brokerDebugInfos = debugBrokers(tableNameWithType);
+
+    // Debug information from servers of the table.
+    List<TableDebugInfo.ServerDebugInfo> serverDebugInfos =
+        debugServers(pinotHelixResourceManager, tableName, tableType);
+
+    // Table size summary.
+    TableDebugInfo.TableSizeSummary tableSizeSummary = getTableSize(tableNameWithType);
+
+    // Number of segments in the table.
+    IdealState idealState = _pinotHelixResourceManager.getTableIdealState(tableNameWithType);
+    int numSegments = (idealState != null) ? idealState.getPartitionSet().size() : 0;
+
+    return new TableDebugInfo(tableNameWithType, tableSizeSummary, segmentDebugInfos, serverDebugInfos,
+        brokerDebugInfos, _pinotHelixResourceManager.getServerInstancesForTable(tableName, tableType).size(),
+        _pinotHelixResourceManager.getBrokerInstancesForTable(tableName, tableType).size(), numSegments);
+  }
+
+  private TableDebugInfo.TableSizeSummary getTableSize(String tableNameWithType) {
+    TableSizeReader tableSizeReader =
+        new TableSizeReader(_executor, _connectionManager, _controllerMetrics, _pinotHelixResourceManager);
+    TableSizeReader.TableSizeDetails tableSizeDetails;
+    try {
+      tableSizeDetails = tableSizeReader
+          .getTableSizeDetails(tableNameWithType, _controllerConf.getServerAdminRequestTimeoutSeconds() * 1000);
+    } catch (Throwable t) {
+      tableSizeDetails = null;
+    }
+
+    return (tableSizeDetails != null) ? new TableDebugInfo.TableSizeSummary(tableSizeDetails.reportedSizeInBytes,
+        tableSizeDetails.estimatedSizeInBytes) : new TableDebugInfo.TableSizeSummary(-1, -1);
+  }
+
+  /**
+   * Helper method to debug segments. Computes differences between ideal state and external view for each segment.
+   *
+   * @param pinotHelixResourceManager Helix Resource Manager
+   * @param tableNameWithType Name of table with type
+   * @return Debug information for segments
+   */
+  private List<TableDebugInfo.SegmentDebugInfo> debugSegments(PinotHelixResourceManager pinotHelixResourceManager,
+      String tableNameWithType) {
+    ExternalView externalView = pinotHelixResourceManager.getTableExternalView(tableNameWithType);

Review comment:
       In my experience, this is only due to delay in deleting segments. So chose not to add it for now, to avoid confusion.




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] mayankshriv merged pull request #6897: Add debug endpoint for tables.

Posted by GitBox <gi...@apache.org>.
mayankshriv merged pull request #6897:
URL: https://github.com/apache/incubator-pinot/pull/6897


   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] Jackie-Jiang commented on a change in pull request #6897: Add debug endpoint for tables.

Posted by GitBox <gi...@apache.org>.
Jackie-Jiang commented on a change in pull request #6897:
URL: https://github.com/apache/incubator-pinot/pull/6897#discussion_r629781413



##########
File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/TableDebugResource.java
##########
@@ -0,0 +1,267 @@
+/**
+ * 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.controller.api.resources;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executor;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import org.apache.commons.httpclient.HttpConnectionManager;
+import org.apache.helix.HelixDataAccessor;
+import org.apache.helix.HelixProperty;
+import org.apache.helix.PropertyKey;
+import org.apache.helix.model.ExternalView;
+import org.apache.helix.model.IdealState;
+import org.apache.helix.model.Message;
+import org.apache.pinot.common.metrics.ControllerMetrics;
+import org.apache.pinot.controller.ControllerConf;
+import org.apache.pinot.controller.api.debug.TableDebugInfo;
+import org.apache.pinot.controller.helix.core.PinotHelixResourceManager;
+import org.apache.pinot.controller.util.TableSizeReader;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.utils.JsonUtils;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+
+import static org.apache.pinot.spi.utils.CommonConstants.Helix.BROKER_RESOURCE_INSTANCE;
+
+
+/**
+ * This class implements the debugging endpoints.
+ */
+@Api(tags = Constants.CLUSTER_TAG)
+@Path("/")
+public class TableDebugResource {
+  @Inject
+  PinotHelixResourceManager _pinotHelixResourceManager;
+
+  @Inject
+  Executor _executor;
+  @Inject
+  HttpConnectionManager _connectionManager;
+
+  @Inject
+  ControllerMetrics _controllerMetrics;
+
+  @Inject
+  ControllerConf _controllerConf;
+
+  @GET
+  @Path("/debug/tables/{tableName}")
+  @Produces(MediaType.APPLICATION_JSON)
+  @ApiOperation(value = "Get debug information for table.", notes = "Debug information for table.")
+  @ApiResponses(value = {@ApiResponse(code = 200, message = "Success"), @ApiResponse(code = 500, message = "Internal server error")})
+  public String getClusterInfo(
+      @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName,
+      @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String tableTypeStr)
+      throws JsonProcessingException {
+    ObjectNode root = JsonUtils.newObjectNode();
+    root.put("clusterName", _pinotHelixResourceManager.getHelixClusterName());
+
+    TableType tableType = Constants.validateTableType(tableTypeStr);
+    List<TableType> tableTypes = (tableType == null) ? Arrays.asList(TableType.OFFLINE, TableType.REALTIME)
+        : Collections.singletonList(tableType);
+
+    List<TableDebugInfo> tableDebugInfos = new ArrayList<>();
+    for (TableType type : tableTypes) {
+      tableDebugInfos.add(debugTable(_pinotHelixResourceManager, tableName, type));
+    }
+    return new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(tableDebugInfos);
+  }
+
+  /**
+   * Helper method to colelct debug information about the table.
+   *
+   * @param pinotHelixResourceManager Helix Resource Manager for the cluster
+   * @param tableName Name of the table
+   * @param tableType Type of the table (offline|realtime)
+   * @return TableDebugInfo
+   */
+  private TableDebugInfo debugTable(PinotHelixResourceManager pinotHelixResourceManager, String tableName,
+      TableType tableType) {
+    String tableNameWithType = TableNameBuilder.forType(tableType).tableNameWithType(tableName);
+
+    // Debug information for segments of the table.
+    List<TableDebugInfo.SegmentDebugInfo> segmentDebugInfos =
+        debugSegments(pinotHelixResourceManager, tableNameWithType);
+
+    // Debug information from brokers of the table.
+    List<TableDebugInfo.BrokerDebugInfo> brokerDebugInfos = debugBrokers(tableNameWithType);
+
+    // Debug information from servers of the table.
+    List<TableDebugInfo.ServerDebugInfo> serverDebugInfos =
+        debugServers(pinotHelixResourceManager, tableName, tableType);
+
+    // Table size summary.
+    TableDebugInfo.TableSizeSummary tableSizeSummary = getTableSize(tableNameWithType);
+
+    // Number of segments in the table.
+    IdealState idealState = _pinotHelixResourceManager.getTableIdealState(tableNameWithType);
+    int numSegments = (idealState != null) ? idealState.getPartitionSet().size() : 0;
+
+    return new TableDebugInfo(tableNameWithType, tableSizeSummary, segmentDebugInfos, serverDebugInfos,
+        brokerDebugInfos, _pinotHelixResourceManager.getServerInstancesForTable(tableName, tableType).size(),
+        _pinotHelixResourceManager.getBrokerInstancesForTable(tableName, tableType).size(), numSegments);
+  }
+
+  private TableDebugInfo.TableSizeSummary getTableSize(String tableNameWithType) {
+    TableSizeReader tableSizeReader =
+        new TableSizeReader(_executor, _connectionManager, _controllerMetrics, _pinotHelixResourceManager);
+    TableSizeReader.TableSizeDetails tableSizeDetails;
+    try {
+      tableSizeDetails = tableSizeReader
+          .getTableSizeDetails(tableNameWithType, _controllerConf.getServerAdminRequestTimeoutSeconds() * 1000);
+    } catch (Throwable t) {
+      tableSizeDetails = null;
+    }
+
+    return (tableSizeDetails != null) ? new TableDebugInfo.TableSizeSummary(tableSizeDetails.reportedSizeInBytes,
+        tableSizeDetails.estimatedSizeInBytes) : new TableDebugInfo.TableSizeSummary(-1, -1);
+  }
+
+  /**
+   * Helper method to debug segments. Computes differences between ideal state and external view for each segment.
+   *
+   * @param pinotHelixResourceManager Helix Resource Manager
+   * @param tableNameWithType Name of table with type
+   * @return Debug information for segments
+   */
+  private List<TableDebugInfo.SegmentDebugInfo> debugSegments(PinotHelixResourceManager pinotHelixResourceManager,
+      String tableNameWithType) {
+    ExternalView externalView = pinotHelixResourceManager.getTableExternalView(tableNameWithType);
+    IdealState idealState = pinotHelixResourceManager.getTableIdealState(tableNameWithType);
+
+    List<TableDebugInfo.SegmentDebugInfo> segmentDebugInfos = new ArrayList<>();
+    if (idealState == null) {
+      return segmentDebugInfos;
+    }
+
+    for (String segment : idealState.getPartitionSet()) {

Review comment:
       ```suggestion
       for (Map.Entry<String, Map<String, String>> entry : idealState.getRecord().getMapFields().entrySet()) {
   ```

##########
File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/TableDebugResource.java
##########
@@ -0,0 +1,251 @@
+/**
+ * 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.controller.api.resources;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executor;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import org.apache.commons.httpclient.HttpConnectionManager;
+import org.apache.helix.HelixDataAccessor;
+import org.apache.helix.HelixProperty;
+import org.apache.helix.PropertyKey;
+import org.apache.helix.model.ExternalView;
+import org.apache.helix.model.IdealState;
+import org.apache.pinot.common.metrics.ControllerMetrics;
+import org.apache.pinot.controller.ControllerConf;
+import org.apache.pinot.controller.api.debug.TableDebugInfo;
+import org.apache.pinot.controller.helix.core.PinotHelixResourceManager;
+import org.apache.pinot.controller.util.TableSizeReader;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.utils.JsonUtils;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+
+import static org.apache.pinot.spi.utils.CommonConstants.Helix.BROKER_RESOURCE_INSTANCE;
+
+
+/**
+ * This class implements the debugging endpoints.
+ */
+@Api(tags = Constants.CLUSTER_TAG)
+@Path("/")
+public class TableDebugResource {
+  @Inject
+  PinotHelixResourceManager _pinotHelixResourceManager;
+
+  @Inject
+  Executor _executor;
+  @Inject
+  HttpConnectionManager _connectionManager;
+
+  @Inject
+  ControllerMetrics _controllerMetrics;
+
+  @Inject
+  ControllerConf _controllerConf;
+
+  @GET
+  @Path("/debug/tables/{tableName}")
+  @Produces(MediaType.APPLICATION_JSON)
+  @ApiOperation(value = "Get debug information for table.", notes = "Debug information for table.")
+  @ApiResponses(value = {@ApiResponse(code = 200, message = "Success"), @ApiResponse(code = 500, message = "Internal server error")})
+  public String getClusterInfo(
+      @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName,
+      @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String tableTypeStr)
+      throws JsonProcessingException {
+    ObjectNode root = JsonUtils.newObjectNode();
+    root.put("clusterName", _pinotHelixResourceManager.getHelixClusterName());
+
+    TableType tableType = Constants.validateTableType(tableTypeStr);
+    List<TableType> tableTypes = (tableType == null) ? Arrays.asList(TableType.OFFLINE, TableType.REALTIME)
+        : Collections.singletonList(tableType);
+
+    List<TableDebugInfo> tableDebugInfos = new ArrayList<>();
+    for (TableType type : tableTypes) {
+      tableDebugInfos.add(debugTable(_pinotHelixResourceManager, tableName, type));
+    }
+    return new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(tableDebugInfos);
+  }
+
+  /**
+   * Helper method to colelct debug information about the table.
+   *
+   * @param pinotHelixResourceManager Helix Resource Manager for the cluster
+   * @param tableName Name of the table
+   * @param tableType Type of the table (offline|realtime)
+   * @return TableDebugInfo
+   */
+  private TableDebugInfo debugTable(PinotHelixResourceManager pinotHelixResourceManager, String tableName,
+      TableType tableType) {
+    String tableNameWithType = TableNameBuilder.forType(tableType).tableNameWithType(tableName);
+
+    // Debug information for segments of the table.
+    List<TableDebugInfo.SegmentDebugInfo> segmentDebugInfos =
+        debugSegments(pinotHelixResourceManager, tableNameWithType);
+
+    // Debug information from brokers of the table.
+    List<TableDebugInfo.BrokerDebugInfo> brokerDebugInfos = debugBrokers(tableNameWithType);
+
+    // Debug information from servers of the table.
+    List<TableDebugInfo.ServerDebugInfo> serverDebugInfos =
+        debugServers(pinotHelixResourceManager, tableName, tableType);
+
+    // Table size summary.
+    TableDebugInfo.TableSizeSummary tableSizeSummary = getTableSize(tableNameWithType);
+
+    // Number of segments in the table.
+    IdealState idealState = _pinotHelixResourceManager.getTableIdealState(tableNameWithType);
+    int numSegments = (idealState != null) ? idealState.getPartitionSet().size() : 0;
+
+    return new TableDebugInfo(tableNameWithType, tableSizeSummary,
+        _pinotHelixResourceManager.getBrokerInstancesForTable(tableName, tableType).size(),
+        _pinotHelixResourceManager.getServerInstancesForTable(tableName, tableType).size(), numSegments,
+        segmentDebugInfos, serverDebugInfos, brokerDebugInfos);
+  }
+
+  private TableDebugInfo.TableSizeSummary getTableSize(String tableNameWithType) {
+    TableSizeReader tableSizeReader =
+        new TableSizeReader(_executor, _connectionManager, _controllerMetrics, _pinotHelixResourceManager);
+    TableSizeReader.TableSizeDetails tableSizeDetails;
+    try {
+      tableSizeDetails = tableSizeReader
+          .getTableSizeDetails(tableNameWithType, _controllerConf.getServerAdminRequestTimeoutSeconds() * 1000);
+    } catch (Throwable t) {
+      tableSizeDetails = null;
+    }
+
+    return (tableSizeDetails != null) ? new TableDebugInfo.TableSizeSummary(tableSizeDetails.reportedSizeInBytes,
+        tableSizeDetails.estimatedSizeInBytes) : new TableDebugInfo.TableSizeSummary(-1, -1);
+  }
+
+  /**
+   * Helper method to debug segments. Computes differences between ideal state and external view for each segment.
+   *
+   * @param pinotHelixResourceManager Helix Resource Manager
+   * @param tableNameWithType Name of table with type
+   * @return Debug information for segments
+   */
+  private List<TableDebugInfo.SegmentDebugInfo> debugSegments(PinotHelixResourceManager pinotHelixResourceManager,
+      String tableNameWithType) {
+    ExternalView externalView = pinotHelixResourceManager.getTableExternalView(tableNameWithType);
+    IdealState idealState = pinotHelixResourceManager.getTableIdealState(tableNameWithType);
+
+    List<TableDebugInfo.SegmentDebugInfo> segmentDebugInfos = new ArrayList<>();
+    if (idealState == null) {
+      return segmentDebugInfos;
+    }
+
+    for (String segment : idealState.getPartitionSet()) {
+      List<TableDebugInfo.IsEvState> isEvStates = new ArrayList<>();
+      for (Map.Entry<String, String> entry : idealState.getInstanceStateMap(segment).entrySet()) {
+        String serverName = entry.getKey();
+        String isState = entry.getValue();
+
+        String evState = (externalView != null) ? externalView.getStateMap(segment).get(serverName) : "null";
+        if (!isState.equals(evState)) {
+          isEvStates.add(new TableDebugInfo.IsEvState(serverName, isState, evState));
+        }
+      }
+
+      if (isEvStates.size() > 0) {
+        segmentDebugInfos.add(new TableDebugInfo.SegmentDebugInfo(segment, isEvStates));
+      }
+    }
+    return segmentDebugInfos;
+  }
+
+  /**
+   * Computes debug information for brokers. Identifies differences in ideal state and external view
+   * for the broker resource.
+   *
+   * @param tableNameWithType Name of table with type suffix
+   * @return Debug information for brokers of the table
+   */
+  private List<TableDebugInfo.BrokerDebugInfo> debugBrokers(String tableNameWithType) {
+    List<TableDebugInfo.BrokerDebugInfo> brokerDebugInfos = new ArrayList<>();
+    HelixDataAccessor helixDataAccessor = _pinotHelixResourceManager.getHelixZkManager().getHelixDataAccessor();
+    IdealState idealState =
+        helixDataAccessor.getProperty(helixDataAccessor.keyBuilder().idealStates(BROKER_RESOURCE_INSTANCE));
+    ExternalView externalView =
+        helixDataAccessor.getProperty(helixDataAccessor.keyBuilder().externalView(BROKER_RESOURCE_INSTANCE));
+
+    for (Map.Entry<String, String> entry : idealState.getInstanceStateMap(tableNameWithType).entrySet()) {
+      String brokerName = entry.getKey();
+      String isState = entry.getValue();
+      String evState = externalView.getStateMap(tableNameWithType).get(brokerName);
+      if (!isState.equals(evState)) {
+        brokerDebugInfos.add(
+            new TableDebugInfo.BrokerDebugInfo(brokerName, new TableDebugInfo.IsEvState(brokerName, isState, evState)));
+      }
+    }
+    return brokerDebugInfos;
+  }
+
+  /**
+   * Computes debug information for servers.
+   *
+   * @param pinotHelixResourceManager Helix Resource Manager
+   * @param tableName Name of table
+   * @param tableType Type of table (offline|realtime)
+   * @return Debug information for servers of the table
+   */
+  private List<TableDebugInfo.ServerDebugInfo> debugServers(PinotHelixResourceManager pinotHelixResourceManager,
+      String tableName, TableType tableType) {
+    HelixDataAccessor accessor = _pinotHelixResourceManager.getHelixZkManager().getHelixDataAccessor();
+    List<TableDebugInfo.ServerDebugInfo> serverDebugInfos = new ArrayList<>();
+
+    for (String instanceName : pinotHelixResourceManager.getServerInstancesForTable(tableName, tableType)) {
+      PropertyKey.Builder keyBuilder = accessor.keyBuilder();
+      List<String> sessionIds = accessor.getChildNames(keyBuilder.errors(instanceName));
+
+      if (sessionIds == null || sessionIds.size() == 0) {
+        return serverDebugInfos;
+      }
+
+      String tableNameWithType = TableNameBuilder.forType(tableType).tableNameWithType(tableName);
+      String currentSessionId = sessionIds.get(0);

Review comment:
       Should we read the current session id from the LIVE_INSTANCE? I thought the sessionIds are random generated, and the order is not guaranteed? Please add some comments if the first sessionId is always the current one.




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] mayankshriv commented on a change in pull request #6897: Add debug endpoint for tables.

Posted by GitBox <gi...@apache.org>.
mayankshriv commented on a change in pull request #6897:
URL: https://github.com/apache/incubator-pinot/pull/6897#discussion_r629580203



##########
File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/TableDebugResource.java
##########
@@ -0,0 +1,267 @@
+/**
+ * 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.controller.api.resources;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executor;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import org.apache.commons.httpclient.HttpConnectionManager;
+import org.apache.helix.HelixDataAccessor;
+import org.apache.helix.HelixProperty;
+import org.apache.helix.PropertyKey;
+import org.apache.helix.model.ExternalView;
+import org.apache.helix.model.IdealState;
+import org.apache.helix.model.Message;
+import org.apache.pinot.common.metrics.ControllerMetrics;
+import org.apache.pinot.controller.ControllerConf;
+import org.apache.pinot.controller.api.debug.TableDebugInfo;
+import org.apache.pinot.controller.helix.core.PinotHelixResourceManager;
+import org.apache.pinot.controller.util.TableSizeReader;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.utils.JsonUtils;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+
+import static org.apache.pinot.spi.utils.CommonConstants.Helix.BROKER_RESOURCE_INSTANCE;
+
+
+/**
+ * This class implements the debugging endpoints.
+ */
+@Api(tags = Constants.CLUSTER_TAG)
+@Path("/")
+public class TableDebugResource {
+  @Inject
+  PinotHelixResourceManager _pinotHelixResourceManager;
+
+  @Inject
+  Executor _executor;
+  @Inject
+  HttpConnectionManager _connectionManager;
+
+  @Inject
+  ControllerMetrics _controllerMetrics;
+
+  @Inject
+  ControllerConf _controllerConf;
+
+  @GET
+  @Path("/debug/tables/{tableName}")
+  @Produces(MediaType.APPLICATION_JSON)
+  @ApiOperation(value = "Get debug information for table.", notes = "Debug information for table.")
+  @ApiResponses(value = {@ApiResponse(code = 200, message = "Success"), @ApiResponse(code = 500, message = "Internal server error")})
+  public String getClusterInfo(
+      @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName,
+      @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String tableTypeStr)
+      throws JsonProcessingException {
+    ObjectNode root = JsonUtils.newObjectNode();
+    root.put("clusterName", _pinotHelixResourceManager.getHelixClusterName());
+
+    TableType tableType = Constants.validateTableType(tableTypeStr);
+    List<TableType> tableTypes = (tableType == null) ? Arrays.asList(TableType.OFFLINE, TableType.REALTIME)
+        : Collections.singletonList(tableType);
+
+    List<TableDebugInfo> tableDebugInfos = new ArrayList<>();
+    for (TableType type : tableTypes) {
+      tableDebugInfos.add(debugTable(_pinotHelixResourceManager, tableName, type));
+    }
+    return new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(tableDebugInfos);
+  }
+
+  /**
+   * Helper method to colelct debug information about the table.
+   *
+   * @param pinotHelixResourceManager Helix Resource Manager for the cluster
+   * @param tableName Name of the table
+   * @param tableType Type of the table (offline|realtime)
+   * @return TableDebugInfo
+   */
+  private TableDebugInfo debugTable(PinotHelixResourceManager pinotHelixResourceManager, String tableName,
+      TableType tableType) {
+    String tableNameWithType = TableNameBuilder.forType(tableType).tableNameWithType(tableName);
+
+    // Debug information for segments of the table.
+    List<TableDebugInfo.SegmentDebugInfo> segmentDebugInfos =
+        debugSegments(pinotHelixResourceManager, tableNameWithType);
+
+    // Debug information from brokers of the table.
+    List<TableDebugInfo.BrokerDebugInfo> brokerDebugInfos = debugBrokers(tableNameWithType);
+
+    // Debug information from servers of the table.
+    List<TableDebugInfo.ServerDebugInfo> serverDebugInfos =
+        debugServers(pinotHelixResourceManager, tableName, tableType);
+
+    // Table size summary.
+    TableDebugInfo.TableSizeSummary tableSizeSummary = getTableSize(tableNameWithType);
+
+    // Number of segments in the table.
+    IdealState idealState = _pinotHelixResourceManager.getTableIdealState(tableNameWithType);
+    int numSegments = (idealState != null) ? idealState.getPartitionSet().size() : 0;
+
+    return new TableDebugInfo(tableNameWithType, tableSizeSummary, segmentDebugInfos, serverDebugInfos,
+        brokerDebugInfos, _pinotHelixResourceManager.getServerInstancesForTable(tableName, tableType).size(),
+        _pinotHelixResourceManager.getBrokerInstancesForTable(tableName, tableType).size(), numSegments);
+  }
+
+  private TableDebugInfo.TableSizeSummary getTableSize(String tableNameWithType) {
+    TableSizeReader tableSizeReader =
+        new TableSizeReader(_executor, _connectionManager, _controllerMetrics, _pinotHelixResourceManager);
+    TableSizeReader.TableSizeDetails tableSizeDetails;
+    try {
+      tableSizeDetails = tableSizeReader
+          .getTableSizeDetails(tableNameWithType, _controllerConf.getServerAdminRequestTimeoutSeconds() * 1000);
+    } catch (Throwable t) {
+      tableSizeDetails = null;
+    }
+
+    return (tableSizeDetails != null) ? new TableDebugInfo.TableSizeSummary(tableSizeDetails.reportedSizeInBytes,
+        tableSizeDetails.estimatedSizeInBytes) : new TableDebugInfo.TableSizeSummary(-1, -1);
+  }
+
+  /**
+   * Helper method to debug segments. Computes differences between ideal state and external view for each segment.
+   *
+   * @param pinotHelixResourceManager Helix Resource Manager
+   * @param tableNameWithType Name of table with type
+   * @return Debug information for segments
+   */
+  private List<TableDebugInfo.SegmentDebugInfo> debugSegments(PinotHelixResourceManager pinotHelixResourceManager,
+      String tableNameWithType) {
+    ExternalView externalView = pinotHelixResourceManager.getTableExternalView(tableNameWithType);
+    IdealState idealState = pinotHelixResourceManager.getTableIdealState(tableNameWithType);
+
+    List<TableDebugInfo.SegmentDebugInfo> segmentDebugInfos = new ArrayList<>();
+    if (idealState == null) {
+      return segmentDebugInfos;
+    }
+
+    for (String segment : idealState.getPartitionSet()) {
+      List<TableDebugInfo.IsEvState> isEvStates = new ArrayList<>();
+      for (Map.Entry<String, String> entry : idealState.getInstanceStateMap(segment).entrySet()) {
+        String serverName = entry.getKey();
+        String isState = entry.getValue();
+
+        String evState = (externalView != null) ? externalView.getStateMap(segment).get(serverName) : "null";
+        if (!isState.equals(evState)) {
+          isEvStates.add(new TableDebugInfo.IsEvState(serverName, isState, evState));
+        }
+      }
+
+      if (isEvStates.size() > 0) {
+        segmentDebugInfos.add(new TableDebugInfo.SegmentDebugInfo(segment, isEvStates));
+      }
+    }
+    return segmentDebugInfos;
+  }
+
+  /**
+   * Computes debug information for brokers. Identifies differences in ideal state and external view
+   * for the broker resource.
+   *
+   * @param tableNameWithType Name of table with type suffix
+   * @return Debug information for brokers of the table
+   */
+  private List<TableDebugInfo.BrokerDebugInfo> debugBrokers(String tableNameWithType) {
+    List<TableDebugInfo.BrokerDebugInfo> brokerDebugInfos = new ArrayList<>();
+    HelixDataAccessor helixDataAccessor = _pinotHelixResourceManager.getHelixZkManager().getHelixDataAccessor();
+    IdealState idealState =
+        helixDataAccessor.getProperty(helixDataAccessor.keyBuilder().idealStates(BROKER_RESOURCE_INSTANCE));
+    ExternalView externalView =
+        helixDataAccessor.getProperty(helixDataAccessor.keyBuilder().externalView(BROKER_RESOURCE_INSTANCE));
+
+    for (Map.Entry<String, String> entry : idealState.getInstanceStateMap(tableNameWithType).entrySet()) {
+      String brokerName = entry.getKey();
+      String isState = entry.getValue();
+      String evState = externalView.getStateMap(tableNameWithType).get(brokerName);
+      if (!isState.equals(evState)) {
+        brokerDebugInfos.add(
+            new TableDebugInfo.BrokerDebugInfo(brokerName, new TableDebugInfo.IsEvState(brokerName, isState, evState)));
+      }
+    }
+    return brokerDebugInfos;
+  }
+
+  /**
+   * Computes debug information for servers.
+   *
+   * @param pinotHelixResourceManager Helix Resource Manager
+   * @param tableName Name of table
+   * @param tableType Type of table (offline|realtime)
+   * @return Debug information for servers of the table
+   */
+  private List<TableDebugInfo.ServerDebugInfo> debugServers(PinotHelixResourceManager pinotHelixResourceManager,
+      String tableName, TableType tableType) {
+    HelixDataAccessor accessor = _pinotHelixResourceManager.getHelixZkManager().getHelixDataAccessor();
+    List<TableDebugInfo.ServerDebugInfo> serverDebugInfos = new ArrayList<>();
+
+    for (String instanceName : pinotHelixResourceManager.getServerInstancesForTable(tableName, tableType)) {
+      PropertyKey.Builder keyBuilder = accessor.keyBuilder();
+      List<String> sessionIds = accessor.getChildNames(keyBuilder.errors(instanceName));
+
+      if (sessionIds == null || sessionIds.size() == 0) {
+        return serverDebugInfos;
+      }
+
+      String tableNameWithType = TableNameBuilder.forType(tableType).tableNameWithType(tableName);
+      int numErrors = 0;
+      for (String sessionId : sessionIds) {
+        List<HelixProperty> childValues =
+            accessor.getChildValues(keyBuilder.errors(instanceName, sessionId, tableNameWithType), false);
+        numErrors = (childValues != null) ? childValues.size() : 0;
+      }
+
+      List<String> messageNames = accessor.getChildNames(accessor.keyBuilder().messages(instanceName));
+      int numNewMessages = 0;
+      int numReadMessages = 0;
+      if (messageNames != null) {
+        for (String messageName : messageNames) {
+          Message message = accessor.getProperty(accessor.keyBuilder().message(instanceName, messageName));

Review comment:
       Yeah, however, we won't have NEW/READ messages. I think that should be ok, we definitely don't want to read lots of unstuck messages.




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] codecov-commenter edited a comment on pull request #6897: Add debug endpoint for tables.

Posted by GitBox <gi...@apache.org>.
codecov-commenter edited a comment on pull request #6897:
URL: https://github.com/apache/incubator-pinot/pull/6897#issuecomment-835921970


   # [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#6897](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (a2f734e) into [master](https://codecov.io/gh/apache/incubator-pinot/commit/bd4239fc6908096f60ead9f1ee2c3576f256618b?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (bd4239f) will **decrease** coverage by `0.06%`.
   > The diff coverage is `0.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-pinot/pull/6897/graphs/tree.svg?width=650&height=150&src=pr&token=4ibza2ugkz&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #6897      +/-   ##
   ============================================
   - Coverage     73.56%   73.50%   -0.07%     
     Complexity       12       12              
   ============================================
     Files          1423     1425       +2     
     Lines         70064    70210     +146     
     Branches      10120    10140      +20     
   ============================================
   + Hits          51546    51608      +62     
   - Misses        15109    15185      +76     
   - Partials       3409     3417       +8     
   ```
   
   | Flag | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | integration | `43.26% <0.00%> (-0.03%)` | `7.00 <0.00> (ø)` | |
   | unittests | `65.42% <0.00%> (-0.09%)` | `12.00 <0.00> (ø)` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | [...che/pinot/controller/api/debug/TableDebugInfo.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9hcGkvZGVidWcvVGFibGVEZWJ1Z0luZm8uamF2YQ==) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
   | [...t/controller/api/resources/TableDebugResource.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9hcGkvcmVzb3VyY2VzL1RhYmxlRGVidWdSZXNvdXJjZS5qYXZh) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
   | [...impl/dictionary/DoubleOnHeapMutableDictionary.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc2VnbWVudC1sb2NhbC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3Qvc2VnbWVudC9sb2NhbC9yZWFsdGltZS9pbXBsL2RpY3Rpb25hcnkvRG91YmxlT25IZWFwTXV0YWJsZURpY3Rpb25hcnkuamF2YQ==) | `54.21% <0.00%> (-12.05%)` | `0.00% <0.00%> (ø%)` | |
   | [...impl/dictionary/FloatOffHeapMutableDictionary.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc2VnbWVudC1sb2NhbC9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3Qvc2VnbWVudC9sb2NhbC9yZWFsdGltZS9pbXBsL2RpY3Rpb25hcnkvRmxvYXRPZmZIZWFwTXV0YWJsZURpY3Rpb25hcnkuamF2YQ==) | `72.34% <0.00%> (-5.32%)` | `0.00% <0.00%> (ø%)` | |
   | [...operator/filter/RangeIndexBasedFilterOperator.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci9maWx0ZXIvUmFuZ2VJbmRleEJhc2VkRmlsdGVyT3BlcmF0b3IuamF2YQ==) | `40.42% <0.00%> (-4.26%)` | `0.00% <0.00%> (ø%)` | |
   | [...t/core/query/selection/SelectionOperatorUtils.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9xdWVyeS9zZWxlY3Rpb24vU2VsZWN0aW9uT3BlcmF0b3JVdGlscy5qYXZh) | `91.58% <0.00%> (-3.67%)` | `0.00% <0.00%> (ø%)` | |
   | [.../predicate/NotEqualsPredicateEvaluatorFactory.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci9maWx0ZXIvcHJlZGljYXRlL05vdEVxdWFsc1ByZWRpY2F0ZUV2YWx1YXRvckZhY3RvcnkuamF2YQ==) | `75.32% <0.00%> (-2.60%)` | `0.00% <0.00%> (ø%)` | |
   | [.../java/org/apache/pinot/spi/data/TimeFieldSpec.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3Qtc3BpL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9zcGkvZGF0YS9UaW1lRmllbGRTcGVjLmphdmE=) | `88.63% <0.00%> (-2.28%)` | `0.00% <0.00%> (ø%)` | |
   | [...lix/core/realtime/PinotRealtimeSegmentManager.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9oZWxpeC9jb3JlL3JlYWx0aW1lL1Bpbm90UmVhbHRpbWVTZWdtZW50TWFuYWdlci5qYXZh) | `81.02% <0.00%> (-2.06%)` | `0.00% <0.00%> (ø%)` | |
   | [...nMaxValueBasedSelectionOrderByCombineOperator.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9vcGVyYXRvci9jb21iaW5lL01pbk1heFZhbHVlQmFzZWRTZWxlY3Rpb25PcmRlckJ5Q29tYmluZU9wZXJhdG9yLmphdmE=) | `70.14% <0.00%> (-0.75%)` | `0.00% <0.00%> (ø%)` | |
   | ... and [24 more](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [bd4239f...a2f734e](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] codecov-commenter commented on pull request #6897: Add debug endpoint for tables.

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on pull request #6897:
URL: https://github.com/apache/incubator-pinot/pull/6897#issuecomment-835921970


   # [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#6897](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (dd526bc) into [master](https://codecov.io/gh/apache/incubator-pinot/commit/bd4239fc6908096f60ead9f1ee2c3576f256618b?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (bd4239f) will **decrease** coverage by `8.20%`.
   > The diff coverage is `0.00%`.
   
   [![Impacted file tree graph](https://codecov.io/gh/apache/incubator-pinot/pull/6897/graphs/tree.svg?width=650&height=150&src=pr&token=4ibza2ugkz&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #6897      +/-   ##
   ============================================
   - Coverage     73.56%   65.36%   -8.21%     
     Complexity       12       12              
   ============================================
     Files          1423     1425       +2     
     Lines         70064    70210     +146     
     Branches      10120    10141      +21     
   ============================================
   - Hits          51546    45892    -5654     
   - Misses        15109    21036    +5927     
   + Partials       3409     3282     -127     
   ```
   
   | Flag | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | integration | `?` | `?` | |
   | unittests | `65.36% <0.00%> (-0.15%)` | `12.00 <0.00> (ø)` | |
   
   Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#carryforward-flags-in-the-pull-request-comment) to find out more.
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | Complexity Δ | |
   |---|---|---|---|
   | [...che/pinot/controller/api/debug/TableDebugInfo.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9hcGkvZGVidWcvVGFibGVEZWJ1Z0luZm8uamF2YQ==) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
   | [...t/controller/api/resources/TableDebugResource.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29udHJvbGxlci9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29udHJvbGxlci9hcGkvcmVzb3VyY2VzL1RhYmxlRGVidWdSZXNvdXJjZS5qYXZh) | `0.00% <0.00%> (ø)` | `0.00 <0.00> (?)` | |
   | [...a/org/apache/pinot/minion/metrics/MinionMeter.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtbWluaW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9taW5pb24vbWV0cmljcy9NaW5pb25NZXRlci5qYXZh) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (ø%)` | |
   | [.../apache/pinot/common/metrics/BrokerQueryPhase.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vbWV0cmljcy9Ccm9rZXJRdWVyeVBoYXNlLmphdmE=) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (ø%)` | |
   | [.../apache/pinot/minion/metrics/MinionQueryPhase.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtbWluaW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9taW5pb24vbWV0cmljcy9NaW5pb25RdWVyeVBoYXNlLmphdmE=) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (ø%)` | |
   | [...pache/pinot/common/utils/grpc/GrpcQueryClient.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29tbW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9jb21tb24vdXRpbHMvZ3JwYy9HcnBjUXVlcnlDbGllbnQuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (ø%)` | |
   | [...pinot/minion/exception/TaskCancelledException.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtbWluaW9uL3NyYy9tYWluL2phdmEvb3JnL2FwYWNoZS9waW5vdC9taW5pb24vZXhjZXB0aW9uL1Rhc2tDYW5jZWxsZWRFeGNlcHRpb24uamF2YQ==) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (ø%)` | |
   | [...t/core/startree/plan/StarTreeDocIdSetPlanNode.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9zdGFydHJlZS9wbGFuL1N0YXJUcmVlRG9jSWRTZXRQbGFuTm9kZS5qYXZh) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (ø%)` | |
   | [.../core/startree/plan/StarTreeTransformPlanNode.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9zdGFydHJlZS9wbGFuL1N0YXJUcmVlVHJhbnNmb3JtUGxhbk5vZGUuamF2YQ==) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (ø%)` | |
   | [...core/startree/plan/StarTreeProjectionPlanNode.java](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-cGlub3QtY29yZS9zcmMvbWFpbi9qYXZhL29yZy9hcGFjaGUvcGlub3QvY29yZS9zdGFydHJlZS9wbGFuL1N0YXJUcmVlUHJvamVjdGlvblBsYW5Ob2RlLmphdmE=) | `0.00% <0.00%> (-100.00%)` | `0.00% <0.00%> (ø%)` | |
   | ... and [341 more](https://codecov.io/gh/apache/incubator-pinot/pull/6897/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [bd4239f...dd526bc](https://codecov.io/gh/apache/incubator-pinot/pull/6897?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org


[GitHub] [incubator-pinot] mayankshriv commented on a change in pull request #6897: Add debug endpoint for tables.

Posted by GitBox <gi...@apache.org>.
mayankshriv commented on a change in pull request #6897:
URL: https://github.com/apache/incubator-pinot/pull/6897#discussion_r629791019



##########
File path: pinot-controller/src/main/java/org/apache/pinot/controller/api/resources/TableDebugResource.java
##########
@@ -0,0 +1,251 @@
+/**
+ * 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.controller.api.resources;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.node.ObjectNode;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import io.swagger.annotations.ApiParam;
+import io.swagger.annotations.ApiResponse;
+import io.swagger.annotations.ApiResponses;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executor;
+import javax.inject.Inject;
+import javax.ws.rs.GET;
+import javax.ws.rs.Path;
+import javax.ws.rs.PathParam;
+import javax.ws.rs.Produces;
+import javax.ws.rs.QueryParam;
+import javax.ws.rs.core.MediaType;
+import org.apache.commons.httpclient.HttpConnectionManager;
+import org.apache.helix.HelixDataAccessor;
+import org.apache.helix.HelixProperty;
+import org.apache.helix.PropertyKey;
+import org.apache.helix.model.ExternalView;
+import org.apache.helix.model.IdealState;
+import org.apache.pinot.common.metrics.ControllerMetrics;
+import org.apache.pinot.controller.ControllerConf;
+import org.apache.pinot.controller.api.debug.TableDebugInfo;
+import org.apache.pinot.controller.helix.core.PinotHelixResourceManager;
+import org.apache.pinot.controller.util.TableSizeReader;
+import org.apache.pinot.spi.config.table.TableType;
+import org.apache.pinot.spi.utils.JsonUtils;
+import org.apache.pinot.spi.utils.builder.TableNameBuilder;
+
+import static org.apache.pinot.spi.utils.CommonConstants.Helix.BROKER_RESOURCE_INSTANCE;
+
+
+/**
+ * This class implements the debugging endpoints.
+ */
+@Api(tags = Constants.CLUSTER_TAG)
+@Path("/")
+public class TableDebugResource {
+  @Inject
+  PinotHelixResourceManager _pinotHelixResourceManager;
+
+  @Inject
+  Executor _executor;
+  @Inject
+  HttpConnectionManager _connectionManager;
+
+  @Inject
+  ControllerMetrics _controllerMetrics;
+
+  @Inject
+  ControllerConf _controllerConf;
+
+  @GET
+  @Path("/debug/tables/{tableName}")
+  @Produces(MediaType.APPLICATION_JSON)
+  @ApiOperation(value = "Get debug information for table.", notes = "Debug information for table.")
+  @ApiResponses(value = {@ApiResponse(code = 200, message = "Success"), @ApiResponse(code = 500, message = "Internal server error")})
+  public String getClusterInfo(
+      @ApiParam(value = "Name of the table", required = true) @PathParam("tableName") String tableName,
+      @ApiParam(value = "OFFLINE|REALTIME") @QueryParam("type") String tableTypeStr)
+      throws JsonProcessingException {
+    ObjectNode root = JsonUtils.newObjectNode();
+    root.put("clusterName", _pinotHelixResourceManager.getHelixClusterName());
+
+    TableType tableType = Constants.validateTableType(tableTypeStr);
+    List<TableType> tableTypes = (tableType == null) ? Arrays.asList(TableType.OFFLINE, TableType.REALTIME)
+        : Collections.singletonList(tableType);
+
+    List<TableDebugInfo> tableDebugInfos = new ArrayList<>();
+    for (TableType type : tableTypes) {
+      tableDebugInfos.add(debugTable(_pinotHelixResourceManager, tableName, type));
+    }
+    return new ObjectMapper().writerWithDefaultPrettyPrinter().writeValueAsString(tableDebugInfos);
+  }
+
+  /**
+   * Helper method to colelct debug information about the table.
+   *
+   * @param pinotHelixResourceManager Helix Resource Manager for the cluster
+   * @param tableName Name of the table
+   * @param tableType Type of the table (offline|realtime)
+   * @return TableDebugInfo
+   */
+  private TableDebugInfo debugTable(PinotHelixResourceManager pinotHelixResourceManager, String tableName,
+      TableType tableType) {
+    String tableNameWithType = TableNameBuilder.forType(tableType).tableNameWithType(tableName);
+
+    // Debug information for segments of the table.
+    List<TableDebugInfo.SegmentDebugInfo> segmentDebugInfos =
+        debugSegments(pinotHelixResourceManager, tableNameWithType);
+
+    // Debug information from brokers of the table.
+    List<TableDebugInfo.BrokerDebugInfo> brokerDebugInfos = debugBrokers(tableNameWithType);
+
+    // Debug information from servers of the table.
+    List<TableDebugInfo.ServerDebugInfo> serverDebugInfos =
+        debugServers(pinotHelixResourceManager, tableName, tableType);
+
+    // Table size summary.
+    TableDebugInfo.TableSizeSummary tableSizeSummary = getTableSize(tableNameWithType);
+
+    // Number of segments in the table.
+    IdealState idealState = _pinotHelixResourceManager.getTableIdealState(tableNameWithType);
+    int numSegments = (idealState != null) ? idealState.getPartitionSet().size() : 0;
+
+    return new TableDebugInfo(tableNameWithType, tableSizeSummary,
+        _pinotHelixResourceManager.getBrokerInstancesForTable(tableName, tableType).size(),
+        _pinotHelixResourceManager.getServerInstancesForTable(tableName, tableType).size(), numSegments,
+        segmentDebugInfos, serverDebugInfos, brokerDebugInfos);
+  }
+
+  private TableDebugInfo.TableSizeSummary getTableSize(String tableNameWithType) {
+    TableSizeReader tableSizeReader =
+        new TableSizeReader(_executor, _connectionManager, _controllerMetrics, _pinotHelixResourceManager);
+    TableSizeReader.TableSizeDetails tableSizeDetails;
+    try {
+      tableSizeDetails = tableSizeReader
+          .getTableSizeDetails(tableNameWithType, _controllerConf.getServerAdminRequestTimeoutSeconds() * 1000);
+    } catch (Throwable t) {
+      tableSizeDetails = null;
+    }
+
+    return (tableSizeDetails != null) ? new TableDebugInfo.TableSizeSummary(tableSizeDetails.reportedSizeInBytes,
+        tableSizeDetails.estimatedSizeInBytes) : new TableDebugInfo.TableSizeSummary(-1, -1);
+  }
+
+  /**
+   * Helper method to debug segments. Computes differences between ideal state and external view for each segment.
+   *
+   * @param pinotHelixResourceManager Helix Resource Manager
+   * @param tableNameWithType Name of table with type
+   * @return Debug information for segments
+   */
+  private List<TableDebugInfo.SegmentDebugInfo> debugSegments(PinotHelixResourceManager pinotHelixResourceManager,
+      String tableNameWithType) {
+    ExternalView externalView = pinotHelixResourceManager.getTableExternalView(tableNameWithType);
+    IdealState idealState = pinotHelixResourceManager.getTableIdealState(tableNameWithType);
+
+    List<TableDebugInfo.SegmentDebugInfo> segmentDebugInfos = new ArrayList<>();
+    if (idealState == null) {
+      return segmentDebugInfos;
+    }
+
+    for (String segment : idealState.getPartitionSet()) {
+      List<TableDebugInfo.IsEvState> isEvStates = new ArrayList<>();
+      for (Map.Entry<String, String> entry : idealState.getInstanceStateMap(segment).entrySet()) {
+        String serverName = entry.getKey();
+        String isState = entry.getValue();
+
+        String evState = (externalView != null) ? externalView.getStateMap(segment).get(serverName) : "null";
+        if (!isState.equals(evState)) {
+          isEvStates.add(new TableDebugInfo.IsEvState(serverName, isState, evState));
+        }
+      }
+
+      if (isEvStates.size() > 0) {
+        segmentDebugInfos.add(new TableDebugInfo.SegmentDebugInfo(segment, isEvStates));
+      }
+    }
+    return segmentDebugInfos;
+  }
+
+  /**
+   * Computes debug information for brokers. Identifies differences in ideal state and external view
+   * for the broker resource.
+   *
+   * @param tableNameWithType Name of table with type suffix
+   * @return Debug information for brokers of the table
+   */
+  private List<TableDebugInfo.BrokerDebugInfo> debugBrokers(String tableNameWithType) {
+    List<TableDebugInfo.BrokerDebugInfo> brokerDebugInfos = new ArrayList<>();
+    HelixDataAccessor helixDataAccessor = _pinotHelixResourceManager.getHelixZkManager().getHelixDataAccessor();
+    IdealState idealState =
+        helixDataAccessor.getProperty(helixDataAccessor.keyBuilder().idealStates(BROKER_RESOURCE_INSTANCE));
+    ExternalView externalView =
+        helixDataAccessor.getProperty(helixDataAccessor.keyBuilder().externalView(BROKER_RESOURCE_INSTANCE));
+
+    for (Map.Entry<String, String> entry : idealState.getInstanceStateMap(tableNameWithType).entrySet()) {
+      String brokerName = entry.getKey();
+      String isState = entry.getValue();
+      String evState = externalView.getStateMap(tableNameWithType).get(brokerName);
+      if (!isState.equals(evState)) {
+        brokerDebugInfos.add(
+            new TableDebugInfo.BrokerDebugInfo(brokerName, new TableDebugInfo.IsEvState(brokerName, isState, evState)));
+      }
+    }
+    return brokerDebugInfos;
+  }
+
+  /**
+   * Computes debug information for servers.
+   *
+   * @param pinotHelixResourceManager Helix Resource Manager
+   * @param tableName Name of table
+   * @param tableType Type of table (offline|realtime)
+   * @return Debug information for servers of the table
+   */
+  private List<TableDebugInfo.ServerDebugInfo> debugServers(PinotHelixResourceManager pinotHelixResourceManager,
+      String tableName, TableType tableType) {
+    HelixDataAccessor accessor = _pinotHelixResourceManager.getHelixZkManager().getHelixDataAccessor();
+    List<TableDebugInfo.ServerDebugInfo> serverDebugInfos = new ArrayList<>();
+
+    for (String instanceName : pinotHelixResourceManager.getServerInstancesForTable(tableName, tableType)) {
+      PropertyKey.Builder keyBuilder = accessor.keyBuilder();
+      List<String> sessionIds = accessor.getChildNames(keyBuilder.errors(instanceName));
+
+      if (sessionIds == null || sessionIds.size() == 0) {
+        return serverDebugInfos;
+      }
+
+      String tableNameWithType = TableNameBuilder.forType(tableType).tableNameWithType(tableName);
+      String currentSessionId = sessionIds.get(0);

Review comment:
       Added comment to point to: https://github.com/apache/helix/blob/master/helix-rest/src/main/java/org/apache/helix/rest/server/resources/helix/PerInstanceAccessor.java#L398




-- 
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.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pinot.apache.org
For additional commands, e-mail: commits-help@pinot.apache.org