Skip to content

Commit

Permalink
remove deubg logs
Browse files Browse the repository at this point in the history
  • Loading branch information
jievince committed Dec 3, 2021
1 parent 6bfb7d3 commit 9491908
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 44 deletions.
1 change: 0 additions & 1 deletion include/nebula/sclient/StorageClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ class StorageClient {
RemoteFunc&& remoteFunc,
folly::Promise<std::pair<bool, Response>> pro);

private:
std::unique_ptr<MetaClient> mClient_;
std::shared_ptr<folly::IOThreadPoolExecutor> ioExecutor_;
std::shared_ptr<thrift::ThriftClientManager<storage::cpp2::GraphStorageServiceAsyncClient>>
Expand Down
29 changes: 4 additions & 25 deletions src/mclient/MetaClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,7 @@ MetaClient::MetaClient(const std::vector<std::string>& metaAddrs) {
std::make_shared<thrift::ThriftClientManager<meta::cpp2::MetaServiceAsyncClient>>(false);
bool b = loadData(); // load data into cache
if (!b) {
LOG(INFO) << "load data failed";
} else {
LOG(INFO) << "load data succecced";
LOG(INFO) << spaceIndexByName_.size();
LOG(INFO) << spaceEdgeIndexByName_.size();
LOG(INFO) << spacePartLeaderMap_.size();
LOG(INFO) << spacePartsMap_.size();
LOG(ERROR) << "load data failed";
}
}

Expand All @@ -54,22 +48,16 @@ std::pair<bool, EdgeType> MetaClient::getEdgeTypeByNameFromCache(GraphSpaceID sp
const std::string& name) {
auto it = spaceEdgeIndexByName_.find(std::make_pair(space, name));
if (it == spaceEdgeIndexByName_.end()) {
LOG(ERROR) << "Get edge type for " << name << " failed";
LOG(ERROR) << "getEdgeTypeByNameFromCache(" << space << ", " << name << ") failed";
return {false, -1};
}
return {true, it->second};
}

