func (n *Node) constructNodeServerInfoResponse(snap *state.StateSnapshot, reply *structs.NodeUpdateResponse) error {
	reply.LeaderRPCAddr = string(n.srv.raft.Leader())

	// Reply with config information required for future RPC requests
	reply.Servers = make([]*structs.NodeServerInfo, 0, len(n.srv.localPeers))
	for k, v := range n.srv.localPeers {
		reply.Servers = append(reply.Servers,
			&structs.NodeServerInfo{
				RPCAdvertiseAddr: string(k),
				RPCMajorVersion:  int32(v.MajorVersion),
				RPCMinorVersion:  int32(v.MinorVersion),
				Datacenter:       v.Datacenter,
			})
	}

	// TODO(sean@): Use an indexed node count instead
	//
	// Snapshot is used only to iterate over all nodes to create a node
	// count to send back to Nomad Clients in their heartbeat so Clients
	// can estimate the size of the cluster.
	ws := memdb.NewWatchSet()
	iter, err := snap.Nodes(ws)
	if err == nil {
		for {
			raw := iter.Next()
			if raw == nil {
				break
			}
			reply.NumNodes++
		}
	}

	return nil
}
// updateNodeUpdateResponse assumes the n.srv.peerLock is held for reading.
updateNodeUpdateResponse assumes the n.srv.peerLock is held for reading.
// updateNodeUpdateResponse assumes the n . srv . peerLock is held for reading .
func (n *Node) constructNodeServerInfoResponse(snap *state.StateSnapshot, reply *structs.NodeUpdateResponse) error {
	reply.LeaderRPCAddr = string(n.srv.raft.Leader())
	reply.Servers = make([]*structs.NodeServerInfo, 0, len(n.srv.localPeers))
	for k, v := range n.srv.localPeers {
		reply.Servers = append(reply.Servers,
			&structs.NodeServerInfo{
				RPCAdvertiseAddr: string(k),
				RPCMajorVersion:  int32(v.MajorVersion),
				RPCMinorVersion:  int32(v.MinorVersion),
				Datacenter:       v.Datacenter,
			})
	}
	 Snapshot is used only to iterate over all nodes to create a node
	 count to send back to Nomad Clients in their heartbeat so Clients
	 can estimate the size of the cluster.
	ws := memdb.NewWatchSet()
	iter, err := snap.Nodes(ws)
	if err == nil {
		for {
			raw := iter.Next()
			if raw == nil {
				break
			}
			reply.NumNodes++
		}
	}
	return nil
}
func ( n * Node ) constructNodeServerInfoResponse ( snap * state . StateSnapshot , reply * structs . NodeUpdateResponse ) error { reply . LeaderRPCAddr = string ( n . srv . raft . Leader ( ) ) reply . Servers = make ( [ ] * structs . NodeServerInfo , 0 , len ( n . srv . localPeers ) ) for k , v := range n . srv . localPeers { reply . Servers = append ( reply . Servers , & structs . NodeServerInfo { RPCAdvertiseAddr : string ( k ) , RPCMajorVersion : int32 ( v . MajorVersion ) , RPCMinorVersion : int32 ( v . MinorVersion ) , Datacenter : v . Datacenter , } ) } ws := memdb . NewWatchSet ( ) iter , err := snap . Nodes ( ws ) if err == nil { for { raw := iter . Next ( ) if raw == nil { break } reply . NumNodes ++ } } return nil }
updateNodeUpdateResponse assumes the n.srv.peerLock is held for reading.
updateNodeUpdateResponse assumes the n . srv . peerLock is held for reading .
// Reply with config information required for future RPC requests // TODO(sean@): Use an indexed node count instead // // Snapshot is used only to iterate over all nodes to create a node // count to send back to Nomad Clients in their heartbeat so Clients // can estimate the size of the cluster.