<ol>
<li>Delete task</li>
</ol>
<p>Task deletion by sending Mesos Call_KILL protobuf package,with the task ID attached which was supposed to be killed.</p>
<pre><code>func (s *Scheduler) KillTask(task *types.Task)(*http.Response, error) {
call := &sched.Call{
FrameworkId: s.framework.GetId(),
Type: sched.Call_KILL.Enum(),
Kill: &sched.Call_Kill{
TaskId: &mesos.TaskID{
Value: proto.String(task.ID),
},
AgentId: &mesos.AgentID{
Value: task.AgentId,
},
},
}
duration := proto.Int64(task.KillPolicy.Duration * 1000 * 1000)
if task.KillPolicy != nil {
if task.KillPolicy.Duration != 0 {
call.Kill.KillPolicy = &mesos.KillPolicy{
GracePeriod: &mesos.DurationInfo{
Nanoseconds: duration,
},
}
}
}
return s.send(call)
}
</code></pre>
<p><code>Type</code> means the type of protobuf package .FrameworkId appoints the ID that current framework was registered in, <code>Mesos.task.ID</code> indicates the task ID that need to be kiled and <code>task.AgentId</code> appoints the agentId of the task need to be killed. </p>
<p>killPolicy is a customized policy about graceful termination. During the process of graceful termination, Mesos will send the task a SIGTERM signal indicates that the very task is supposed to be exit. If the task does not exit as expected within a certain interval, SIGKILL will be send to the task to kill it by force, the interval can be changed by the <code>duration</code> field in the message, default value is 3s.</p>
<p>more details please go to:<a href="https://github.com/Dataman-Cloud/swan">https://github.com/Dataman-Cloud/swan</a></p>
<p><a href="https://www.reddit.com/r/golang/comments/5ofhwl/how_to_write_a_mesos_framework3/">How to write a mesos framework (3)</a></p>
<p><a href="https://www.reddit.com/r/golang/comments/5md143/how_to_write_a_mesos_framework_2/">How to write a mesos framework (2)</a></p>
<p><a href="https://www.reddit.com/r/mesos/comments/5kdb52/how_to_write_a_mesos_framework_1/">How to write a mesos framework (1)</a></p>
这是一个分享于 的资源,其中的信息可能已经有所发展或是发生改变。
入群交流(和以上内容无关):加入Go大咖交流群,或添加微信:liuxiaoyan-s 备注:入群;或加QQ群:692541889
0 回复
- 请尽量让自己的回复能够对别人有帮助
- 支持 Markdown 格式, **粗体**、~~删除线~~、
`单行代码`
- 支持 @ 本站用户;支持表情(输入 : 提示),见 Emoji cheat sheet
- 图片支持拖拽、截图粘贴等方式上传