| 368 | |
| 369 | |
| 370 | Future<Nothing> HDFS::copyToLocal(const string& from, const string& to) |
| 371 | { |
| 372 | Try<Subprocess> s = subprocess( |
| 373 | hadoop, |
| 374 | {hadoop, "fs", "-copyToLocal", normalize(from), to}, |
| 375 | Subprocess::PATH(os::DEV_NULL), |
| 376 | Subprocess::PIPE(), |
| 377 | Subprocess::PIPE()); |
| 378 | |
| 379 | if (s.isError()) { |
| 380 | return Failure("Failed to execute the subprocess: " + s.error()); |
| 381 | } |
| 382 | |
| 383 | return result(s.get()) |
| 384 | .then([](const CommandResult& result) -> Future<Nothing> { |
| 385 | if (result.status.isNone()) { |
| 386 | return Failure("Failed to reap the subprocess"); |
| 387 | } |
| 388 | |
| 389 | if (result.status.get() != 0) { |
| 390 | return Failure( |
| 391 | "Unexpected result from the subprocess: " |
| 392 | "status='" + stringify(result.status.get()) + "', " + |
| 393 | "stdout='" + result.out + "', " + |
| 394 | "stderr='" + result.err + "'"); |
| 395 | } |
| 396 | |
| 397 | return Nothing(); |
| 398 | }); |
| 399 | } |