MCPcopy Create free account
hub / github.com/apache/mesos / createMasterInfo

Function createMasterInfo

src/common/protobuf_utils.cpp:624–656  ·  view source on GitHub ↗

* Creates a MasterInfo protobuf from the process's UPID. * * This is only used by the `StandaloneMasterDetector` (used in tests * and outside tests when ZK is not used). * * For example, when we start a slave with * `--master=master@127.0.0.1:5050`, since the slave (and consequently * its detector) doesn't have enough information about `MasterInfo`, it * tries to construct it based on the

Source from the content-addressed store, hash-verified

622 * as derived from the `UPID`.
623 */
624MasterInfo createMasterInfo(const UPID& pid)
625{
626 MasterInfo info;
627 info.set_id(stringify(pid) + "-" + id::UUID::random().toString());
628
629 // NOTE: Currently, we store the ip in network order, which should
630 // be fixed. See MESOS-1201 for more details.
631 // TODO(marco): `ip` and `port` are deprecated in favor of `address`;
632 // remove them both after the deprecation cycle.
633 info.set_ip(pid.address.ip.in()->s_addr);
634 info.set_port(pid.address.port);
635
636 info.mutable_address()->set_ip(stringify(pid.address.ip));
637 info.mutable_address()->set_port(pid.address.port);
638
639 info.set_pid(pid);
640
641 Try<string> hostname = net::getHostname(pid.address.ip);
642 if (hostname.isSome()) {
643 // Hostname is deprecated; but we need to update it
644 // to maintain backward compatibility.
645 // TODO(marco): Remove once we deprecate it.
646 info.set_hostname(hostname.get());
647 info.mutable_address()->set_hostname(hostname.get());
648 }
649
650 foreach (const MasterInfo::Capability& capability,
651 mesos::internal::master::MASTER_CAPABILITIES()) {
652 info.add_capabilities()->CopyFrom(capability);
653 }
654
655 return info;
656}
657
658
659Label createLabel(const string& key, const Option<string>& value)

Callers 8

TESTFunction · 0.85
TEST_FFunction · 0.85
SetUpMethod · 0.85
fetchedMethod · 0.85
createMethod · 0.85
appointMethod · 0.85

Calls 7

randomFunction · 0.85
stringifyFunction · 0.50
getHostnameFunction · 0.50
toStringMethod · 0.45
inMethod · 0.45
isSomeMethod · 0.45
getMethod · 0.45

Tested by 4

TESTFunction · 0.68
TEST_FFunction · 0.68
SetUpMethod · 0.68