This is an automated email from the ASF dual-hosted git repository.
awong pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/kudu.git
The following commit(s) were added to refs/heads/master by this push:
new 541e7c9 util: remove test-only metrics from header
541e7c9 is described below
commit 541e7c9a377f349f0a2228c0e098555b8bc9207a
Author: Andrew Wong <[email protected]>
AuthorDate: Tue Dec 17 15:56:52 2019 -0800
util: remove test-only metrics from header
It's easy for these metrics to accidentally be included in any
metrics-collection that is based off of the Kudu binaries, so I moved
them into the test file in which they're used.
Change-Id: Ie945c503c2821c873c1cff30eb0b04b3c2e03ba0
Reviewed-on: http://gerrit.cloudera.org:8080/14919
Reviewed-by: Adar Dembo <[email protected]>
Reviewed-by: Alexey Serbin <[email protected]>
Tested-by: Kudu Jenkins
---
src/kudu/util/CMakeLists.txt | 1 -
src/kudu/util/ttl_cache-test.cc | 75 ++++++++++++++++++++++++-----
src/kudu/util/ttl_cache_test_metrics.cc | 83 ---------------------------------
src/kudu/util/ttl_cache_test_metrics.h | 31 ------------
4 files changed, 64 insertions(+), 126 deletions(-)
diff --git a/src/kudu/util/CMakeLists.txt b/src/kudu/util/CMakeLists.txt
index 70a0bce..737d806 100644
--- a/src/kudu/util/CMakeLists.txt
+++ b/src/kudu/util/CMakeLists.txt
@@ -227,7 +227,6 @@ set(UTIL_SRCS
throttler.cc
trace.cc
trace_metrics.cc
- ttl_cache_test_metrics.cc
user.cc
url-coding.cc
version_info.cc
diff --git a/src/kudu/util/ttl_cache-test.cc b/src/kudu/util/ttl_cache-test.cc
index 821a066..bdd35b3 100644
--- a/src/kudu/util/ttl_cache-test.cc
+++ b/src/kudu/util/ttl_cache-test.cc
@@ -17,7 +17,6 @@
#include "kudu/util/ttl_cache.h"
-#include <algorithm>
#include <atomic>
#include <cstddef>
#include <cstdint>
@@ -26,6 +25,7 @@
#include <set>
#include <string>
#include <thread>
+#include <utility>
#include <vector>
#include <gflags/gflags_declare.h>
@@ -44,20 +44,10 @@
#include "kudu/util/test_macros.h"
#include "kudu/util/test_util.h"
#include "kudu/util/ttl_cache_metrics.h"
-#include "kudu/util/ttl_cache_test_metrics.h"
DECLARE_bool(cache_force_single_shard);
DECLARE_double(cache_memtracker_approximation_ratio);
-METRIC_DECLARE_counter(test_ttl_cache_evictions);
-METRIC_DECLARE_counter(test_ttl_cache_evictions_expired);
-METRIC_DECLARE_counter(test_ttl_cache_hits);
-METRIC_DECLARE_counter(test_ttl_cache_hits_expired);
-METRIC_DECLARE_counter(test_ttl_cache_inserts);
-METRIC_DECLARE_counter(test_ttl_cache_lookups);
-METRIC_DECLARE_counter(test_ttl_cache_misses);
-METRIC_DECLARE_gauge_uint64(test_ttl_cache_memory_usage);
-
using std::atomic;
using std::set;
using std::string;
@@ -68,6 +58,69 @@ using strings::Substitute;
namespace kudu {
+struct TTLCacheTestMetrics : public TTLCacheMetrics {
+ explicit TTLCacheTestMetrics(const scoped_refptr<MetricEntity>& entity);
+};
+
+METRIC_DEFINE_counter(server, test_ttl_cache_inserts,
+ "TTL Cache Inserts",
+ kudu::MetricUnit::kEntries,
+ "Number of entries inserted in the cache",
+ kudu::MetricLevel::kInfo);
+METRIC_DEFINE_counter(server, test_ttl_cache_lookups,
+ "TTL Cache Lookups",
+ kudu::MetricUnit::kEntries,
+ "Number of entries looked up from the cache",
+ kudu::MetricLevel::kInfo);
+METRIC_DEFINE_counter(server, test_ttl_cache_evictions,
+ "TTL Cache Evictions",
+ kudu::MetricUnit::kEntries,
+ "Number of entries evicted from the cache",
+ kudu::MetricLevel::kInfo);
+METRIC_DEFINE_counter(server, test_ttl_cache_evictions_expired,
+ "TTL Cache Evictions of Expired Entries",
+ kudu::MetricUnit::kEntries,
+ "Number of entries that had already expired upon "
+ "eviction from the cache",
+ kudu::MetricLevel::kInfo);
+METRIC_DEFINE_counter(server, test_ttl_cache_misses,
+ "TTL Cache Misses",
+ kudu::MetricUnit::kEntries,
+ "Number of lookups that didn't find a cached entry",
+ kudu::MetricLevel::kInfo);
+METRIC_DEFINE_counter(server, test_ttl_cache_hits,
+ "TTL Cache Hits",
+ kudu::MetricUnit::kEntries,
+ "Number of lookups that found a cached entry",
+ kudu::MetricLevel::kInfo);
+METRIC_DEFINE_counter(server, test_ttl_cache_hits_expired,
+ "TTL Cache Hits of Expired Entries",
+ kudu::MetricUnit::kEntries,
+ "Number of lookups that found an entry, but the entry "
+ "had already expired at the time of lookup",
+ kudu::MetricLevel::kInfo);
+METRIC_DEFINE_gauge_uint64(server, test_ttl_cache_memory_usage,
+ "TTL Cache Memory Usage",
+ kudu::MetricUnit::kBytes,
+ "Memory consumed by the cache",
+ kudu::MetricLevel::kInfo);
+
+#define MINIT(member, x) member = METRIC_##x.Instantiate(entity)
+#define GINIT(member, x) member = METRIC_##x.Instantiate(entity, 0)
+TTLCacheTestMetrics::TTLCacheTestMetrics(
+ const scoped_refptr<MetricEntity>& entity) {
+ MINIT(inserts, test_ttl_cache_inserts);
+ MINIT(lookups, test_ttl_cache_lookups);
+ MINIT(evictions, test_ttl_cache_evictions);
+ MINIT(evictions_expired, test_ttl_cache_evictions_expired);
+ MINIT(cache_hits_caching, test_ttl_cache_hits);
+ MINIT(cache_hits_expired, test_ttl_cache_hits_expired);
+ MINIT(cache_misses_caching, test_ttl_cache_misses);
+ GINIT(cache_usage, test_ttl_cache_memory_usage);
+}
+#undef MINIT
+#undef GINIT
+
// A class to represent values with constant memory footprint of 1.
class TestValue {
public:
diff --git a/src/kudu/util/ttl_cache_test_metrics.cc
b/src/kudu/util/ttl_cache_test_metrics.cc
deleted file mode 100644
index 1bb0e5f..0000000
--- a/src/kudu/util/ttl_cache_test_metrics.cc
+++ /dev/null
@@ -1,83 +0,0 @@
-// 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.
-
-#include "kudu/util/ttl_cache_test_metrics.h"
-
-#include "kudu/util/metrics.h"
-
-METRIC_DEFINE_counter(server, test_ttl_cache_inserts,
- "TTL Cache Inserts",
- kudu::MetricUnit::kEntries,
- "Number of entries inserted in the cache",
- kudu::MetricLevel::kInfo);
-METRIC_DEFINE_counter(server, test_ttl_cache_lookups,
- "TTL Cache Lookups",
- kudu::MetricUnit::kEntries,
- "Number of entries looked up from the cache",
- kudu::MetricLevel::kInfo);
-METRIC_DEFINE_counter(server, test_ttl_cache_evictions,
- "TTL Cache Evictions",
- kudu::MetricUnit::kEntries,
- "Number of entries evicted from the cache",
- kudu::MetricLevel::kInfo);
-METRIC_DEFINE_counter(server, test_ttl_cache_evictions_expired,
- "TTL Cache Evictions of Expired Entries",
- kudu::MetricUnit::kEntries,
- "Number of entries that had already expired upon "
- "eviction from the cache",
- kudu::MetricLevel::kInfo);
-METRIC_DEFINE_counter(server, test_ttl_cache_misses,
- "TTL Cache Misses",
- kudu::MetricUnit::kEntries,
- "Number of lookups that didn't find a cached entry",
- kudu::MetricLevel::kInfo);
-METRIC_DEFINE_counter(server, test_ttl_cache_hits,
- "TTL Cache Hits",
- kudu::MetricUnit::kEntries,
- "Number of lookups that found a cached entry",
- kudu::MetricLevel::kInfo);
-METRIC_DEFINE_counter(server, test_ttl_cache_hits_expired,
- "TTL Cache Hits of Expired Entries",
- kudu::MetricUnit::kEntries,
- "Number of lookups that found an entry, but the entry "
- "had already expired at the time of lookup",
- kudu::MetricLevel::kInfo);
-METRIC_DEFINE_gauge_uint64(server, test_ttl_cache_memory_usage,
- "TTL Cache Memory Usage",
- kudu::MetricUnit::kBytes,
- "Memory consumed by the cache",
- kudu::MetricLevel::kInfo);
-
-namespace kudu {
-
-#define MINIT(member, x) member = METRIC_##x.Instantiate(entity)
-#define GINIT(member, x) member = METRIC_##x.Instantiate(entity, 0)
-TTLCacheTestMetrics::TTLCacheTestMetrics(
- const scoped_refptr<MetricEntity>& entity) {
- MINIT(inserts, test_ttl_cache_inserts);
- MINIT(lookups, test_ttl_cache_lookups);
- MINIT(evictions, test_ttl_cache_evictions);
- MINIT(evictions_expired, test_ttl_cache_evictions_expired);
- MINIT(cache_hits_caching, test_ttl_cache_hits);
- MINIT(cache_hits_expired, test_ttl_cache_hits_expired);
- MINIT(cache_misses_caching, test_ttl_cache_misses);
- GINIT(cache_usage, test_ttl_cache_memory_usage);
-}
-#undef MINIT
-#undef GINIT
-
-} // namespace kudu
diff --git a/src/kudu/util/ttl_cache_test_metrics.h
b/src/kudu/util/ttl_cache_test_metrics.h
deleted file mode 100644
index 5889639..0000000
--- a/src/kudu/util/ttl_cache_test_metrics.h
+++ /dev/null
@@ -1,31 +0,0 @@
-// 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.
-
-#pragma once
-
-#include "kudu/gutil/ref_counted.h"
-#include "kudu/util/ttl_cache_metrics.h"
-
-namespace kudu {
-
-class MetricEntity;
-
-struct TTLCacheTestMetrics : public TTLCacheMetrics {
- explicit TTLCacheTestMetrics(const scoped_refptr<MetricEntity>& entity);
-};
-
-} // namespace kudu