kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From laiyingc...@apache.org
Subject [kudu] 17/23: [collector] modify some APIs
Date Sat, 15 Aug 2020 14:59:45 GMT
This is an automated email from the ASF dual-hosted git repository.

laiyingchun pushed a commit to tag kudu-1.12.0-mdh1.0.0-4c2c075-centos-release
in repository https://gitbox.apache.org/repos/asf/kudu.git

commit 7caa5a7dbebdd3d9386063365f2814ba4f276ed7
Author: zhangyifan8 <zhangyifan8@xiaomi.com>
AuthorDate: Thu May 21 11:52:57 2020 +0800

    [collector] modify some APIs
    
    Modify some APIs for collector according to the following patches:
    1. thread: simplify Thread::Create API https://gerrit.cloudera.org/c/15448/
    2. threadpool: simplify Submit API  threadpool: simplify Submit API
       https://gerrit.cloudera.org/c/15401/
    3. [master/tserver] non-zero code from main() instead of crashing
       https://gerrit.cloudera.org/c/14908/
    4. [tools] Support running the master and tablet server via the kudu binary
       https://gerrit.cloudera.org/c/12517/
---
 src/kudu/collector/cluster_rebalancer.cc |  5 +++--
 src/kudu/collector/collector.cc          |  5 +++--
 src/kudu/collector/collector_main.cc     | 10 ++++------
 src/kudu/collector/falcon_reporter.cc    |  2 +-
 src/kudu/collector/metrics_collector.cc  | 15 ++++++++++-----
 src/kudu/collector/nodes_checker.cc      |  5 +++--
 src/kudu/collector/service_monitor.cc    |  5 +++--
 src/kudu/master/master.cc                |  4 ++--
 8 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/src/kudu/collector/cluster_rebalancer.cc b/src/kudu/collector/cluster_rebalancer.cc
