kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a...@apache.org
Subject [kudu] 02/02: KUDU-2825: add a column named role in 'kudu master list'
Date Tue, 28 May 2019 04:54:39 GMT
This is an automated email from the ASF dual-hosted git repository.

adar pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit fc8218463fc8b58a606314af71b6b9b3b78aa5ce
Author: GuangchaoDeng <532869068@qq.com>
AuthorDate: Sat May 25 15:40:37 2019 +0800

    KUDU-2825: add a column named role in 'kudu master list'
    
    Added a column named 'role' in 'kudu master list' to show the
    role of each master, Roles include leader, follower, learner,
    nonparticipant and unknown role. By default, the tool's
    output has the 'role' column.
    
    Change-Id: I29da5024ec59d3fb1d576247b2f0f7af0e7968dc
    Reviewed-on: http://gerrit.cloudera.org:8080/13435
    Reviewed-by: Adar Dembo <adar@cloudera.com>
    Tested-by: Adar Dembo <adar@cloudera.com>
---
 src/kudu/tools/tool_action_master.cc | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/kudu/tools/tool_action_master.cc b/src/kudu/tools/tool_action_master.cc
index 352ace1..015037a 100644
--- a/src/kudu/tools/tool_action_master.cc
+++ b/src/kudu/tools/tool_action_master.cc
@@ -34,6 +34,7 @@
 #include "kudu/common/common.pb.h"
 #include "kudu/common/wire_protocol.h"
 #include "kudu/common/wire_protocol.pb.h"
+#include "kudu/consensus/metadata.pb.h"
 #include "kudu/gutil/map-util.h"
 #include "kudu/gutil/strings/join.h"
 #include "kudu/gutil/strings/split.h"
@@ -61,6 +62,7 @@ using kudu::master::MasterServiceProxy;
 using kudu::master::MasterServiceProxy;
 using kudu::master::ResetAuthzCacheRequestPB;
 using kudu::master::ResetAuthzCacheResponsePB;
+using kudu::consensus::RaftPeerPB;
 using kudu::rpc::RpcController;
 using std::cout;
 using std::map;
@@ -164,6 +166,10 @@ Status ListMasters(const RunnerContext& context) {
       for (const auto& master : masters) {
         values.emplace_back(StartTimeToString(master.registration()));
       }
+    } else if (boost::iequals(column, "role")) {
+      for (const auto& master : masters) {
+        values.emplace_back(RaftPeerPB::Role_Name(master.role()));
+      }
     } else {
       return Status::InvalidArgument("unknown column (--columns)", column);
     }
@@ -372,11 +378,11 @@ unique_ptr<Mode> BuildMasterMode() {
         .AddRequiredParameter({ kMasterAddressesArg, kMasterAddressesArgDesc })
         .AddOptionalParameter(
             "columns",
-            string("uuid,rpc-addresses"),
+            string("uuid,rpc-addresses,role"),
             string("Comma-separated list of master info fields to "
                    "include in output.\nPossible values: uuid, "
-                   "rpc-addresses, http-addresses, version, seqno "
-                   "and start_time"))
+                   "rpc-addresses, http-addresses, version, seqno, "
+                   "start_time and role"))
         .AddOptionalParameter("format")
         .AddOptionalParameter("timeout_ms")
         .Build();


Mime
View raw message