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

Function main

src/cli/resolve.cpp:64–124  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

62
63
64int main(int argc, char** argv)
65{
66 Flags flags;
67 flags.setUsageMessage("Usage: " + Path(argv[0]).basename() + " <master>");
68
69 // Load flags from environment and command line, and remove
70 // them from argv.
71 Try<flags::Warnings> load = flags.load(None(), &argc, &argv);
72
73 if (flags.help) {
74 cout << flags.usage() << endl;
75 return EXIT_SUCCESS;
76 }
77
78 if (load.isError()) {
79 cerr << flags.usage(load.error()) << endl;
80 return EXIT_FAILURE;
81 }
82
83 // Log any flag warnings.
84 foreach (const flags::Warning& warning, load->warnings) {
85 cerr << warning.message << endl;
86 }
87
88 // 'master' argument must be the only argument left after parsing.
89 if (argc != 2) {
90 cerr << flags.usage("There must be only one argument: <master>") << endl;
91 return EXIT_FAILURE;
92 }
93
94 string master = argv[1];
95 Try<mesos::master::detector::MasterDetector*> detector =
96 mesos::master::detector::MasterDetector::create(master);
97
98 if (detector.isError()) {
99 cerr << "Failed to create a master detector: " << detector.error() << endl;
100 return EXIT_FAILURE;
101 }
102
103 Future<Option<MasterInfo>> masterInfo = detector.get()->detect();
104
105 if (!masterInfo.await(flags.timeout)) {
106 cerr << "Failed to detect master from '" << master
107 << "' within " << flags.timeout << endl;
108 return -1;
109 } else {
110 CHECK(!masterInfo.isDiscarded());
111
112 if (masterInfo.isFailed()) {
113 cerr << "Failed to detect master from '" << master
114 << "': " << masterInfo.failure() << endl;
115 return EXIT_FAILURE;
116 }
117 }
118
119 // The future is not satisfied unless the result is Some.
120 CHECK_SOME(masterInfo.get());
121 cout << strings::remove(masterInfo->get().pid(), "master@") << endl;

Callers

nothing calls this directly

Calls 15

PathClass · 0.85
NoneClass · 0.85
setUsageMessageMethod · 0.80
isDiscardedMethod · 0.80
isFailedMethod · 0.80
failureMethod · 0.80
errorMethod · 0.65
createFunction · 0.50
removeFunction · 0.50
basenameMethod · 0.45
loadMethod · 0.45
usageMethod · 0.45

Tested by

no test coverage detected