MCPcopy Create free account
hub / github.com/apache/mesos / kill

Method kill

src/slave/slave.cpp:4112–4262  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4110
4111
4112void Slave::kill(
4113 const FrameworkID& frameworkId,
4114 Framework* framework,
4115 Executor* executor,
4116 const TaskID& taskId,
4117 const Option<KillPolicy>& killPolicy)
4118{
4119 // This function should only be called on tasks which are queued or launched,
4120 // so both the framework and executor should always exist.
4121 CHECK_NOTNULL(framework);
4122 CHECK_NOTNULL(executor);
4123
4124 switch (executor->state) {
4125 case Executor::REGISTERING: {
4126 LOG(WARNING) << "Transitioning the state of task " << taskId
4127 << " of framework " << frameworkId
4128 << " to TASK_KILLED because the executor is not registered";
4129
4130 // This task might be part of a task group. If so, we need to
4131 // send a TASK_KILLED update for all tasks in the group.
4132 Option<TaskGroupInfo> taskGroup = executor->getQueuedTaskGroup(taskId);
4133
4134 vector<StatusUpdate> updates;
4135 if (taskGroup.isSome()) {
4136 foreach (const TaskInfo& task, taskGroup->tasks()) {
4137 updates.push_back(protobuf::createStatusUpdate(
4138 frameworkId,
4139 info.id(),
4140 task.task_id(),
4141 TASK_KILLED,
4142 TaskStatus::SOURCE_SLAVE,
4143 id::UUID::random(),
4144 "A task within the task group was killed before"
4145 " delivery to the executor",
4146 TaskStatus::REASON_TASK_KILLED_DURING_LAUNCH,
4147 executor->id));
4148 }
4149 } else {
4150 updates.push_back(protobuf::createStatusUpdate(
4151 frameworkId,
4152 info.id(),
4153 taskId,
4154 TASK_KILLED,
4155 TaskStatus::SOURCE_SLAVE,
4156 id::UUID::random(),
4157 "Killed before delivery to the executor",
4158 TaskStatus::REASON_TASK_KILLED_DURING_LAUNCH,
4159 executor->id));
4160 }
4161
4162 foreach (const StatusUpdate& update, updates) {
4163 // NOTE: Sending a terminal update (TASK_KILLED) removes the
4164 // task/task group from 'executor->queuedTasks' and
4165 // 'executor->queuedTaskGroup', so that if the executor registers at
4166 // a later point in time, it won't get this task or task group.
4167 statusUpdate(update, UPID());
4168 }
4169

Callers 7

_killContainerMethod · 0.45
foreachFunction · 0.45
sendMethod · 0.45
cleanupMethod · 0.45
mainFunction · 0.45
__del__Method · 0.45
mainFunction · 0.45

Calls 11

createStatusUpdateFunction · 0.85
randomFunction · 0.85
getQueuedTaskGroupMethod · 0.80
everSentTaskMethod · 0.80
MergeFromMethod · 0.80
sendMethod · 0.65
isSomeMethod · 0.45
idMethod · 0.45
containsMethod · 0.45
emptyMethod · 0.45
getMethod · 0.45

Tested by 2

__del__Method · 0.36
mainFunction · 0.36