From 83d4420a30d9005e755c2a46d0ea731dd9c4585d Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Fri, 15 Jan 2021 12:42:31 +0300 Subject: [PATCH] [#313] control: Rename HealthStatus enum to NetmapStatus Signed-off-by: Leonard Lyubich --- cmd/neofs-cli/modules/control.go | 2 +- cmd/neofs-node/config.go | 2 +- cmd/neofs-node/control.go | 6 +++--- cmd/neofs-node/main.go | 2 +- cmd/neofs-node/netmap.go | 2 +- pkg/services/control/server/healthcheck.go | 2 +- .../control/server/netmap_snapshot.go | 8 ++++---- pkg/services/control/server/server.go | 4 ++-- pkg/services/control/service.go | 10 +++++----- pkg/services/control/service.pb.go | Bin 29489 -> 29629 bytes pkg/services/control/service.proto | 4 ++-- pkg/services/control/service_test.go | 4 ++-- pkg/services/control/types.go | 2 +- pkg/services/control/types.pb.go | Bin 17927 -> 17945 bytes pkg/services/control/types.proto | 6 +++--- pkg/services/control/types_test.go | 2 +- 16 files changed, 28 insertions(+), 28 deletions(-) diff --git a/cmd/neofs-cli/modules/control.go b/cmd/neofs-cli/modules/control.go index 4cf21e6291..a2e47db5f9 100644 --- a/cmd/neofs-cli/modules/control.go +++ b/cmd/neofs-cli/modules/control.go @@ -84,7 +84,7 @@ func healthCheck(cmd *cobra.Command, _ []string) error { return err } - cmd.Printf("Node status: %s\n", resp.GetBody().GetStatus()) + cmd.Printf("Node network status: %s\n", resp.GetBody().GetNetmapStatus()) return nil } diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index ec4660898f..850a8b6fc3 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -342,7 +342,7 @@ func initCfg(path string) *cfg { cfgObject: cfgObject{ pool: initObjectPool(viperCfg), }, - healthStatus: atomic.NewInt32(int32(control.HealthStatus_STATUS_UNDEFINED)), + healthStatus: atomic.NewInt32(int32(control.NetmapStatus_STATUS_UNDEFINED)), } initLocalStorage(c) diff --git a/cmd/neofs-node/control.go b/cmd/neofs-node/control.go index 47f69e81e5..ed9572cc3c 100644 --- a/cmd/neofs-node/control.go +++ b/cmd/neofs-node/control.go @@ -68,10 +68,10 @@ func initControlService(c *cfg) { })) } -func (c *cfg) setHealthStatus(st control.HealthStatus) { +func (c *cfg) setNetmapStatus(st control.NetmapStatus) { c.healthStatus.Store(int32(st)) } -func (c *cfg) HealthStatus() control.HealthStatus { - return control.HealthStatus(c.healthStatus.Load()) +func (c *cfg) NetmapStatus() control.NetmapStatus { + return control.NetmapStatus(c.healthStatus.Load()) } diff --git a/cmd/neofs-node/main.go b/cmd/neofs-node/main.go index e7aa5be8d8..ff88dad978 100644 --- a/cmd/neofs-node/main.go +++ b/cmd/neofs-node/main.go @@ -56,7 +56,7 @@ func bootUp(c *cfg) { bootstrapNode(c) startWorkers(c) - c.setHealthStatus(control.HealthStatus_ONLINE) + c.setNetmapStatus(control.NetmapStatus_ONLINE) } func wait(c *cfg) { diff --git a/cmd/neofs-node/netmap.go b/cmd/neofs-node/netmap.go index ce03f9383b..10007b5a70 100644 --- a/cmd/neofs-node/netmap.go +++ b/cmd/neofs-node/netmap.go @@ -117,7 +117,7 @@ func addNewEpochNotificationHandler(c *cfg, h event.Handler) { } func goOffline(c *cfg) { - c.setHealthStatus(control.HealthStatus_OFFLINE) + c.setNetmapStatus(control.NetmapStatus_OFFLINE) err := c.cfgNetmap.wrapper.UpdatePeerState( crypto.MarshalPublicKey(&c.key.PublicKey), diff --git a/pkg/services/control/server/healthcheck.go b/pkg/services/control/server/healthcheck.go index fbafbd0a72..42e1f7e132 100644 --- a/pkg/services/control/server/healthcheck.go +++ b/pkg/services/control/server/healthcheck.go @@ -23,7 +23,7 @@ func (s *Server) HealthCheck(_ context.Context, req *control.HealthCheckRequest) body := new(control.HealthCheckResponse_Body) resp.SetBody(body) - body.SetStatus(s.healthChecker.HealthStatus()) + body.SetNetmapStatus(s.healthChecker.NetmapStatus()) // sign the response if err := SignMessage(s.key, resp); err != nil { diff --git a/pkg/services/control/server/netmap_snapshot.go b/pkg/services/control/server/netmap_snapshot.go index c790f8208d..d7252b330f 100644 --- a/pkg/services/control/server/netmap_snapshot.go +++ b/pkg/services/control/server/netmap_snapshot.go @@ -63,14 +63,14 @@ func nodesFromAPI(apiNodes netmapAPI.Nodes) []*control.NodeInfo { return nodes } -func stateFromAPI(s netmapAPI.NodeState) control.HealthStatus { +func stateFromAPI(s netmapAPI.NodeState) control.NetmapStatus { switch s { default: - return control.HealthStatus_STATUS_UNDEFINED + return control.NetmapStatus_STATUS_UNDEFINED case netmapAPI.NodeStateOffline: - return control.HealthStatus_OFFLINE + return control.NetmapStatus_OFFLINE case netmapAPI.NodeStateOnline: - return control.HealthStatus_ONLINE + return control.NetmapStatus_ONLINE } } diff --git a/pkg/services/control/server/server.go b/pkg/services/control/server/server.go index 6f88ffac1a..eb3fea6224 100644 --- a/pkg/services/control/server/server.go +++ b/pkg/services/control/server/server.go @@ -16,11 +16,11 @@ type Server struct { // HealthChecker is component interface for calculating // the current health status of a node. type HealthChecker interface { - // Must calculate and return current node health status. + // Must calculate and return current status of the node in NeoFS network map. // // If status can not be calculated for any reason, // control.HealthStatus_STATUS_UNDEFINED should be returned. - HealthStatus() control.HealthStatus + NetmapStatus() control.NetmapStatus } // Option of the Server's constructor. diff --git a/pkg/services/control/service.go b/pkg/services/control/service.go index 237a8987d0..1ab9f6b851 100644 --- a/pkg/services/control/service.go +++ b/pkg/services/control/service.go @@ -59,10 +59,10 @@ func (x *HealthCheckRequest) SignedDataSize() int { return x.GetBody().StableSize() } -// SetStatus sets health status of storage node. -func (x *HealthCheckResponse_Body) SetStatus(v HealthStatus) { +// SetNetmapStatus sets status of the storage node in NeoFS network map. +func (x *HealthCheckResponse_Body) SetNetmapStatus(v NetmapStatus) { if x != nil { - x.Status = v + x.NetmapStatus = v } } @@ -89,7 +89,7 @@ func (x *HealthCheckResponse_Body) StableMarshal(buf []byte) ([]byte, error) { buf = make([]byte, sz) } - _, err := proto.EnumMarshal(healthRespBodyStatusFNum, buf, int32(x.Status)) + _, err := proto.EnumMarshal(healthRespBodyStatusFNum, buf, int32(x.NetmapStatus)) if err != nil { return nil, err } @@ -108,7 +108,7 @@ func (x *HealthCheckResponse_Body) StableSize() int { size := 0 - size += proto.EnumSize(healthRespBodyStatusFNum, int32(x.Status)) + size += proto.EnumSize(healthRespBodyStatusFNum, int32(x.NetmapStatus)) return size } diff --git a/pkg/services/control/service.pb.go b/pkg/services/control/service.pb.go index c571ed0cff28c748919d0eb10582ac9b87cd970f..598ea9f9d6b184a5591c4092664c232cbbe8f371 100644 GIT binary patch delta 895 zcmY*YO-~b16b)a+4lPs5M@So*QUM`0WoFvWbfzuSf*mmCp#+VInqX7fg-VO1NL`q) z(1j+t@T}ZujO<*XX+aNbLY;TSD#wmd~SKU zGt@O#tgTn7*MiIW6?`1>_0XJ#3$=W0Z8c~o=nM_}%Dld~%7O6J)k-;SmlhBX`TU1z zp&)~eP?PffVyOK;d~CcaY`ehIKNvX77o4{RXSG;ctCpLMjm^;=v9+KyHdI$zYfQmI zeWE9t4+o{XWIvZ!tU^c)x0JB0kF*L-?CRqkv?|B3o0GAZjNz^^A{2OMF-#lWsZqQ( zj`uPd`9MsLGw{1Xux@#o(0r2MPtMAMJANd;GO9A7an2%N8RW-Ub^#yOHt z#Ic+SbpLZu5{&;ivw(WS#k4PHg79Udw2P-d(*$GIJ-nOL@muE_ev=?#xsaK1Fv3Re zG#*&p*wc9Wfueo3*<^;`rX4<|VLid)$qP8%O0NJhEigBD*x`D84hSsR#NQK;lPa<0=FVMDZ-{v zN|4P6+GqVxqhe!XHr*i}KGg9s328ELR5yZ!O1W08T#wjrW0NekxtsTI|1#K`>&Noh K&c=y(N9ZqRy%2=} delta 785 zcmZ8fOK1~e5T29hWui6ki&L3{C{ z2OoT(S5Mx=#y~-&_o5VfjtcRjh={#a@#6pQMq9iL!_4>iXa3pwGS>S%wl!Gr7wgsQ z-K%V;TkWoQ*j9sNt#2dkXjt{3z!$6o8SnsH7S!R1LG zhHIw&4!1i#t0O#1>~R97ZO%DOm@(gG%n7~)1gr}sZk8dQeoy4uQgHj*o72;{chqN6Z zQ#M#KC0h3LZfs^^_@3o3$Y_s#C(PqbIDLjLMGR>>4bvDTTgHQ|3U5|HK%RnEoY6o* zZH50mzwVutdN&l zQl4Lwt&p2opvP5GS&*vWms$ekO!j5AVS_Rq#KhTQ!fTloq#(i&8{+-_d_4VJVbaf; z6{S(7-Q1Anm046# zfr6DS&?DsQj=AUl_xWss%&O5yvxjzs>8)OS;JUiGqdR;R+y2i St(0Lpu2?N*gt2RFx;OzJdzl~r delta 467 zcmbQ)!`R-#xIvzo!y`2@rzAt6c(MYsB(EMu0><3WtRMvu z4K7J6DJ_oo_w(`ebA@U8$*d@iD(&WmEN{x9iXyMaRhC$!puxonwW*XP24>TBmMT+Z zqcjy<^Gb6yG!?XvMHQ;KI13c4Y!&iS%Qc{ew6Utf4B5z90As4NwZNDg+45jaRrVAZ zv!7iN%G|t-J)9FJEG%dT6Al;L&BB9h`{WJMvXiaF1Yv3yGK+7{6ibnkx6n~As4z1H zlZIe28AO_!fY}z41x+4$Nv!LlRR+#a7t(0L-d1kek5ytMf>EZ+c D#3+~1 diff --git a/pkg/services/control/types.proto b/pkg/services/control/types.proto index f481e04eee..03b5a128f2 100644 --- a/pkg/services/control/types.proto +++ b/pkg/services/control/types.proto @@ -13,8 +13,8 @@ message Signature { bytes sign = 2 [json_name = "signature"]; } -// Health status of the storage node. -enum HealthStatus { +// Status of the storage node in the NeoFS network map. +enum NetmapStatus { // Undefined status, default value. STATUS_UNDEFINED = 0; @@ -90,7 +90,7 @@ message NodeInfo { repeated Attribute attributes = 3 [json_name = "attributes"]; // Carries state of the NeoFS node. - HealthStatus state = 4 [json_name = "state"]; + NetmapStatus state = 4 [json_name = "state"]; } // Network map structure. diff --git a/pkg/services/control/types_test.go b/pkg/services/control/types_test.go index aa7237e3b0..faed9ba772 100644 --- a/pkg/services/control/types_test.go +++ b/pkg/services/control/types_test.go @@ -25,7 +25,7 @@ func generateNetmap() *control.Netmap { n := new(control.NodeInfo) n.SetPublicKey(testData(33)) n.SetAddress(testString()) - n.SetState(control.HealthStatus_ONLINE) + n.SetState(control.NetmapStatus_ONLINE) const attrCount = 2