forked from TrueCloudLab/frostfs-node
[#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
|
||||
}
|
||||
|
||||
cmd.Printf("Node status: %s\n", resp.GetBody().GetStatus())
|
||||
cmd.Printf("Node network status: %s\n", resp.GetBody().GetNetmapStatus())
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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())
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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),
|
||||
|
|
|
@ -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 {
|
||||
|
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
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 {
|
||||
// Health check response body
|
||||
message Body {
|
||||
// Health status of storage node.
|
||||
HealthStatus status = 1;
|
||||
// Status of the storage node in NeoFS network map.
|
||||
NetmapStatus netmap_status = 1;
|
||||
}
|
||||
|
||||
// Body of health check response message.
|
||||
|
|
|
@ -21,13 +21,13 @@ func TestHealthCheckResponse_Body_StableMarshal(t *testing.T) {
|
|||
|
||||
func generateHealthCheckResponseBody() *control.HealthCheckResponse_Body {
|
||||
body := new(control.HealthCheckResponse_Body)
|
||||
body.SetStatus(control.HealthStatus_ONLINE)
|
||||
body.SetNetmapStatus(control.NetmapStatus_ONLINE)
|
||||
|
||||
return body
|
||||
}
|
||||
|
||||
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) {
|
||||
|
|
|
@ -140,7 +140,7 @@ func (x *NodeInfo) SetAttributes(v []*NodeInfo_Attribute) {
|
|||
}
|
||||
|
||||
// SetState sets state of the NeoFS node.
|
||||
func (x *NodeInfo) SetState(v HealthStatus) {
|
||||
func (x *NodeInfo) SetState(v NetmapStatus) {
|
||||
if x != nil {
|
||||
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"];
|
||||
}
|
||||
|
||||
// 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.
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue