Skip to content

Commit

Permalink
3
Browse files Browse the repository at this point in the history
  • Loading branch information
shuaihehe committed Dec 1, 2023
1 parent 41b912b commit 2b11e41
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
17 changes: 5 additions & 12 deletions curvefs/src/client/kvclient/kvclient_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ bool KVClientManager::Init(const KVClientManagerOpt& config,
const std::string& fsName) {
client_ = kvclient;
kvClientManagerMetric_ = absl::make_unique<KVClientManagerMetric>(fsName);
brpc::StartDummyServerAt(9000);
getQueueSize_.expose("getQueueSize_");
setQueueSize_.expose("setQueueSize_");
getQueueSize_.reset();
setQueueSize_.reset();
return threadPool_.Start(config.setThreadPooln) == 0;
}

Expand All @@ -69,11 +64,11 @@ void KVClientManager::Uninit() {
void KVClientManager::Set(std::shared_ptr<SetKVCacheTask> task) {
threadPool_.Enqueue([task, this]() {
std::string error_log;
setQueueSize_ << 1;
kvClientManagerMetric_->setQueueSize << 1;
task->res =
client_->Set(task->key, task->value, task->length, &error_log);
if (task->res) {
setQueueSize_ << -1;
kvClientManagerMetric_->setQueueSize << -1;
if (task->res) {
kvClientManagerMetric_->count << 1;
}
OnReturn(&kvClientManagerMetric_->set, task);
Expand Down Expand Up @@ -106,13 +101,11 @@ void KVClientManager::Get(std::shared_ptr<GetKVCacheTask> task) {
threadPool_.Enqueue([task, this]() {
std::string error_log;
memcached_return_t retCode;
getQueueSize_ << 1;
kvClientManagerMetric_->getQueueSize << 1;
task->res = client_->Get(task->key, task->value, task->offset,
task->valueLength, &error_log, &task->length,
&retCode);
if (task->res) {
getQueueSize_ << -1;
}
kvClientManagerMetric_->getQueueSize << -1;
UpdateHitMissMetric(retCode, kvClientManagerMetric_.get());
OnReturn(&kvClientManagerMetric_->get, task);
});
Expand Down
8 changes: 7 additions & 1 deletion curvefs/src/client/metric/client_metric.h
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,10 @@ struct KVClientManagerMetric {
bvar::Adder<uint64_t> hit;
// kvcache miss
bvar::Adder<uint64_t> miss;
// kvcache getQueueSize
bvar::Adder<uint64_t> getQueueSize;
// kvcache setQueueSize
bvar::Adder<uint64_t> setQueueSize;

explicit KVClientManagerMetric(const std::string& name = "")
: fsName(!name.empty() ? name
Expand All @@ -325,7 +329,9 @@ struct KVClientManagerMetric {
set(prefix, fsName + "_set"),
count(prefix, fsName + "_count"),
hit(prefix, fsName + "_hit"),
miss(prefix, fsName + "_miss") {}
miss(prefix, fsName + "_miss"),
getQueueSize(prefix, fsName + "_getQueueSize"),
setQueueSize(prefix, fsName + "_setQueueSize") {}
};

struct MemcacheClientMetric {
Expand Down

0 comments on commit 2b11e41

Please sign in to comment.