You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by to...@apache.org on 2016/08/17 23:03:00 UTC

[2/3] kudu git commit: improvements to /table

improvements to /table

This is a bunch of improvements to the /table endpoint:

0. The order of elements has been made more logical. It's now basic
info, then schema, then partition schema, then the tablets table,
then the Impala create table statement, and finally the tasks list.
Every section now has a title.

1. The partition schema section has been reformatted and improved to
show the table's range bounds.

2. The column RaftConfig in the tablets table has been renamed to
Peers.

3. The peers are now sorted so the leader appears at the top of the
list in the Peers column.

4. A rendering issue where the Impala create table's container would
"leak" a little bit of background to a line above and below it has
been fixed.

See https://raw.githubusercontent.com/wdberkeley/kudu-cr/master/table_after_top.png
for a sample of the new look.

Change-Id: Ib6724348b1cd199c4d651c1282f1eadb58226bea
Reviewed-on: http://gerrit.cloudera.org:8080/4021
Reviewed-by: Todd Lipcon <to...@apache.org>
Tested-by: Kudu Jenkins


Project: http://git-wip-us.apache.org/repos/asf/kudu/repo
Commit: http://git-wip-us.apache.org/repos/asf/kudu/commit/07c50b80
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/07c50b80
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/07c50b80

Branch: refs/heads/master
Commit: 07c50b803476f17728dd0c9ad1bfab12caf924e2
Parents: 0174fda
Author: Will Berkeley <wd...@gmail.com>
Authored: Wed Aug 17 15:32:00 2016 -0400
Committer: Todd Lipcon <to...@apache.org>
Committed: Wed Aug 17 23:01:13 2016 +0000

----------------------------------------------------------------------
 src/kudu/common/partition.cc            | 20 ++++++++-----
 src/kudu/master/master-path-handlers.cc | 44 ++++++++++++++++++++++------
 src/kudu/server/webui_util.cc           | 15 +++++-----
 src/kudu/server/webui_util.h            |  5 ++++
 4 files changed, 61 insertions(+), 23 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/07c50b80/src/kudu/common/partition.cc
----------------------------------------------------------------------
diff --git a/src/kudu/common/partition.cc b/src/kudu/common/partition.cc
index b3b31c7..5a24228 100644
--- a/src/kudu/common/partition.cc
+++ b/src/kudu/common/partition.cc
@@ -770,27 +770,33 @@ string PartitionSchema::DisplayString(const Schema& schema) const {
   string display_string;
 
   if (!hash_bucket_schemas_.empty()) {
-    display_string.append("Hash bucket schemas:\n");
+    display_string.append("Hash components:\n");
     for (const HashBucketSchema& hash_bucket_schema : hash_bucket_schemas_) {
-      display_string.append("  Key columns:\n");
+      display_string.append("  (");
+      vector<string> hash_components;
+      hash_components.reserve(hash_bucket_schema.column_ids.size());
       for (const ColumnId& col_id : hash_bucket_schema.column_ids) {
         const ColumnSchema& col = schema.column_by_id(col_id);
-        SubstituteAndAppend(&display_string, "    $0 $1\n", col.name(), col.type_info()->name());
+        hash_components.push_back(Substitute("$0 $1", col.name(), col.type_info()->name()));
       }
-      SubstituteAndAppend(&display_string, "  Bucket count: $0\n", hash_bucket_schema.num_buckets);
+      display_string.append(JoinStrings(hash_components, ", "));
+      SubstituteAndAppend(&display_string, ") bucket count: $0", hash_bucket_schema.num_buckets);
       if (hash_bucket_schema.seed != 0) {
-        SubstituteAndAppend(&display_string, "  Seed: $0\n", hash_bucket_schema.seed);
+        SubstituteAndAppend(&display_string, " seed: $0", hash_bucket_schema.seed);
       }
       display_string.append("\n");
     }
   }
 
   if (!range_schema_.column_ids.empty()) {
-    display_string.append("Range columns:\n");
+    display_string.append("Range component:\n");
+    vector<string> range_component;
+    range_component.reserve(range_schema_.column_ids.size());
     for (const ColumnId& col_id : range_schema_.column_ids) {
       const ColumnSchema& col = schema.column_by_id(col_id);
-      SubstituteAndAppend(&display_string, "  $0 $1\n", col.name(), col.type_info()->name());
+      range_component.push_back(Substitute("$0 $1", col.name(), col.type_info()->name()));
     }
+    SubstituteAndAppend(&display_string, "  ($0)\n", JoinStrings(range_component, ", "));
   }
   return display_string;
 }

