| 811 | } |
| 812 | |
| 813 | void kill(const TaskID& _taskId, const Option<KillPolicy>& override = None()) |
| 814 | { |
| 815 | // Cancel the taskCompletionTimer if it is set and ongoing. |
| 816 | if (taskCompletionTimer.isSome()) { |
| 817 | Clock::cancel(taskCompletionTimer.get()); |
| 818 | taskCompletionTimer = None(); |
| 819 | } |
| 820 | |
| 821 | // Default grace period is set to 3s for backwards compatibility. |
| 822 | // |
| 823 | // TODO(alexr): Replace it with a more meaningful default, e.g. |
| 824 | // `shutdownGracePeriod` after the deprecation cycle, started in 1.0. |
| 825 | Duration gracePeriod = Seconds(3); |
| 826 | |
| 827 | // Kill policy provided in the `Kill` event takes precedence |
| 828 | // over kill policy specified when the task was launched. |
| 829 | if (override.isSome() && override->has_grace_period()) { |
| 830 | gracePeriod = Nanoseconds(override->grace_period().nanoseconds()); |
| 831 | } else if (killPolicy.isSome() && killPolicy->has_grace_period()) { |
| 832 | gracePeriod = Nanoseconds(killPolicy->grace_period().nanoseconds()); |
| 833 | } |
| 834 | |
| 835 | LOG(INFO) << "Received kill for task " << _taskId.value() |
| 836 | << " with grace period of " << gracePeriod; |
| 837 | |
| 838 | kill(_taskId, gracePeriod); |
| 839 | } |
| 840 | |
| 841 | void shutdown() |
| 842 | { |
no test coverage detected