index b46baa4..c33d1a7 100644
--- a/src/kudu/collector/cluster_rebalancer.cc
+++ b/src/kudu/collector/cluster_rebalancer.cc
@@ -101,8 +101,9 @@ string ClusterRebalancer::ToString() const {
 }
 
 Status ClusterRebalancer::StartClusterRebalancerThread() {
-  return Thread::Create("server", "cluster-rebalancer", &ClusterRebalancer::ClusterRebalancerThread,
-                        this, &cluster_rebalancer_thread_);
+  return Thread::Create("server", "cluster-rebalancer",
+                        [this]() { this->ClusterRebalancerThread(); },
+                        &cluster_rebalancer_thread_);
 }
 
 void ClusterRebalancer::ClusterRebalancerThread() {
diff --git a/src/kudu/collector/collector.cc b/src/kudu/collector/collector.cc
index 3501300..9eb5f3d 100644
--- a/src/kudu/collector/collector.cc
+++ b/src/kudu/collector/collector.cc
@@ -148,8 +148,9 @@ Status Collector::StartExcessLogFileDeleterThread() {
     RETURN_NOT_OK_PREPEND(DeleteExcessLogFiles(Env::Default()),
                           "Unable to delete excess log files");
   }
-  return Thread::Create("server", "excess-log-deleter", &Collector::ExcessLogFileDeleterThread,
-                        this, &excess_log_deleter_thread_);
+  return Thread::Create("server", "excess-log-deleter",
+                        [this]() { this->ExcessLogFileDeleterThread(); },
+                        &excess_log_deleter_thread_);
 }
 
 void Collector::ExcessLogFileDeleterThread() {
diff --git a/src/kudu/collector/collector_main.cc b/src/kudu/collector/collector_main.cc
index afc0768..614c288 100644
--- a/src/kudu/collector/collector_main.cc
+++ b/src/kudu/collector/collector_main.cc
@@ -33,16 +33,14 @@ namespace kudu {
 namespace collector {
 
 static int CollectorMain(int argc, char** argv) {
-  InitKuduOrDie();
-
-  GFlagsMap default_flags = GetFlagsMap();
+  RETURN_MAIN_NOT_OK(InitKudu(), "InitKudu() failed", 1);
 
   ParseCommandLineFlags(&argc, &argv, true);
   if (argc != 1) {
     std::cerr << "usage: " << argv[0] << std::endl;
     return 1;
   }
-  std::string nondefault_flags = GetNonDefaultFlags(default_flags);
+  std::string nondefault_flags = GetNonDefaultFlags();
   InitGoogleLoggingSafe(argv[0]);
 
   LOG(INFO) << "Collector non-default flags:\n"
@@ -52,10 +50,10 @@ static int CollectorMain(int argc, char** argv) {
 
   Collector collector;
   LOG(INFO) << "Initializing collector...";
-  CHECK_OK(collector.Init());
+  RETURN_MAIN_NOT_OK(collector.Init(), "Init() failed", 3);
 
   LOG(INFO) << "Starting collector...";
-  CHECK_OK(collector.Start());
+  RETURN_MAIN_NOT_OK(collector.Start(), "Start() failed", 4);
 
   LOG(INFO) << "Collector successfully started.";
   while (!RunOnceMode()) {
diff --git a/src/kudu/collector/falcon_reporter.cc b/src/kudu/collector/falcon_reporter.cc
index efe387b..35d8af4 100644
--- a/src/kudu/collector/falcon_reporter.cc
+++ b/src/kudu/collector/falcon_reporter.cc
@@ -152,7 +152,7 @@ Status FalconReporter::StartFalconPusherThreadPool() {
       .set_idle_timeout(MonoDelta::FromMilliseconds(1))
       .Build(&pusher_thread_pool_));
   for (int i = 0; i < FLAGS_collector_falcon_pusher_count; ++i) {
-    RETURN_NOT_OK(pusher_thread_pool_->SubmitFunc(std::bind(&FalconReporter::FalconPusher,
+    RETURN_NOT_OK(pusher_thread_pool_->Submit(std::bind(&FalconReporter::FalconPusher,
                                                             this)));
   }
 
diff --git a/src/kudu/collector/metrics_collector.cc b/src/kudu/collector/metrics_collector.cc
index 6d09a0d..a79a609 100644
--- a/src/kudu/collector/metrics_collector.cc
+++ b/src/kudu/collector/metrics_collector.cc
@@ -142,8 +142,9 @@ string MetricsCollector::ToString() const {
 }
 
 Status MetricsCollector::StartMetricCollectorThread() {
-  return Thread::Create("server", "metric-collector", &MetricsCollector::MetricCollectorThread,
-                        this, &metric_collector_thread_);
+  return Thread::Create("server", "metric-collector",
+                        [this]() { this->MetricCollectorThread(); },
+                        &metric_collector_thread_);
 }
 
 void MetricsCollector::MetricCollectorThread() {
@@ -334,7 +335,7 @@ Status MetricsCollector::CollectAndReportMasterMetrics() {
   RETURN_NOT_OK(UpdateThreadPool(std::max(host_metric_collector_thread_pool_->num_threads(),
                                           static_cast<int32_t>(master_http_addrs.size()))));
   for (int i = 0; i < master_http_addrs.size(); ++i) {
-    RETURN_NOT_OK(host_metric_collector_thread_pool_->SubmitFunc(
+    RETURN_NOT_OK(host_metric_collector_thread_pool_->Submit(
       std::bind(&MetricsCollector::CollectAndReportHostLevelMetrics,
                 this,
                 NodeType::kMaster,
@@ -373,7 +374,7 @@ Status MetricsCollector::CollectAndReportTServerMetrics() {
   vector<TablesMetrics> hosts_metrics_by_table_name(tserver_http_addrs.size());
   vector<TablesHistMetrics> hosts_hist_metrics_by_table_name(tserver_http_addrs.size());
   for (int i = 0; i < tserver_http_addrs.size(); ++i) {
-    RETURN_NOT_OK(host_metric_collector_thread_pool_->SubmitFunc(
+    RETURN_NOT_OK(host_metric_collector_thread_pool_->Submit(
       std::bind(&MetricsCollector::CollectAndReportHostLevelMetrics,
                 this,
                 NodeType::kTServer,
@@ -654,8 +655,12 @@ Status MetricsCollector::ParseEntityMetrics(const JsonReader& r,
         case rapidjson::Type::kNumberType:
           CHECK_OK(GetNumberMetricValue(val, name, &value));
           break;
+        case rapidjson::Type::kFalseType:
+        case rapidjson::Type::kTrueType:
+          // Do not process true/false type.
+          break;
         default:
-          LOG(FATAL) << "Unknown type, metrics name: " << name;
+          LOG(WARNING) << "Unknown type, metrics name: " << name;
       }
 
       EmplaceOrDie(kv_metrics, std::make_pair(name, value));
diff --git a/src/kudu/collector/nodes_checker.cc b/src/kudu/collector/nodes_checker.cc
index 036d72a..15a6d22 100644
--- a/src/kudu/collector/nodes_checker.cc
+++ b/src/kudu/collector/nodes_checker.cc
@@ -131,8 +131,9 @@ string NodesChecker::GetFirstTServer() {
 }
 
 Status NodesChecker::StartNodesCheckerThread() {
-  return Thread::Create("collector", "nodes-checker", &NodesChecker::NodesCheckerThread,
-                        this, &nodes_checker_thread_);
+  return Thread::Create("collector", "nodes-checker",
+                        [this]() { this->NodesCheckerThread(); },
+                        &nodes_checker_thread_);
 }
 
 void NodesChecker::NodesCheckerThread() {
diff --git a/src/kudu/collector/service_monitor.cc b/src/kudu/collector/service_monitor.cc
index e97fb79..70ea57a 100644
--- a/src/kudu/collector/service_monitor.cc
+++ b/src/kudu/collector/service_monitor.cc
@@ -342,8 +342,9 @@ Status ServiceMonitor::CallLeaderStepDown(const string& tablet_id,
const string&
 }
 
 Status ServiceMonitor::StartServiceMonitorThread() {
-  return Thread::Create("collector", "nodes-checker", &ServiceMonitor::ServiceMonitorThread,
-                        this, &service_monitor_thread_);
+  return Thread::Create("collector", "nodes-checker",
+                        [this]() { this->ServiceMonitorThread(); },
+                        &service_monitor_thread_);
 }
 
 void ServiceMonitor::ServiceMonitorThread() {
diff --git a/src/kudu/master/master.cc b/src/kudu/master/master.cc
index 32d6e8d..0fc7718 100644
--- a/src/kudu/master/master.cc
+++ b/src/kudu/master/master.cc
@@ -312,8 +312,8 @@ void Master::CrashMasterOnCFileCorruption(const string& tablet_id)
{
 
 Status Master::StartOutdatedReservedTablesDeleterThread() {
   return Thread::Create("master", "outdated-reserved-tables-deleter",
-                        &Master::OutdatedReservedTablesDeleterThread,
-                        this, &outdated_reserved_tables_deleter_thread_);
+                        [this]() { this->OutdatedReservedTablesDeleterThread(); },
+                        &outdated_reserved_tables_deleter_thread_);
 }
 
 void Master::OutdatedReservedTablesDeleterThread() {


Mime
View raw message