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

Method _setup

fdbserver/workloads/UDPWorkload.actor.cpp:65–90  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

63
64 std::string description() const override { return name; }
65 ACTOR static Future<Void> _setup(UDPWorkload* self, Database cx) {
66 state NetworkAddress localAddress(g_network->getLocalAddress().ip,
67 deterministicRandom()->randomInt(self->minPort, self->maxPort + 1),
68 true,
69 false);
70 state Key key = self->keyPrefix.withSuffix(BinaryWriter::toValue(self->clientId, Unversioned()));
71 state Value serializedLocalAddress = BinaryWriter::toValue(localAddress, IncludeVersion());
72 state ReadYourWritesTransaction tr(cx);
73 Reference<IUDPSocket> s = wait(INetworkConnections::net()->createUDPSocket(localAddress.isV6()));
74 self->serverSocket = std::move(s);
75 self->serverSocket->bind(localAddress);
76 self->serverAddress = localAddress;
77 loop {
78 try {
79 Optional<Value> v = wait(tr.get(key));
80 if (v.present()) {
81 return Void();
82 }
83 tr.set(key, serializedLocalAddress);
84 wait(tr.commit());
85 return Void();
86 } catch (Error& e) {
87 wait(tr.onError(e));
88 }
89 }
90 }
91 Future<Void> setup(Database const& cx) override { return _setup(this, cx); }
92
93 class Message {

Callers

nothing calls this directly

Calls 15

deterministicRandomFunction · 0.85
UnversionedFunction · 0.85
IncludeVersionFunction · 0.85
moveFunction · 0.85
withSuffixMethod · 0.80
getMethod · 0.65
setMethod · 0.65
commitMethod · 0.65
onErrorMethod · 0.65
VoidClass · 0.50
getLocalAddressMethod · 0.45
randomIntMethod · 0.45

Tested by

no test coverage detected