本文整理汇总了Golang中github.com/mesos/mesos-go/mesosproto.TaskStatus.GetTaskId方法的典型用法代码示例。如果您正苦于以下问题:Golang TaskStatus.GetTaskId方法的具体用法?Golang TaskStatus.GetTaskId怎么用?Golang TaskStatus.GetTaskId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/mesos/mesos-go/mesosproto.TaskStatus
的用法示例。
在下文中一共展示了TaskStatus.GetTaskId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: StatusUpdate
func (sched *NoneScheduler) StatusUpdate(driver sched.SchedulerDriver, status *mesos.TaskStatus) {
taskId := status.GetTaskId().GetValue()
log.Infoln("Status update: task", taskId, "is in state", status.State.Enum().String())
c := sched.queue.GetCommandById(taskId)
if c == nil {
log.Errorln("Unable to find command for task", taskId)
driver.Abort()
}
if c.Status.GetState() == status.GetState() {
// ignore repeated status updates
return
}
c.Status = status
// send status update to CommandHandler
if status.GetState() == mesos.TaskState_TASK_RUNNING {
sched.handler.CommandRunning(c)
} else if status.GetState() == mesos.TaskState_TASK_FINISHED {
sched.handler.CommandEnded(c)
sched.handler.CommandFinished(c)
} else if status.GetState() == mesos.TaskState_TASK_FAILED ||
status.GetState() == mesos.TaskState_TASK_LOST ||
status.GetState() == mesos.TaskState_TASK_KILLED {
sched.handler.CommandEnded(c)
sched.handler.CommandFailed(c)
}
// stop if Commands channel was closed and all tasks are finished
if sched.queue.Closed() && !sched.handler.HasRunningTasks() {
log.Infoln("All tasks finished, stopping framework.")
sched.handler.FinishAllCommands()
driver.Stop(false)
}
}
示例2: StatusUpdate
func (sched *testScheduler) StatusUpdate(dr SchedulerDriver, stat *mesos.TaskStatus) {
log.Infoln("Sched.StatusUpdate() called.")
sched.s.NotNil(stat)
sched.s.Equal("test-task-001", stat.GetTaskId().GetValue())
sched.wg.Done()
log.Infof("Status update done with waitGroup")
}
示例3: UpdateStatus
func (k *inMemoryRegistry) UpdateStatus(status *mesos.TaskStatus) (*T, StateType) {
taskId := status.GetTaskId().GetValue()
k.rw.Lock()
defer k.rw.Unlock()
task, state := k._get(taskId)
switch status.GetState() {
case mesos.TaskState_TASK_STAGING:
k.handleTaskStaging(task, state, status)
case mesos.TaskState_TASK_STARTING:
k.handleTaskStarting(task, state, status)
case mesos.TaskState_TASK_RUNNING:
k.handleTaskRunning(task, state, status)
case mesos.TaskState_TASK_FINISHED:
k.handleTaskFinished(task, state, status)
case mesos.TaskState_TASK_FAILED:
k.handleTaskFailed(task, state, status)
case mesos.TaskState_TASK_ERROR:
k.handleTaskError(task, state, status)
case mesos.TaskState_TASK_KILLED:
k.handleTaskKilled(task, state, status)
case mesos.TaskState_TASK_LOST:
k.handleTaskLost(task, state, status)
default:
log.Warningf("unhandled status update for task: %v", taskId)
}
return task.Clone(), state
}
示例4: StatusUpdate
// mesos.Scheduler interface method.
// Invoked when the status of a task has changed.
func (this *TransformScheduler) StatusUpdate(driver scheduler.SchedulerDriver, status *mesos.TaskStatus) {
fmt.Printf("Status update: task %s is in state %s\n", status.TaskId.GetValue(), status.State.Enum().String())
if status.GetState() == mesos.TaskState_TASK_LOST || status.GetState() == mesos.TaskState_TASK_FAILED || status.GetState() == mesos.TaskState_TASK_FINISHED {
this.removeTask(status.GetTaskId())
this.decRunningInstances()
}
}
示例5: Update
func (r *Reconciler) Update(status *mesos.TaskStatus) {
r.taskLock.Lock()
defer r.taskLock.Unlock()
delete(r.tasks, status.GetTaskId().GetValue())
if len(r.tasks) == 0 {
r.reconciles = 0
}
}
示例6: updateTaskState
func (ctx *RunOnceApplicationContext) updateTaskState(status *mesos.TaskStatus) {
for _, task := range ctx.tasks {
if task.TaskID == status.GetTaskId().GetValue() {
task.State = status.GetState()
return
}
}
framework.Logger.Warn("Got unexpected status update for unknown task with ID %s", status.GetTaskId().GetValue())
}
示例7: onTaskFailed
func (s *Scheduler) onTaskFailed(id string, status *mesos.TaskStatus) {
if s.cluster.Exists(id) {
task := s.cluster.Get(id)
if task.Data().State != TaskStateInactive {
task.Data().State = TaskStateStopped
}
} else {
Logger.Infof("Got %s for unknown/stopped task %s", pretty.Status(status), status.GetTaskId().GetValue())
}
}
示例8: StatusUpdate
func (s *Scheduler) StatusUpdate(driver scheduler.SchedulerDriver, status *mesos.TaskStatus) {
Logger.Infof("[StatusUpdate] %s", statusString(status))
slave := s.slaveFromTaskId(status.GetTaskId().GetValue())
if status.GetState() == mesos.TaskState_TASK_FAILED || status.GetState() == mesos.TaskState_TASK_KILLED ||
status.GetState() == mesos.TaskState_TASK_LOST || status.GetState() == mesos.TaskState_TASK_ERROR ||
status.GetState() == mesos.TaskState_TASK_FINISHED {
s.cluster.Remove(slave)
}
}
示例9: StatusUpdate
func (sched *Scheduler) StatusUpdate(driver sched.SchedulerDriver, status *mesos.TaskStatus) {
if glog.V(1) {
glog.Infof("status update from task %s in state %s under executor %s on slave %s: %s",
status.GetTaskId().GetValue(),
status.GetState(),
status.GetExecutorId().GetValue(),
status.GetSlaveId().GetValue(),
status.GetMessage(),
)
}
}
示例10: statusString
func statusString(status *mesos.TaskStatus) string {
s := fmt.Sprintf("%s %s slave: %s", status.GetTaskId().GetValue(), status.GetState().String(), idString(status.GetSlaveId().GetValue()))
if status.GetState() != mesos.TaskState_TASK_RUNNING {
s += " reason: " + status.GetReason().String()
}
if status.GetMessage() != "" {
s += " message: " + status.GetMessage()
}
return s
}
示例11: StatusUpdate
func (r *RunOnceRunner) StatusUpdate(driver scheduler.SchedulerDriver, status *mesos.TaskStatus) bool {
r.applicationLock.Lock()
defer r.applicationLock.Unlock()
applicationID := applicationIDFromTaskID(status.GetTaskId().GetValue())
ctx, exists := r.applications[applicationID]
if !exists {
// this status update was not for run once application, just let it go
return false
}
if ctx.StatusUpdate(driver, status) {
delete(r.applications, applicationID)
}
return true
}
示例12: handleTaskFinished
func (k *inMemoryRegistry) handleTaskFinished(task *T, state StateType, status *mesos.TaskStatus) {
taskId := status.GetTaskId().GetValue()
switch state {
case StatePending:
panic(fmt.Sprintf("Pending task %v finished, this couldn't happen", taskId))
case StateRunning:
log.V(2).Infof("received finished status for running task: %v", taskId)
delete(k.podToTask, task.podKey)
task.State = StateFinished
task.UpdatedTime = time.Now()
k.tasksFinished = k.recordFinishedTask(task.ID)
case StateFinished:
log.Warningf("Ignore status TASK_FINISHED because the task %v is already finished", taskId)
default:
log.Warningf("Ignore status TASK_FINISHED because the task %v is not running", taskId)
}
}
示例13: handleTaskRunning
func (k *inMemoryRegistry) handleTaskRunning(task *T, state StateType, status *mesos.TaskStatus) {
taskId := status.GetTaskId().GetValue()
switch state {
case StatePending:
task.UpdatedTime = time.Now()
log.Infof("Received running status for pending task: %v", taskId)
fillRunningPodInfo(task, status)
task.State = StateRunning
case StateRunning:
task.UpdatedTime = time.Now()
log.V(2).Infof("Ignore status TASK_RUNNING because the task %v is already running", taskId)
case StateFinished:
log.Warningf("Ignore status TASK_RUNNING because the task %v is already finished", taskId)
default:
log.Warningf("Ignore status TASK_RUNNING because the task %v is discarded", taskId)
}
}
示例14: handleTaskStarting
func (k *inMemoryRegistry) handleTaskStarting(task *T, state StateType, status *mesos.TaskStatus) {
// we expect to receive this when a launched task is finally "bound"
// via the API server. however, there's nothing specific for us to do here.
switch state {
case StatePending:
task.UpdatedTime = time.Now()
if !task.Has(Bound) {
task.Set(Bound)
task.bindTime = task.UpdatedTime
timeToBind := task.bindTime.Sub(task.launchTime)
metrics.BindLatency.Observe(metrics.InMicroseconds(timeToBind))
}
default:
taskId := status.GetTaskId().GetValue()
log.Warningf("Ignore status TASK_STARTING because the task %v is not pending", taskId)
}
}
示例15: StatusUpdate
func (s *Scheduler) StatusUpdate(driver scheduler.SchedulerDriver, status *mesos.TaskStatus) {
Logger.Infof("[StatusUpdate] %s", pretty.Status(status))
id := s.idFromTaskId(status.GetTaskId().GetValue())
switch status.GetState() {
case mesos.TaskState_TASK_RUNNING:
s.onTaskStarted(id, status)
case mesos.TaskState_TASK_LOST, mesos.TaskState_TASK_FAILED, mesos.TaskState_TASK_ERROR:
s.onTaskFailed(id, status)
case mesos.TaskState_TASK_FINISHED, mesos.TaskState_TASK_KILLED:
s.onTaskFinished(id, status)
default:
Logger.Warnf("Got unexpected task state %s for task %s", pretty.Status(status), id)
}
s.cluster.Save()
}