Revert "Revert "[#16] object: Allow set `copy_number` for every placement vector""

This reverts commit 4a34188c9ef4b7404e1abaac5f72d1c302d322e7.
feature/40-autogen_marsh/refs_grpc
Evgenii Stratonikov 2023-04-11 10:37:11 +03:00
parent 84dc99a045
commit 3b938873cc
5 changed files with 23 additions and 13 deletions

View File

@ -109,7 +109,7 @@ func (m *PutRequest_Body_Init) SetHeader(v *Header) {
} }
// SetCopiesNumber sets number of the copies to save. // SetCopiesNumber sets number of the copies to save.
func (m *PutRequest_Body_Init) SetCopiesNumber(v uint32) { func (m *PutRequest_Body_Init) SetCopiesNumber(v []uint32) {
m.CopiesNumber = v m.CopiesNumber = v
} }

View File

@ -1452,9 +1452,17 @@ type PutRequest_Body_Init struct {
Signature *grpc1.Signature `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"` Signature *grpc1.Signature `protobuf:"bytes,2,opt,name=signature,proto3" json:"signature,omitempty"`
// Object's Header // Object's Header
Header *Header `protobuf:"bytes,3,opt,name=header,proto3" json:"header,omitempty"` Header *Header `protobuf:"bytes,3,opt,name=header,proto3" json:"header,omitempty"`
// Number of the object copies to store within the RPC call. By default // Number of copies of the object to store within the RPC call. By default,
// object is processed according to the container's placement policy. // object is processed according to the container's placement policy.
CopiesNumber uint32 `protobuf:"varint,4,opt,name=copies_number,json=copiesNumber,proto3" json:"copies_number,omitempty"` // Can be one of:
// 1. A single number; applied to the whole request and is treated as
// a minimal number of nodes that must store an object to complete the
// request successfully.
// 2. An ordered array; every number is treated as a minimal number of
// nodes in a corresponding placement vector that must store an object
// to complete the request successfully. The length MUST equal the placement
// vectors number, otherwise request is considered malformed.
CopiesNumber []uint32 `protobuf:"varint,4,rep,packed,name=copies_number,json=copiesNumber,proto3" json:"copies_number,omitempty"`
} }
func (x *PutRequest_Body_Init) Reset() { func (x *PutRequest_Body_Init) Reset() {
@ -1510,11 +1518,11 @@ func (x *PutRequest_Body_Init) GetHeader() *Header {
return nil return nil
} }
func (x *PutRequest_Body_Init) GetCopiesNumber() uint32 { func (x *PutRequest_Body_Init) GetCopiesNumber() []uint32 {
if x != nil { if x != nil {
return x.CopiesNumber return x.CopiesNumber
} }
return 0 return nil
} }
// PUT Object response body // PUT Object response body
@ -2457,7 +2465,7 @@ var file_object_grpc_service_proto_rawDesc = []byte{
0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6e, 0x65, 0x6f, 0x2e, 0x66, 0x65, 0x72, 0x18, 0x03, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x6e, 0x65, 0x6f, 0x2e, 0x66,
0x73, 0x2e, 0x76, 0x32, 0x2e, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x48, 0x65, 0x61, 0x64, 0x73, 0x2e, 0x76, 0x32, 0x2e, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x2e, 0x48, 0x65, 0x61, 0x64,
0x65, 0x72, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6f, 0x65, 0x72, 0x52, 0x06, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x23, 0x0a, 0x0d, 0x63, 0x6f,
0x70, 0x69, 0x65, 0x73, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x04, 0x20, 0x01, 0x28, 0x70, 0x69, 0x65, 0x73, 0x5f, 0x6e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x18, 0x04, 0x20, 0x03, 0x28,
0x0d, 0x52, 0x0c, 0x63, 0x6f, 0x70, 0x69, 0x65, 0x73, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x42, 0x0d, 0x52, 0x0c, 0x63, 0x6f, 0x70, 0x69, 0x65, 0x73, 0x4e, 0x75, 0x6d, 0x62, 0x65, 0x72, 0x42,
0x0d, 0x0a, 0x0b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x22, 0xa0, 0x0d, 0x0a, 0x0b, 0x6f, 0x62, 0x6a, 0x65, 0x63, 0x74, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x22, 0xa0,
0x02, 0x0a, 0x0b, 0x50, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x36, 0x02, 0x0a, 0x0b, 0x50, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x36,

View File

@ -516,7 +516,7 @@ func (r *PutObjectPartInit) StableMarshal(buf []byte) []byte {
offset += proto.NestedStructureMarshal(putReqInitObjectIDField, buf[offset:], r.id) offset += proto.NestedStructureMarshal(putReqInitObjectIDField, buf[offset:], r.id)
offset += proto.NestedStructureMarshal(putReqInitSignatureField, buf[offset:], r.sig) offset += proto.NestedStructureMarshal(putReqInitSignatureField, buf[offset:], r.sig)
offset += proto.NestedStructureMarshal(putReqInitHeaderField, buf[offset:], r.hdr) offset += proto.NestedStructureMarshal(putReqInitHeaderField, buf[offset:], r.hdr)
proto.UInt32Marshal(putReqInitCopiesNumField, buf[offset:], r.copyNum) proto.RepeatedUInt32Marshal(putReqInitCopiesNumField, buf[offset:], r.copyNum)
return buf return buf
} }
@ -529,7 +529,9 @@ func (r *PutObjectPartInit) StableSize() (size int) {
size += proto.NestedStructureSize(putReqInitObjectIDField, r.id) size += proto.NestedStructureSize(putReqInitObjectIDField, r.id)
size += proto.NestedStructureSize(putReqInitSignatureField, r.sig) size += proto.NestedStructureSize(putReqInitSignatureField, r.sig)
size += proto.NestedStructureSize(putReqInitHeaderField, r.hdr) size += proto.NestedStructureSize(putReqInitHeaderField, r.hdr)
size += proto.UInt32Size(putReqInitCopiesNumField, r.copyNum)
arrSize, _ := proto.RepeatedUInt32Size(putReqInitCopiesNumField, r.copyNum)
size += arrSize
return size return size
} }

View File

@ -216,7 +216,7 @@ func GeneratePutObjectPartInit(empty bool) *object.PutObjectPartInit {
m := new(object.PutObjectPartInit) m := new(object.PutObjectPartInit)
if !empty { if !empty {
m.SetCopiesNumber(234) m.SetCopiesNumber([]uint32{234})
m.SetObjectID(refstest.GenerateObjectID(false)) m.SetObjectID(refstest.GenerateObjectID(false))
} }

View File

@ -128,7 +128,7 @@ type PutObjectPartInit struct {
hdr *Header hdr *Header
copyNum uint32 copyNum []uint32
} }
type PutObjectPartChunk struct { type PutObjectPartChunk struct {
@ -894,15 +894,15 @@ func (r *PutObjectPartInit) SetHeader(v *Header) {
r.hdr = v r.hdr = v
} }
func (r *PutObjectPartInit) GetCopiesNumber() uint32 { func (r *PutObjectPartInit) GetCopiesNumber() []uint32 {
if r != nil { if r != nil {
return r.copyNum return r.copyNum
} }
return 0 return nil
} }
func (r *PutObjectPartInit) SetCopiesNumber(v uint32) { func (r *PutObjectPartInit) SetCopiesNumber(v []uint32) {
r.copyNum = v r.copyNum = v
} }