Repository: incubator-impala Updated Branches: refs/heads/master 1ed8ada66 -> fe97579fe
IMPALA-3972: Improve display of /varz page gflags has an API that returns metadata for all command-line flags. This patch changes /varz to use that to generate a table view, where rows are highlighted if the flag has changed from its default value. Change-Id: I5a0d47da7abf913918d5fba5c327e26b73d701d2 Reviewed-on: http://gerrit.cloudera.org:8080/3941 Reviewed-by: Henry Robinson <[email protected]> Tested-by: Internal Jenkins Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/fe97579f Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/fe97579f Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/fe97579f Branch: refs/heads/master Commit: fe97579fe805b34bdccf4569ac626d11801a4823 Parents: 1ed8ada Author: Henry Robinson <[email protected]> Authored: Wed Aug 10 22:23:36 2016 -0700 Committer: Internal Jenkins <[email protected]> Committed: Fri Aug 12 10:39:39 2016 +0000 ---------------------------------------------------------------------- be/src/util/default-path-handlers.cc | 45 +++++++++++++++++++++++--- www/common-header.tmpl | 4 +++ www/flags.tmpl | 52 +++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/fe97579f/be/src/util/default-path-handlers.cc ---------------------------------------------------------------------- diff --git a/be/src/util/default-path-handlers.cc b/be/src/util/default-path-handlers.cc index f643425..e1e1f44 100644 --- a/be/src/util/default-path-handlers.cc +++ b/be/src/util/default-path-handlers.cc @@ -72,13 +72,48 @@ void LogsHandler(const Webserver::ArgumentMap& args, Document* document) { } } -// Registered to handle "/flags", and produces Json with 'title" and 'contents' members -// where the latter is a string with all the command-line flags and their values. +// Registered to handle "/flags", and produces json containing an array of flag metadata +// objects: +// +// "title": "Command-line Flags", +// "flags": [ +// { +// "name": "catalog_service_port", +// "type": "int32", +// "description": "port where the CatalogService is running", +// "default": "26000", +// "current": "26000" +// }, +// .. etc void FlagsHandler(const Webserver::ArgumentMap& args, Document* document) { + vector<CommandLineFlagInfo> flag_info; + GetAllFlags(&flag_info); + Value flag_arr(kArrayType); + for (const CommandLineFlagInfo& flag: flag_info) { + Value flag_val(kObjectType); + Value name(flag.name.c_str(), document->GetAllocator()); + flag_val.AddMember("name", name, document->GetAllocator()); + + Value type(flag.type.c_str(), document->GetAllocator()); + flag_val.AddMember("type", type, document->GetAllocator()); + + Value description(flag.description.c_str(), document->GetAllocator()); + flag_val.AddMember("description", description, document->GetAllocator()); + + Value default_value(flag.default_value.c_str(), document->GetAllocator()); + flag_val.AddMember("default", default_value, document->GetAllocator()); + + Value current_value(flag.current_value.c_str(), document->GetAllocator()); + flag_val.AddMember("current", current_value, document->GetAllocator()); + + if (!flag.is_default) { + flag_val.AddMember("value_changed", 1, document->GetAllocator()); + } + flag_arr.PushBack(flag_val, document->GetAllocator()); + } Value title("Command-line Flags", document->GetAllocator()); document->AddMember("title", title, document->GetAllocator()); - Value flags(CommandlineFlagsIntoString().c_str(), document->GetAllocator()); - document->AddMember("contents", flags, document->GetAllocator()); + document->AddMember("flags", flag_arr, document->GetAllocator()); } // Registered to handle "/memz" @@ -124,7 +159,7 @@ void MemUsageHandler(MemTracker* mem_tracker, const Webserver::ArgumentMap& args void impala::AddDefaultUrlCallbacks( Webserver* webserver, MemTracker* process_mem_tracker) { webserver->RegisterUrlCallback("/logs", "logs.tmpl", LogsHandler); - webserver->RegisterUrlCallback("/varz", "common-pre.tmpl", FlagsHandler); + webserver->RegisterUrlCallback("/varz", "flags.tmpl", FlagsHandler); if (process_mem_tracker != NULL) { webserver->RegisterUrlCallback("/memz","memz.tmpl", bind<void>(&MemUsageHandler, process_mem_tracker, _1, _2)); http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/fe97579f/www/common-header.tmpl ---------------------------------------------------------------------- diff --git a/www/common-header.tmpl b/www/common-header.tmpl index 5536bda..9dd1788 100644 --- a/www/common-header.tmpl +++ b/www/common-header.tmpl @@ -21,6 +21,10 @@ common-footer.tmpl) }} <!DOCTYPE html> <html> <head><title>Apache Impala (incubating)</title> + <script src='/www/jquery/jquery-1.12.4.min.js'></script> + <script src='/www/bootstrap/js/bootstrap.min.js'></script> + <link rel="stylesheet" type="text/css" href="/www/datatables.min.css"/> + <script type="text/javascript" src="/www/datatables.min.js"></script> <link href='/www/bootstrap/css/bootstrap.min.css' rel='stylesheet' media='screen'> <style> </style> http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/fe97579f/www/flags.tmpl ---------------------------------------------------------------------- diff --git a/www/flags.tmpl b/www/flags.tmpl new file mode 100644 index 0000000..eac731d --- /dev/null +++ b/www/flags.tmpl @@ -0,0 +1,52 @@ +<!-- +Licensed to the Apache Software Foundation (ASF) under one +or more contributor license agreements. See the NOTICE file +distributed with this work for additional information +regarding copyright ownership. The ASF licenses this file +to you under the Apache License, Version 2.0 (the +"License"); you may not use this file except in compliance +with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, +software distributed under the License is distributed on an +"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +KIND, either express or implied. See the License for the +specific language governing permissions and limitations +under the License. +--> +{{> www/common-header.tmpl }} + +<table id="flags" class='table table-hover table-bordered' + style='table-layout:fixed; word-wrap: break-word'> + <thead> + <tr> + <th>Flag</th> + <th>Description</th> + <th>Default</th> + <th>Current value</th> + </tr> + </thead> + <tbody> + {{#flags}} + <tr {{?value_changed}}class="active"{{/value_changed}}> + <td> <samp>{{name}} ({{type}})</samp></td> + <td>{{description}}</td> + <td><samp>{{default}}</samp></td> + <td><samp>{{current}}</samp></td> + </tr> + {{/flags}} + </tbody> +</table> + +<script> + $(document).ready(function() { + $('#flags').DataTable({ + "order": [[ 1, "desc" ]], + "pageLength": 100 + }); + }); +</script> + +{{> www/common-footer.tmpl }}
