Skip to content

Commit

Permalink
add kv stats
Browse files Browse the repository at this point in the history
rebase on upstream/master

address @darionyaphet's comments
  • Loading branch information
critical27 committed Oct 12, 2019
1 parent 6a1d432 commit 58c63b0
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 22 deletions.
10 changes: 0 additions & 10 deletions src/storage/BaseProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,6 @@ class BaseProcessor {
}
}

void pushResultCode(cpp2::ErrorCode code, PartitionID partId, HostAddr leader) {
if (code != cpp2::ErrorCode::SUCCEEDED) {
cpp2::ResultCode thriftRet;
thriftRet.set_code(code);
thriftRet.set_part_id(partId);
thriftRet.set_leader(toThriftHost(leader));
result_.failed_codes.emplace_back(std::move(thriftRet));
}
}

nebula::cpp2::HostAddr toThriftHost(const HostAddr& host) {
nebula::cpp2::HostAddr tHost;
tHost.set_ip(host.first);
Expand Down
12 changes: 8 additions & 4 deletions src/storage/GetProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@ class GetProcessor : public BaseProcessor<cpp2::GeneralResponse> {
public:
static GetProcessor* instance(kvstore::KVStore* kvstore,
meta::SchemaManager* schemaMan,
StorageStats* stats,
folly::Executor* executor) {
return new GetProcessor(kvstore, schemaMan, executor);
return new GetProcessor(kvstore, schemaMan, stats, executor);
}

void process(const cpp2::GetRequest& req);

protected:
explicit GetProcessor(kvstore::KVStore* kvstore, meta::SchemaManager* schemaMan,
folly::Executor* executor = nullptr)
: BaseProcessor<cpp2::GeneralResponse>(kvstore, schemaMan), executor_(executor) {}
explicit GetProcessor(kvstore::KVStore* kvstore,
meta::SchemaManager* schemaMan,
StorageStats* stats,
folly::Executor* executor = nullptr):
BaseProcessor<cpp2::GeneralResponse>(kvstore, schemaMan, stats),
executor_(executor) {}

private:
folly::Future<std::pair<PartitionID, kvstore::ResultCode>>
Expand Down
11 changes: 7 additions & 4 deletions src/storage/PutProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,18 @@ namespace storage {
class PutProcessor : public BaseProcessor<cpp2::ExecResponse> {
public:
static PutProcessor* instance(kvstore::KVStore* kvstore,
meta::SchemaManager* schemaMan) {
return new PutProcessor(kvstore, schemaMan);
meta::SchemaManager* schemaMan,
StorageStats* stats) {
return new PutProcessor(kvstore, schemaMan, stats);
}

void process(const cpp2::PutRequest& req);

private:
explicit PutProcessor(kvstore::KVStore* kvstore, meta::SchemaManager* schemaMan)
: BaseProcessor<cpp2::ExecResponse>(kvstore, schemaMan) {}
explicit PutProcessor(kvstore::KVStore* kvstore,
meta::SchemaManager* schemaMan,
StorageStats* stats)
: BaseProcessor<cpp2::ExecResponse>(kvstore, schemaMan, stats) {}
};

} // namespace storage
Expand Down
7 changes: 5 additions & 2 deletions src/storage/StorageServiceHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,13 +149,16 @@ StorageServiceHandler::future_getLeaderPart(const cpp2::GetLeaderReq& req) {

folly::Future<cpp2::ExecResponse>
StorageServiceHandler::future_put(const cpp2::PutRequest& req) {
auto* processor = PutProcessor::instance(kvstore_, schemaMan_);
auto* processor = PutProcessor::instance(kvstore_, schemaMan_, &putKvQpsStat_);
RETURN_FUTURE(processor);
}

folly::Future<cpp2::GeneralResponse>
StorageServiceHandler::future_get(const cpp2::GetRequest& req) {
auto* processor = GetProcessor::instance(kvstore_, schemaMan_, getThreadManager());
auto* processor = GetProcessor::instance(kvstore_,
schemaMan_,
&getKvQpsStat_,
getThreadManager());
RETURN_FUTURE(processor);
}

Expand Down
4 changes: 4 additions & 0 deletions src/storage/StorageServiceHandler.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ class StorageServiceHandler final : public cpp2::StorageServiceSvIf {
delVertexQpsStat_ = StorageStats("del_vertex");
updateVertexQpsStat_ = StorageStats("update_vertex");
updateEdgeQpsStat_ = StorageStats("update_edge");
getKvQpsStat_ = StorageStats("get_kv");
putKvQpsStat_ = StorageStats("put_kv");
}

folly::Future<cpp2::QueryResponse>
Expand Down Expand Up @@ -117,6 +119,8 @@ class StorageServiceHandler final : public cpp2::StorageServiceSvIf {
StorageStats delVertexQpsStat_;
StorageStats updateVertexQpsStat_;
StorageStats updateEdgeQpsStat_;
StorageStats getKvQpsStat_;
StorageStats putKvQpsStat_;
};

} // namespace storage
Expand Down
4 changes: 2 additions & 2 deletions src/tools/storage-perf/StorageIntegrityTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ class IntegrityTest {
tag.set_props(writer.encode());
tags.emplace_back(std::move(tag));

v.set_tags(tags);
v.set_tags(std::move(tags));
vertices.emplace_back(std::move(v));
VLOG(2) << "Build " << cur[i] << " -> " << prev[i];
PLOG_EVERY_N(INFO, 10000) << "We have inserted " << vId - firstVertexId_ - width_
Expand All @@ -218,7 +218,7 @@ class IntegrityTest {
auto resp = std::move(future).get();
if (!resp.succeeded()) {
LOG(ERROR) << "Failed to fetch props of vertex " << nextId;
break;
return false;
}
auto& results = resp.responses();
// get tag schema
Expand Down

0 comments on commit 58c63b0

Please sign in to comment.