[#313] control: Rename HealthStatus enum to NetmapStatus
Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
a89567a88d
commit
83d4420a30
16 changed files with 28 additions and 28 deletions
|
@ -84,7 +84,7 @@ func healthCheck(cmd *cobra.Command, _ []string) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
cmd.Printf("Node status: %s\n", resp.GetBody().GetStatus())
|
cmd.Printf("Node network status: %s\n", resp.GetBody().GetNetmapStatus())
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -342,7 +342,7 @@ func initCfg(path string) *cfg {
|
||||||
cfgObject: cfgObject{
|
cfgObject: cfgObject{
|
||||||
pool: initObjectPool(viperCfg),
|
pool: initObjectPool(viperCfg),
|
||||||
},
|
},
|
||||||
healthStatus: atomic.NewInt32(int32(control.HealthStatus_STATUS_UNDEFINED)),
|
healthStatus: atomic.NewInt32(int32(control.NetmapStatus_STATUS_UNDEFINED)),
|
||||||
}
|
}
|
||||||
|
|
||||||
initLocalStorage(c)
|
initLocalStorage(c)
|
||||||
|
|
|
@ -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))
|
c.healthStatus.Store(int32(st))
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *cfg) HealthStatus() control.HealthStatus {
|
func (c *cfg) NetmapStatus() control.NetmapStatus {
|
||||||
return control.HealthStatus(c.healthStatus.Load())
|
return control.NetmapStatus(c.healthStatus.Load())
|
||||||
}
|
}
|
||||||
|
|
|
@ -56,7 +56,7 @@ func bootUp(c *cfg) {
|
||||||
bootstrapNode(c)
|
bootstrapNode(c)
|
||||||
startWorkers(c)
|
startWorkers(c)
|
||||||
|
|
||||||
c.setHealthStatus(control.HealthStatus_ONLINE)
|
c.setNetmapStatus(control.NetmapStatus_ONLINE)
|
||||||
}
|
}
|
||||||
|
|
||||||
func wait(c *cfg) {
|
func wait(c *cfg) {
|
||||||
|
|
|
@ -117,7 +117,7 @@ func addNewEpochNotificationHandler(c *cfg, h event.Handler) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func goOffline(c *cfg) {
|
func goOffline(c *cfg) {
|
||||||
c.setHealthStatus(control.HealthStatus_OFFLINE)
|
c.setNetmapStatus(control.NetmapStatus_OFFLINE)
|
||||||
|
|
||||||
err := c.cfgNetmap.wrapper.UpdatePeerState(
|
err := c.cfgNetmap.wrapper.UpdatePeerState(
|
||||||
crypto.MarshalPublicKey(&c.key.PublicKey),
|
crypto.MarshalPublicKey(&c.key.PublicKey),
|
||||||
|
|
|
@ -23,7 +23,7 @@ func (s *Server) HealthCheck(_ context.Context, req *control.HealthCheckRequest)
|
||||||
body := new(control.HealthCheckResponse_Body)
|
body := new(control.HealthCheckResponse_Body)
|
||||||
resp.SetBody(body)
|
resp.SetBody(body)
|
||||||
|
|
||||||
body.SetStatus(s.healthChecker.HealthStatus())
|
body.SetNetmapStatus(s.healthChecker.NetmapStatus())
|
||||||
|
|
||||||
// sign the response
|
// sign the response
|
||||||
if err := SignMessage(s.key, resp); err != nil {
|
if err := SignMessage(s.key, resp); err != nil {
|
||||||
|
|
|
@ -63,14 +63,14 @@ func nodesFromAPI(apiNodes netmapAPI.Nodes) []*control.NodeInfo {
|
||||||
return nodes
|
return nodes
|
||||||
}
|
}
|
||||||
|
|
||||||
func stateFromAPI(s netmapAPI.NodeState) control.HealthStatus {
|
func stateFromAPI(s netmapAPI.NodeState) control.NetmapStatus {
|
||||||
switch s {
|
switch s {
|
||||||
default:
|
default:
|
||||||
return control.HealthStatus_STATUS_UNDEFINED
|
return control.NetmapStatus_STATUS_UNDEFINED
|
||||||
case netmapAPI.NodeStateOffline:
|
case netmapAPI.NodeStateOffline:
|
||||||
return control.HealthStatus_OFFLINE
|
return control.NetmapStatus_OFFLINE
|
||||||
case netmapAPI.NodeStateOnline:
|
case netmapAPI.NodeStateOnline:
|
||||||
return control.HealthStatus_ONLINE
|
return control.NetmapStatus_ONLINE
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,11 +16,11 @@ type Server struct {
|
||||||
// HealthChecker is component interface for calculating
|
// HealthChecker is component interface for calculating
|
||||||
// the current health status of a node.
|
// the current health status of a node.
|
||||||
type HealthChecker interface {
|
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,
|
// If status can not be calculated for any reason,
|
||||||
// control.HealthStatus_STATUS_UNDEFINED should be returned.
|
// control.HealthStatus_STATUS_UNDEFINED should be returned.
|
||||||
HealthStatus() control.HealthStatus
|
NetmapStatus() control.NetmapStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
// Option of the Server's constructor.
|
// Option of the Server's constructor.
|
||||||
|
|
|
@ -59,10 +59,10 @@ func (x *HealthCheckRequest) SignedDataSize() int {
|
||||||
return x.GetBody().StableSize()
|
return x.GetBody().StableSize()
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetStatus sets health status of storage node.
|
// SetNetmapStatus sets status of the storage node in NeoFS network map.
|
||||||
func (x *HealthCheckResponse_Body) SetStatus(v HealthStatus) {
|
func (x *HealthCheckResponse_Body) SetNetmapStatus(v NetmapStatus) {
|
||||||
if x != nil {
|
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)
|
buf = make([]byte, sz)
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err := proto.EnumMarshal(healthRespBodyStatusFNum, buf, int32(x.Status))
|
_, err := proto.EnumMarshal(healthRespBodyStatusFNum, buf, int32(x.NetmapStatus))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
@ -108,7 +108,7 @@ func (x *HealthCheckResponse_Body) StableSize() int {
|
||||||
|
|
||||||
size := 0
|
size := 0
|
||||||
|
|
||||||
size += proto.EnumSize(healthRespBodyStatusFNum, int32(x.Status))
|
size += proto.EnumSize(healthRespBodyStatusFNum, int32(x.NetmapStatus))
|
||||||
|
|
||||||
return size
|
return size
|
||||||
}
|
}
|
||||||
|
|
BIN
pkg/services/control/service.pb.go
generated
BIN
pkg/services/control/service.pb.go
generated
Binary file not shown.
|
@ -32,8 +32,8 @@ message HealthCheckRequest {
|
||||||
message HealthCheckResponse {
|
message HealthCheckResponse {
|
||||||
// Health check response body
|
// Health check response body
|
||||||
message Body {
|
message Body {
|
||||||
// Health status of storage node.
|
// Status of the storage node in NeoFS network map.
|
||||||
HealthStatus status = 1;
|
NetmapStatus netmap_status = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Body of health check response message.
|
// Body of health check response message.
|
||||||
|
|
|
@ -21,13 +21,13 @@ func TestHealthCheckResponse_Body_StableMarshal(t *testing.T) {
|
||||||
|
|
||||||
func generateHealthCheckResponseBody() *control.HealthCheckResponse_Body {
|
func generateHealthCheckResponseBody() *control.HealthCheckResponse_Body {
|
||||||
body := new(control.HealthCheckResponse_Body)
|
body := new(control.HealthCheckResponse_Body)
|
||||||
body.SetStatus(control.HealthStatus_ONLINE)
|
body.SetNetmapStatus(control.NetmapStatus_ONLINE)
|
||||||
|
|
||||||
return body
|
return body
|
||||||
}
|
}
|
||||||
|
|
||||||
func equalHealthCheckResponseBodies(b1, b2 *control.HealthCheckResponse_Body) bool {
|
func equalHealthCheckResponseBodies(b1, b2 *control.HealthCheckResponse_Body) bool {
|
||||||
return b1.GetStatus() == b2.GetStatus()
|
return b1.GetNetmapStatus() == b2.GetNetmapStatus()
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestNetmapSnapshotResponse_Body_StableMarshal(t *testing.T) {
|
func TestNetmapSnapshotResponse_Body_StableMarshal(t *testing.T) {
|
||||||
|
|
|
@ -140,7 +140,7 @@ func (x *NodeInfo) SetAttributes(v []*NodeInfo_Attribute) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetState sets state of the NeoFS node.
|
// SetState sets state of the NeoFS node.
|
||||||
func (x *NodeInfo) SetState(v HealthStatus) {
|
func (x *NodeInfo) SetState(v NetmapStatus) {
|
||||||
if x != nil {
|
if x != nil {
|
||||||
x.State = v
|
x.State = v
|
||||||
}
|
}
|
||||||
|
|
BIN
pkg/services/control/types.pb.go
generated
BIN
pkg/services/control/types.pb.go
generated
Binary file not shown.
|
@ -13,8 +13,8 @@ message Signature {
|
||||||
bytes sign = 2 [json_name = "signature"];
|
bytes sign = 2 [json_name = "signature"];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Health status of the storage node.
|
// Status of the storage node in the NeoFS network map.
|
||||||
enum HealthStatus {
|
enum NetmapStatus {
|
||||||
// Undefined status, default value.
|
// Undefined status, default value.
|
||||||
STATUS_UNDEFINED = 0;
|
STATUS_UNDEFINED = 0;
|
||||||
|
|
||||||
|
@ -90,7 +90,7 @@ message NodeInfo {
|
||||||
repeated Attribute attributes = 3 [json_name = "attributes"];
|
repeated Attribute attributes = 3 [json_name = "attributes"];
|
||||||
|
|
||||||
// Carries state of the NeoFS node.
|
// Carries state of the NeoFS node.
|
||||||
HealthStatus state = 4 [json_name = "state"];
|
NetmapStatus state = 4 [json_name = "state"];
|
||||||
}
|
}
|
||||||
|
|
||||||
// Network map structure.
|
// Network map structure.
|
||||||
|
|
|
@ -25,7 +25,7 @@ func generateNetmap() *control.Netmap {
|
||||||
n := new(control.NodeInfo)
|
n := new(control.NodeInfo)
|
||||||
n.SetPublicKey(testData(33))
|
n.SetPublicKey(testData(33))
|
||||||
n.SetAddress(testString())
|
n.SetAddress(testString())
|
||||||
n.SetState(control.HealthStatus_ONLINE)
|
n.SetState(control.NetmapStatus_ONLINE)
|
||||||
|
|
||||||
const attrCount = 2
|
const attrCount = 2
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue