( w http.ResponseWriter, req *http.Request)
| 927 | } |
| 928 | |
| 929 | func (h *NsStatusHandler) ServeHTTP( |
| 930 | w http.ResponseWriter, req *http.Request) { |
| 931 | initNsServerCaching(h.mgr) |
| 932 | |
| 933 | rd := getRecentInfo() |
| 934 | if rd.err != nil { |
| 935 | rest.ShowError(w, req, fmt.Sprintf("could not retrieve defs: %v", rd.err), |
| 936 | http.StatusInternalServerError) |
| 937 | return |
| 938 | } |
| 939 | |
| 940 | indexDefsMap := rd.indexDefsMap |
| 941 | nodeDefs := rd.nodeDefs |
| 942 | planPIndexes := rd.planPIndexes |
| 943 | |
| 944 | w.Header().Set("Content-Type", "application/json; charset=utf-8") |
| 945 | w.Write(cbgt.JsonOpenBrace) |
| 946 | w.Write(statsNamePrefix) |
| 947 | w.Write([]byte("status")) |
| 948 | w.Write(statsNameSuffix) |
| 949 | w.Write([]byte("[")) |
| 950 | |
| 951 | indexDefNames := make(sort.StringSlice, 0, len(indexDefsMap)) |
| 952 | for indexDefName := range indexDefsMap { |
| 953 | indexDefNames = append(indexDefNames, indexDefName) |
| 954 | } |
| 955 | |
| 956 | sort.Sort(indexDefNames) |
| 957 | |
| 958 | for i, indexDefName := range indexDefNames { |
| 959 | indexDef := indexDefsMap[indexDefName] |
| 960 | if i > 0 { |
| 961 | w.Write(cbgt.JsonComma) |
| 962 | } |
| 963 | |
| 964 | rest.MustEncode(w, struct { |
| 965 | Hosts []string `json:"hosts"` |
| 966 | Bucket string `json:"bucket"` |
| 967 | Name string `json:"name"` |
| 968 | }{ |
| 969 | Bucket: indexDef.SourceName, |
| 970 | Name: indexDefName, |
| 971 | Hosts: NsHostsForIndex(indexDefName, planPIndexes, nodeDefs), |
| 972 | }) |
| 973 | } |
| 974 | |
| 975 | w.Write([]byte("],")) |
| 976 | w.Write(statsNamePrefix) |
| 977 | w.Write([]byte("code")) |
| 978 | w.Write(statsNameSuffix) |
| 979 | w.Write([]byte("\"success\"")) |
| 980 | w.Write(cbgt.JsonCloseBrace) |
| 981 | } |
| 982 | |
| 983 | // --------------------------------------------------------------- |
| 984 |
nothing calls this directly
no test coverage detected