You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@kudu.apache.org by gr...@apache.org on 2019/02/05 22:18:14 UTC

[kudu] 02/04: [rebalancer] always output summary on policy violations

This is an automated email from the ASF dual-hosted git repository.

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

commit fd089bf259d3e17f2801ee3122c6fe7844efd4ae
Author: Alexey Serbin <al...@apache.org>
AuthorDate: Mon Feb 4 15:43:26 2019 -0800

    [rebalancer] always output summary on policy violations
    
    This patch makes the location-aware rebalancer always output summary
    on the detected violations of the replica placement policy.  The
    detailed information on the violations is output if the runtime
    flag --output_replica_distribution_details is specified.
    
    Prior to this patch, the rebalancer would output either the summary
    or the detailed information on the detected violations of the replica
    placement policy, depending on the presence of the
    --output_replica_distribution_details flag.
    
    Change-Id: I5f68cebcef9a3c02203e80414082a0994a1721ee
    Reviewed-on: http://gerrit.cloudera.org:8080/12358
    Tested-by: Kudu Jenkins
    Reviewed-by: Will Berkeley <wd...@gmail.com>
---
 src/kudu/tools/rebalancer.cc | 48 +++++++++++++++++++++++---------------------
 1 file changed, 25 insertions(+), 23 deletions(-)

diff --git a/src/kudu/tools/rebalancer.cc b/src/kudu/tools/rebalancer.cc
index 51e1869..72b81c5 100644
--- a/src/kudu/tools/rebalancer.cc
+++ b/src/kudu/tools/rebalancer.cc
@@ -632,7 +632,31 @@ Status Rebalancer::PrintPolicyViolationInfo(const ClusterRawInfo& raw_info,
     return Status::OK();
   }
 
+  DataTable summary({ "Location",
+                      "Number of non-complying tables",
+                      "Number of non-complying tablets" });
+  typedef pair<unordered_set<string>, unordered_set<string>> TableTabletIds;
+  // Location --> sets of identifiers of tables and tablets hosted by the
+  // tablet servers at the location. The summary is sorted by location.
+  map<string, TableTabletIds> info_by_location;
+  for (const auto& info : ppvi) {
+    const auto& table_id = FindOrDie(placement_info.tablet_to_table_id,
+                                     info.tablet_id);
+    auto& elem = LookupOrEmplace(&info_by_location,
+                                 info.majority_location, TableTabletIds());
+    elem.first.emplace(table_id);
+    elem.second.emplace(info.tablet_id);
+  }
+  for (const auto& elem : info_by_location) {
+    summary.AddRow({ elem.first,
+                     to_string(elem.second.first.size()),
+                     to_string(elem.second.second.size()) });
+  }
+  RETURN_NOT_OK(summary.PrintTo(out));
+  out << endl;
+  // If requested, print details on detected policy violations.
   if (config_.output_replica_distribution_details) {
+    out << "Placement policy violation details:" << endl;
     DataTable stats(
         { "Location", "Table Name", "Tablet", "RF", "Replicas at location" });
     for (const auto& info : ppvi) {
@@ -646,30 +670,8 @@ Status Rebalancer::PrintPolicyViolationInfo(const ClusterRawInfo& raw_info,
                      to_string(info.replicas_num_at_majority_location) });
     }
     RETURN_NOT_OK(stats.PrintTo(out));
-  } else {
-    DataTable summary({ "Location",
-                        "Number of non-complying tables",
-                        "Number of non-complying tablets" });
-    typedef pair<unordered_set<string>, unordered_set<string>> TableTabletIds;
-    // Location --> sets of identifiers of tables and tablets hosted by the
-    // tablet servers at the location. The summary is sorted by location.
-    map<string, TableTabletIds> info_by_location;
-    for (const auto& info : ppvi) {
-      const auto& table_id = FindOrDie(placement_info.tablet_to_table_id,
-                                       info.tablet_id);
-      auto& elem = LookupOrEmplace(&info_by_location,
-                                   info.majority_location, TableTabletIds());
-      elem.first.emplace(table_id);
-      elem.second.emplace(info.tablet_id);
-    }
-    for (const auto& elem : info_by_location) {
-      summary.AddRow({ elem.first,
-                       to_string(elem.second.first.size()),
-                       to_string(elem.second.second.size()) });
-    }
-    RETURN_NOT_OK(summary.PrintTo(out));
+    out << endl;
   }
-  out << endl;
 
   return Status::OK();
 }