kudu-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ale...@apache.org
Subject [1/2] kudu git commit: [tablet] Add tablet metric for number of diskrowsets
Date Tue, 04 Sep 2018 20:07:14 GMT
Repository: kudu
Updated Branches:
  refs/heads/master cf6927cb1 -> a58867c59


[tablet] Add tablet metric for number of diskrowsets

Change-Id: Ifb1ca202c281da07007eff1f555af2eef9b2393e
Reviewed-on: http://gerrit.cloudera.org:8080/11378
Reviewed-by: Adar Dembo <adar@cloudera.com>
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/060d7b0f
Tree: http://git-wip-us.apache.org/repos/asf/kudu/tree/060d7b0f
Diff: http://git-wip-us.apache.org/repos/asf/kudu/diff/060d7b0f

Branch: refs/heads/master
Commit: 060d7b0f59b287c18c0690a7795ae225a1f534ee
Parents: cf6927c
Author: Will Berkeley <wdberkeley@gmail.org>
Authored: Fri Aug 31 17:06:54 2018 -0700
Committer: Will Berkeley <wdberkeley@gmail.com>
Committed: Tue Sep 4 18:23:11 2018 +0000

----------------------------------------------------------------------
 src/kudu/tablet/tablet.cc              |  8 +++++++-
 src/kudu/tserver/tablet_server-test.cc | 19 +++++++++++++++++++
 2 files changed, 26 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/kudu/blob/060d7b0f/src/kudu/tablet/tablet.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tablet/tablet.cc b/src/kudu/tablet/tablet.cc
index f3a5143..7a44b91 100644
--- a/src/kudu/tablet/tablet.cc
+++ b/src/kudu/tablet/tablet.cc
@@ -170,6 +170,9 @@ METRIC_DEFINE_gauge_size(tablet, memrowset_size, "MemRowSet Memory Usage",
 METRIC_DEFINE_gauge_size(tablet, on_disk_data_size, "Tablet Data Size On Disk",
                          kudu::MetricUnit::kBytes,
                          "Space used by this tablet's data blocks.");
+METRIC_DEFINE_gauge_size(tablet, num_rowsets_on_disk, "Tablet Number of Rowsets on Disk",
+                         kudu::MetricUnit::kUnits,
+                         "Number of diskrowsets in this tablet");
 
 using kudu::MaintenanceManager;
 using kudu::clock::HybridClock;
@@ -236,6 +239,9 @@ Tablet::Tablet(scoped_refptr<TabletMetadata> metadata,
     METRIC_on_disk_data_size.InstantiateFunctionGauge(
       metric_entity_, Bind(&Tablet::OnDiskDataSize, Unretained(this)))
       ->AutoDetach(&metric_detacher_);
+    METRIC_num_rowsets_on_disk.InstantiateFunctionGauge(
+      metric_entity_, Bind(&Tablet::num_rowsets, Unretained(this)))
+      ->AutoDetach(&metric_detacher_);
   }
 
   if (FLAGS_tablet_throttler_rpc_per_sec > 0 || FLAGS_tablet_throttler_bytes_per_sec >
0) {
@@ -2250,7 +2256,7 @@ int64_t Tablet::CountRedoDeltasForTests() const {
 
 size_t Tablet::num_rowsets() const {
   shared_lock<rw_spinlock> l(component_lock_);
-  return components_->rowsets->all_rowsets().size();
+  return components_ ? components_->rowsets->all_rowsets().size() : 0;
 }
 
 void Tablet::PrintRSLayout(ostream* o) {

http://git-wip-us.apache.org/repos/asf/kudu/blob/060d7b0f/src/kudu/tserver/tablet_server-test.cc
----------------------------------------------------------------------
diff --git a/src/kudu/tserver/tablet_server-test.cc b/src/kudu/tserver/tablet_server-test.cc
index 671949f..084da03 100644
--- a/src/kudu/tserver/tablet_server-test.cc
+++ b/src/kudu/tserver/tablet_server-test.cc
@@ -169,6 +169,7 @@ METRIC_DECLARE_gauge_uint64(log_block_manager_containers);
 METRIC_DECLARE_counter(log_block_manager_holes_punched);
 METRIC_DECLARE_gauge_size(active_scanners);
 METRIC_DECLARE_gauge_size(tablet_active_scanners);
+METRIC_DECLARE_gauge_size(num_rowsets_on_disk);
 
 namespace kudu {
 
@@ -3323,6 +3324,24 @@ TEST_F(TabletServerTest, TestNoMetricsForTombstonedTablet) {
   }
 }
 
+TEST_F(TabletServerTest, TestTabletNumberOfDiskRowSetsMetric) {
+  scoped_refptr<TabletReplica> tablet;
+  ASSERT_TRUE(mini_server_->server()->tablet_manager()->LookupTablet(kTabletId,
&tablet));
+  ASSERT_TRUE(tablet->tablet()->GetMetricEntity());
+
+  // We don't care what the function is, since the metric is already instantiated.
+  auto num_diskrowsets = METRIC_num_rowsets_on_disk.InstantiateFunctionGauge(
+      tablet->tablet()->GetMetricEntity(), Callback<size_t(void)>());
+
+  // No data, no diskrowsets.
+  ASSERT_EQ(0, num_diskrowsets->value());
+
+  // Insert a row and flush. There should be 1 diskrowset.
+  ASSERT_NO_FATAL_FAILURE(InsertTestRowsRemote(0, 1, 1));
+  ASSERT_OK(tablet->tablet()->Flush());
+  ASSERT_EQ(1, num_diskrowsets->value());
+}
+
 // Test ensuring that when rowset min/max keys are stored with and read from
 // the rowset metadata, the tablet server doesn't read any blocks when
 // bootstrapping.


Mime
View raw message