// Inspect inspects given node and returns the state
344765
func (c *ClusterManager) Inspect(nodeID string) (api.Node, error) {
	c.nodeCacheLock.Lock()
	defer c.nodeCacheLock.Unlock()
	return c.getNodeEntry(nodeID, &cluster.ClusterInfo{})
}
1225083
func (v *complexityVisitor) Visit(n ast.Node) ast.Visitor {
	switch n := n.(type) {
	case *ast.FuncDecl, *ast.IfStmt, *ast.ForStmt, *ast.RangeStmt, *ast.CaseClause, *ast.CommClause:
		v.Complexity++
	case *ast.BinaryExpr:
		if n.Op == token.LAND || n.Op == token.LOR {
			v.Complexity++
		}
	}
	return v
}
529012
func (r *Ring) Peek() interface{} {
	r.Lock()
	defer r.Unlock()

	r.checkInit()
	if r.head == -1 {
		return nil
	}
	return r.get(r.tail)
}
634366
func (s *ClusterServer) InspectCurrent(
	ctx context.Context,
	req *api.SdkClusterInspectCurrentRequest,
) (*api.SdkClusterInspectCurrentResponse, error) {
	if s.cluster() == nil {
		return nil, status.Error(codes.Unavailable, "Resource has not been initialized")
	}

	c, err := s.cluster().Enumerate()
	if err != nil {
		return nil, status.Error(codes.Internal, err.Error())
	}

	// Get cluster information
	cluster := c.ToStorageCluster()

	// Get cluster unique id
	cluster.Id = s.cluster().Uuid()

	return &api.SdkClusterInspectCurrentResponse{
		Cluster: cluster,
	}, nil
}
958174
func (n *Node) Evaluate(args *structs.NodeEvaluateRequest, reply *structs.NodeUpdateResponse) error {
	if done, err := n.srv.forward("Node.Evaluate", args, args, reply); done {
		return err
	}
	defer metrics.MeasureSince([]string{"nomad", "client", "evaluate"}, time.Now())

	// Check node write permissions
	if aclObj, err := n.srv.ResolveToken(args.AuthToken); err != nil {
		return err
	} else if aclObj != nil && !aclObj.AllowNodeWrite() {
		return structs.ErrPermissionDenied
	}

	// Verify the arguments
	if args.NodeID == "" {
		return fmt.Errorf("missing node ID for evaluation")
	}

	// Look for the node
	snap, err := n.srv.fsm.State().Snapshot()
	if err != nil {
		return err
	}
	ws := memdb.NewWatchSet()
	node, err := snap.NodeByID(ws, args.NodeID)
	if err != nil {
		return err
	}
	if node == nil {
		return fmt.Errorf("node not found")
	}

	// Create the evaluation
	evalIDs, evalIndex, err := n.createNodeEvals(args.NodeID, node.ModifyIndex)
	if err != nil {
		n.logger.Error("eval creation failed", "error", err)
		return err
	}
	reply.EvalIDs = evalIDs
	reply.EvalCreateIndex = evalIndex

	// Set the reply index
	reply.Index = evalIndex

	n.srv.peerLock.RLock()
	defer n.srv.peerLock.RUnlock()
	if err := n.constructNodeServerInfoResponse(snap, reply); err != nil {
		n.logger.Error("failed to populate NodeUpdateResponse", "error", err)
		return err
	}
	return nil
}
236345
func (ens *NetpluginNameServer) InspectState() (interface{}, error) {

	s := struct {
		SvcChan int                                       `json:"serviceQueue"`
		EpChan  int                                       `json:"endpointQueue"`
		Dtbl    map[string]map[string]map[string][]string `json:"dnsRecords"`
		Stats   map[string]map[string]uint64              `json:"stats"`
	}{SvcChan: len(ens.svcChan), EpChan: len(ens.epChan),
		Dtbl: ens.inspectNameRecord(), Stats: ens.inspectStats()}
	return &s, nil
}
1293091
func Inspect(val reflect.Value) string {

	if val.CanInterface() {
		if s, ok := val.Interface().(fmt.Stringer); ok {
			return s.String()
		}
	}
	switch val.Kind() {
	case reflect.String:
		return strconv.QuoteToASCII(val.String())
	case reflect.Slice, reflect.Array:
		if val.Len() == 0 {
			return "[]"
		}
		sep := "{"
		str := ""
		for i:=0; i < val.Len(); i++ {
			str += sep
			sep = ", "
			str += InspectShort(val.Index(i))
		}
		str += "}"
		return str

	case reflect.Struct:
		if val.Type() == untypedNilType {
			return "nil"
		}
		n  := val.NumField()
		str := val.Type().String()
		if n == 0 {
			return str + "{}"
		}
		sep := "{\n\t"
		unexported := false
		for i := 0; i < n; i++ {
			name  := val.Type().Field(i).Name
			if unicode.IsLower([]rune(name)[0]) {
				unexported = true
				continue
			}
			field := val.Field(i)
			str += fmt.Sprintf("%s%s: %s", sep, name, InspectShort(field))
			sep = ",\n\t"
		}
		if unexported {
			str += fmt.Sprintf("\n\t// unexported fields")
		}
		str += "\n}"
		return str

	case reflect.Map:
		str := val.Type().String()
		if val.Len() == 0 {
			return str + "{}"
		}
		sep := " {\n\t"
		keys := sortMapKeys(val.MapKeys())
		for _, k := range keys {
			v := val.MapIndex(k)
			str += fmt.Sprintf("%s%s: %s", sep, InspectShort(k), InspectShort(v))
			sep = ",\n\t"
		}
		str += "\n}"
		return str

	case reflect.Ptr:
		// Internal const numbers
		i := val.Interface()
		if cn, ok := i.(*ConstNumber); ok {
			return fmt.Sprint(cn)
		} else if val.IsNil() {
			return "nil"
		} else {
			return "&" + InspectShort(reflect.Indirect(val))
		}
	case reflect.Interface:
		if val.IsNil() {
			return "nil"
		} else {
			return fmt.Sprintf("%s.(%v)", InspectShort(val.Elem()), val.Type())
		}
	default:
		// FIXME: add more Kinds as folks are annoyed with the output of
		// the below:
		if val.CanInterface() {
			return fmt.Sprintf("%v", val.Interface())
		} else {
			return fmt.Sprintf("<%v>", val.Type())
		}
	}
}
1004025
func (c *Client) InspectContainer(id string) (*Container, error) {
	return c.inspectContainer(id, doOptions{})
}
698715
func (p *Peeker) Peek() *Token {
	if p.peeked == nil {
		p.peeked = <-p.ch
	}
	return p.peeked
}
132586
func (s *NodeServer) Inspect(
	ctx context.Context,
	req *api.SdkNodeInspectRequest,
) (*api.SdkNodeInspectResponse, error) {
	if s.cluster() == nil {
		return nil, status.Error(codes.Unavailable, "Resource has not been initialized")
	}

	if len(req.GetNodeId()) == 0 {
		return nil, status.Error(codes.InvalidArgument, "Node id must be provided")
	}

	node, err := s.cluster().Inspect(req.GetNodeId())
	if err != nil {
		if err == kvdb.ErrNotFound {
			return nil, status.Errorf(
				codes.NotFound,
				"Id %s not found",
				req.GetNodeId())
		}
		return nil, status.Error(codes.Internal, err.Error())
	}

	return &api.SdkNodeInspectResponse{
		Node: node.ToStorageNode(),
	}, nil
}
961522
func (s *SchedulePolicyServer) Inspect(
	ctx context.Context,
	req *api.SdkSchedulePolicyInspectRequest,
) (*api.SdkSchedulePolicyInspectResponse, error) {
	if s.cluster() == nil {
		return nil, status.Error(codes.Unavailable, "Resource has not been initialized")
	}

	if len(req.GetName()) == 0 {
		return nil, status.Error(codes.InvalidArgument, "Must supply Schedule name")
	}

	policy, err := s.cluster().SchedPolicyGet(req.GetName())
	if err != nil {
		if err == kvdb.ErrNotFound {
			return nil, status.Errorf(
				codes.NotFound,
				"Schedule policy %s not found",
				req.GetName())
		}
		return nil, status.Errorf(
			codes.Internal,
			"Failed to inspect schedule policy: %v",
			err.Error())
	}

	schedules, err := retainInternalSpecYamlByteToSdkSched([]byte(policy.Schedule))
	if err != nil {
		return nil, err
	}

	sdkpolicy := &api.SdkSchedulePolicy{
		Name:      policy.Name,
		Schedules: schedules,
	}

	return &api.SdkSchedulePolicyInspectResponse{Policy: sdkpolicy}, err
}
785956
func (s *ObjectstoreServer) Inspect(
	ctx context.Context,
	req *api.SdkObjectstoreInspectRequest,
) (*api.SdkObjectstoreInspectResponse, error) {
	if s.cluster() == nil {
		return nil, status.Error(codes.Unavailable, "Resource has not been initialized")
	}

	objResp, err := s.cluster().ObjectStoreInspect(req.GetObjectstoreId())
	if err != nil {
		if err == kvdb.ErrNotFound {
			return nil, status.Errorf(
				codes.NotFound,
				"Id %s not found",
				req.GetObjectstoreId())
		}
		return nil, status.Errorf(
			codes.Internal,
			"Failed to inspect objectstore: %v",
			err.Error())
	}

	return &api.SdkObjectstoreInspectResponse{ObjectstoreStatus: objResp}, nil
}
1094480
func (v *volumeClient) Inspect(ids []string) ([]*api.Volume, error) {
	if len(ids) == 0 {
		return nil, nil
	}
	var volumes []*api.Volume
	request := v.c.Get().Resource(volumePath)
	for _, id := range ids {
		request.QueryOption(api.OptVolumeID, id)
	}
	if err := request.Do().Unmarshal(&volumes); err != nil {
		return nil, err
	}
	return volumes, nil
}
730703
func (c *Client) InspectVolume(name string) (*Volume, error) {
	resp, err := c.do("GET", "/volumes/"+name, doOptions{})
	if err != nil {
		if e, ok := err.(*Error); ok && e.Status == http.StatusNotFound {
			return nil, ErrNoSuchVolume
		}
		return nil, err
	}
	defer resp.Body.Close()
	var volume Volume
	if err := json.NewDecoder(resp.Body).Decode(&volume); err != nil {
		return nil, err
	}
	return &volume, nil
}
247409
func (d *OvsDriver) InspectBgp() ([]byte, error) {

	// get vlan switch state
	bgpState, err := d.switchDb["vlan"].InspectBgp()
	if err != nil {
		return []byte{}, err
	}

	// json marshall the map
	jsonState, err := json.Marshal(bgpState)
	if err != nil {
		log.Errorf("Error encoding epstats. Err: %v", err)
		return []byte{}, err
	}

	return jsonState, nil
}
535444
func (pm *Manager) Inspect(refOrID string) (tp *types.Plugin, err error) {
	p, err := pm.config.Store.GetV2Plugin(refOrID)
	if err != nil {
		return nil, err
	}

	return &p.PluginObj, nil
}
1168006
func (c *Cluster) InspectImage(repo string) (*docker.Image, error) {
	img, err := c.storage().RetrieveImage(repo)
	if err != nil {
		return nil, err
	}
	node, err := c.getNodeByAddr(img.LastNode)
	if err != nil {
		return nil, err
	}
	dockerImg, err := node.InspectImage(repo)
	return dockerImg, wrapError(node, err)
}