// queueHealthState queues a health state Notification for processing by a
// vserver.
428649
func (h *healthcheckManager) queueHealthState(n *healthcheck.Notification) error {
	h.lock.RLock()
	cfg := h.cfgs[n.Id]
	check := h.checks[n.Id]
	h.lock.RUnlock()

	if cfg == nil || check == nil {
		log.Warningf("Unknown healthcheck ID %v", n.Id)
		return nil
	}

	note := &checkNotification{
		key:         check.key,
		description: cfg.Checker.String(),
		status:      n.Status,
	}
	check.vserver.queueCheckNotification(note)

	return nil
}
292656
func (h *Handler) healthStatus() status.Status {
	info, err := h.Process.Info()
	if err != nil || !info.Running {
		return status.Unhealthy
	}
	return status.Healthy
}
87455
func (c *healthcheckClient) Healthcheck() (string, error) {
	resp, err := c.client.Get(context.Background(), c.url)
	if err != nil {
		return c.service, err
	}

	if resp.StatusCode != http.StatusOK {
		return c.service, &errorResponse{c.service, http.StatusOK, resp.StatusCode, c.url}
	}

	return c.service, nil
}
1075694
func (ar *allocRunner) AllocState() *state.State {
	ar.stateLock.RLock()
	state := ar.state.Copy()
	ar.stateLock.RUnlock()

	// If TaskStateUpdated has not been called yet, ar.state.TaskStates
	// won't be set as it is not the canonical source of TaskStates.
	if len(state.TaskStates) == 0 {
		ar.state.TaskStates = make(map[string]*structs.TaskState, len(ar.tasks))
		for k, tr := range ar.tasks {
			state.TaskStates[k] = tr.TaskState()
		}
	}

	// Generate alloc to get other state fields
	alloc := ar.clientAlloc(state.TaskStates)
	state.ClientStatus = alloc.ClientStatus
	state.ClientDescription = alloc.ClientDescription
	state.DeploymentStatus = alloc.DeploymentStatus

	return state
}
174600
func (s *Task) SetHealthStatus(v string) *Task {
	s.HealthStatus = &v
	return s
}
1178000
func (s *UpdateHealthCheckInput) SetHealthCheckId(v string) *UpdateHealthCheckInput {
	s.HealthCheckId = &v
	return s
}
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
}
896741
func (s *UpdateEndpointGroupInput) SetHealthCheckIntervalSeconds(v int64) *UpdateEndpointGroupInput {
	s.HealthCheckIntervalSeconds = &v
	return s
}
214581
func (_m *ClientInterface) GetServicesHealth() (map[string]map[int]map[string]health.HealthStatus, error) {
	ret := _m.Called()

	var r0 map[string]map[int]map[string]health.HealthStatus
	if rf, ok := ret.Get(0).(func() map[string]map[int]map[string]health.HealthStatus); ok {
		r0 = rf()
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(map[string]map[int]map[string]health.HealthStatus)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func() error); ok {
		r1 = rf()
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
757726
func (s *Health) Status() string {
	s.mu.Lock()
	defer s.mu.Unlock()

	// This happens when the monitor has yet to be setup.
	if s.Health.Status == "" {
		return types.Unhealthy
	}

	return s.Health.Status
}
988198
func (m *HealthCheckClient) Healthcheck() (res string, err error) {
	s := m.mongo.Copy()
	defer s.Close()
	res = m.serviceName
	err = s.Ping()
	if err != nil {
		log.ErrorC("Ping mongo", err, nil)
	}

	return
}
91861
func GetState() (HealthState, time.Time, time.Time) {
	mutex.RLock()
	defer mutex.RUnlock()

	hs := make(HealthState)
	for key := range healthState {
		hs[key] = healthState[key]
	}

	return hs, healthLastChecked, healthLastSuccess
}
373762
func (c *ClusterClient) ReloadState() error {
	_, err := c.state.Reload()
	return err
}
394809
func deploymentState(deployment *deployment, ctx *context) stateFn {
	_, err := deployment.client.CreateApp(deployment.application)
	time.Sleep(2000 * time.Millisecond)
	if err != nil {
		deployment.status.code = FAIL
		deployment.status.message = fmt.Sprintf("%s", err)
		log.Printf("Error Deployment: %s - %s", deployment.application.ID, err)
		return nil
	}
	return postActionState
}
359057
func (s *EnvironmentDescription) SetHealthStatus(v string) *EnvironmentDescription {
	s.HealthStatus = &v
	return s
}
557812
func (h *Health) safeGetStates() map[string]State {
	h.statesLock.Lock()
	defer h.statesLock.Unlock()

	// deep copy h.states to avoid race
	statesCopy := make(map[string]State, 0)

	for k, v := range h.states {
		statesCopy[k] = v
	}

	return statesCopy
}
1244375
func (s *SingleInstanceHealth) SetHealthStatus(v string) *SingleInstanceHealth {
	s.HealthStatus = &v
	return s
}