From 01b9bbef762baef9db3b17cff2cc21abb3057f6f Mon Sep 17 00:00:00 2001 From: Bay Date: Wed, 27 Dec 2017 12:24:05 +0800 Subject: [PATCH] [REV] optimize node reg to hosts,and optimize collect system info for master --- cmd/node/server/server.go | 4 +++- pkg/api/region/node.go | 2 +- pkg/node/masterserver/node/nodecluster.go | 6 ++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/cmd/node/server/server.go b/cmd/node/server/server.go index 5da4c4059..95e84d563 100644 --- a/cmd/node/server/server.go +++ b/cmd/node/server/server.go @@ -87,7 +87,9 @@ func Run(c *option.Conf) error { logrus.Errorf(err.Error()) return err } - getInfoForMaster(s) + if !s.HostNode.Role.HasRule("compute"){ + getInfoForMaster(s) + } ms.Cluster.UpdateNode(s.HostNode) if err := ms.Start(); err != nil { logrus.Errorf(err.Error()) diff --git a/pkg/api/region/node.go b/pkg/api/region/node.go index b6e4b648e..cf4268b6e 100644 --- a/pkg/api/region/node.go +++ b/pkg/api/region/node.go @@ -395,7 +395,7 @@ func (r *RNodeClient) handleErrAndCode(err error, code int) *util.APIHandleError return util.CreateAPIHandleError(code, err) } if code != 200 { - return util.CreateAPIHandleError(code, fmt.Errorf("error with code %d", code)) + return util.CreateAPIHandleError(code, fmt.Errorf("error with code %d,details %s", code,err.Error())) } return nil } diff --git a/pkg/node/masterserver/node/nodecluster.go b/pkg/node/masterserver/node/nodecluster.go index 9a631b6c9..23d2a4e90 100644 --- a/pkg/node/masterserver/node/nodecluster.go +++ b/pkg/node/masterserver/node/nodecluster.go @@ -196,6 +196,7 @@ func (n *NodeCluster) loadAndWatchNodes() error { if !node.Alived { node.Alived = true node.UpTime = time.Now() + n.UpdateNode(node) } } } @@ -226,15 +227,16 @@ func (n *NodeCluster) loadAndWatchNodes() error { if node := n.getNodeFromKey(string(ev.Kv.Key)); node != nil { node.Alived = true node.UpTime = time.Now() - RegToHost(node, "add") + //getInfoForMaster(node) n.UpdateNode(node) + RegToHost(node, "add") } case ev.Type == client.EventTypeDelete: if node := n.getNodeFromKey(string(ev.Kv.Key)); node != nil { node.Alived = false node.DownTime = time.Now() - RegToHost(node, "del") n.UpdateNode(node) + RegToHost(node, "del") } } }