From 2c23d7fbd909a146334d742cf133b36f587b4f9c Mon Sep 17 00:00:00 2001 From: boyce Date: Tue, 19 Mar 2019 14:43:01 +0800 Subject: [PATCH] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=A3=80=E6=9F=A5nodeid?= =?UTF-8?q?=E6=98=AF=E5=90=A6=E5=AD=98=E5=9C=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cluster/config.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cluster/config.go b/cluster/config.go index 66eedff..3aad6d0 100644 --- a/cluster/config.go +++ b/cluster/config.go @@ -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)