Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

remove some useless code #3341

Merged
merged 4 commits into from
Nov 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 0 additions & 58 deletions src/meta/processors/job/BalanceJobExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -755,64 +755,6 @@ ErrorOr<nebula::cpp2::ErrorCode, HostAddr> DataBalanceJobExecutor::hostWithMinim
return nebula::cpp2::ErrorCode::E_NO_HOSTS;
}

nebula::cpp2::ErrorCode BalanceJobExecutor::collectZoneParts(const std::string& groupName,
HostParts& hostParts) {
auto groupKey = MetaKeyUtils::groupKey(groupName);
std::string groupValue;
auto retCode = kvstore_->get(kDefaultSpaceId, kDefaultPartId, groupKey, &groupValue);
if (retCode != nebula::cpp2::ErrorCode::SUCCEEDED) {
LOG(ERROR) << "Get group " << groupName
<< " failed, error: " << apache::thrift::util::enumNameSafe(retCode);
return retCode;
}

// zoneHosts use to record this host belong to zone's hosts
std::unordered_map<std::pair<HostAddr, std::string>, std::vector<HostAddr>> zoneHosts;
auto zoneNames = MetaKeyUtils::parseZoneNames(std::move(groupValue));
for (auto zoneName : zoneNames) {
auto zoneKey = MetaKeyUtils::zoneKey(zoneName);
std::string zoneValue;
retCode = kvstore_->get(kDefaultSpaceId, kDefaultPartId, zoneKey, &zoneValue);
if (retCode != nebula::cpp2::ErrorCode::SUCCEEDED) {
LOG(ERROR) << "Get zone " << zoneName
<< " failed, error: " << apache::thrift::util::enumNameSafe(retCode);
return retCode;
}

auto hosts = MetaKeyUtils::parseZoneHosts(std::move(zoneValue));
for (const auto& host : hosts) {
auto pair = std::pair<HostAddr, std::string>(std::move(host), zoneName);
auto& hs = zoneHosts[std::move(pair)];
hs.insert(hs.end(), hosts.begin(), hosts.end());
}
}

for (auto it = hostParts.begin(); it != hostParts.end(); it++) {
auto host = it->first;
auto zoneIter =
std::find_if(zoneHosts.begin(), zoneHosts.end(), [host](const auto& pair) -> bool {
return host == pair.first.first;
});

if (zoneIter == zoneHosts.end()) {
LOG(INFO) << it->first << " have lost";
continue;
}

auto& hosts = zoneIter->second;
auto name = zoneIter->first.second;
for (auto hostIter = hosts.begin(); hostIter != hosts.end(); hostIter++) {
auto partIter = hostParts.find(*hostIter);
if (partIter == hostParts.end()) {
zoneParts_[it->first] = ZoneNameAndParts(name, std::vector<PartitionID>());
} else {
zoneParts_[it->first] = ZoneNameAndParts(name, partIter->second);
}
}
}
return nebula::cpp2::ErrorCode::SUCCEEDED;
}

bool DataBalanceJobExecutor::checkZoneLegal(const HostAddr& source, const HostAddr& target) {
VLOG(3) << "Check " << source << " : " << target;
auto sourceIter = std::find_if(zoneParts_.begin(), zoneParts_.end(), [&source](const auto& pair) {
Expand Down
2 changes: 0 additions & 2 deletions src/meta/processors/job/BalanceJobExecutor.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,6 @@ class BalanceJobExecutor : public MetaJobExecutor {

nebula::cpp2::ErrorCode assembleZoneParts(const std::string& groupName, HostParts& hostParts);

nebula::cpp2::ErrorCode collectZoneParts(const std::string& groupName, HostParts& hostParts);

nebula::cpp2::ErrorCode save(const std::string& k, const std::string& v);

protected:
Expand Down