修改集群结点配置自己身的结点名称,导致rpc call失败

This commit is contained in:
boyce
2019-03-20 13:39:42 +08:00
parent ffe2e967f8
commit 671159cc87
3 changed files with 22 additions and 9 deletions

View File

@@ -221,8 +221,8 @@ func (slf *CCluster) Call(NodeServiceMethod string, args interface{}, reply inte
var callServiceName string
nodeidList := slf.GetNodeList(NodeServiceMethod, &callServiceName)
if len(nodeidList) > 1 || len(nodeidList) < 1 {
service.GetLogger().Printf(sysmodule.LEVER_ERROR, "CCluster.Call(%s) not find nodes.", NodeServiceMethod)
return fmt.Errorf("CCluster.Call(%s) not find nodes.", NodeServiceMethod)
service.GetLogger().Printf(sysmodule.LEVER_ERROR, "CCluster.Call(%s) find nodes count %d is error.", NodeServiceMethod, len(nodeidList))
return fmt.Errorf("CCluster.Call(%s) find nodes count %d is error.", NodeServiceMethod, len(nodeidList))
}
nodeid := nodeidList[0]

View File

@@ -81,7 +81,10 @@ func ReadCfg(path string, nodeid int) (*ClusterConfig, error) {
for _, cn := range custerNodeName {
for _, n := range c.mapIdNode {
if n.NodeName == cn {
c.mapClusterNodeService[n.NodeName] = append(c.mapClusterNodeService[n.NodeName], n)
nodeList := c.mapClusterNodeService[n.NodeName]
if IsExistsNode(nodeList, &n) == false {
c.mapClusterNodeService[n.NodeName] = append(c.mapClusterNodeService[n.NodeName], n)
}
}
}
}
@@ -143,3 +146,13 @@ func (slf *ClusterConfig) HasLocalService(serviceName string) bool {
_, ok := slf.currentNode.ServiceList[serviceName]
return ok == true
}
func IsExistsNode(nodelist []CNode, pNode *CNode) bool {
for _, node := range nodelist {
if node.NodeID == pNode.NodeID {
return true
}
}
return false
}