http://git-wip-us.apache.org/repos/asf/kudu/blob/07c50b80/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 d97281c..68f090c 100644
--- a/src/kudu/master/master-path-handlers.cc
+++ b/src/kudu/master/master-path-handlers.cc
@@ -21,6 +21,7 @@
 #include <boost/bind.hpp>
 #include <map>
 #include <memory>
+#include <set>
 #include <string>
 #include <utility>
 #include <vector>
@@ -43,7 +44,6 @@
 #include "kudu/util/string_case.h"
 #include "kudu/util/url-coding.h"
 
-
 namespace kudu {
 
 using consensus::ConsensusStatePB;
@@ -120,9 +120,16 @@ void MasterPathHandlers::HandleCatalogManager(const Webserver::WebRequest& req,
 
 namespace {
 
+int RoleToSortIndex(RaftPeerPB::Role r) {
+  switch (r) {
+    case RaftPeerPB::LEADER: return 0;
+    default: return 1 + static_cast<int>(r);
+  }
+}
+
 bool CompareByRole(const pair<string, RaftPeerPB::Role>& a,
                    const pair<string, RaftPeerPB::Role>& b) {
-  return a.second < b.second;
+  return RoleToSortIndex(a.second) < RoleToSortIndex(b.second);
 }
 
 } // anonymous namespace
@@ -186,11 +193,17 @@ void MasterPathHandlers::HandleTablePage(const Webserver::WebRequest& req,
     table->GetAllTablets(&tablets);
   }
 
+  *output << "<h3>Schema</h3>";
   HtmlOutputSchemaTable(schema, output);
 
-  *output << "<table class='table table-striped'>\n";
-  *output << "  <tr><th>Tablet ID</th><th>Partition</th><th>State</th>"
-      "<th>Message</th><th>RaftConfig</th></tr>\n";
+  // Prepare the tablets table first because the tablet partition information is
+  // also used to make the range bounds.
+  std::set<std::pair<string, string>> range_bounds;
+  std::stringstream tablets_output;
+  tablets_output << "<h3>Tablets</h3>";
+  tablets_output << "<table class='table table-striped'>\n";
+  tablets_output << "  <tr><th>Tablet ID</th><th>Partition</th><th>State</th>"
+      "<th>Message</th><th>Peers</th></tr>\n";
   for (const scoped_refptr<TabletInfo>& tablet : tablets) {
     vector<pair<string, RaftPeerPB::Role>> sorted_replicas;
     TabletMetadataLock l(tablet.get(), TabletMetadataLock::READ);
@@ -227,10 +240,12 @@ void MasterPathHandlers::HandleTablePage(const Webserver::WebRequest& req,
 
     Partition partition;
     Partition::FromPB(l.data().pb.partition(), &partition);
+    range_bounds.insert({partition.range_key_start().ToString(),
+                         partition.range_key_end().ToString()});
 
     string state = SysTabletsEntryPB_State_Name(l.data().pb.state());
     Capitalize(&state);
-    *output << Substitute(
+    tablets_output << Substitute(
         "<tr><th>$0</th><td>$1</td><td>$2</td><td>$3</td><td>$4</td></tr>\n",
         tablet->tablet_id(),
         EscapeForHtmlToString(partition_schema.PartitionDebugString(partition, schema)),
@@ -238,15 +253,25 @@ void MasterPathHandlers::HandleTablePage(const Webserver::WebRequest& req,
         EscapeForHtmlToString(l.data().pb.state_msg()),
         raft_config_html.str());
   }
-  *output << "</table>\n";
+  tablets_output << "</table>\n";
 
-  *output << "<h2>Partition schema</h2>";
+  // Write out the partition schema and range bound information...
+  *output << "<h3>Partition schema &amp; range bounds</h3>";
   *output << "<pre>";
   *output << EscapeForHtmlToString(partition_schema.DisplayString(schema));
+  *output << "Range bounds:\n";
+  for (const auto& pair : range_bounds) {
+    string range_bound = partition_schema.RangePartitionDebugString(pair.first,
+                                                                    pair.second,
+                                                                    schema);
+    *output << Substitute("  $0\n", EscapeForHtmlToString(range_bound));
+  }
   *output << "</pre>";
 
-  *output << "<h2>Impala CREATE TABLE statement</h2>\n";
+  // ...then the tablets table.
+  *output << tablets_output.str();
 
+  *output << "<h3>Impala CREATE TABLE statement</h3>\n";
   string master_addresses;
   if (master_->opts().IsDistributed()) {
     vector<string> all_addresses;
@@ -268,6 +293,7 @@ void MasterPathHandlers::HandleTablePage(const Webserver::WebRequest& req,
   }
   HtmlOutputImpalaSchema(table_name, schema, master_addresses, output);
 
+  *output << "<h3>Tasks</h3>";
   std::vector<scoped_refptr<MonitoredTask> > task_list;
   table->GetTaskList(&task_list);
   HtmlOutputTaskList(task_list, output);

http://git-wip-us.apache.org/repos/asf/kudu/blob/07c50b80/src/kudu/server/webui_util.cc
----------------------------------------------------------------------
diff --git a/src/kudu/server/webui_util.cc b/src/kudu/server/webui_util.cc
index 1b90700..05047ce 100644
--- a/src/kudu/server/webui_util.cc
+++ b/src/kudu/server/webui_util.cc
@@ -19,7 +19,6 @@
 
 #include <string>
 
-#include "kudu/common/schema.h"
 #include "kudu/gutil/strings/join.h"
 #include "kudu/gutil/map-util.h"
 #include "kudu/gutil/strings/human_readable.h"
@@ -70,7 +69,7 @@ void HtmlOutputImpalaSchema(const std::string& table_name,
                             const Schema& schema,
                             const string& master_addresses,
                             std::stringstream* output) {
-  *output << "<code><pre>\n";
+  *output << "<pre><code>\n";
 
   // Escape table and column names with ` to avoid conflicts with Impala reserved words.
   *output << "CREATE EXTERNAL TABLE " << EscapeForHtmlToString("`" + table_name + "`")
@@ -134,11 +133,14 @@ void HtmlOutputImpalaSchema(const std::string& table_name,
 
   *output << "TBLPROPERTIES(\n";
   *output << "  'storage_handler' = 'com.cloudera.kudu.hive.KuduStorageHandler',\n";
-  *output << "  'kudu.table_name' = '" << table_name << "',\n";
-  *output << "  'kudu.master_addresses' = '" << master_addresses << "',\n";
-  *output << "  'kudu.key_columns' = '" << JoinElements(key_columns, ", ") << "'\n";
+  *output << "  'kudu.table_name' = '";
+  *output << EscapeForHtmlToString(table_name) << "',\n";
+  *output << "  'kudu.master_addresses' = '";
+  *output << EscapeForHtmlToString(master_addresses) << "',\n";
+  *output << "  'kudu.key_columns' = '";
+  *output << EscapeForHtmlToString(JoinElements(key_columns, ", ")) << "'\n";
   *output << ");\n";
-  *output << "</pre></code>\n";
+  *output << "</code></pre>\n";
 }
 
 void HtmlOutputTaskList(const std::vector<scoped_refptr<MonitoredTask> >& tasks,
@@ -182,5 +184,4 @@ void HtmlOutputTaskList(const std::vector<scoped_refptr<MonitoredTask> >& tasks,
   }
   *output << "</table>\n";
 }
-
 } // namespace kudu

http://git-wip-us.apache.org/repos/asf/kudu/blob/07c50b80/src/kudu/server/webui_util.h
----------------------------------------------------------------------
diff --git a/src/kudu/server/webui_util.h b/src/kudu/server/webui_util.h
index 43ac6ea..397a8aa 100644
--- a/src/kudu/server/webui_util.h
+++ b/src/kudu/server/webui_util.h
@@ -21,6 +21,7 @@
 #include <sstream>
 #include <vector>
 
+#include "kudu/common/schema.h"
 #include "kudu/gutil/ref_counted.h"
 
 namespace kudu {
@@ -36,6 +37,10 @@ void HtmlOutputImpalaSchema(const std::string& table_name,
                             std::stringstream* output);
 void HtmlOutputTaskList(const std::vector<scoped_refptr<MonitoredTask> >& tasks,
                         std::stringstream* output);
+
+string FriendlyEncodingTypeName(EncodingType enc);
+
+string FriendlyCompressionTypeName(CompressionType enc);
 } // namespace kudu
 
 #endif // KUDU_SERVER_WEBUI_UTIL_H