mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-17 09:54:45 +08:00
如果id为本地node,直接返回localrpcclient
This commit is contained in:
@@ -45,6 +45,10 @@ func (slf *CCluster) ReadNodeInfo(nodeid int) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (slf *CCluster) GetClusterClient(id int) *rpc.Client {
|
func (slf *CCluster) GetClusterClient(id int) *rpc.Client {
|
||||||
|
if id == GetNodeId() {
|
||||||
|
return slf.LocalRpcClient
|
||||||
|
}
|
||||||
|
|
||||||
v, ok := slf.nodeclient[id]
|
v, ok := slf.nodeclient[id]
|
||||||
if ok == false {
|
if ok == false {
|
||||||
return nil
|
return nil
|
||||||
@@ -130,12 +134,14 @@ func (slf *CCluster) ConnService() error {
|
|||||||
if rpcClient.isConnect == true {
|
if rpcClient.isConnect == true {
|
||||||
ping.TimeStamp = 0
|
ping.TimeStamp = 0
|
||||||
err := rpcClient.pclient.Call("CPing.Ping", &ping, &pong)
|
err := rpcClient.pclient.Call("CPing.Ping", &ping, &pong)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
rpcClient.pclient.Close()
|
rpcClient.pclient.Close()
|
||||||
rpcClient.pclient = nil
|
rpcClient.pclient = nil
|
||||||
rpcClient.isConnect = false
|
rpcClient.isConnect = false
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user