mirror of
https://github.com/duanhf2012/origin.git
synced 2026-02-03 22:45:13 +08:00
扩展获取node接口
This commit is contained in:
@@ -201,7 +201,7 @@ func GetRpcClient(nodeId int,serviceMethod string,clientList []*rpc.Client) (err
|
||||
serviceName := serviceMethod[:findIndex]
|
||||
|
||||
//1.找到对应的rpcNodeid
|
||||
return GetCluster().GetNodeIdByService(serviceName,clientList)
|
||||
return GetCluster().GetNodeIdByService(serviceName,clientList,true)
|
||||
}
|
||||
|
||||
func GetRpcServer() *rpc.Server{
|
||||
|
||||
@@ -194,7 +194,7 @@ func (cls *Cluster) IsConfigService(serviceName string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func (cls *Cluster) GetNodeIdByService(serviceName string,rpcClientList []*rpc.Client) (error,int) {
|
||||
func (cls *Cluster) GetNodeIdByService(serviceName string,rpcClientList []*rpc.Client,bAll bool) (error,int) {
|
||||
cls.locker.RLock()
|
||||
defer cls.locker.RUnlock()
|
||||
nodeIdList,ok := cls.mapServiceNode[serviceName]
|
||||
@@ -202,8 +202,7 @@ func (cls *Cluster) GetNodeIdByService(serviceName string,rpcClientList []*rpc.C
|
||||
if ok == true {
|
||||
for _,nodeId := range nodeIdList {
|
||||
pClient := GetCluster().GetRpcClient(nodeId)
|
||||
if pClient==nil {
|
||||
log.Error("Cannot connect node id %d",nodeId)
|
||||
if pClient==nil || (bAll == false && pClient.IsConnected()==false) {
|
||||
continue
|
||||
}
|
||||
rpcClientList[count] = pClient
|
||||
|
||||
Reference in New Issue
Block a user