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

Method getInterface

fdbclient/NativeAPI.actor.cpp:345–373  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

343}
344
345Reference<StorageServerInfo> StorageServerInfo::getInterface(DatabaseContext* cx,
346 StorageServerInterface const& ssi,
347 LocalityData const& locality) {
348 auto it = cx->server_interf.find(ssi.id());
349 if (it != cx->server_interf.end()) {
350 if (it->second->interf.getValue.getEndpoint().token != ssi.getValue.getEndpoint().token) {
351 if (it->second->interf.locality == ssi.locality) {
352 // FIXME: load balance holds pointers to individual members of the interface, and this assignment will
353 // swap out the object they are
354 // pointing to. This is technically correct, but is very unnatural. We may want to refactor load
355 // balance to take an AsyncVar<Reference<Interface>> so that it is notified when the interface
356 // changes.
357
358 it->second->interf = ssi;
359 } else {
360 it->second->notifyContextDestroyed();
361 Reference<StorageServerInfo> loc(new StorageServerInfo(cx, ssi, locality));
362 cx->server_interf[ssi.id()] = loc.getPtr();
363 return loc;
364 }
365 }
366
367 return Reference<StorageServerInfo>::addRef(it->second);
368 }
369
370 Reference<StorageServerInfo> loc(new StorageServerInfo(cx, ssi, locality));
371 cx->server_interf[ssi.id()] = loc.getPtr();
372 return loc;
373}
374
375void StorageServerInfo::notifyContextDestroyed() {
376 cx = nullptr;

Calls 5

findMethod · 0.45
idMethod · 0.45
endMethod · 0.45
getPtrMethod · 0.45

Tested by

no test coverage detected