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

Method persist

fdbclient/ClusterConnectionFile.actor.cpp:148–182  ·  view source on GitHub ↗

Writes the connection string to the cluster file

Source from the content-addressed store, hash-verified

146
147// Writes the connection string to the cluster file
148Future<bool> ClusterConnectionFile::persist() {
149 setPersisted();
150
151 if (filename.size()) {
152 try {
153 atomicReplace(filename,
154 "# DO NOT EDIT!\n# This file is auto-generated, it is not to be edited by hand\n" +
155 cs.toString().append("\n"));
156
157 Future<bool> isUpToDate = IClusterConnectionRecord::upToDate();
158
159 // The implementation of upToDate in this class is synchronous
160 ASSERT(isUpToDate.isReady());
161
162 if (!isUpToDate.get()) {
163 // This should only happen in rare scenarios where multiple processes are updating the same file to
164 // different values simultaneously In that case, we don't have any guarantees about which file will
165 // ultimately be written
166 TraceEvent(SevWarnAlways, "ClusterFileChangedAfterReplace")
167 .detail("Filename", filename)
168 .detail("ConnectionString", cs.toString());
169 return false;
170 }
171
172 return true;
173 } catch (Error& e) {
174 TraceEvent(SevWarnAlways, "UnableToChangeConnectionFile")
175 .error(e)
176 .detail("Filename", filename)
177 .detail("ConnectionString", cs.toString());
178 }
179 }
180
181 return false;
182}

Callers

nothing calls this directly

Calls 9

atomicReplaceFunction · 0.85
TraceEventClass · 0.85
detailMethod · 0.80
getMethod · 0.65
sizeMethod · 0.45
appendMethod · 0.45
toStringMethod · 0.45
isReadyMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected