diff options
| author | Chris Lu <chris.lu@gmail.com> | 2014-02-14 17:10:49 -0800 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2014-02-14 17:10:49 -0800 |
| commit | edae676913363bdd1e5a50bf0778fdcc3c6d6051 (patch) | |
| tree | 8711d0e0382ba15b2810e7783cdede4283d7e1c4 /go/operation/list_masters.go | |
| parent | ef4c2c0d1e5bb45a63cde703013871daa401d1ef (diff) | |
| download | seaweedfs-edae676913363bdd1e5a50bf0778fdcc3c6d6051.tar.xz seaweedfs-edae676913363bdd1e5a50bf0778fdcc3c6d6051.zip | |
1. volume server auto detect clustered master nodes
2. remove operation package dependency on storage
Diffstat (limited to 'go/operation/list_masters.go')
| -rw-r--r-- | go/operation/list_masters.go | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/go/operation/list_masters.go b/go/operation/list_masters.go new file mode 100644 index 000000000..05235aed0 --- /dev/null +++ b/go/operation/list_masters.go @@ -0,0 +1,27 @@ +package operation + +import ( + "code.google.com/p/weed-fs/go/glog" + "code.google.com/p/weed-fs/go/util" + "encoding/json" +) + +type ClusterStatusResult struct { + IsLeader bool + Leader string + Peers []string +} + +func ListMasters(server string) ([]string, error) { + jsonBlob, err := util.Get("http://" + server + "/cluster/status") + glog.V(2).Info("list masters result :", string(jsonBlob)) + if err != nil { + return nil, err + } + var ret ClusterStatusResult + err = json.Unmarshal(jsonBlob, &ret) + if err != nil { + return nil, err + } + return ret.Peers, nil +} |
