Permalink
Browse files
dhtrunner: add ongoing op count to node info
- Loading branch information
|
@@ -78,6 +78,7 @@ struct OPENDHT_PUBLIC NodeInfo { |
|
|
InfoHash node_id; |
|
|
NodeStats ipv4; |
|
|
NodeStats ipv6; |
|
|
size_t ongoing_ops; |
|
|
|
|
|
#ifdef OPENDHT_JSONCPP |
|
|
/** |
|
|
|
@@ -522,7 +522,7 @@ class OPENDHT_PUBLIC DhtRunner { |
|
|
std::mutex storage_mtx {}; |
|
|
|
|
|
std::atomic<State> running {State::Idle}; |
|
|
std::atomic_uint ongoing_ops {0}; |
|
|
std::atomic_size_t ongoing_ops {0}; |
|
|
std::vector<ShutdownCallback> shutdownCallbacks_; |
|
|
|
|
|
NodeStatus status4 {NodeStatus::Disconnected}, |
|
|
|
@@ -121,6 +121,7 @@ NodeInfo::toJson() const |
|
|
val["node_id"] = node_id.toString(); |
|
|
val["ipv4"] = ipv4.toJson(); |
|
|
val["ipv6"] = ipv6.toJson(); |
|
|
val["ops"] = Json::Value::LargestUInt(ongoing_ops); |
|
|
return val; |
|
|
} |
|
|
|
|
@@ -131,6 +132,7 @@ NodeInfo::NodeInfo(const Json::Value& v) |
|
|
node_id = InfoHash(v["node_id"].asString()); |
|
|
ipv4 = NodeStats(v["ipv4"]); |
|
|
ipv6 = NodeStats(v["ipv6"]); |
|
|
ongoing_ops = v["ops"].asLargestUInt(); |
|
|
} |
|
|
|
|
|
#endif |
|
|
|
@@ -467,6 +467,7 @@ DhtRunner::getNodeInfo() const { |
|
|
NodeInfo info; |
|
|
info.id = getId(); |
|
|
info.node_id = getNodeId(); |
|
|
info.ongoing_ops = ongoing_ops; |
|
|
info.ipv4 = dht_->getNodesStats(AF_INET); |
|
|
info.ipv6 = dht_->getNodesStats(AF_INET6); |
|
|
return info; |
|
|
|
@@ -140,11 +140,13 @@ void cmd_loop(std::shared_ptr<DhtRunner>& node, dht_params& params |
|
|
print_help(); |
|
|
continue; |
|
|
} else if (op == "ll") { |
|
|
auto nodeInfo = node->getNodeInfo(); |
|
|
print_node_info(*node, params); |
|
|
std::cout << nodeInfo.ongoing_ops << " ongoing operations" << std::endl; |
|
|
std::cout << "IPv4 stats:" << std::endl; |
|
|
std::cout << node->getNodesStats(AF_INET).toString() << std::endl; |
|
|
std::cout << nodeInfo.ipv4.toString() << std::endl; |
|
|
std::cout << "IPv6 stats:" << std::endl; |
|
|
std::cout << node->getNodesStats(AF_INET6).toString() << std::endl; |
|
|
std::cout << nodeInfo.ipv6.toString() << std::endl; |
|
|
#ifdef OPENDHT_PROXY_SERVER |
|
|
for (const auto& proxy : proxies) { |
|
|
std::cout << "Stats for proxy on port " << proxy.first << std::endl; |
|
|
0 comments on commit
83f2b27