本文整理匯總了Golang中github.com/mesos/mesos-go/mesosproto.TaskInfo.GetSlaveId方法的典型用法代碼示例。如果您正苦於以下問題:Golang TaskInfo.GetSlaveId方法的具體用法?Golang TaskInfo.GetSlaveId怎麽用?Golang TaskInfo.GetSlaveId使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/mesos/mesos-go/mesosproto.TaskInfo
的用法示例。
在下文中一共展示了TaskInfo.GetSlaveId方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: LaunchTask
func (e *Executor) LaunchTask(driver executor.ExecutorDriver, task *mesos.TaskInfo) {
Logger.Infof("[LaunchTask] %s", task)
Config.Read(task)
serializer := e.serializer(Config.Transform)
producer, err := e.newProducer(serializer) //create producer before sending the running status
if err != nil {
Logger.Errorf("Failed to create producer: %s", err)
os.Exit(1)
}
runStatus := &mesos.TaskStatus{
TaskId: task.GetTaskId(),
State: mesos.TaskState_TASK_RUNNING.Enum(),
}
if _, err := driver.SendStatusUpdate(runStatus); err != nil {
Logger.Errorf("Failed to send status update: %s", runStatus)
os.Exit(1) //TODO not sure if we should exit in this case, but probably yes
}
go func() {
//TODO configs should come from scheduler
e.reporter = NewMetricsReporter(task.GetSlaveId().GetValue(), e.slaveInfo.GetHostname(), e.slaveInfo.GetPort(), Config.ReportingInterval, producer, Config.Topic, Config.Transform)
e.reporter.Start()
// finish task
Logger.Infof("Finishing task %s", task.GetName())
finStatus := &mesos.TaskStatus{
TaskId: task.GetTaskId(),
State: mesos.TaskState_TASK_FINISHED.Enum(),
}
if _, err := driver.SendStatusUpdate(finStatus); err != nil {
Logger.Errorf("Failed to send status update: %s", finStatus)
os.Exit(1)
}
Logger.Infof("Task %s has finished", task.GetName())
}()
}