| 332 | |
| 333 | |
| 334 | Future<Nothing> HDFS::copyFromLocal(const string& from, const string& to) |
| 335 | { |
| 336 | if (!os::exists(from)) { |
| 337 | return Failure("Failed to find '" + from + "'"); |
| 338 | } |
| 339 | |
| 340 | Try<Subprocess> s = subprocess( |
| 341 | hadoop, |
| 342 | {"hadoop", "fs", "-copyFromLocal", from, normalize(to)}, |
| 343 | Subprocess::PATH(os::DEV_NULL), |
| 344 | Subprocess::PIPE(), |
| 345 | Subprocess::PIPE()); |
| 346 | |
| 347 | if (s.isError()) { |
| 348 | return Failure("Failed to execute the subprocess: " + s.error()); |
| 349 | } |
| 350 | |
| 351 | return result(s.get()) |
| 352 | .then([](const CommandResult& result) -> Future<Nothing> { |
| 353 | if (result.status.isNone()) { |
| 354 | return Failure("Failed to reap the subprocess"); |
| 355 | } |
| 356 | |
| 357 | if (result.status.get() != 0) { |
| 358 | return Failure( |
| 359 | "Unexpected result from the subprocess: " |
| 360 | "status='" + stringify(result.status.get()) + "', " + |
| 361 | "stdout='" + result.out + "', " + |
| 362 | "stderr='" + result.err + "'"); |
| 363 | } |
| 364 | |
| 365 | return Nothing(); |
| 366 | }); |
| 367 | } |
| 368 | |
| 369 | |
| 370 | Future<Nothing> HDFS::copyToLocal(const string& from, const string& to) |