diff --git a/pkg/services/control/service.go b/pkg/services/control/service.go index f4ce62439c..083dc48095 100644 --- a/pkg/services/control/service.go +++ b/pkg/services/control/service.go @@ -310,3 +310,146 @@ func (x *NetmapSnapshotResponse) ReadSignedData(buf []byte) ([]byte, error) { func (x *NetmapSnapshotResponse) SignedDataSize() int { return x.GetBody().StableSize() } + +// SetStatus sets new storage node status in NeoFS network map. +func (x *SetNetmapStatusRequest_Body) SetStatus(v NetmapStatus) { + if x != nil { + x.Status = v + } +} + +const ( + _ = iota + setNetmapStatusReqBodyStatusFNum +) + +// StableMarshal reads binary representation of set netmap status request body +// in protobuf binary format. +// +// If buffer length is less than x.StableSize(), new buffer is allocated. +// +// Returns any error encountered which did not allow writing the data completely. +// Otherwise, returns the buffer in which the data is written. +// +// Structures with the same field values have the same binary format. +func (x *SetNetmapStatusRequest_Body) StableMarshal(buf []byte) ([]byte, error) { + if x == nil { + return []byte{}, nil + } + + if sz := x.StableSize(); len(buf) < sz { + buf = make([]byte, sz) + } + + _, err := proto.EnumMarshal(setNetmapStatusReqBodyStatusFNum, buf, int32(x.Status)) + if err != nil { + return nil, err + } + + return buf, nil +} + +// StableSize returns binary size of health check response body +// in protobuf binary format. +// +// Structures with the same field values have the same binary size. +func (x *SetNetmapStatusRequest_Body) StableSize() int { + if x == nil { + return 0 + } + + size := 0 + + size += proto.EnumSize(setNetmapStatusReqBodyStatusFNum, int32(x.Status)) + + return size +} + +// SetBody sets body of the set netmap status request . +func (x *SetNetmapStatusRequest) SetBody(v *SetNetmapStatusRequest_Body) { + if x != nil { + x.Body = v + } +} + +// SetSignature sets signature of the set netmap status request body. +func (x *SetNetmapStatusRequest) SetSignature(body *Signature) { + if x != nil { + x.Signature = body + } +} + +// ReadSignedData reads signed data of set netmap status request to buf. +// +// If buffer length is less than x.SignedDataSize(), new buffer is allocated. +// +// Returns any error encountered which did not allow writing the data completely. +// Otherwise, returns the buffer in which the data is written. +// +// Structures with the same field values have the same signed data. +func (x *SetNetmapStatusRequest) ReadSignedData(buf []byte) ([]byte, error) { + return x.GetBody().StableMarshal(buf) +} + +// SignedDataSize returns binary size of the signed data +// of set netmap status request. +// +// Structures with the same field values have the same signed data size. +func (x *SetNetmapStatusRequest) SignedDataSize() int { + return x.GetBody().StableSize() +} + +// StableMarshal reads binary representation of set netmap status response body +// in protobuf binary format. +// +// If buffer length is less than x.StableSize(), new buffer is allocated. +// +// Returns any error encountered which did not allow writing the data completely. +// Otherwise, returns the buffer in which the data is written. +// +// Structures with the same field values have the same binary format. +func (x *SetNetmapStatusResponse_Body) StableMarshal(buf []byte) ([]byte, error) { + return buf, nil +} + +// StableSize returns binary size of set netmap status response body +// in protobuf binary format. +// +// Structures with the same field values have the same binary size. +func (x *SetNetmapStatusResponse_Body) StableSize() int { + return 0 +} + +// SetBody sets set body of the netmap status response. +func (x *SetNetmapStatusResponse) SetBody(v *SetNetmapStatusResponse_Body) { + if x != nil { + x.Body = v + } +} + +// SetSignature sets signature of the set netmap status response body. +func (x *SetNetmapStatusResponse) SetSignature(v *Signature) { + if x != nil { + x.Signature = v + } +} + +// ReadSignedData reads signed data of set netmap status response to buf. +// +// If buffer length is less than x.SignedDataSize(), new buffer is allocated. +// +// Returns any error encountered which did not allow writing the data completely. +// Otherwise, returns the buffer in which the data is written. +// +// Structures with the same field values have the same signed data. +func (x *SetNetmapStatusResponse) ReadSignedData(buf []byte) ([]byte, error) { + return x.GetBody().StableMarshal(buf) +} + +// SignedDataSize returns binary size of the signed data +// of set netmap status response. +// +// Structures with the same field values have the same signed data size. +func (x *SetNetmapStatusResponse) SignedDataSize() int { + return x.GetBody().StableSize() +} diff --git a/pkg/services/control/service.pb.go b/pkg/services/control/service.pb.go index a253b35917..c5758b83c0 100644 Binary files a/pkg/services/control/service.pb.go and b/pkg/services/control/service.pb.go differ diff --git a/pkg/services/control/service.proto b/pkg/services/control/service.proto index 50c23eeb37..2565a9df82 100644 --- a/pkg/services/control/service.proto +++ b/pkg/services/control/service.proto @@ -13,6 +13,9 @@ service ControlService { // Returns network map snapshot of the current NeoFS epoch. rpc NetmapSnapshot (NetmapSnapshotRequest) returns (NetmapSnapshotResponse); + + // Sets status of the storage node in NeoFS network map. + rpc SetNetmapStatus (SetNetmapStatusRequest) returns (SetNetmapStatusResponse); } // Health check request. @@ -73,3 +76,31 @@ message NetmapSnapshotResponse { // Body signature. Signature signature = 2; } + +// Set netmap status request. +message SetNetmapStatusRequest { + // Set netmap status request body. + message Body { + // New storage node status in NeoFS network map. + NetmapStatus status = 1; + } + + // Body of set netmap status request message. + Body body = 1; + + // Body signature. + Signature signature = 2; +} + +// Set netmap status response. +message SetNetmapStatusResponse { + // Set netmap status response body + message Body { + } + + // Body of set netmap status response message. + Body body = 1; + + // Body signature. + Signature signature = 2; +} diff --git a/pkg/services/control/service_test.go b/pkg/services/control/service_test.go index 3c9bb6012b..76933b4b29 100644 --- a/pkg/services/control/service_test.go +++ b/pkg/services/control/service_test.go @@ -55,3 +55,27 @@ func generateNetmapSnapshotResponseBody() *control.NetmapSnapshotResponse_Body { func equalNetmapSnapshotResponseBodies(b1, b2 *control.NetmapSnapshotResponse_Body) bool { return equalNetmaps(b1.GetNetmap(), b2.GetNetmap()) } + +func TestSetNetmapStatusRequest_Body_StableMarshal(t *testing.T) { + testStableMarshal(t, + generateSetNetmapStatusRequestBody(), + new(control.SetNetmapStatusRequest_Body), + func(m1, m2 protoMessage) bool { + return equalSetnetmapStatusRequestBodies( + m1.(*control.SetNetmapStatusRequest_Body), + m2.(*control.SetNetmapStatusRequest_Body), + ) + }, + ) +} + +func generateSetNetmapStatusRequestBody() *control.SetNetmapStatusRequest_Body { + body := new(control.SetNetmapStatusRequest_Body) + body.SetStatus(control.NetmapStatus_ONLINE) + + return body +} + +func equalSetnetmapStatusRequestBodies(b1, b2 *control.SetNetmapStatusRequest_Body) bool { + return b1.GetStatus() == b2.GetStatus() +}