diff --git a/curvefs/src/tools/copyset/curvefs_copyset_base_tool.cpp b/curvefs/src/tools/copyset/curvefs_copyset_base_tool.cpp index d7b463a069..9f1c5ab94d 100644 --- a/curvefs/src/tools/copyset/curvefs_copyset_base_tool.cpp +++ b/curvefs/src/tools/copyset/curvefs_copyset_base_tool.cpp @@ -88,7 +88,6 @@ bool CopysetInfo2CopysetStatus( uint64_t key = (static_cast(copysets[m].poolid()) << 32) | copysets[m].copysetid(); (*key2Status)[key].push_back(copysetsStatus[n]); - // TODO(chengyi01): check copysetsStatus[n].status() } } return ret; @@ -135,7 +134,8 @@ bool CopysetInfo2CopysetStatus( getCopysetStatusTool.SetRequestQueue(i.second); auto checkRet = getCopysetStatusTool.RunCommand(); if (checkRet < 0) { - std::cerr << "send request to mds get error." << std::endl; + std::cerr << "send request to metaserver (" << FLAGS_metaserverAddr + << ") get error." << std::endl; ret = false; } const auto& copysetsStatus = @@ -146,7 +146,6 @@ bool CopysetInfo2CopysetStatus( uint64_t key = (static_cast(copysets[m].poolid()) << 32) | copysets[m].copysetid(); (*key2Status)[key].push_back(copysetsStatus[n]); - // TODO(chengyi01): check copysetsStatus[n].status() } } return ret; diff --git a/curvefs/src/tools/status/curvefs_copyset_status.cpp b/curvefs/src/tools/status/curvefs_copyset_status.cpp index 3a84b99420..b3ce1c2806 100644 --- a/curvefs/src/tools/status/curvefs_copyset_status.cpp +++ b/curvefs/src/tools/status/curvefs_copyset_status.cpp @@ -41,46 +41,47 @@ void CopysetStatusTool::PrintHelp() { } int CopysetStatusTool::RunCommand() { - if (copyInfoListTool_->RunCommand() == 0) { - auto response = copyInfoListTool_->GetResponse(); - std::map< - uint64_t, - std::vector> - key2Status; - copyset::CopysetInfo2CopysetStatus(*response.get(), &key2Status); + copyInfoListTool_->RunCommand(); + auto response = copyInfoListTool_->GetResponse(); + std::map> + key2Status; + copyset::CopysetInfo2CopysetStatus(*response.get(), &key2Status); - std::map> - key2Info; + std::map> + key2Info; - copyset::Response2CopysetInfo(*response.get(), &key2Info); + copyset::Response2CopysetInfo(*response.get(), &key2Info); - bool isHealth = true; - for (auto const& i : key2Info) { - if (copyset::checkCopysetHelthy(i.second, key2Status[i.first]) != - copyset::CheckResult::kHealthy) { - isHealth = false; - break; - } + bool isHealth = true; + for (auto const& i : key2Info) { + if (copyset::checkCopysetHelthy(i.second, key2Status[i.first]) != + copyset::CheckResult::kHealthy) { + isHealth = false; + break; + } + } + int ret = 0; + if (show_) { + if (isHealth) { + std::cout << "all copyset is healthy." << std::endl; + } else { + std::cout << "copysets is unhealthy." << std::endl; + ret = -1; } - if (show_) { - if (isHealth) { - std::cout << "all copyset is health." << std::endl; - } else { - std::cout << "copysets is unhealth." << std::endl; + for (auto const& i : key2Info) { + std::cout << "copyset[" << i.first << "]:\n-info:\n"; + for (auto const& j : i.second) { + std::cout << j.ShortDebugString() << std::endl; } - for (auto const& i : key2Info) { - std::cout << "copyset[" << i.first << "]:\n-info:\n"; - for (auto const& j : i.second) { - std::cout << j.ShortDebugString() << std::endl; - } - std::cout << "-status:\n"; - for (auto const& j : key2Status[i.first]) { - std::cout << j.ShortDebugString() << std::endl; - } + std::cout << "-status:\n"; + for (auto const& j : key2Status[i.first]) { + std::cout << j.ShortDebugString() << std::endl; } } } - return 0; + + return ret; } } // namespace status