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

Function decodeProcessIOData

src/checks/checker_process.cpp:169–201  ·  view source on GitHub ↗

Reads `ProcessIO::Data` records from a string containing "Record-IO" data encoded in protobuf messages, and returns the stdout and stderr. NOTE: This function ignores any `ProcessIO::Control` records. TODO(gkleiman): This function is very similar to one in `api_tests.cpp`, we should refactor them into a common helper when fixing MESOS-7903.

Source from the content-addressed store, hash-verified

167// TODO(gkleiman): This function is very similar to one in `api_tests.cpp`, we
168// should refactor them into a common helper when fixing MESOS-7903.
169static Try<tuple<string, string>> decodeProcessIOData(const string& data)
170{
171 string stdoutReceived;
172 string stderrReceived;
173
174 ::recordio::Decoder decoder;
175
176 Try<std::deque<string>> records = decoder.decode(data);
177
178 if (records.isError()) {
179 return Error(records.error());
180 }
181
182 while (!records->empty()) {
183 string record = std::move(records->front());
184 records->pop_front();
185
186 Try<v1::agent::ProcessIO> result = deserialize<v1::agent::ProcessIO>(
187 ContentType::PROTOBUF, record);
188
189 if (result.isError()) {
190 return Error(result.error());
191 }
192
193 if (result->data().type() == v1::agent::ProcessIO::Data::STDOUT) {
194 stdoutReceived += result->data().data();
195 } else if (result->data().type() == v1::agent::ProcessIO::Data::STDERR) {
196 stderrReceived += result->data().data();
197 }
198 }
199
200 return std::make_tuple(stdoutReceived, stderrReceived);
201}
202
203
204static Variant<check::Command, check::Http, check::Tcp> checkInfoToCheck(

Callers 1

___nestedCommandCheckMethod · 0.85

Calls 7

typeMethod · 0.80
dataMethod · 0.80
errorMethod · 0.65
ErrorFunction · 0.50
decodeMethod · 0.45
isErrorMethod · 0.45
emptyMethod · 0.45

Tested by

no test coverage detected