// sniffNode sniffs a single node. This method is run as a goroutine
// in sniff. If successful, it returns the list of node URLs extracted
// from the result of calling Nodes Info API. Otherwise, an empty array
// is returned.
542572
func (c *Client) sniffNode(ctx context.Context, url string) []*conn {
	var nodes []*conn

	// Call the Nodes Info API at /_nodes/http
	req, err := NewRequest("GET", url+"/_nodes/http")
	if err != nil {
		return nodes
	}

	c.mu.RLock()
	if c.basicAuth {
		req.SetBasicAuth(c.basicAuthUsername, c.basicAuthPassword)
	}
	c.mu.RUnlock()

	res, err := c.c.Do((*http.Request)(req).WithContext(ctx))
	if err != nil {
		return nodes
	}
	if res == nil {
		return nodes
	}

	if res.Body != nil {
		defer res.Body.Close()
	}

	var info NodesInfoResponse
	if err := json.NewDecoder(res.Body).Decode(&info); err == nil {
		if len(info.Nodes) > 0 {
			for nodeID, node := range info.Nodes {
				if c.snifferCallback(node) {
					if node.HTTP != nil && len(node.HTTP.PublishAddress) > 0 {
						url := c.extractHostname(c.scheme, node.HTTP.PublishAddress)
						if url != "" {
							nodes = append(nodes, newConn(nodeID, url))
						}
					}
				}
			}
		}
	}
	return nodes
}
730849
func Nodes(sel interface{}, nodes *[]*cdp.Node, opts ...QueryOption) Action {
	if nodes == nil {
		panic("nodes cannot be nil")
	}

	return QueryAfter(sel, func(ctx context.Context, n ...*cdp.Node) error {
		*nodes = n
		return nil
	}, opts...)
}
1049019
func (d *JsonDumper) EnterNode(w walker.Walkable) bool {
	n := w.(node.Node)

	nodeType := reflect.TypeOf(n).String()

	fmt.Fprintf(d.Writer, "{%q:%q", "type", nodeType)

	if p := n.GetPosition(); p != nil {
		p := n.GetPosition()
		fmt.Fprintf(d.Writer, ",%q:{%q:%d,%q:%d,%q:%d,%q:%d}",
			"position",
			"startPos", p.StartPos,
			"endPos", p.EndPos,
			"startLine", p.StartLine,
			"endLine", p.EndLine)
	}

	if d.NsResolver != nil {
		if namespacedName, ok := d.NsResolver.ResolvedNames[n]; ok {
			fmt.Fprintf(d.Writer, ",%q:%q", "namespacedName", namespacedName)
		}
	}

	if !n.GetFreeFloating().IsEmpty() {
		fmt.Fprintf(d.Writer, ",%q:{", "freefloating")

		var freefloatingStringsKeys []int
		for key := range *n.GetFreeFloating() {
			freefloatingStringsKeys = append(freefloatingStringsKeys, int(key))
		}

		sort.Ints(freefloatingStringsKeys)

		i := 0
		for _, k := range freefloatingStringsKeys {
			key := freefloating.Position(k)
			freeFloatingStrings := (*n.GetFreeFloating())[key]
			if i != 0 {
				fmt.Fprint(d.Writer, ",")
			}
			i++

			fmt.Fprintf(d.Writer, "%q: [", key.String())

			j := 0
			for _, freeFloatingString := range freeFloatingStrings {
				if j != 0 {
					fmt.Fprint(d.Writer, ",")
				}
				j++

				switch freeFloatingString.StringType {
				case freefloating.CommentType:
					fmt.Fprintf(d.Writer, "{%q:%q,%q:%q}", "type", "freefloating.CommentType", "value", freeFloatingString.Value)
				case freefloating.WhiteSpaceType:
					fmt.Fprintf(d.Writer, "{%q:%q,%q:%q}", "type", "freefloating.WhiteSpaceType", "value", freeFloatingString.Value)
				case freefloating.TokenType:
					fmt.Fprintf(d.Writer, "{%q:%q,%q:%q}", "type", "freefloating.TokenType", "value", freeFloatingString.Value)
				}
			}

			fmt.Fprint(d.Writer, "]")
		}

		fmt.Fprint(d.Writer, "}")
	}

	if a := n.Attributes(); len(a) > 0 {
		var attributes []string
		for key := range n.Attributes() {
			attributes = append(attributes, key)
		}

		sort.Strings(attributes)

		for _, attributeName := range attributes {
			attr := a[attributeName]
			switch attr.(type) {
			case string:
				fmt.Fprintf(d.Writer, ",\"%s\":%q", attributeName, attr)
			default:
				fmt.Fprintf(d.Writer, ",\"%s\":%v", attributeName, attr)
			}
		}
	}

	return true
}
849081
func (clnt *Client) ScanNode(apolicy *ScanPolicy, node *Node, namespace string, setName string, binNames ...string) (*Recordset, error) {
	policy := *clnt.getUsableScanPolicy(apolicy)

	// results channel must be async for performance
	taskID := uint64(xornd.Int64())
	res := newRecordset(policy.RecordQueueSize, 1, taskID)

	go clnt.scanNode(&policy, node, res, namespace, setName, taskID, binNames...)
	return res, nil
}
799353
func (m *Mercury) DeleteNode(ctx context.Context, node *types.Node) {
	if node == nil {
		return
	}
	m.doDeleteNode(ctx, node.Podname, node.Name, node.Endpoint)
}
1291383
func (c *DOM) RemoveNode(nodeId int) (*gcdmessage.ChromeResponse, error) {
	var v DOMRemoveNodeParams
	v.NodeId = nodeId
	return c.RemoveNodeWithParams(&v)
}
946037
func encodeNode(n *pilosa.Node) *internal.Node {
	return &internal.Node{
		ID:            n.ID,
		URI:           encodeURI(n.URI),
		IsCoordinator: n.IsCoordinator,
		State:         n.State,
	}
}
764364
func (_m *Cluster) AddNode(ctx context.Context, nodename string, endpoint string, podname string, ca string, cert string, key string, cpu int, share int, memory int64, labels map[string]string) (*types.Node, error) {
	ret := _m.Called(ctx, nodename, endpoint, podname, ca, cert, key, cpu, share, memory, labels)

	var r0 *types.Node
	if rf, ok := ret.Get(0).(func(context.Context, string, string, string, string, string, string, int, int, int64, map[string]string) *types.Node); ok {
		r0 = rf(ctx, nodename, endpoint, podname, ca, cert, key, cpu, share, memory, labels)
	} else {
		if ret.Get(0) != nil {
			r0 = ret.Get(0).(*types.Node)
		}
	}

	var r1 error
	if rf, ok := ret.Get(1).(func(context.Context, string, string, string, string, string, string, int, int, int64, map[string]string) error); ok {
		r1 = rf(ctx, nodename, endpoint, podname, ca, cert, key, cpu, share, memory, labels)
	} else {
		r1 = ret.Error(1)
	}

	return r0, r1
}
1303732
func NewFilterNode(filters []string, body Node, p Pos) *FilterNode {
	return &FilterNode{p, TrimmableNode{}, filters, body}
}
772868
func newNode(id, network, address string) (*node, error) {
	if len(id) != 20 {
		return nil, errors.New("node id should be a 20-length string")
	}

	addr, err := net.ResolveUDPAddr(network, address)
	if err != nil {
		return nil, err
	}

	return &node{newBitmapFromString(id), addr, time.Now()}, nil
}
838016
func nextNode(it iterator.Iterator) *Node {
	for end := false; !end; end = !it.Next() {
		id, field := splitKey(it.Key())
		if field != nodeDBDiscoverRoot {
			continue
		}
		var n Node
		if err := rlp.DecodeBytes(it.Value(), &n); err != nil {
			log.Warn(fmt.Sprintf("invalid node %x: %v", id, err))
			continue
		}
		return &n
	}
	return nil
}
432743
func (j *Jenkins) DeleteNode(name string) (bool, error) {
	node := Node{Jenkins: j, Raw: new(NodeResponse), Base: "/computer/" + name}
	return node.Delete()
}
307039
func newFilterNode(n, m node) node {
	return &filterNode{nodeType: nodeFilter, Input: n, Condition: m}
}
452278
func (group *NodeGroup) GetNode(i int) Node {
	group.mux.RLock()
	defer group.mux.RUnlock()

	if i < 0 || group == nil || len(group.nodes) <= i {
		return Node{}
	}
	return group.nodes[i]
}
418427
func (net *Network) internNode(pkt *ingressPacket) *Node {
	if n := net.nodes[pkt.remoteID]; n != nil {
		n.IP = pkt.remoteAddr.IP
		n.UDP = uint16(pkt.remoteAddr.Port)
		n.TCP = uint16(pkt.remoteAddr.Port)
		return n
	}
	n := NewNode(pkt.remoteID, pkt.remoteAddr.IP, uint16(pkt.remoteAddr.Port), uint16(pkt.remoteAddr.Port))
	n.state = unknown
	net.nodes[pkt.remoteID] = n
	return n
}
285298
func (nt *NodeTree) RemoveNode(n *v1.Node) error {
	nt.mu.Lock()
	defer nt.mu.Unlock()
	return nt.removeNode(n)
}
472410
func (s *Server) GetNodes(w http.ResponseWriter, req *http.Request) {
	nodes := s.network.GetNodes()

	infos := make([]*p2p.NodeInfo, len(nodes))
	for i, node := range nodes {
		infos[i] = node.NodeInfo()
	}

	s.JSON(w, http.StatusOK, infos)
}