MCPcopy Create free account
hub / github.com/couchbase/cbft / NsHostsForIndex

Function NsHostsForIndex

ns_server.go:887–927  ·  view source on GitHub ↗
(name string, planPIndexes *cbgt.PlanPIndexes,
	nodeDefs *cbgt.NodeDefs)

Source from the content-addressed store, hash-verified

885}
886
887func NsHostsForIndex(name string, planPIndexes *cbgt.PlanPIndexes,
888 nodeDefs *cbgt.NodeDefs) []string {
889 if planPIndexes == nil {
890 return nil
891 }
892
893 v := struct{}{}
894
895 // find the node UUIDs related to this index
896 nodes := make(map[string]struct{})
897 for _, planPIndex := range planPIndexes.PlanPIndexes {
898 if planPIndex.IndexName == name {
899 for planPIndexNodeUUID := range planPIndex.Nodes {
900 nodes[planPIndexNodeUUID] = v
901 }
902 }
903 }
904
905 // look for all these nodes in the nodes wanted
906 nodeExtras := make(map[string]string) // Keyed by node UUID.
907 for _, nodeDef := range nodeDefs.NodeDefs {
908 _, ok := nodes[nodeDef.UUID]
909 if ok {
910 extras, err := ParseExtras(nodeDef.Extras)
911 if err == nil {
912 nodeExtras[nodeDef.UUID] = extras["nsHostPort"]
913 }
914 }
915 }
916
917 // build slice of node extras
918 nodeStrings := make(sort.StringSlice, 0, len(nodeExtras))
919 for _, nodeExtra := range nodeExtras {
920 nodeStrings = append(nodeStrings, nodeExtra)
921 }
922
923 // sort slice for stability
924 sort.Sort(nodeStrings)
925
926 return nodeStrings
927}
928
929func (h *NsStatusHandler) ServeHTTP(
930 w http.ResponseWriter, req *http.Request) {

Callers 1

ServeHTTPMethod · 0.85

Calls 1

ParseExtrasFunction · 0.85

Tested by

no test coverage detected