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

Function decodeLocality

fdbclient/ManagementAPI.actor.cpp:1738–1748  ·  view source on GitHub ↗

Decodes the locality string to a pair of locality prefix and its value. The prefix could be dcid, processid, machineid, processid.

Source from the content-addressed store, hash-verified

1736// Decodes the locality string to a pair of locality prefix and its value.
1737// The prefix could be dcid, processid, machineid, processid.
1738std::pair<std::string, std::string> decodeLocality(const std::string& locality) {
1739 StringRef localityRef((const uint8_t*)(locality.c_str()), locality.size());
1740
1741 std::string localityKeyValue = localityRef.removePrefix(LocalityData::ExcludeLocalityPrefix).toString();
1742 int split = localityKeyValue.find(':');
1743 if (split != std::string::npos) {
1744 return std::make_pair(localityKeyValue.substr(0, split), localityKeyValue.substr(split + 1));
1745 }
1746
1747 return std::make_pair("", "");
1748}
1749
1750// Returns the list of IPAddresses of the workers that match the given locality.
1751// Example: locality="dcid:primary" returns all the ip addresses of the workers in the primary dc.

Callers 1

getAddressesByLocalityFunction · 0.85

Calls 6

substrMethod · 0.80
c_strMethod · 0.45
sizeMethod · 0.45
toStringMethod · 0.45
removePrefixMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected