Skip to content
Snippets Groups Projects
Commit 91bf4f96 authored by ale's avatar ale
Browse files

fix partition cluster status

parent 26a64a31
Branches
No related tags found
No related merge requests found
......@@ -59,12 +59,12 @@ Versions:
</tr>
</thead>
<tbody>
{{range .GlobalStatus.Sort}}
{{range $s := .GlobalStatus.Sort}}
<tr>
<td>{{.Name}}</td>
<td>{{.Version}}</td>
<td>{{.Stamp}}</td>
<td>{{.Total}}</td>
<td><a href="{{$s.Target | httpize}}/debug/part/{{.Name}}">{{$s.Target}}</a></td>
<td>{{$s.Version}}</td>
<td>{{$s.Stamp}}</td>
<td>{{$s.Total}}</td>
</tr>
{{end}}
</tbody>
......
......@@ -10,6 +10,7 @@ import (
type PartitionStatus struct {
Name string
Target string
Version string
Stamp time.Time
Counters map[string]int
......@@ -75,23 +76,24 @@ func target2addr(target string) string {
func getPartitionStatus(name, target string) *PartitionStatus {
client, err := rpc.DialHTTP("tcp", target2addr(target))
if err != nil {
return &PartitionStatus{Name: name, Err: err}
return &PartitionStatus{Name: name, Target: target, Err: err}
}
defer client.Close()
req := &GetVersionRequest{Name: name}
var resp GetVersionResponse
if err := client.Call("Partition.GetVersion", req, &resp); err != nil {
return &PartitionStatus{Name: name, Err: err}
return &PartitionStatus{Name: name, Target: target, Err: err}
}
var sreq struct{}
var sresp PartitionStatsResponse
if err := client.Call("PartitionedService.GetStats", &sreq, &sresp); err != nil {
return &PartitionStatus{Name: name, Err: err}
return &PartitionStatus{Name: name, Target: target, Err: err}
}
return &PartitionStatus{
Name: name,
Target: target,
Version: resp.Version,
Stamp: resp.Stamp,
Counters: sresp.Counters,
......@@ -112,7 +114,7 @@ func getGlobalPartitionStatus(pmap *PartitionMap, name string) statusMap {
status := make(statusMap)
for i := 0; i < len(targets); i++ {
result := <-c
status[result.Name] = result
status[result.Target] = result
}
return status
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment