本文整理汇总了Golang中github.com/mesos/mesos-go/mesosproto.TaskStatus类的典型用法代码示例。如果您正苦于以下问题:Golang TaskStatus类的具体用法?Golang TaskStatus怎么用?Golang TaskStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了TaskStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: 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
}
示例2: StatusUpdate
func (sched *MesosRunonceScheduler) StatusUpdate(driver sched.SchedulerDriver, status *mesos.TaskStatus) {
log.V(1).Infoln("Status update: task", status.TaskId.GetValue(), " is in state ", status.State.Enum().String())
eventCh <- status
if status.GetState() == mesos.TaskState_TASK_FINISHED {
sched.tasksFinished++
}
if sched.tasksFinished >= sched.totalTasks {
log.V(1).Infoln("Total tasks completed, stopping framework.")
driver.Stop(false)
}
if status.GetState() == mesos.TaskState_TASK_LOST ||
status.GetState() == mesos.TaskState_TASK_KILLED ||
status.GetState() == mesos.TaskState_TASK_FAILED ||
status.GetState() == mesos.TaskState_TASK_ERROR {
exitStatus = 1
log.Warningf("mesos TaskStatus: %v", status)
driver.Stop(false)
log.Errorln(
"Aborting because task", status.TaskId.GetValue(),
"is in unexpected state", status.State.String(),
"with message.", status.GetMessage(),
)
}
}
示例3: 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")
}
示例4: StatusUpdate
func (sched *SdcScheduler) StatusUpdate(driver sched.SchedulerDriver, status *mesos.TaskStatus) {
log.Infoln("Status update: task", status.TaskId.GetValue(), " is in state ", status.State.Enum().String())
if status.GetState() == mesos.TaskState_TASK_FINISHED {
sched.tasksFinished++
// KillTaskを実行するとTASK_LOSTが検知され、フレームワークが止まる
// driver.KillTask(status.TaskId)
// log.Infoln("!! Status update: task", status.TaskId.GetValue(), " is in state ", status.State.Enum().String())
// return
}
if sched.tasksFinished >= sched.totalTasks {
// log.Infoln("Total tasks completed, stopping framework.")
log.Infoln("Total tasks completed.")
sched.tasksFinished = 0
sched.totalTasks = 0
sched.tasksLaunched = 0
// driver.Stop(false)
}
if status.GetState() == mesos.TaskState_TASK_LOST ||
status.GetState() == mesos.TaskState_TASK_KILLED ||
status.GetState() == mesos.TaskState_TASK_FAILED ||
status.GetState() == mesos.TaskState_TASK_ERROR {
log.Infoln(
"Aborting because task", status.TaskId.GetValue(),
"is in unexpected state", status.State.String(),
"with message", status.GetMessage(),
)
driver.Abort()
}
}
示例5: StatusUpdate
func (sched *Scheduler) StatusUpdate(driver sched.SchedulerDriver, status *mesos.TaskStatus) {
log.Infoln("Status update: task", status.TaskId.GetValue(), " is in state ", status.State.Enum().String())
if status.GetState() == mesos.TaskState_TASK_FINISHED {
sched.tasksFinished++
log.Infoln("%v of %v tasks finished.", sched.tasksFinished, sched.totalTasks)
}
//TODO if a job is finished, failed, error, lost, killed
// figure out how this impacts dependent jobs and update job graph
/*
//never shut down framework!
if sched.tasksFinished >= sched.totalTasks {
log.Infoln("Total tasks completed, stopping framework.")
driver.Stop(false)
}
*/
/*
if status.GetState() == mesos.TaskState_TASK_LOST ||
status.GetState() == mesos.TaskState_TASK_KILLED ||
status.GetState() == mesos.TaskState_TASK_FAILED {
log.Infoln(
"Aborting because task", status.TaskId.GetValue(),
"is in unexpected state", status.State.String(),
"with message", status.GetMessage(),
)
driver.Abort()
}
*/
}
示例6: StatusUpdate
func (sched *ExampleScheduler) StatusUpdate(driver sched.SchedulerDriver, status *mesos.TaskStatus) {
log.Infoln("Status update: task", status.TaskId.GetValue(), " is in state ", status.State.Enum().String())
//if RunContainer finished, add
if status.State.Enum().String() == "TASK_FINISHED" {
labels := status.GetLabels()
taskType, err := shared.GetValueFromLabels(labels, shared.Tags.TASK_TYPE)
if err != nil {
log.Infof("ERROR: Malformed task info, discarding task with status: %v", status)
return
}
acceptedHost, err := shared.GetValueFromLabels(labels, shared.Tags.ACCEPTED_HOST)
if err != nil {
log.Infof("ERROR: Malformed task info, discarding task with status: %v", status)
return
}
containerName, err := shared.GetValueFromLabels(labels, shared.Tags.CONTAINER_NAME)
if err != nil {
log.Infof("ERROR: Malformed task info, discarding task with status: %v", status)
return
}
switch taskType {
case shared.TaskTypes.RUN_CONTAINER:
sched.ContainerSlaveMap[containerName] = acceptedHost
break
case shared.TaskTypes.CHECKPOINT_CONTAINER:
delete(sched.ContainerSlaveMap, containerName)
break
case shared.TaskTypes.RESTORE_CONTAINER:
sched.ContainerSlaveMap[containerName] = acceptedHost
break
}
}
}
示例7: StatusUpdate
func (sched *Scheduler) StatusUpdate(driver sched.SchedulerDriver, status *mesos.TaskStatus) {
log.Infoln("Status update: task", status.TaskId.GetValue(), " is in state ", status.State.Enum().String())
if status.GetState() == mesos.TaskState_TASK_FINISHED {
sched.tasksFinished++
log.Infoln("%v of %v tasks finished.", sched.tasksFinished, sched.totalTasks)
}
}
示例8: StatusUpdate
// StatusUpdate is called when a status update message is sent to the scheduler.
func (k *KubernetesScheduler) StatusUpdate(driver bindings.SchedulerDriver, taskStatus *mesos.TaskStatus) {
source, reason := "none", "none"
if taskStatus.Source != nil {
source = (*taskStatus.Source).String()
}
if taskStatus.Reason != nil {
reason = (*taskStatus.Reason).String()
}
taskState := taskStatus.GetState()
metrics.StatusUpdates.WithLabelValues(source, reason, taskState.String()).Inc()
log.Infof(
"task status update %q from %q for task %q on slave %q executor %q for reason %q",
taskState.String(),
source,
taskStatus.TaskId.GetValue(),
taskStatus.SlaveId.GetValue(),
taskStatus.ExecutorId.GetValue(),
reason)
switch taskState {
case mesos.TaskState_TASK_RUNNING, mesos.TaskState_TASK_FINISHED, mesos.TaskState_TASK_STARTING, mesos.TaskState_TASK_STAGING:
if _, state := k.taskRegistry.UpdateStatus(taskStatus); state == podtask.StateUnknown {
if taskState != mesos.TaskState_TASK_FINISHED {
//TODO(jdef) what if I receive this after a TASK_LOST or TASK_KILLED?
//I don't want to reincarnate then.. TASK_LOST is a special case because
//the master is stateless and there are scenarios where I may get TASK_LOST
//followed by TASK_RUNNING.
//TODO(jdef) consider running this asynchronously since there are API server
//calls that may be made
k.reconcileNonTerminalTask(driver, taskStatus)
} // else, we don't really care about FINISHED tasks that aren't registered
return
}
if _, exists := k.slaves.getSlave(taskStatus.GetSlaveId().GetValue()); !exists {
// a registered task has an update reported by a slave that we don't recognize.
// this should never happen! So we don't reconcile it.
log.Errorf("Ignore status %+v because the slave does not exist", taskStatus)
return
}
case mesos.TaskState_TASK_FAILED:
if task, _ := k.taskRegistry.UpdateStatus(taskStatus); task != nil {
if task.Has(podtask.Launched) && !task.Has(podtask.Bound) {
go k.plugin.reconcilePod(task.Pod)
return
}
} else {
// unknown task failed, not much we can do about it
return
}
// last-ditch effort to reconcile our records
fallthrough
case mesos.TaskState_TASK_LOST, mesos.TaskState_TASK_KILLED:
k.reconcileTerminalTask(driver, taskStatus)
}
}
示例9: 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
}
}
示例10: 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())
}
}
示例11: 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(),
)
}
}
示例12: 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)
}
}
示例13: fillRunningPodInfo
func fillRunningPodInfo(task *T, taskStatus *mesos.TaskStatus) {
if taskStatus.GetReason() == mesos.TaskStatus_REASON_RECONCILIATION && taskStatus.GetSource() == mesos.TaskStatus_SOURCE_MASTER {
// there is no data..
return
}
//TODO(jdef) determine the usefullness of this information (if any)
if result, err := ParsePodStatusResult(taskStatus); err != nil {
log.Errorf("invalid TaskStatus.Data for task '%v': %v", task.ID, err)
} else {
task.podStatus = result.Status
log.Infof("received pod status for task %v: %+v", task.ID, result.Status)
}
}
示例14: StatusUpdate
// StatusUpdate handles status updates messages received from Mesos master
//
// Currently this method only logs status updates. This might change in the future
func (bw *BasicWorker) StatusUpdate(driver scheduler.SchedulerDriver, status *mesos.TaskStatus) {
taskId := status.TaskId.GetValue()
taskStatus := status.GetState()
log.Println("Task", taskId, "is in state", taskStatus.String())
switch taskStatus {
case mesos.TaskState_TASK_RUNNING:
log.Printf("Marking task %s as %s", taskId, taurus.RUNNING)
case mesos.TaskState_TASK_KILLED, mesos.TaskState_TASK_FINISHED,
mesos.TaskState_TASK_FAILED, mesos.TaskState_TASK_LOST:
log.Printf("Marking task %s as %s", taskId, taurus.STOPPED)
}
}
示例15: testErrorStatus
func testErrorStatus(t *testing.T, ctx *RunOnceApplicationContext, driver *mesostest.MockSchedulerDriver, status *mesos.TaskStatus) {
appDone := ctx.StatusUpdate(driver, status)
So(appDone, ShouldBeTrue)
select {
case sts := <-ctx.StatusChan:
So(sts.Error, ShouldNotBeNil)
So(sts.Error.Error(), ShouldContainSubstring, "failed to run on host")
default:
t.Fail()
}
So(ctx.tasks[0].State, ShouldEqual, status.GetState())
}