MCPcopy Create free account
hub / github.com/deepseek-ai/3FS / handle

Function handle

src/client/cli/admin/DropUserCache.cc:18–70  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16}
17
18CoTryTask<Dispatcher::OutputTable> handle(IEnv &ienv,
19 const argparse::ArgumentParser &parser,
20 const Dispatcher::Args &args) {
21 auto &env = dynamic_cast<AdminEnv &>(ienv);
22 ENSURE_USAGE(args.empty());
23 Dispatcher::OutputTable table;
24
25 auto u = parser.present<uint32_t>("-u");
26 auto all = parser.get<bool>("-a");
27
28 std::optional<flat::Uid> uid;
29 if (u) uid = flat::Uid(*u);
30
31 CO_RETURN_ON_ERROR(co_await env.mgmtdClientGetter()->refreshRoutingInfo(/*force=*/true));
32 auto routingInfo = env.mgmtdClientGetter()->getRoutingInfo()->raw();
33
34 auto req = meta::DropUserCacheReq(uid, all);
35
36 table.push_back({"NodeId", "Status", "Desc"});
37
38 auto client = env.clientGetter();
39 for (const auto &[nid, ni] : routingInfo->nodes) {
40 if (ni.type != flat::NodeType::META) continue;
41 if (ni.status != flat::NodeStatus::HEARTBEAT_CONNECTED) {
42 table.push_back({std::to_string(nid), "Skip", fmt::format("Status is {}", toStringView(ni.status))});
43 continue;
44 }
45 auto addrs = ni.extractAddresses("MetaSerde");
46 if (addrs.empty()) {
47 table.push_back({std::to_string(nid), "Skip", "Address of MetaSerde not found"});
48 continue;
49 }
50 auto result = co_await [&]() -> CoTask<std::vector<Status>> {
51 std::vector<Status> rets;
52 for (auto addr : addrs) {
53 auto ctx = client->serdeCtx(addr);
54 auto stub = meta::MetaServiceStub<serde::ClientContext>(ctx);
55 auto ret = co_await stub.dropUserCache(req, {});
56 if (!ret.hasError()) co_return std::vector<Status>{};
57 rets.push_back(std::move(ret.error()));
58 }
59 co_return rets;
60 }();
61
62 if (result.empty()) {
63 table.push_back({std::to_string(nid), "Succeed", ""});
64 } else {
65 table.push_back({std::to_string(nid), "Failed", fmt::format("[{}]", fmt::join(result, ", "))});
66 }
67 }
68
69 co_return table;
70}
71
72} // namespace
73

Callers

nothing calls this directly

Calls 14

DropUserCacheReqClass · 0.85
toStringViewFunction · 0.85
joinFunction · 0.85
rawMethod · 0.80
push_backMethod · 0.80
extractAddressesMethod · 0.80
dropUserCacheMethod · 0.80
hasErrorMethod · 0.80
formatFunction · 0.70
emptyMethod · 0.45
refreshRoutingInfoMethod · 0.45
getRoutingInfoMethod · 0.45

Tested by

no test coverage detected