From 29690a338ba4482d187e6036903e138437ae3bb4 Mon Sep 17 00:00:00 2001 From: Yin Congmin Date: Fri, 31 Jul 2020 02:15:24 -0400 Subject: [PATCH] tools: add throttle mechanism to immutable object cache Signed-off-by: Yin Congmin --- .../dashboard/test_cluster_configuration.py | 2 +- src/common/options.cc | 41 +++++ src/common/options.h | 20 ++- src/librbd/cache/ParentCacheObjectDispatch.cc | 1 + src/mgr/PyUtil.cc | 1 + .../immutable_object_cache/MockCacheDaemon.h | 4 +- .../test_DomainSocket.cc | 4 +- .../immutable_object_cache/test_message.cc | 6 +- .../test_multi_session.cc | 2 +- .../test_object_store.cc | 10 +- .../test_mock_ParentCacheObjectDispatch.cc | 4 +- .../immutable_object_cache/CacheClient.cc | 7 +- .../immutable_object_cache/CacheClient.h | 2 +- .../immutable_object_cache/CacheController.cc | 5 +- .../ObjectCacheStore.cc | 165 +++++++++++++++++- .../immutable_object_cache/ObjectCacheStore.h | 24 ++- src/tools/immutable_object_cache/Types.cc | 28 ++- src/tools/immutable_object_cache/Types.h | 23 ++- 18 files changed, 298 insertions(+), 51 deletions(-) diff --git a/qa/tasks/mgr/dashboard/test_cluster_configuration.py b/qa/tasks/mgr/dashboard/test_cluster_configuration.py index dc96bced02a..9c8245d238d 100644 --- a/qa/tasks/mgr/dashboard/test_cluster_configuration.py +++ b/qa/tasks/mgr/dashboard/test_cluster_configuration.py @@ -369,7 +369,7 @@ class ClusterConfigurationTest(DashboardTestCase): self.assertIn('type', data) self.assertIn('desc', data) self.assertIn(data['type'], ['str', 'bool', 'float', 'int', 'size', 'uint', 'addr', - 'addrvec', 'uuid', 'secs']) + 'addrvec', 'uuid', 'secs', 'millisecs']) if 'value' in data: self.assertIn('source', data) diff --git a/src/common/options.cc b/src/common/options.cc index 806da4e1215..9127a061958 100644 --- a/src/common/options.cc +++ b/src/common/options.cc @@ -49,6 +49,9 @@ public: void operator()(const std::chrono::seconds v) const { out << v.count(); } + void operator()(const std::chrono::milliseconds v) const { + out << v.count(); + } }; } @@ -203,6 +206,13 @@ int Option::parse_value( *error_message = e.what(); return -EINVAL; } + } else if (type == Option::TYPE_MILLISECS) { + try { + *out = boost::lexical_cast(val); + } catch (const boost::bad_lexical_cast& e) { + *error_message = e.what(); + return -EINVAL; + } } else { ceph_abort(); } @@ -7878,6 +7888,37 @@ static std::vector