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.
| 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. |
| 169 | static 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 | |
| 204 | static Variant<check::Command, check::Http, check::Tcp> checkInfoToCheck( |