2013-07-14 22:45:35 +04:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
2013-08-03 07:21:11 +04:00
|
|
|
"path"
|
|
|
|
"strings"
|
2013-07-14 22:45:35 +04:00
|
|
|
)
|
|
|
|
|
2013-08-03 07:21:11 +04:00
|
|
|
func getClientAddr(name string) (string, bool) {
|
|
|
|
response, _ := etcdStore.RawGet(path.Join("_etcd/machines", name))
|
2013-07-14 22:45:35 +04:00
|
|
|
|
2013-08-03 07:21:11 +04:00
|
|
|
values := strings.Split(response[0].Value, ",")
|
2013-07-14 22:45:35 +04:00
|
|
|
|
2013-08-03 07:21:11 +04:00
|
|
|
hostname := values[0]
|
|
|
|
clientPort := values[2]
|
2013-07-14 22:45:35 +04:00
|
|
|
|
2013-08-03 07:21:11 +04:00
|
|
|
addr := fmt.Sprintf("%s:%s", hostname, clientPort)
|
2013-07-14 22:45:35 +04:00
|
|
|
|
|
|
|
return addr, true
|
|
|
|
}
|
2013-07-31 22:05:12 +04:00
|
|
|
|
|
|
|
// machineNum returns the number of machines in the cluster
|
|
|
|
func machineNum() int {
|
2013-08-03 07:21:11 +04:00
|
|
|
response, _ := etcdStore.RawGet("_etcd/machines")
|
|
|
|
|
|
|
|
return len(response)
|
2013-07-31 22:05:12 +04:00
|
|
|
}
|