[webui] Add rudimentary balance info to /table See what it looks like at:
https://github.com/wdberkeley/kudu/blob/rbweb/www/tablebalancesection.png Clicking the (?) pops out a quick explanation of what skew is, the same way as the (?)'s work on /config. Change-Id: Ieb6e29c10e7d5a3a48ea11438c54576664703bb9 Reviewed-on: http://gerrit.cloudera.org:8080/10461 Tested-by: Kudu Jenkins Reviewed-by: Alexey Serbin <[email protected]> Project: http://git-wip-us.apache.org/repos/asf/kudu/repo Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/9de558c2 Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/9de558c2 Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/9de558c2 Branch: refs/heads/master Commit: 9de558c2ff0c53f9abb8940b7d9ce0e2befde051 Parents: b73dec1 Author: Will Berkeley <[email protected]> Authored: Fri May 18 23:31:33 2018 -0700 Committer: Alexey Serbin <[email protected]> Committed: Sat May 19 19:50:40 2018 +0000 ---------------------------------------------------------------------- src/kudu/master/master_path_handlers.cc | 19 +++++++++++++++++++ www/table.mustache | 28 ++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/kudu/blob/9de558c2/src/kudu/master/master_path_handlers.cc ---------------------------------------------------------------------- diff --git a/src/kudu/master/master_path_handlers.cc b/src/kudu/master/master_path_handlers.cc index ae9de5c..eda548b 100644 --- a/src/kudu/master/master_path_handlers.cc +++ b/src/kudu/master/master_path_handlers.cc @@ -21,6 +21,7 @@ #include <array> #include <cstdint> #include <iosfwd> +#include <limits> #include <map> #include <memory> #include <sstream> @@ -291,6 +292,7 @@ void MasterPathHandlers::HandleTablePage(const Webserver::WebRequest& req, // up the partition schema, tablet summary, and tablet detail tables. std::vector<string> range_partitions; map<string, int> summary_states; + map<string, int> replica_counts; (*output)["detail_partition_schema_header"] = partition_schema.PartitionTableHeader(schema); EasyJson tablets_detail_json = output->Set("tablets_detail", EasyJson::kArray); for (const scoped_refptr<TabletInfo>& tablet : tablets) { @@ -304,6 +306,7 @@ void MasterPathHandlers::HandleTablePage(const Webserver::WebRequest& req, if (l.data().pb.has_consensus_state()) { const ConsensusStatePB& cstate = l.data().pb.consensus_state(); for (const auto& peer : cstate.committed_config().peers()) { + replica_counts[peer.permanent_uuid()]++; TabletDetailPeerInfo peer_info; shared_ptr<TSDescriptor> ts_desc; if (master_->ts_manager()->LookupTSByUUID(peer.permanent_uuid(), &ts_desc)) { @@ -368,6 +371,22 @@ void MasterPathHandlers::HandleTablePage(const Webserver::WebRequest& req, state_json["percentage"] = tablets.empty() ? "0.0" : StringPrintf("%.2f", percentage); } + // Set up the report on replica distribution. + EasyJson replica_dist_json = output->Set("replica_distribution", EasyJson::kObject); + EasyJson counts_json = replica_dist_json.Set("counts", EasyJson::kArray); + int min_count = replica_counts.empty() ? 0 : std::numeric_limits<int>::max(); + int max_count = 0; + for (const auto& entry : replica_counts) { + EasyJson count_json = counts_json.PushBack(EasyJson::kObject); + count_json["ts_uuid"] = entry.first; + count_json["count"] = entry.second; + min_count = std::min(min_count, entry.second); + max_count = std::max(max_count, entry.second); + } + replica_dist_json["max_count"] = max_count; + replica_dist_json["min_count"] = min_count; + replica_dist_json["skew"] = max_count - min_count; + // Used to make the Impala CREATE TABLE statement. (*output)["master_addresses"] = MasterAddrsToCsv(); http://git-wip-us.apache.org/repos/asf/kudu/blob/9de558c2/www/table.mustache ---------------------------------------------------------------------- diff --git a/www/table.mustache b/www/table.mustache index 734f084..8de206b 100644 --- a/www/table.mustache +++ b/www/table.mustache @@ -121,6 +121,34 @@ under the License. </table> </div> + {{#replica_distribution}} + <h3>Tablet Replica Distribution</h3> + <table class='table table-striped table-hover'> + <tbody> + <tr><td>Min Count</td><td>{{min_count}}</td></tr> + <tr><td>Max Count</td><td>{{max_count}}</td></tr> + <tr> + <td> + <p>Skew <small>(<a href="#skew-help" data-toggle="collapse">?</a>)</small></p> + <div id="skew-help" class="collapse text-muted"><p> + Skew is the difference between the max and min replica counts. + It measures how imbalanced the table is. + </p></div> + </td> + <td>{{skew}}</td> + </tr> + </tbody> + </table> + <table class='table table-striped table-hover'> + <thead><tr><th>Tablet Server</th><th>Replica Count</th></thead> + <tbody> + {{#counts}} + <tr><td>{{ts_uuid}}</td><td>{{count}}</td></tr> + {{/counts}} + </tbody> + </table> + {{/replica_distribution}} + <h3>Impala CREATE TABLE statement</h3> {{! Unusual formatting below because <pre> preserves whitespace in the output. }} <pre><code>CREATE EXTERNAL TABLE `{{name}}` STORED AS KUDU
