Browse Source

remove duplicate codes

Xiang Li 12 years ago
parent
commit
6120fa634e
2 changed files with 2 additions and 16 deletions
  1. 2 2
      etcd_handlers.go
  2. 0 14
      machines.go

+ 2 - 2
etcd_handlers.go

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

+ 0 - 14
machines.go

@@ -5,20 +5,6 @@ import (
 	"path"
 	"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
 // machineNum returns the number of machines in the cluster
 func machineNum() int {
 func machineNum() int {
 	response, _ := etcdStore.RawGet("_etcd/machines")
 	response, _ := etcdStore.RawGet("_etcd/machines")