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

Method execute

src/log/tool/read.cpp:63–171  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

61
62
63Try<Nothing> Read::execute(int argc, char** argv)
64{
65 flags.setUsageMessage(
66 "Usage: " + name() + " [options]\n"
67 "\n"
68 "This command is used to read the log.\n"
69 "\n");
70
71 // Configure the tool by parsing command line arguments.
72 if (argc > 0 && argv != nullptr) {
73 Try<flags::Warnings> load = flags.load(None(), argc, argv);
74 if (load.isError()) {
75 return Error(flags.usage(load.error()));
76 }
77
78 if (flags.help) {
79 return Error(flags.usage());
80 }
81
82 process::initialize();
83 logging::initialize(argv[0], false, flags);
84
85 // Log any flag warnings (after logging is initialized).
86 foreach (const flags::Warning& warning, load->warnings) {
87 LOG(WARNING) << warning.message;
88 }
89 }
90
91 if (flags.path.isNone()) {
92 return Error(flags.usage("Missing required flag --path"));
93 }
94
95 // Setup the timeout if specified.
96 Option<Timeout> timeout = None();
97 if (flags.timeout.isSome()) {
98 timeout = Timeout::in(flags.timeout.get());
99 }
100
101 Replica replica(flags.path.get());
102
103 // Get the beginning of the replica.
104 Future<uint64_t> begin = replica.beginning();
105 if (timeout.isSome()) {
106 begin.await(timeout->remaining());
107 } else {
108 begin.await();
109 }
110
111 if (begin.isPending()) {
112 return Error("Timed out while getting the beginning of the replica");
113 } else if (begin.isDiscarded()) {
114 return Error(
115 "Failed to get the beginning of the replica (discarded future)");
116 } else if (begin.isFailed()) {
117 return Error(begin.failure());
118 }
119
120 // Get the ending of the replica.

Callers 1

mainFunction · 0.45

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