// TaskInfo gives info about a given task
162220
func (w *Worker) TaskInfo(taskId string) (task TaskInfo, err error) {
	out := TaskInfo{}
	err = w.tasks(taskId).Req("GET", nil, &out)
	return out, err
}
1065951
func taskDefinitionToProcess(td *ecs.TaskDefinition) (*twelvefactor.Process, error) {
	// If this task definition has no container definitions, then something
	// funky is up.
	if len(td.ContainerDefinitions) == 0 {
		return nil, errors.New("task definition had no container definitions")
	}

	container := td.ContainerDefinitions[0]

	var command []string
	for _, s := range container.Command {
		command = append(command, *s)
	}

	env := make(map[string]string)
	for _, kvp := range container.Environment {
		if kvp != nil {
			env[aws.StringValue(kvp.Name)] = aws.StringValue(kvp.Value)
		}
	}

	return &twelvefactor.Process{
		Type:      aws.StringValue(container.Name),
		Command:   command,
		Env:       env,
		CPUShares: uint(*container.Cpu),
		Memory:    uint(*container.Memory) * bytesize.MB,
		Nproc:     uint(softLimit(container.Ulimits, "nproc")),
	}, nil
}
747165
func (d *PendingDeployment) GetInfo() map[string]string {
	d.mutex.RLock()
	defer d.mutex.RUnlock()
	status, _ := d.status.Get()
	return map[string]string{
		"TemplateID":   d.templateID,
		"templateName": d.templateName,
		"PoolID":       d.poolID,
		"DeploymentID": d.deploymentID,
		"status":       status.(string),
	}
}
1004275
func (c oauthClient) Task(taskID uint) (wl.Task, error) {
	url := fmt.Sprintf(
		"%s/tasks/%d",
		c.apiURL,
		taskID,
	)

	req, err := c.newGetRequest(url)
	if err != nil {
		return wl.Task{}, err
	}

	resp, err := c.do(req)
	if err != nil {
		return wl.Task{}, err
	}

	if resp.StatusCode != http.StatusOK {
		return wl.Task{}, fmt.Errorf("Unexpected response code %d - expected %d", resp.StatusCode, http.StatusOK)
	}

	task := transportTask{}
	err = json.NewDecoder(resp.Body).Decode(&task)
	if err != nil {
		return wl.Task{}, err
	}
	return taskFromTransport(task)
}
305133
func TaskInspect(id string) (task swarm.Task, raw []byte, err error) {
	err = mgr.Do(func(ctx context.Context, cli *client.Client) (err error) {
		task, raw, err = cli.TaskInspectWithRaw(ctx, id)
		return
	})
	return
}
673138
func CpuInfo(cpu int, property string) string {
	if cpuInfo == nil {
		loadCpuInfo()
	}

	return cpuInfo[fmt.Sprintf("%d:%s", cpu, property)]
}
962912
func (s *globalTaskService) TaskWaitC(taskID int) <-chan int {
	c := make(chan int)

	go func() {
		defer close(c)

		s.RLock()
		t, ok := s.tasks[taskID]
		s.RUnlock()

		if !ok {
			return
		}

		// remove the task from the queue after a configured about of time
		defer s.taskRemoveAfter(t)

		// signal that the task is complete
		<-t.done
	}()

	return c
}
1068600
func (c *Client) StackInfo(stackIdentity string) (*Stack, error) {
	var stack Stack
	return &stack, c.Get(&stack, "/stacks/"+stackIdentity)
}
1068416
func (s *globalTaskService) Tasks() <-chan *types.Task {
	tasks := []*types.Task{}
	s.RLock()
	for _, v := range s.tasks {
		tasks = append(tasks, &v.Task)
	}
	s.RUnlock()

	c := make(chan *types.Task)
	go func() {
		for _, t := range tasks {
			c <- t
		}
		close(c)
	}()
	return c
}
50838
func (l *intLogger) IsInfo() bool {
	return Level(atomic.LoadInt32(l.level)) <= Info
}
946784
func (_m *APIClient) TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) {
	ret := _m.Called(ctx, options)

	var r0 []swarm.Task
	if rf, ok := ret.Get(0).(func(context.Context, types.TaskListOptions) []swarm.Task); ok {
		r0 = rf(ctx, options)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).([]swarm.Task)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(context.Context, types.TaskListOptions) error); ok {
		r1 = rf(ctx, options)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
269049
func (e *Explain) prepareOperatorInfo(p PhysicalPlan, taskType string, indent string, isLastChild bool) {
	operatorInfo := p.ExplainInfo()
	count := string(strconv.AppendFloat([]byte{}, p.statsInfo().RowCount, 'f', 2, 64))
	explainID := p.ExplainID().String()
	row := []string{e.prettyIdentifier(explainID, indent, isLastChild), count, taskType, operatorInfo}
	if e.Analyze {
		runtimeStatsColl := e.ctx.GetSessionVars().StmtCtx.RuntimeStatsColl
		// There maybe some mock information for cop task to let runtimeStatsColl.Exists(p.ExplainID()) is true.
		// So check copTaskExecDetail first and print the real cop task information if it's not empty.
		if runtimeStatsColl.ExistsCopStats(explainID) {
			row = append(row, runtimeStatsColl.GetCopStats(explainID).String())
		} else if runtimeStatsColl.ExistsRootStats(explainID) {
			row = append(row, runtimeStatsColl.GetRootStats(explainID).String())
		} else {
			row = append(row, "time:0ns, loops:0, rows:0")
		}
	}
	e.Rows = append(e.Rows, row)
}
117968
func (prj *Project) ProjectInfo() *ProjectInfo {
	website, _ := url.Parse(prj.Website.String)
	photo, _ := url.Parse(prj.Photo.String)

	return &ProjectInfo{
		ID:               prj.ID(),
		Owner:            prj.Owner(),
		Members:          prj.Members(),
		NumericMembers:   prj.NumericMembers(),
		Followers:        prj.Followers(),
		NumericFollowers: prj.NumericFollowers(),
		Description:      prj.Description,
		Name:             prj.Name,
		Photo:            photo,
		Website:          website,
		Goal:             prj.Goal,
		Visible:          prj.Visible,
		Private:          prj.Private,
		Open:             prj.Open}
}
505423
func (s *globalTaskService) TaskTrack(ctx types.Context) *types.Task {
	return &s.taskTrack(ctx).Task
}
1076511
func taskInTerminalState(task *api.Task) bool {
	return task.Status.State > api.TaskStateRunning
}
344948
func (a Allocation) RescheduleInfo(t time.Time) (int, int) {
	var reschedulePolicy *ReschedulePolicy
	for _, tg := range a.Job.TaskGroups {
		if *tg.Name == a.TaskGroup {
			reschedulePolicy = tg.ReschedulePolicy
		}
	}
	if reschedulePolicy == nil {
		return 0, 0
	}
	availableAttempts := *reschedulePolicy.Attempts
	interval := *reschedulePolicy.Interval
	attempted := 0

	// Loop over reschedule tracker to find attempts within the restart policy's interval
	if a.RescheduleTracker != nil && availableAttempts > 0 && interval > 0 {
		for j := len(a.RescheduleTracker.Events) - 1; j >= 0; j-- {
			lastAttempt := a.RescheduleTracker.Events[j].RescheduleTime
			timeDiff := t.UTC().UnixNano() - lastAttempt
			if timeDiff < interval.Nanoseconds() {
				attempted += 1
			}
		}
	}
	return attempted, availableAttempts
}
1188985
func (cli *Client) TaskList(ctx context.Context, options types.TaskListOptions) ([]swarm.Task, error) {
	query := url.Values{}

	if options.Filter.Len() > 0 {
		filterJSON, err := filters.ToParam(options.Filter)
		if err != nil {
			return nil, err
		}

		query.Set("filters", filterJSON)
	}

	resp, err := cli.get(ctx, "/tasks", query, nil)
	if err != nil {
		return nil, err
	}

	var tasks []swarm.Task
	err = json.NewDecoder(resp.body).Decode(&tasks)
	ensureReaderClosed(resp)
	return tasks, err
}