MCPcopy Create free account
hub / github.com/apple/foundationdb / addInterfacesFromKVs

Function addInterfacesFromKVs

fdbcli/Util.actor.cpp:65–91  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63}
64
65void addInterfacesFromKVs(RangeResult& kvs,
66 std::map<Key, std::pair<Value, ClientLeaderRegInterface>>* address_interface) {
67 for (const auto& kv : kvs) {
68 ClientWorkerInterface workerInterf;
69 try {
70 // the interface is back-ward compatible, thus if parsing failed, it needs to upgrade cli version
71 workerInterf = BinaryReader::fromStringRef<ClientWorkerInterface>(kv.value, IncludeVersion());
72 } catch (Error& e) {
73 fprintf(stderr, "Error: %s; CLI version is too old, please update to use a newer version\n", e.what());
74 return;
75 }
76 ClientLeaderRegInterface leaderInterf(workerInterf.address());
77 StringRef ip_port =
78 (kv.key.endsWith(LiteralStringRef(":tls")) ? kv.key.removeSuffix(LiteralStringRef(":tls")) : kv.key)
79 .removePrefix(LiteralStringRef("\xff\xff/worker_interfaces/"));
80 (*address_interface)[ip_port] = std::make_pair(kv.value, leaderInterf);
81
82 if (workerInterf.reboot.getEndpoint().addresses.secondaryAddress.present()) {
83 Key full_ip_port2 =
84 StringRef(workerInterf.reboot.getEndpoint().addresses.secondaryAddress.get().toString());
85 StringRef ip_port2 = full_ip_port2.endsWith(LiteralStringRef(":tls"))
86 ? full_ip_port2.removeSuffix(LiteralStringRef(":tls"))
87 : full_ip_port2;
88 (*address_interface)[ip_port2] = std::make_pair(kv.value, leaderInterf);
89 }
90 }
91}
92
93ACTOR Future<Void> getWorkerInterfaces(Reference<ITransaction> tr,
94 std::map<Key, std::pair<Value, ClientLeaderRegInterface>>* address_interface,

Callers 1

Calls 11

IncludeVersionFunction · 0.85
fprintfFunction · 0.85
endsWithMethod · 0.80
removeSuffixMethod · 0.80
getMethod · 0.65
StringRefClass · 0.50
whatMethod · 0.45
addressMethod · 0.45
removePrefixMethod · 0.45
presentMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected