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

Method monitorProtocolVersion

fdbclient/MultiVersionTransaction.actor.cpp:1893–1916  ·  view source on GitHub ↗

Watch the cluster protocol version for changes and update the database state when it does. Must be called from the main thread

Source from the content-addressed store, hash-verified

1891// Watch the cluster protocol version for changes and update the database state when it does.
1892// Must be called from the main thread
1893ThreadFuture<Void> MultiVersionDatabase::DatabaseState::monitorProtocolVersion() {
1894 startLegacyVersionMonitors();
1895
1896 Optional<ProtocolVersion> expected = dbProtocolVersion;
1897 ThreadFuture<ProtocolVersion> f = versionMonitorDb->getServerProtocol(dbProtocolVersion);
1898
1899 Reference<DatabaseState> self = Reference<DatabaseState>::addRef(this);
1900 return mapThreadFuture<ProtocolVersion, Void>(f, [self, expected](ErrorOr<ProtocolVersion> cv) {
1901 if (cv.isError()) {
1902 if (cv.getError().code() == error_code_operation_cancelled) {
1903 return ErrorOr<Void>(cv.getError());
1904 }
1905
1906 TraceEvent("ErrorGettingClusterProtocolVersion")
1907 .error(cv.getError())
1908 .detail("ExpectedProtocolVersion", expected);
1909 }
1910
1911 ProtocolVersion clusterVersion =
1912 !cv.isError() ? cv.get() : self->dbProtocolVersion.orDefault(currentProtocolVersion());
1913 onMainThreadVoid([self, clusterVersion]() { self->protocolVersionChanged(clusterVersion); });
1914 return ErrorOr<Void>(Void());
1915 });
1916}
1917
1918// Called when a change to the protocol version of the cluster has been detected.
1919// Must be called from the main thread

Callers 1

MultiVersionDatabaseMethod · 0.80

Calls 13

TraceEventClass · 0.85
currentProtocolVersionFunction · 0.85
onMainThreadVoidFunction · 0.85
detailMethod · 0.80
getMethod · 0.65
VoidClass · 0.50
getServerProtocolMethod · 0.45
isErrorMethod · 0.45
codeMethod · 0.45
getErrorMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected