| 649 | |
| 650 | |
| 651 | TaskStatusUpdateStream::TaskStatusUpdateStream( |
| 652 | const TaskID& _taskId, |
| 653 | const FrameworkID& _frameworkId, |
| 654 | const SlaveID& _slaveId, |
| 655 | const Flags& _flags, |
| 656 | bool _checkpoint, |
| 657 | const Option<ExecutorID>& executorId, |
| 658 | const Option<ContainerID>& containerId) |
| 659 | : checkpoint(_checkpoint), |
| 660 | terminated(false), |
| 661 | taskId(_taskId), |
| 662 | frameworkId(_frameworkId), |
| 663 | slaveId(_slaveId), |
| 664 | flags(_flags), |
| 665 | error(None()) |
| 666 | { |
| 667 | if (checkpoint) { |
| 668 | CHECK_SOME(executorId); |
| 669 | CHECK_SOME(containerId); |
| 670 | |
| 671 | path = paths::getTaskUpdatesPath( |
| 672 | paths::getMetaRootDir(flags.work_dir), |
| 673 | slaveId, |
| 674 | frameworkId, |
| 675 | executorId.get(), |
| 676 | containerId.get(), |
| 677 | taskId); |
| 678 | |
| 679 | // Create the base updates directory, if it doesn't exist. |
| 680 | const string& dirName = Path(path.get()).dirname(); |
| 681 | Try<Nothing> directory = os::mkdir(dirName); |
| 682 | if (directory.isError()) { |
| 683 | error = "Failed to create '" + dirName + "': " + directory.error(); |
| 684 | return; |
| 685 | } |
| 686 | |
| 687 | // Open the updates file. |
| 688 | // NOTE: We don't use `O_SYNC` here because we only read this file |
| 689 | // if the host did not crash. `os::write` success implies the kernel |
| 690 | // will have flushed our data to the page cache. This is sufficient |
| 691 | // for the recovery scenarios we use this data for. |
| 692 | Try<int_fd> result = os::open( |
| 693 | path.get(), |
| 694 | O_CREAT | O_WRONLY | O_APPEND | O_CLOEXEC, |
| 695 | S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH); |
| 696 | |
| 697 | if (result.isError()) { |
| 698 | error = "Failed to open '" + path.get() + |
| 699 | "' for status updates: " + result.error(); |
| 700 | return; |
| 701 | } |
| 702 | |
| 703 | // We keep the file open through the lifetime of the task, because it |
| 704 | // makes it easy to append status update records to the file. |
| 705 | fd = result.get(); |
| 706 | } |
| 707 | } |
| 708 |
nothing calls this directly
no test coverage detected