std::pair<bool, std::vector<PartitionID>> MetaClient::getPartsFromCache(GraphSpaceID spaceId) {
LOG(INFO) << "getPartsFromCache(" << spaceId << ")";
for (auto kv : spacePartsMap_) {
LOG(INFO) << kv.first << ", ";
for (auto partId : kv.second) {
LOG(INFO) << partId;
}
}
auto iter = spacePartsMap_.find(spaceId);
if (iter == spacePartsMap_.end()) {
LOG(ERROR) << "getPartsFromCache(" << spaceId << ") failed";
return {false, {}};
}

Expand All @@ -80,6 +68,7 @@ std::pair<bool, HostAddr> MetaClient::getPartLeaderFromCache(GraphSpaceID spaceI
PartitionID partId) {
auto iter = spacePartLeaderMap_.find({spaceId, partId});
if (iter == spacePartLeaderMap_.end()) {
LOG(ERROR) << "getPartLeaderFromCache(" << spaceId << ", " << partId << ") failed";
return {false, HostAddr()};
}

Expand Down Expand Up @@ -165,30 +154,20 @@ std::pair<bool, std::vector<meta::cpp2::EdgeItem>> MetaClient::listEdgeSchemas(

void MetaClient::loadLeader(const std::vector<meta::cpp2::HostItem>& hostItems,
const SpaceNameIdMap& spaceIndexByName) {
LOG(INFO) << "loadLeader start";
for (auto& item : hostItems) {
LOG(INFO) << "item.get_leader_parts().size()=" << item.get_leader_parts().size();
LOG(INFO) << "item.get_all_parts().size()=" << item.get_all_parts().size();
for (auto& spaceEntry : item.get_leader_parts()) {
auto spaceName = spaceEntry.first;
LOG(INFO) << "[" << spaceName << "]";
auto iter = spaceIndexByName.find(spaceName);
if (iter == spaceIndexByName.end()) {
LOG(INFO) << "dont' find " << spaceName;
continue;
}
auto spaceId = iter->second;
LOG(INFO) << "spaceId:" << spaceId;
LOG(INFO) << "spaceEntry.second.size()" << spaceEntry.second.size();
for (const auto& partId : spaceEntry.second) {
LOG(INFO) << "spaceId: " << spaceId << ", partId: " << partId
<< ", host: " << item.get_hostAddr();
spacePartLeaderMap_[{spaceId, partId}] = item.get_hostAddr();
spacePartsMap_[spaceId].emplace_back(partId);
}
}
}
LOG(INFO) << "loadLeader end";
}

std::vector<SpaceIdName> MetaClient::toSpaceIdName(
Expand Down
17 changes: 5 additions & 12 deletions src/sclient/ScanEdgeIter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,11 @@ DataSet ScanEdgeIter::next() {
return DataSet();
}
DCHECK(!!req_);
if (firstScan_) {
firstScan_ = false;
} else {
auto partCursorMapReq = req_->get_parts();
DCHECK_EQ(partCursorMapReq.size(), 1);
partCursorMapReq.begin()->second.set_has_next(true);
partCursorMapReq.begin()->second.set_next_cursor(nextCursor_);
LOG(INFO) << "nextCursor of req: " << partCursorMapReq.begin()->second.get_next_cursor();
req_->set_parts(partCursorMapReq);
}
auto partCursorMapReq = req_->get_parts();
DCHECK_EQ(partCursorMapReq.size(), 1);
partCursorMapReq.begin()->second.set_has_next(true);
partCursorMapReq.begin()->second.set_next_cursor(nextCursor_);
req_->set_parts(partCursorMapReq);
auto r = client_->doScanEdge(*req_);
if (!r.first) {
LOG(ERROR) << "Scan edge failed";
Expand All @@ -50,10 +45,8 @@ DataSet ScanEdgeIter::next() {
DCHECK_EQ(partCursorMapResp.size(), 1);
auto scanCursor = partCursorMapResp.begin()->second;
hasNext_ = scanCursor.get_has_next();
LOG(INFO) << "hasNext: " << hasNext_;
if (hasNext_) {
nextCursor_ = *scanCursor.get_next_cursor();
LOG(INFO) << "nextCursor: " << nextCursor_;
}

return scanResponse.get_edge_data();
Expand Down
6 changes: 3 additions & 3 deletions src/sclient/StorageClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ ScanEdgeIter StorageClient::scanEdgeWithPart(std::string spaceName,
bool enableReadFromFollower) {
auto spaceIdResult = mClient_->getSpaceIdByNameFromCache(spaceName);
if (!spaceIdResult.first) {
return ScanEdgeIter(nullptr, nullptr, false);
return {nullptr, nullptr, false};
}
int32_t spaceId = spaceIdResult.second;
auto edgeTypeResult = mClient_->getEdgeTypeByNameFromCache(spaceId, edgeName);
if (!edgeTypeResult.second) {
return ScanEdgeIter(nullptr, nullptr, false);
return {nullptr, nullptr, false};
}
int32_t edgeType = edgeTypeResult.second;

Expand All @@ -80,7 +80,7 @@ ScanEdgeIter StorageClient::scanEdgeWithPart(std::string spaceName,
req->set_only_latest_version(onlyLatestVersion);
req->set_enable_read_from_follower(enableReadFromFollower);

return ScanEdgeIter(this, req);
return {this, req};
}

std::pair<bool, storage::cpp2::ScanEdgeResponse> StorageClient::doScanEdge(
Expand Down
6 changes: 3 additions & 3 deletions src/sclient/tests/StorageClientTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class StorageClientTest : public ClientTest {
protected:
static void prepare() {
nebula::ConnectionPool pool;
pool.init({kServerHost ":9669"}, nebula::Config{});
pool.init({kServerHost ":38996"}, nebula::Config{});
auto session = pool.getSession("root", "nebula");
ASSERT_TRUE(session.valid());
EXPECT_TRUE(session.ping());
Expand Down Expand Up @@ -67,7 +67,7 @@ class StorageClientTest : public ClientTest {

auto ret4 = c.getPartLeaderFromCache(spaceId, 1);
ASSERT_TRUE(ret4.first);
EXPECT_EQ(ret4.second, nebula::HostAddr(kServerHost, 9779));
EXPECT_EQ(ret4.second, nebula::HostAddr("192.168.8.6", 48856));
}

static void runGetParts(nebula::StorageClient &c) {
Expand Down Expand Up @@ -133,7 +133,7 @@ class StorageClientTest : public ClientTest {
TEST_F(StorageClientTest, Basic) {
LOG(INFO) << "Prepare data.";
prepare();
nebula::StorageClient c({kServerHost ":9559"});
nebula::StorageClient c({kServerHost ":45996"});
auto *m = c.getMetaClient();
LOG(INFO) << "Testing run once of meta client";
runOnce(*m);
Expand Down

0 comments on commit 9491908

Please sign in to comment.