From e74b50544622728a75f29d93cef4ea9c9d26f688 Mon Sep 17 00:00:00 2001 From: sunty <1172534965@qq.com> Date: 星期四, 16 四月 2020 11:31:47 +0800 Subject: [PATCH] uasa unit test --- controllers/swfsControllers.go | 29 ++++++++++++++++++----------- 1 files changed, 18 insertions(+), 11 deletions(-) diff --git a/controllers/swfsControllers.go b/controllers/swfsControllers.go index a52ec64..cd4c6f0 100644 --- a/controllers/swfsControllers.go +++ b/controllers/swfsControllers.go @@ -117,21 +117,27 @@ } //鏇存柊鎵�鏈夎妭鐐圭殑鑴氭湰鍙傛暟 -func UpdateAllNodesScriptArgument(nowPeers []interface{}) { - for _, val := range nowPeers { - ip := val.(string) +func UpdateAllNodesScriptArgument(peersIp []string) { + for _, ip := range peersIp { fmt.Println("ip: ", ip) url := "http://" + ip + ":7020/node/api-v/swfs/updateSWFSService" fmt.Println("url", url) - http.Get(url) + resp, _ := http.Get(url) + if resp.StatusCode == 200 { + fmt.Println("璇锋眰瀹屾瘯", resp.StatusCode) + } } } //璇锋眰浣滀负涓昏妭鐐规搷浣滄祦绋� func RequestMasterNodesOperation(nowPeers []interface{}) { + peersIp := make([]string, 0) + for _, val := range nowPeers { + peersIp = append(peersIp, strings.Split(val.(string), ":")[0]) + } coreBaseUnit, _ := strconv.Atoi(config.Server.CoreBaseUnit) - UpdateAllNodesScriptArgument(nowPeers) - RestartAllServer(nowPeers, coreBaseUnit) + UpdateAllNodesScriptArgument(peersIp) + RestartAllServer(peersIp, coreBaseUnit) } //閲嶅惎鎵�鏈夎妭鐐规湇鍔″苟楠岃瘉 @@ -196,13 +202,14 @@ } //鏋勫缓閲嶅惎娴佺▼ -func RestartAllServer(nowPeers []interface{}, coreBaseUnit int) { - coreThread := len(nowPeers)/coreBaseUnit + 1 +func RestartAllServer(peersIp []string, coreBaseUnit int) { + fmt.Println("寮�濮嬫瀯寤洪噸鍚祦绋�") + coreThread := len(peersIp)/coreBaseUnit + 1 masterIp := make([]string, 0) timeOut, _ := strconv.Atoi(config.Server.TimeOut) var waitGroup sync.WaitGroup - for i, val := range nowPeers { - ip := val.(string) + for i, ip := range peersIp { + fmt.Println("閲嶅惎绗竴缁勬湇鍔�" + ip) if (i+1)%coreThread == 0 { masterIp = append(masterIp, strings.Split(ip, ":")[0]) for i := 0; i < len(masterIp); i++ { @@ -213,7 +220,7 @@ masterIp = make([]string, 0) } else { masterIp = append(masterIp, strings.Split(ip, ":")[0]) - if len(nowPeers) == i+1 { + if len(peersIp) == i+1 { var waitGroup sync.WaitGroup for i := 0; i < len(masterIp); i++ { go Restart(masterIp[i], timeOut) -- Gitblit v1.8.0