Skip to content

Commit

Permalink
fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Nivras committed Dec 1, 2021
1 parent bdccbf7 commit ca00e75
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/clients/meta/MetaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2415,7 +2415,7 @@ folly::Future<StatusOr<bool>> MetaClient::heartbeat() {
req.set_leader_partIds(std::move(leaderIds));
}

kvstore::DiskParts diskParts;
kvstore::SpaceDiskPartsMap diskParts;
if (listener_ != nullptr) {
listener_->fetchDiskParts(diskParts);
if (diskParts_ != diskParts) {
Expand Down
5 changes: 3 additions & 2 deletions src/clients/meta/MetaClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ class MetaChangedListener {
virtual void onPartUpdated(const PartHosts& partHosts) = 0;
virtual void fetchLeaderInfo(
std::unordered_map<GraphSpaceID, std::vector<cpp2::LeaderInfo>>& leaders) = 0;
virtual void fetchDiskParts(kvstore::DiskParts& diskParts) = 0;
virtual void fetchDiskParts(kvstore::SpaceDiskPartsMap& diskParts) = 0;
virtual void onListenerAdded(GraphSpaceID spaceId,
PartitionID partId,
const ListenerHosts& listenerHosts) = 0;
Expand Down Expand Up @@ -732,11 +732,12 @@ class MetaClient {
std::shared_ptr<folly::IOThreadPoolExecutor> ioThreadPool_;
std::shared_ptr<thrift::ThriftClientManager<cpp2::MetaServiceAsyncClient>> clientsMan_;

// heartbeat is a single thread, maybe leaderIdsLock_ and diskPartsLock_ is unuseful?
// leaderIdsLock_ is used to protect leaderIds_
std::unordered_map<GraphSpaceID, std::vector<cpp2::LeaderInfo>> leaderIds_;
folly::RWSpinLock leaderIdsLock_;
// diskPartsLock_ is used to protect diskParts_;
kvstore::DiskParts diskParts_;
kvstore::SpaceDiskPartsMap diskParts_;
folly::RWSpinLock diskPartsLock_;

std::atomic<int64_t> localDataLastUpdateTime_{-1};
Expand Down
2 changes: 1 addition & 1 deletion src/kvstore/DiskManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ void DiskManager::removePartFromPath(GraphSpaceID spaceId,
}
}

void DiskManager::getDiskParts(DiskParts& diskParts) {
void DiskManager::getDiskParts(SpaceDiskPartsMap& diskParts) {
std::lock_guard<std::mutex> lg(lock_);
for (const auto& [space, partDiskMap] : partPath_) {
std::unordered_map<std::string, meta::cpp2::PartitionList> tmpPartPaths;
Expand Down
4 changes: 2 additions & 2 deletions src/kvstore/DiskManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ namespace nebula {
namespace kvstore {

using PartDiskMap = std::unordered_map<std::string, std::set<PartitionID>>;
using DiskParts =
using SpaceDiskPartsMap =
std::unordered_map<GraphSpaceID, std::unordered_map<std::string, meta::cpp2::PartitionList>>;

class DiskManager {
Expand Down Expand Up @@ -56,7 +56,7 @@ class DiskManager {
StatusOr<PartDiskMap> partDist(GraphSpaceID spaceId);

// Get all space data path and all partition in the path
void getDiskParts(DiskParts& diskParts);
void getDiskParts(SpaceDiskPartsMap& diskParts);

private:
// refresh free bytes of data path periodically
Expand Down
4 changes: 3 additions & 1 deletion src/kvstore/NebulaStore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,9 @@ void NebulaStore::checkRemoteListeners(GraphSpaceID spaceId,
}
}

void NebulaStore::fetchDiskParts(DiskParts& diskParts) { diskMan_->getDiskParts(diskParts); }
void NebulaStore::fetchDiskParts(SpaceDiskPartsMap& diskParts) {
diskMan_->getDiskParts(diskParts);
}

void NebulaStore::updateSpaceOption(GraphSpaceID spaceId,
const std::unordered_map<std::string, std::string>& options,
Expand Down
2 changes: 1 addition & 1 deletion src/kvstore/NebulaStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,7 @@ class NebulaStore : public KVStore, public Handler {
PartitionID partId,
const std::vector<HostAddr>& remoteListeners) override;

void fetchDiskParts(DiskParts& diskParts) override;
void fetchDiskParts(SpaceDiskPartsMap& diskParts) override;

nebula::cpp2::ErrorCode multiPutWithoutReplicator(GraphSpaceID spaceId,
std::vector<KV> keyValues) override;
Expand Down
2 changes: 1 addition & 1 deletion src/kvstore/PartManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ void MetaServerBasedPartManager::fetchLeaderInfo(
}
}

void MetaServerBasedPartManager::fetchDiskParts(DiskParts& diskParts) {
void MetaServerBasedPartManager::fetchDiskParts(SpaceDiskPartsMap& diskParts) {
if (handler_ != nullptr) {
handler_->fetchDiskParts(diskParts);
} else {
Expand Down
11 changes: 6 additions & 5 deletions src/kvstore/PartManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ class Handler {

virtual void removePart(GraphSpaceID spaceId, PartitionID partId) = 0;

virtual int32_t allLeader(
std::unordered_map<GraphSpaceID, std::vector<meta::cpp2::LeaderInfo>>& leaderIds) = 0;

virtual void addListener(GraphSpaceID spaceId,
PartitionID partId,
meta::cpp2::ListenerType type,
Expand All @@ -51,7 +48,11 @@ class Handler {
PartitionID partId,
const std::vector<HostAddr>& remoteListeners) = 0;

virtual void fetchDiskParts(DiskParts& diskParts) = 0;
// get infos from handler(nebula store) to listener(meta_client -> meta)
virtual int32_t allLeader(
std::unordered_map<GraphSpaceID, std::vector<meta::cpp2::LeaderInfo>>& leaderIds) = 0;

virtual void fetchDiskParts(SpaceDiskPartsMap& diskParts) = 0;
};

/**
Expand Down Expand Up @@ -213,7 +214,7 @@ class MetaServerBasedPartManager : public PartManager, public meta::MetaChangedL
void fetchLeaderInfo(
std::unordered_map<GraphSpaceID, std::vector<meta::cpp2::LeaderInfo>>& leaderParts) override;

void fetchDiskParts(DiskParts& diskParts) override;
void fetchDiskParts(SpaceDiskPartsMap& diskParts) override;

void onListenerAdded(GraphSpaceID spaceId,
PartitionID partId,
Expand Down
1 change: 1 addition & 0 deletions src/meta/processors/admin/HBProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ void HBProcessor::process(const cpp2::HBReq& req) {
std::string key = MetaKeyUtils::diskPartsKey(host, spaceId, path);
std::vector<kvstore::KV> data;
data.emplace_back(key, partListVal);
// doPut() not work, will trigger the asan: use heap memory which is free
folly::Baton<true, std::atomic> baton;
kvstore_->asyncMultiPut(kDefaultSpaceId,
kDefaultPartId,
Expand Down
2 changes: 1 addition & 1 deletion src/meta/test/MetaClientTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1544,7 +1544,7 @@ class TestListener : public MetaChangedListener {
UNUSED(remoteListeners);
}

void fetchDiskParts(kvstore::DiskParts& diskParts) override {
void fetchDiskParts(kvstore::SpaceDiskPartsMap& diskParts) override {
UNUSED(diskParts);
LOG(INFO) << "Fetch Disk Paths";
}
Expand Down

0 comments on commit ca00e75

Please sign in to comment.