//LaunchTask is an implementation required by Mesos
LaunchTask is an implementation required by Mesos
// LaunchTask is an implementation required by Mesos
func (e *exampleExecutor) LaunchTask(driver executor.ExecutorDriver, taskInfo *mesosproto.TaskInfo) {
	fmt.Printf("Launching task %v with data [%#x]\n", taskInfo.GetName(), taskInfo.Data)
	var port string
	for _, resource := range taskInfo.Resources {
		if resource.GetName() == "ports" {
			port = strconv.FormatUint(resource.GetRanges().GetRange()[0].GetBegin(), 10)
		}
	}
	runStatus := &mesosproto.TaskStatus{
		TaskId: taskInfo.GetTaskId(),
		State:  mesosproto.TaskState_TASK_RUNNING.Enum(),
	}
	_, err := driver.SendStatusUpdate(runStatus)
	if err != nil {
		fmt.Println("Got error", err)
	}
	launchMyServer(taskInfo.Data, port)
	fmt.Println("Finishing task", taskInfo.GetName())
	finStatus := &mesosproto.TaskStatus{
		TaskId: taskInfo.GetTaskId(),
		State:  mesosproto.TaskState_TASK_FINISHED.Enum(),
	}
	_, err = driver.SendStatusUpdate(finStatus)
	if err != nil {
		fmt.Println("Got error", err)
		return
	}
	fmt.Println("Task finished", taskInfo.GetName())
}
func ( e * exampleExecutor ) LaunchTask ( driver executor . ExecutorDriver , taskInfo * mesosproto . TaskInfo ) { fmt . Printf ( " \n " , taskInfo . GetName ( ) , taskInfo . Data ) var port string for _ , resource := range taskInfo . Resources { if resource . GetName ( ) == " " { port = strconv . FormatUint ( resource . GetRanges ( ) . GetRange ( ) [ 0 ] . GetBegin ( ) , 10 ) } } runStatus := & mesosproto . TaskStatus { TaskId : taskInfo . GetTaskId ( ) , State : mesosproto . TaskState_TASK_RUNNING . Enum ( ) , } _ , err := driver . SendStatusUpdate ( runStatus ) if err != nil { fmt . Println ( " " , err ) } launchMyServer ( taskInfo . Data , port ) fmt . Println ( " " , taskInfo . GetName ( ) ) finStatus := & mesosproto . TaskStatus { TaskId : taskInfo . GetTaskId ( ) , State : mesosproto . TaskState_TASK_FINISHED . Enum ( ) , } _ , err = driver . SendStatusUpdate ( finStatus ) if err != nil { fmt . Println ( " " , err ) return } fmt . Println ( " " , taskInfo . GetName ( ) ) }
LaunchTask is an implementation required by Mesos
LaunchTask is an implementation required by Mesos
//Send a status update to the scheduler //Send a status update to the scheduler