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

add more table in meta dump #3870

Merged
merged 6 commits into from
Mar 8, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
add more table in meta dump
  • Loading branch information
pengweisong committed Mar 2, 2022
commit 050b65c77e4883ba56d5446ce5e68333d26ceaf1
5 changes: 4 additions & 1 deletion src/common/utils/MetaKeyUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1247,7 +1247,10 @@ GraphSpaceID MetaKeyUtils::parseLocalIdSpace(folly::StringPiece rawData) {
}

/**
* diskPartsKey = kDiskPartsTable + len(serialized(hostAddr)) + serialized(hostAddr) + path
* diskPartsKey = kDiskPartsTable +
* len(serialized(hostAddr)) + serialized(hostAddr) +
* space id +
* disk path
*/

HostAddr MetaKeyUtils::parseDiskPartsHost(const folly::StringPiece& rawData) {
Expand Down
92 changes: 80 additions & 12 deletions src/tools/meta-dump/MetaDumpTool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,12 @@ class MetaDumper {
if (!iter) {
return Status::Error("Init iterator failed");
}

std::string prefix;
{
LOG(INFO) << "Space info";
prefix = "__spaces__";
LOG(INFO) << "------------------------------------------\n\n";
LOG(INFO) << "Space info:";
prefix = MetaKeyUtils::spacePrefix();
iter->Seek(rocksdb::Slice(prefix));
while (iter->Valid() && iter->key().starts_with(prefix)) {
auto key = folly::StringPiece(iter->key().data(), iter->key().size());
Expand All @@ -52,8 +54,9 @@ class MetaDumper {
}
}
{
LOG(INFO) << "Partition info";
prefix = "__parts__";
LOG(INFO) << "------------------------------------------\n\n";
LOG(INFO) << "Partition info::";
prefix = MetaKeyUtils::partPrefix();
iter->Seek(rocksdb::Slice(prefix));
while (iter->Valid() && iter->key().starts_with(prefix)) {
auto key = folly::StringPiece(iter->key().data(), iter->key().size());
Expand All @@ -71,8 +74,21 @@ class MetaDumper {
}
}
{
LOG(INFO) << "Host info";
prefix = "__hosts__";
LOG(INFO) << "------------------------------------------\n\n";
LOG(INFO) << "Registered machine info:";
prefix = MetaKeyUtils::machinePrefix();
iter->Seek(rocksdb::Slice(prefix));
while (iter->Valid() && iter->key().starts_with(prefix)) {
auto key = folly::StringPiece(iter->key().data(), iter->key().size());
auto machine = MetaKeyUtils::parseMachineKey(key);
LOG(INFO) << folly::sformat("registered machine: {}", machine.toString());
iter->Next();
}
}
{
LOG(INFO) << "------------------------------------------\n\n";
LOG(INFO) << "Host info:";
prefix = MetaKeyUtils::hostPrefix();
iter->Seek(rocksdb::Slice(prefix));
while (iter->Valid() && iter->key().starts_with(prefix)) {
auto key = folly::StringPiece(iter->key().data(), iter->key().size());
Expand All @@ -87,7 +103,55 @@ class MetaDumper {
}
}
{
LOG(INFO) << "Tag info";
LOG(INFO) << "------------------------------------------\n\n";
LOG(INFO) << "Host directories info:";
prefix = MetaKeyUtils::hostDirPrefix();
iter->Seek(rocksdb::Slice(prefix));
while (iter->Valid() && iter->key().starts_with(prefix)) {
auto key = folly::StringPiece(iter->key().data(), iter->key().size());
auto val = folly::StringPiece(iter->value().data(), iter->value().size());
auto addr = MetaKeyUtils::parseHostDirKey(key);
auto dir = MetaKeyUtils::parseHostDir(val);

std::string dataDirs = "";
for (auto d : dir.get_data()) {
dataDirs += d + ", ";
}
LOG(INFO) << folly::sformat("host addr: {}, data dirs: {}, root dir: {}",
addr.toString(),
dataDirs,
dir.get_root());
iter->Next();
}
}
{
LOG(INFO) << "------------------------------------------\n\n";
LOG(INFO) << "Disk partitions info:";
prefix = MetaKeyUtils::diskPartsPrefix();
iter->Seek(rocksdb::Slice(prefix));
while (iter->Valid() && iter->key().starts_with(prefix)) {
auto key = folly::StringPiece(iter->key().data(), iter->key().size());
auto val = folly::StringPiece(iter->value().data(), iter->value().size());
auto addr = MetaKeyUtils::parseDiskPartsHost(key);
auto spaceId = MetaKeyUtils::parseDiskPartsSpace(key);
auto diskPath = MetaKeyUtils::parseDiskPartsPath(key);
auto parts = MetaKeyUtils::parseDiskPartsVal(val);

std::string partsStr = "";
for (auto p : parts.get_part_list()) {
partsStr += (std::to_string(p) + ", ");
}
LOG(INFO) << folly::sformat("host addr: {}, data dir: {}, space id: {}, parts: {}",
addr.toString(),
diskPath,
spaceId,
partsStr);
iter->Next();
}
}
{
LOG(INFO) << "------------------------------------------\n\n";
LOG(INFO) << "Tag info:";
prefix = "__tags__";
iter->Seek(rocksdb::Slice(prefix));
while (iter->Valid() && iter->key().starts_with(prefix)) {
Expand All @@ -100,7 +164,8 @@ class MetaDumper {
}
}
{
LOG(INFO) << "Edge info";
LOG(INFO) << "------------------------------------------\n\n";
LOG(INFO) << "Edge info:";
prefix = "__edges__";
iter->Seek(rocksdb::Slice(prefix));
while (iter->Valid() && iter->key().starts_with(prefix)) {
Expand All @@ -113,7 +178,8 @@ class MetaDumper {
}
}
{
LOG(INFO) << "Index info";
LOG(INFO) << "------------------------------------------\n\n";
LOG(INFO) << "Index info:";
prefix = "__indexes__";
iter->Seek(rocksdb::Slice(prefix));
while (iter->Valid() && iter->key().starts_with(prefix)) {
Expand All @@ -125,7 +191,8 @@ class MetaDumper {
}
}
{
LOG(INFO) << "Leader info";
LOG(INFO) << "------------------------------------------\n\n";
LOG(INFO) << "Leader info:";
prefix = "__leader_terms__";
HostAddr host;
TermID term;
Expand All @@ -152,8 +219,9 @@ class MetaDumper {
}
}
{
LOG(INFO) << "Zone info";
prefix = "__zones__";
LOG(INFO) << "------------------------------------------\n\n";
LOG(INFO) << "Zone info:";
prefix = MetaKeyUtils::zonePrefix();
iter->Seek(rocksdb::Slice(prefix));
while (iter->Valid() && iter->key().starts_with(prefix)) {
auto key = folly::StringPiece(iter->key().data(), iter->key().size());
Expand Down