remove duplicate codes

This commit is contained in:
Xiang Li
2013-08-11 11:40:45 -07:00
parent fa6c8f4f18
commit 6120fa634e
2 changed files with 2 additions and 16 deletions

View File

@@ -218,14 +218,14 @@ func MachinesHttpHandler(w http.ResponseWriter, req *http.Request) {
// Add itself to the machine list first
// Since peer map does not contain the server itself
machines, _ := getEtcdURL(raftServer.Name())
machines, _ := nameToEtcdURL(raftServer.Name())
// Add all peers to the list and separate by comma
// We do not use json here since we accept machines list
// in the command line separate by comma.
for peerName, _ := range peers {
if addr, ok := getEtcdURL(peerName); ok {
if addr, ok := nameToEtcdURL(peerName); ok {
machines = machines + "," + addr
}
}

View File

@@ -5,20 +5,6 @@ import (
"path"
)
func getEtcdURL(name string) (string, bool) {
resps, _ := etcdStore.RawGet(path.Join("_etcd/machines", name))
m, err := url.ParseQuery(resps[0].Value)
if err != nil {
panic("Failed to parse machines entry")
}
addr := m["etcd"][0]
return addr, true
}
// machineNum returns the number of machines in the cluster
func machineNum() int {
response, _ := etcdStore.RawGet("_etcd/machines")