配置检查nodeid是否存在

This commit is contained in:
boyce
2019-03-19 14:43:01 +08:00
parent f406f614e5
commit 2c23d7fbd9

View File

@@ -2,6 +2,7 @@ package cluster
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
)
@@ -69,6 +70,10 @@ func ReadCfg(path string, nodeid int) (*ClusterConfig, error) {
}
}
if c.currentNode.NodeID == 0 {
return nil, errors.New(fmt.Sprintf("Cannot find NodeId %d in cluster.json!", nodeid))
}
//3.存入当前Node服务名
c.mapClusterNodeService[c.currentNode.NodeName] = append(c.mapClusterNodeService[c.currentNode.NodeName], c.currentNode)