// State is used to retrieve all the checks in a given state.
// The wildcard "any" state can also be used for all checks.
972208
func (h *Health) State(state string, q *QueryOptions) (HealthChecks, *QueryMeta, error) {
	switch state {
	case HealthAny:
	case HealthWarning:
	case HealthCritical:
	case HealthPassing:
	default:
		return nil, nil, fmt.Errorf("Unsupported state: %v", state)
	}
	r := h.c.newRequest("GET", "/v1/health/state/"+state)
	r.setQueryOptions(q)
	rtt, resp, err := requireOK(h.c.doRequest(r))
	if err != nil {
		return nil, nil, err
	}
	defer resp.Body.Close()

	qm := &QueryMeta{}
	parseQueryMeta(resp, qm)
	qm.RequestTime = rtt

	var out HealthChecks
	if err := decodeBody(resp, &out); err != nil {
		return nil, nil, err
	}
	return out, qm, nil
}
965506
func (s *service) State(ctx context.Context, r *taskAPI.StateRequest) (*taskAPI.StateResponse, error) {
	log.G(ctx).Debugf("State: %s: %s", r.ID, r.ExecID)

	s.mu.Lock()
	defer s.mu.Unlock()

	var p *process
	var err error
	if p, err = s.getProcessLocked(r.ID, r.ExecID); err != nil {
		return nil, err
	}

	var tstatus string

	// This is a container
	if p.cid == p.id {
		rhcs := s.newRunhcs()
		cs, err := rhcs.State(ctx, p.id)
		if err != nil {
			return nil, err
		}
		tstatus = cs.Status
	} else {
		if p.started {
			tstatus = "running"
		} else {
			tstatus = "created"
		}
	}

	status := task.StatusUnknown
	switch tstatus {
	case "created":
		status = task.StatusCreated
	case "running":
		status = task.StatusRunning
	case "stopped":
		status = task.StatusStopped
	case "paused":
		status = task.StatusPaused
	}
	pe := p.stat()
	return &taskAPI.StateResponse{
		ID:         p.id,
		Bundle:     p.bundle,
		Pid:        pe.pid,
		Status:     status,
		Stdin:      p.stdin,
		Stdout:     p.stdout,
		Stderr:     p.stderr,
		Terminal:   p.terminal,
		ExitStatus: pe.exitStatus,
		ExitedAt:   pe.exitedAt,
	}, nil
}
878079
func (s *LogStream) State(c context.Context) *LogStreamState {
	var lst LogStreamState
	s.PopulateState(c, &lst)
	return &lst
}
1290643
func (xc *CommonExchange) state() *ExchangeState {
	xc.mtx.RLock()
	defer xc.mtx.RUnlock()
	return xc.currentState
}
897402
func (p *Process) State(ctx context.Context) (runtime.State, error) {
	// use the container status for the status of the process
	response, err := p.t.shim.State(ctx, &shim.StateRequest{
		ID: p.id,
	})
	if err != nil {
		if errors.Cause(err) != ttrpc.ErrClosed {
			return runtime.State{}, errdefs.FromGRPC(err)
		}

		// We treat ttrpc.ErrClosed as the shim being closed, but really this
		// likely means that the process no longer exists. We'll have to plumb
		// the connection differently if this causes problems.
		return runtime.State{}, errdefs.ErrNotFound
	}
	var status runtime.Status
	switch response.Status {
	case task.StatusCreated:
		status = runtime.CreatedStatus
	case task.StatusRunning:
		status = runtime.RunningStatus
	case task.StatusStopped:
		status = runtime.StoppedStatus
	case task.StatusPaused:
		status = runtime.PausedStatus
	case task.StatusPausing:
		status = runtime.PausingStatus
	}
	return runtime.State{
		Pid:        response.Pid,
		Status:     status,
		Stdin:      response.Stdin,
		Stdout:     response.Stdout,
		Stderr:     response.Stderr,
		Terminal:   response.Terminal,
		ExitStatus: response.ExitStatus,
	}, nil
}
443212
func (evpool *EvidencePool) State() sm.State {
	evpool.mtx.Lock()
	defer evpool.mtx.Unlock()
	return evpool.state
}
285048
func (p *Pod) State() string {
	switch {
	case p.isEmbryo:
		return Embryo
	case p.isPreparing:
		return Preparing
	case p.isAbortedPrepare:
		return AbortedPrepare
	case p.isPrepared:
		return Prepared
	case p.isDeleting:
		return Deleting
	case p.isExitedDeleting:
		return ExitedDeleting
	case p.isExited: // this covers p.isExitedGarbage
		if p.isExitedGarbage {
			return ExitedGarbage
		}
		return Exited
	case p.isGarbage:
		return Garbage
	}

	return Running
}
911458
func (o *PooledObject) GetState() PooledObjectState {
	o.lock.Lock()
	defer o.lock.Unlock()
	return o.state
}
1204570
func (s *service) State(ctx context.Context, r *taskAPI.StateRequest) (*taskAPI.StateResponse, error) {
	return nil, errdefs.ErrNotImplemented
}
1265049
func (d *decoder) state() json.Delim {
	if len(d.parseState) == 0 {
		return 0
	}
	return d.parseState[len(d.parseState)-1]
}
1359809
func (c *upgradeContext) State() StateBackend {
	if c.st == nil {
		panic("State not available from this context")
	}
	return c.st
}
530430
func (s *Store) State() ClusterState {
	state := s.raft.State()
	switch state {
	case raft.Leader:
		return Leader
	case raft.Candidate:
		return Candidate
	case raft.Follower:
		return Follower
	case raft.Shutdown:
		return Shutdown
	default:
		return Unknown
	}
}
303083
func (m *Milestone) State() api.StateType {
	if m.IsClosed {
		return api.STATE_CLOSED
	}
	return api.STATE_OPEN
}
1225028
func GetState(fd int) (*State, error) {
	var oldState State
	if _, _, err := syscall.Syscall6(syscall.SYS_IOCTL, uintptr(fd), ioctlReadTermios, uintptr(unsafe.Pointer(&oldState.termios)), 0, 0, 0); err != 0 {
		return nil, err
	}

	return &oldState, nil
}
837127
func (r *RepoStatus) GetState() string {
	if r == nil || r.State == nil {
		return ""
	}
	return *r.State
}
288333
func (d *Attempt_Data) State() Attempt_State {
	if d != nil {
		switch d.AttemptType.(type) {
		case *Attempt_Data_Scheduling_:
			return Attempt_SCHEDULING
		case *Attempt_Data_Executing_:
			return Attempt_EXECUTING
		case *Attempt_Data_Waiting_:
			return Attempt_WAITING
		case *Attempt_Data_Finished_:
			return Attempt_FINISHED
		case *Attempt_Data_AbnormalFinish:
			return Attempt_ABNORMAL_FINISHED
		}
	}
	return Attempt_SCHEDULING
}
1054089
func (r *ReleaseAsset) GetState() string {
	if r == nil || r.State == nil {
		return ""
	}
	return *r.State
}