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

Method addClient

fdbclient/MultiVersionTransaction.actor.cpp:1860–1889  ·  view source on GitHub ↗

Adds a client (local or externally loaded) that can be used to connect to the cluster

Source from the content-addressed store, hash-verified

1858
1859// Adds a client (local or externally loaded) that can be used to connect to the cluster
1860void MultiVersionDatabase::DatabaseState::addClient(Reference<ClientInfo> client) {
1861 ProtocolVersion baseVersion = client->protocolVersion.normalizedVersion();
1862 auto [itr, inserted] = clients.insert({ baseVersion, client });
1863 if (!inserted) {
1864 // SOMEDAY: prefer client with higher release version if protocol versions are compatible
1865 Reference<ClientInfo> keptClient = itr->second;
1866 Reference<ClientInfo> discardedClient = client;
1867 if (client->canReplace(itr->second)) {
1868 std::swap(keptClient, discardedClient);
1869 clients[baseVersion] = client;
1870 }
1871
1872 discardedClient->failed = true;
1873 TraceEvent(SevWarn, "DuplicateClientVersion")
1874 .detail("Keeping", keptClient->libPath)
1875 .detail("KeptProtocolVersion", keptClient->protocolVersion)
1876 .detail("Disabling", discardedClient->libPath)
1877 .detail("DisabledProtocolVersion", discardedClient->protocolVersion);
1878
1879 MultiVersionApi::api->updateSupportedVersions();
1880 }
1881
1882 if (!client->protocolVersion.hasInexpensiveMultiVersionClient() && !client->failed) {
1883 TraceEvent("AddingLegacyVersionMonitor")
1884 .detail("LibPath", client->libPath)
1885 .detail("ProtocolVersion", client->protocolVersion);
1886
1887 legacyVersionMonitors.emplace_back(new LegacyVersionMonitor(client));
1888 }
1889}
1890
1891// Watch the cluster protocol version for changes and update the database state when it does.
1892// Must be called from the main thread

Callers 1

MultiVersionDatabaseMethod · 0.80

Calls 7

swapFunction · 0.85
TraceEventClass · 0.85
canReplaceMethod · 0.80
detailMethod · 0.80
emplace_backMethod · 0.80
insertMethod · 0.45

Tested by

no test coverage detected