Skip to content

Commit

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

Expand All @@ -64,9 +66,11 @@ void KVClientManager::Uninit() {
void KVClientManager::Set(std::shared_ptr<SetKVCacheTask> task) {
threadPool_.Enqueue([task, this]() {
std::string error_log;
setQueueSize_ << 1
task->res =
client_->Set(task->key, task->value, task->length, &error_log);
if (task->res) {
setQueueSize_ << -1;
kvClientManagerMetric_->count << 1;
}
OnReturn(&kvClientManagerMetric_->set, task);
Expand Down Expand Up @@ -99,9 +103,13 @@ void KVClientManager::Get(std::shared_ptr<GetKVCacheTask> task) {
threadPool_.Enqueue([task, this]() {
std::string error_log;
memcached_return_t retCode;
getQueueSize_ << 1;
task->res = client_->Get(task->key, task->value, task->offset,
task->valueLength, &error_log, &task->length,
&retCode);
if (task->res) {
getQueueSize_ << -1;
}
UpdateHitMissMetric(retCode, kvClientManagerMetric_.get());
OnReturn(&kvClientManagerMetric_->get, task);
});
Expand Down
3 changes: 3 additions & 0 deletions curvefs/src/client/kvclient/kvclient_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "curvefs/src/client/metric/client_metric.h"
#include "src/common/concurrent/task_thread_pool.h"
#include "src/common/s3_adapter.h"
#include "bvar/bvar.h"

using curvefs::client::metric::KVClientManagerMetric;

Expand Down Expand Up @@ -160,6 +161,8 @@ class KVClientManager {
TaskThreadPool<bthread::Mutex, bthread::ConditionVariable> threadPool_;
std::shared_ptr<KVClient> client_;
std::unique_ptr<KVClientManagerMetric> kvClientManagerMetric_;
bvar::Adder<int64_t> getQueueSize_;
bvar::Adder<int64_t> setQueueSize_;
};

} // namespace client
Expand Down

0 comments on commit 0b9a4d3

Please sign in to comment.