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

Method execute

src/log/tool/initialize.cpp:47–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

45
46
47Try<Nothing> Initialize::execute(int argc, char** argv)
48{
49 flags.setUsageMessage(
50 "Usage: " + name() + " [option]\n"
51 "\n"
52 "This command is used to initialize the log.\n"
53 "\n");
54
55 // Configure the tool by parsing command line arguments.
56 if (argc > 0 && argv != nullptr) {
57 Try<flags::Warnings> load = flags.load(None(), argc, argv);
58 if (load.isError()) {
59 return Error(flags.usage(load.error()));
60 }
61
62 if (flags.help) {
63 return Error(flags.usage());
64 }
65
66 process::initialize();
67 logging::initialize(argv[0], false, flags);
68
69 // Log any flag warnings (after logging is initialized).
70 foreach (const flags::Warning& warning, load->warnings) {
71 LOG(WARNING) << warning.message;
72 }
73 }
74
75 if (flags.path.isNone()) {
76 return Error(flags.usage("Missing required option --path"));
77 }
78
79 // Setup the timeout if specified.
80 Option<Timeout> timeout = None();
81 if (flags.timeout.isSome()) {
82 timeout = Timeout::in(flags.timeout.get());
83 }
84
85 Replica replica(flags.path.get());
86
87 // Get the current status of the replica.
88 Future<Metadata::Status> status = replica.status();
89 if (timeout.isSome()) {
90 status.await(timeout->remaining());
91 } else {
92 status.await();
93 }
94
95 if (status.isPending()) {
96 return Error("Timed out while getting replica status");
97 } else if (status.isDiscarded()) {
98 return Error("Failed to get status of replica (discarded future)");
99 } else if (status.isFailed()) {
100 return Error(status.failure());
101 }
102
103 // We only initialize a log if it is empty.
104 if (status.get() != Metadata::EMPTY) {

Callers

nothing calls this directly

Calls 15

nameFunction · 0.85
NoneClass · 0.85
NothingClass · 0.85
setUsageMessageMethod · 0.80
isDiscardedMethod · 0.80
isFailedMethod · 0.80
failureMethod · 0.80
errorMethod · 0.65
ErrorFunction · 0.50
initializeFunction · 0.50
loadMethod · 0.45
isErrorMethod · 0.45

Tested by

no test coverage detected