forked from TrueCloudLab/frostfs-node
[#1238] Adopt neofs-node for non pointer slices in SDK
Signed-off-by: Alex Vanin <alexey@nspcc.ru>
This commit is contained in:
parent
9fad29dfe0
commit
8f476f3c4d
41 changed files with 146 additions and 148 deletions
|
@ -16,7 +16,7 @@ const (
|
||||||
defaultPrice = 0
|
defaultPrice = 0
|
||||||
)
|
)
|
||||||
|
|
||||||
func parseAttributes(c *config.Config) []*netmap.NodeAttribute {
|
func parseAttributes(c *config.Config) []netmap.NodeAttribute {
|
||||||
if nodeconfig.Relay(c) {
|
if nodeconfig.Relay(c) {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ func listWellKnownAttrDesc() map[string]wellKnownNodeAttrDesc {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func addWellKnownAttributes(attrs []*netmap.NodeAttribute) []*netmap.NodeAttribute {
|
func addWellKnownAttributes(attrs []netmap.NodeAttribute) []netmap.NodeAttribute {
|
||||||
mWellKnown := listWellKnownAttrDesc()
|
mWellKnown := listWellKnownAttrDesc()
|
||||||
|
|
||||||
// check how user defined well-known attributes
|
// check how user defined well-known attributes
|
||||||
|
@ -59,11 +59,10 @@ func addWellKnownAttributes(attrs []*netmap.NodeAttribute) []*netmap.NodeAttribu
|
||||||
}
|
}
|
||||||
|
|
||||||
// set default value of the attribute
|
// set default value of the attribute
|
||||||
a := netmap.NewNodeAttribute()
|
index := len(attrs)
|
||||||
a.SetKey(key)
|
attrs = append(attrs, netmap.NodeAttribute{})
|
||||||
a.SetValue(desc.defaultVal)
|
attrs[index].SetKey(key)
|
||||||
|
attrs[index].SetValue(desc.defaultVal)
|
||||||
attrs = append(attrs, a)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return attrs
|
return attrs
|
||||||
|
|
|
@ -468,7 +468,7 @@ func (c *usedSpaceService) AnnounceUsedSpace(ctx context.Context, req *container
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, aV2 := range req.GetBody().GetAnnouncements() {
|
for _, aV2 := range req.GetBody().GetAnnouncements() {
|
||||||
if err := c.processLoadValue(ctx, *containerSDK.NewAnnouncementFromV2(aV2), passedRoute, w); err != nil {
|
if err := c.processLoadValue(ctx, *containerSDK.NewAnnouncementFromV2(&aV2), passedRoute, w); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -354,7 +354,7 @@ func (n *netInfo) Dump(ver *refs.Version) (*netmapV2.NetworkInfo, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ps []*netmapV2.NetworkParameter
|
ps []netmapV2.NetworkParameter
|
||||||
netCfg netmapV2.NetworkConfig
|
netCfg netmapV2.NetworkConfig
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -364,7 +364,7 @@ func (n *netInfo) Dump(ver *refs.Version) (*netmapV2.NetworkInfo, error) {
|
||||||
p.SetKey(key)
|
p.SetKey(key)
|
||||||
p.SetValue(value)
|
p.SetValue(value)
|
||||||
|
|
||||||
ps = append(ps, &p)
|
ps = append(ps, p)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}); err != nil {
|
}); err != nil {
|
||||||
|
|
|
@ -260,7 +260,7 @@ func (s *reputationServer) AnnounceLocalTrust(ctx context.Context, req *v2reputa
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, trust := range body.GetTrusts() {
|
for _, trust := range body.GetTrusts() {
|
||||||
err = s.processLocalTrust(body.GetEpoch(), apiToLocalTrust(trust, passedRoute[0].PublicKey()), passedRoute, w)
|
err = s.processLocalTrust(body.GetEpoch(), apiToLocalTrust(&trust, passedRoute[0].PublicKey()), passedRoute, w)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("could not write one of local trusts: %w", err)
|
return nil, fmt.Errorf("could not write one of local trusts: %w", err)
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,7 +42,7 @@ func TestCheckFormat(t *testing.T) {
|
||||||
require.NoError(t, CheckFormat(c))
|
require.NoError(t, CheckFormat(c))
|
||||||
|
|
||||||
// set empty value attribute
|
// set empty value attribute
|
||||||
attr1 := container.NewAttribute()
|
var attr1 container.Attribute
|
||||||
attr1.SetKey("attr")
|
attr1.SetKey("attr")
|
||||||
attrs := container.Attributes{attr1}
|
attrs := container.Attributes{attr1}
|
||||||
|
|
||||||
|
@ -51,11 +51,11 @@ func TestCheckFormat(t *testing.T) {
|
||||||
require.ErrorIs(t, CheckFormat(c), errEmptyAttribute)
|
require.ErrorIs(t, CheckFormat(c), errEmptyAttribute)
|
||||||
|
|
||||||
// add same key attribute
|
// add same key attribute
|
||||||
attr2 := container.NewAttribute()
|
var attr2 container.Attribute
|
||||||
attr2.SetKey(attr1.Key())
|
attr2.SetKey(attr1.Key())
|
||||||
attr2.SetValue("val")
|
attr2.SetValue("val")
|
||||||
|
|
||||||
attr1.SetValue(attr2.Value())
|
attrs[0].SetValue(attr2.Value())
|
||||||
|
|
||||||
attrs = append(attrs, attr2)
|
attrs = append(attrs, attr2)
|
||||||
|
|
||||||
|
@ -63,7 +63,9 @@ func TestCheckFormat(t *testing.T) {
|
||||||
|
|
||||||
require.ErrorIs(t, CheckFormat(c), errRepeatedAttributes)
|
require.ErrorIs(t, CheckFormat(c), errRepeatedAttributes)
|
||||||
|
|
||||||
attr2.SetKey(attr1.Key() + "smth")
|
attrs[1].SetKey(attr1.Key() + "smth")
|
||||||
|
|
||||||
|
c.SetAttributes(attrs)
|
||||||
|
|
||||||
require.NoError(t, CheckFormat(c))
|
require.NoError(t, CheckFormat(c))
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ func TestFormatValidator_Validate(t *testing.T) {
|
||||||
require.Error(t, v.ValidateContent(obj)) // no tombstone content
|
require.Error(t, v.ValidateContent(obj)) // no tombstone content
|
||||||
|
|
||||||
content := object.NewTombstone()
|
content := object.NewTombstone()
|
||||||
content.SetMembers([]*oidSDK.ID{nil})
|
content.SetMembers([]oidSDK.ID{*testObjectID(t)})
|
||||||
|
|
||||||
data, err := content.Marshal()
|
data, err := content.Marshal()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -128,7 +128,7 @@ func TestFormatValidator_Validate(t *testing.T) {
|
||||||
|
|
||||||
require.Error(t, v.ValidateContent(obj)) // no members in tombstone
|
require.Error(t, v.ValidateContent(obj)) // no members in tombstone
|
||||||
|
|
||||||
content.SetMembers([]*oidSDK.ID{testObjectID(t)})
|
content.SetMembers([]oidSDK.ID{*testObjectID(t)})
|
||||||
|
|
||||||
data, err = content.Marshal()
|
data, err = content.Marshal()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -137,7 +137,7 @@ func TestFormatValidator_Validate(t *testing.T) {
|
||||||
|
|
||||||
require.Error(t, v.ValidateContent(obj)) // no expiration epoch in tombstone
|
require.Error(t, v.ValidateContent(obj)) // no expiration epoch in tombstone
|
||||||
|
|
||||||
expirationAttribute := object.NewAttribute()
|
var expirationAttribute object.Attribute
|
||||||
expirationAttribute.SetKey(objectV2.SysAttributeExpEpoch)
|
expirationAttribute.SetKey(objectV2.SysAttributeExpEpoch)
|
||||||
expirationAttribute.SetValue(strconv.Itoa(10))
|
expirationAttribute.SetValue(strconv.Itoa(10))
|
||||||
|
|
||||||
|
@ -161,7 +161,7 @@ func TestFormatValidator_Validate(t *testing.T) {
|
||||||
require.Error(t, v.ValidateContent(obj))
|
require.Error(t, v.ValidateContent(obj))
|
||||||
|
|
||||||
content := storagegroup.New()
|
content := storagegroup.New()
|
||||||
content.SetMembers([]*oidSDK.ID{nil})
|
content.SetMembers([]oidSDK.ID{})
|
||||||
|
|
||||||
data, err := content.Marshal()
|
data, err := content.Marshal()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -170,7 +170,7 @@ func TestFormatValidator_Validate(t *testing.T) {
|
||||||
|
|
||||||
require.Error(t, v.ValidateContent(obj))
|
require.Error(t, v.ValidateContent(obj))
|
||||||
|
|
||||||
content.SetMembers([]*oidSDK.ID{testObjectID(t)})
|
content.SetMembers([]oidSDK.ID{*testObjectID(t)})
|
||||||
|
|
||||||
data, err = content.Marshal()
|
data, err = content.Marshal()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -184,7 +184,7 @@ func TestFormatValidator_Validate(t *testing.T) {
|
||||||
fn := func(val string) *object.Object {
|
fn := func(val string) *object.Object {
|
||||||
obj := blankValidObject(&ownerKey.PrivateKey)
|
obj := blankValidObject(&ownerKey.PrivateKey)
|
||||||
|
|
||||||
a := object.NewAttribute()
|
var a object.Attribute
|
||||||
a.SetKey(objectV2.SysAttributeExpEpoch)
|
a.SetKey(objectV2.SysAttributeExpEpoch)
|
||||||
a.SetValue(val)
|
a.SetValue(val)
|
||||||
|
|
||||||
|
@ -218,11 +218,11 @@ func TestFormatValidator_Validate(t *testing.T) {
|
||||||
t.Run("duplication", func(t *testing.T) {
|
t.Run("duplication", func(t *testing.T) {
|
||||||
obj := blankValidObject(&ownerKey.PrivateKey)
|
obj := blankValidObject(&ownerKey.PrivateKey)
|
||||||
|
|
||||||
a1 := object.NewAttribute()
|
var a1 object.Attribute
|
||||||
a1.SetKey("key1")
|
a1.SetKey("key1")
|
||||||
a1.SetValue("val1")
|
a1.SetValue("val1")
|
||||||
|
|
||||||
a2 := object.NewAttribute()
|
var a2 object.Attribute
|
||||||
a2.SetKey("key2")
|
a2.SetKey("key2")
|
||||||
a2.SetValue("val2")
|
a2.SetValue("val2")
|
||||||
|
|
||||||
|
@ -232,6 +232,7 @@ func TestFormatValidator_Validate(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
a2.SetKey(a1.Key())
|
a2.SetKey(a1.Key())
|
||||||
|
obj.SetAttributes(a1, a2)
|
||||||
|
|
||||||
err = v.checkAttributes(obj)
|
err = v.checkAttributes(obj)
|
||||||
require.Equal(t, errDuplAttr, err)
|
require.Equal(t, errDuplAttr, err)
|
||||||
|
@ -240,7 +241,7 @@ func TestFormatValidator_Validate(t *testing.T) {
|
||||||
t.Run("empty value", func(t *testing.T) {
|
t.Run("empty value", func(t *testing.T) {
|
||||||
obj := blankValidObject(&ownerKey.PrivateKey)
|
obj := blankValidObject(&ownerKey.PrivateKey)
|
||||||
|
|
||||||
a := object.NewAttribute()
|
var a object.Attribute
|
||||||
a.SetKey("key")
|
a.SetKey("key")
|
||||||
|
|
||||||
obj.SetAttributes(a)
|
obj.SetAttributes(a)
|
||||||
|
|
|
@ -98,7 +98,7 @@ func TestBlobstor_needsCompression(t *testing.T) {
|
||||||
newObjectWithCt := func(contentType string) *objectSDK.Object {
|
newObjectWithCt := func(contentType string) *objectSDK.Object {
|
||||||
obj := testObject(smallSizeLimit + 1)
|
obj := testObject(smallSizeLimit + 1)
|
||||||
if contentType != "" {
|
if contentType != "" {
|
||||||
a := objectSDK.NewAttribute()
|
var a objectSDK.Attribute
|
||||||
a.SetKey(objectSDK.AttributeContentType)
|
a.SetKey(objectSDK.AttributeContentType)
|
||||||
a.SetValue(contentType)
|
a.SetValue(contentType)
|
||||||
obj.SetAttributes(a)
|
obj.SetAttributes(a)
|
||||||
|
|
|
@ -171,7 +171,7 @@ func generateObjectWithCID(t testing.TB, cid *cid.ID) *object.Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
func addAttribute(obj *object.Object, key, val string) {
|
func addAttribute(obj *object.Object, key, val string) {
|
||||||
attr := object.NewAttribute()
|
var attr object.Attribute
|
||||||
attr.SetKey(key)
|
attr.SetKey(key)
|
||||||
attr.SetValue(val)
|
attr.SetValue(val)
|
||||||
|
|
||||||
|
|
|
@ -32,7 +32,7 @@ func TestHeadRaw(t *testing.T) {
|
||||||
link := generateObjectWithCID(t, cid)
|
link := generateObjectWithCID(t, cid)
|
||||||
link.SetParent(parent)
|
link.SetParent(parent)
|
||||||
link.SetParentID(parent.ID())
|
link.SetParentID(parent.ID())
|
||||||
link.SetChildren(child.ID())
|
link.SetChildren(*child.ID())
|
||||||
link.SetSplitID(splitID)
|
link.SetSplitID(splitID)
|
||||||
|
|
||||||
t.Run("virtual object split in different shards", func(t *testing.T) {
|
t.Run("virtual object split in different shards", func(t *testing.T) {
|
||||||
|
|
|
@ -31,7 +31,7 @@ func TestStorageEngine_Inhume(t *testing.T) {
|
||||||
link := generateObjectWithCID(t, cid)
|
link := generateObjectWithCID(t, cid)
|
||||||
link.SetParent(parent)
|
link.SetParent(parent)
|
||||||
link.SetParentID(parent.ID())
|
link.SetParentID(parent.ID())
|
||||||
link.SetChildren(child.ID())
|
link.SetChildren(*child.ID())
|
||||||
link.SetSplitID(splitID)
|
link.SetSplitID(splitID)
|
||||||
|
|
||||||
t.Run("delete small object", func(t *testing.T) {
|
t.Run("delete small object", func(t *testing.T) {
|
||||||
|
|
|
@ -102,7 +102,7 @@ func TestLockUserScenario(t *testing.T) {
|
||||||
tombObj := generateObjectWithCID(t, cnr)
|
tombObj := generateObjectWithCID(t, cnr)
|
||||||
tombObj.SetType(object.TypeTombstone)
|
tombObj.SetType(object.TypeTombstone)
|
||||||
tombObj.SetID(tombForLockID)
|
tombObj.SetID(tombForLockID)
|
||||||
tombObj.SetAttributes(&a)
|
tombObj.SetAttributes(a)
|
||||||
|
|
||||||
err = Put(e, tombObj)
|
err = Put(e, tombObj)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
@ -171,7 +171,7 @@ func TestLockExpiration(t *testing.T) {
|
||||||
|
|
||||||
lock := generateObjectWithCID(t, cnr)
|
lock := generateObjectWithCID(t, cnr)
|
||||||
lock.SetType(object.TypeLock)
|
lock.SetType(object.TypeLock)
|
||||||
lock.SetAttributes(&a)
|
lock.SetAttributes(a)
|
||||||
|
|
||||||
err = Put(e, lock)
|
err = Put(e, lock)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
|
@ -97,7 +97,7 @@ func generateAddress() *addressSDK.Address {
|
||||||
}
|
}
|
||||||
|
|
||||||
func addAttribute(obj *object.Object, key, val string) {
|
func addAttribute(obj *object.Object, key, val string) {
|
||||||
attr := object.NewAttribute()
|
var attr object.Attribute
|
||||||
attr.SetKey(key)
|
attr.SetKey(key)
|
||||||
attr.SetValue(val)
|
attr.SetValue(val)
|
||||||
|
|
||||||
|
|
|
@ -99,7 +99,7 @@ func TestDB_Exists(t *testing.T) {
|
||||||
link := generateObjectWithCID(t, cid)
|
link := generateObjectWithCID(t, cid)
|
||||||
link.SetParent(parent)
|
link.SetParent(parent)
|
||||||
link.SetParentID(parent.ID())
|
link.SetParentID(parent.ID())
|
||||||
link.SetChildren(child.ID())
|
link.SetChildren(*child.ID())
|
||||||
link.SetSplitID(splitID)
|
link.SetSplitID(splitID)
|
||||||
|
|
||||||
t.Run("direct order", func(t *testing.T) {
|
t.Run("direct order", func(t *testing.T) {
|
||||||
|
|
|
@ -178,7 +178,7 @@ func TestDB_SelectRootPhyParent(t *testing.T) {
|
||||||
link := generateObjectWithCID(t, cid)
|
link := generateObjectWithCID(t, cid)
|
||||||
link.SetParent(parent)
|
link.SetParent(parent)
|
||||||
link.SetParentID(parent.ID())
|
link.SetParentID(parent.ID())
|
||||||
link.SetChildren(leftChild.ID(), rightChild.ID())
|
link.SetChildren(*leftChild.ID(), *rightChild.ID())
|
||||||
|
|
||||||
err = putBig(db, link)
|
err = putBig(db, link)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
|
@ -71,9 +71,10 @@ func TestRefillMetabase(t *testing.T) {
|
||||||
|
|
||||||
tombMembers := make([]*addressSDK.Address, 0, len(tombstone.Members()))
|
tombMembers := make([]*addressSDK.Address, 0, len(tombstone.Members()))
|
||||||
|
|
||||||
for _, member := range tombstone.Members() {
|
members := tombstone.Members()
|
||||||
|
for i := range tombstone.Members() {
|
||||||
a := addressSDK.NewAddress()
|
a := addressSDK.NewAddress()
|
||||||
a.SetObjectID(member)
|
a.SetObjectID(&members[i])
|
||||||
a.SetContainerID(tombObj.ContainerID())
|
a.SetContainerID(tombObj.ContainerID())
|
||||||
|
|
||||||
tombMembers = append(tombMembers, a)
|
tombMembers = append(tombMembers, a)
|
||||||
|
|
|
@ -105,7 +105,7 @@ func generateObjectWithPayload(cid *cid.ID, data []byte) *object.Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
func addAttribute(obj *object.Object, key, val string) {
|
func addAttribute(obj *object.Object, key, val string) {
|
||||||
attr := object.NewAttribute()
|
var attr object.Attribute
|
||||||
attr.SetKey(key)
|
attr.SetKey(key)
|
||||||
attr.SetValue(val)
|
attr.SetValue(val)
|
||||||
|
|
||||||
|
|
|
@ -126,9 +126,9 @@ func (s *morphExecutor) List(ctx context.Context, body *container.ListRequestBod
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
cidList := make([]*refs.ContainerID, 0, len(cnrs))
|
cidList := make([]refs.ContainerID, len(cnrs))
|
||||||
for i := range cnrs {
|
for i := range cnrs {
|
||||||
cidList = append(cidList, cnrs[i].ToV2())
|
cidList[i] = *cnrs[i].ToV2()
|
||||||
}
|
}
|
||||||
|
|
||||||
res := new(container.ListResponseBody)
|
res := new(container.ListResponseBody)
|
||||||
|
|
|
@ -51,15 +51,12 @@ func testAddress(t *testing.T) *objectSDKAddress.Address {
|
||||||
return addr
|
return addr
|
||||||
}
|
}
|
||||||
|
|
||||||
func testXHeaders(strs ...string) []*session.XHeader {
|
func testXHeaders(strs ...string) []session.XHeader {
|
||||||
res := make([]*session.XHeader, 0, len(strs)/2)
|
res := make([]session.XHeader, len(strs)/2)
|
||||||
|
|
||||||
for i := 0; i < len(strs); i += 2 {
|
for i := 0; i < len(strs); i += 2 {
|
||||||
x := new(session.XHeader)
|
res[i/2].SetKey(strs[i])
|
||||||
x.SetKey(strs[i])
|
res[i/2].SetValue(strs[i+1])
|
||||||
x.SetValue(strs[i+1])
|
|
||||||
|
|
||||||
res = append(res, x)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
@ -89,7 +86,7 @@ func TestHeadRequest(t *testing.T) {
|
||||||
|
|
||||||
attrKey := "attr_key"
|
attrKey := "attr_key"
|
||||||
attrVal := "attr_val"
|
attrVal := "attr_val"
|
||||||
attr := object.NewAttribute()
|
var attr object.Attribute
|
||||||
attr.SetKey(attrKey)
|
attr.SetKey(attrKey)
|
||||||
attr.SetValue(attrVal)
|
attr.SetValue(attrVal)
|
||||||
obj.SetAttributes(attr)
|
obj.SetAttributes(attr)
|
||||||
|
@ -138,7 +135,7 @@ func TestHeadRequest(t *testing.T) {
|
||||||
|
|
||||||
meta.SetXHeaders(xHdrs)
|
meta.SetXHeaders(xHdrs)
|
||||||
|
|
||||||
obj.SetAttributes(nil)
|
obj.SetAttributes()
|
||||||
|
|
||||||
require.Equal(t, eaclSDK.ActionAllow, validator.CalculateAction(unit))
|
require.Equal(t, eaclSDK.ActionAllow, validator.CalculateAction(unit))
|
||||||
}
|
}
|
||||||
|
|
|
@ -75,7 +75,7 @@ func requestHeaders(msg xHeaderSource) []eaclSDK.Header {
|
||||||
res := make([]eaclSDK.Header, 0, len(xHdrs))
|
res := make([]eaclSDK.Header, 0, len(xHdrs))
|
||||||
|
|
||||||
for i := range xHdrs {
|
for i := range xHdrs {
|
||||||
res = append(res, sessionSDK.NewXHeaderFromV2(xHdrs[i]))
|
res = append(res, sessionSDK.NewXHeaderFromV2(&xHdrs[i]))
|
||||||
}
|
}
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
|
@ -90,7 +90,7 @@ func headersFromObject(obj *object.Object, addr *objectSDKAddress.Address) []eac
|
||||||
|
|
||||||
attrs := obj.Attributes()
|
attrs := obj.Attributes()
|
||||||
for i := range attrs {
|
for i := range attrs {
|
||||||
res = append(res, attrs[i])
|
res = append(res, &attrs[i]) // only pointer attrs can implement eaclSDK.Header interface
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type xHeaderSource interface {
|
type xHeaderSource interface {
|
||||||
GetXHeaders() []*session.XHeader
|
GetXHeaders() []session.XHeader
|
||||||
}
|
}
|
||||||
|
|
||||||
type requestXHeaderSource struct {
|
type requestXHeaderSource struct {
|
||||||
|
@ -18,9 +18,9 @@ type responseXHeaderSource struct {
|
||||||
req Request
|
req Request
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *requestXHeaderSource) GetXHeaders() []*session.XHeader {
|
func (s *requestXHeaderSource) GetXHeaders() []session.XHeader {
|
||||||
ln := 0
|
ln := 0
|
||||||
xHdrs := make([][]*session.XHeader, 0)
|
xHdrs := make([][]session.XHeader, 0)
|
||||||
|
|
||||||
for meta := s.req.GetMetaHeader(); meta != nil; meta = meta.GetOrigin() {
|
for meta := s.req.GetMetaHeader(); meta != nil; meta = meta.GetOrigin() {
|
||||||
x := meta.GetXHeaders()
|
x := meta.GetXHeaders()
|
||||||
|
@ -30,7 +30,7 @@ func (s *requestXHeaderSource) GetXHeaders() []*session.XHeader {
|
||||||
xHdrs = append(xHdrs, x)
|
xHdrs = append(xHdrs, x)
|
||||||
}
|
}
|
||||||
|
|
||||||
res := make([]*session.XHeader, 0, ln)
|
res := make([]session.XHeader, 0, ln)
|
||||||
|
|
||||||
for i := range xHdrs {
|
for i := range xHdrs {
|
||||||
for j := range xHdrs[i] {
|
for j := range xHdrs[i] {
|
||||||
|
@ -41,9 +41,9 @@ func (s *requestXHeaderSource) GetXHeaders() []*session.XHeader {
|
||||||
return res
|
return res
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *responseXHeaderSource) GetXHeaders() []*session.XHeader {
|
func (s *responseXHeaderSource) GetXHeaders() []session.XHeader {
|
||||||
ln := 0
|
ln := 0
|
||||||
xHdrs := make([][]*session.XHeader, 0)
|
xHdrs := make([][]session.XHeader, 0)
|
||||||
|
|
||||||
for meta := s.req.GetMetaHeader(); meta != nil; meta = meta.GetOrigin() {
|
for meta := s.req.GetMetaHeader(); meta != nil; meta = meta.GetOrigin() {
|
||||||
x := meta.GetXHeaders()
|
x := meta.GetXHeaders()
|
||||||
|
@ -53,7 +53,7 @@ func (s *responseXHeaderSource) GetXHeaders() []*session.XHeader {
|
||||||
xHdrs = append(xHdrs, x)
|
xHdrs = append(xHdrs, x)
|
||||||
}
|
}
|
||||||
|
|
||||||
res := make([]*session.XHeader, 0, ln)
|
res := make([]session.XHeader, 0, ln)
|
||||||
|
|
||||||
for i := range xHdrs {
|
for i := range xHdrs {
|
||||||
for j := range xHdrs[i] {
|
for j := range xHdrs[i] {
|
||||||
|
|
|
@ -124,13 +124,13 @@ func (exec *execCtx) collectMembers() (ok bool) {
|
||||||
func (exec *execCtx) collectChain() bool {
|
func (exec *execCtx) collectChain() bool {
|
||||||
var (
|
var (
|
||||||
err error
|
err error
|
||||||
chain []*oidSDK.ID
|
chain []oidSDK.ID
|
||||||
)
|
)
|
||||||
|
|
||||||
exec.log.Debug("assembling chain...")
|
exec.log.Debug("assembling chain...")
|
||||||
|
|
||||||
for prev := exec.splitInfo.LastPart(); prev != nil; {
|
for prev := exec.splitInfo.LastPart(); prev != nil; {
|
||||||
chain = append(chain, prev)
|
chain = append(chain, *prev)
|
||||||
prev, err = exec.svc.header.previous(exec, prev)
|
prev, err = exec.svc.header.previous(exec, prev)
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
|
@ -174,7 +174,7 @@ func (exec *execCtx) collectChildren() bool {
|
||||||
exec.status = statusOK
|
exec.status = statusOK
|
||||||
exec.err = nil
|
exec.err = nil
|
||||||
|
|
||||||
exec.addMembers(append(children, exec.splitInfo.Link()))
|
exec.addMembers(append(children, *exec.splitInfo.Link()))
|
||||||
|
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
@ -205,12 +205,12 @@ func (exec *execCtx) supplementBySplitID() bool {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (exec *execCtx) addMembers(incoming []*oidSDK.ID) {
|
func (exec *execCtx) addMembers(incoming []oidSDK.ID) {
|
||||||
members := exec.tombstone.Members()
|
members := exec.tombstone.Members()
|
||||||
|
|
||||||
for i := range members {
|
for i := range members {
|
||||||
for j := 0; j < len(incoming); j++ { // don't use range, slice mutates in body
|
for j := 0; j < len(incoming); j++ { // don't use range, slice mutates in body
|
||||||
if members[i].Equal(incoming[j]) {
|
if members[i].Equal(&incoming[j]) {
|
||||||
incoming = append(incoming[:j], incoming[j+1:]...)
|
incoming = append(incoming[:j], incoming[j+1:]...)
|
||||||
j--
|
j--
|
||||||
}
|
}
|
||||||
|
@ -245,7 +245,7 @@ func (exec *execCtx) initTombstoneObject() bool {
|
||||||
exec.tombstoneObj.SetType(object.TypeTombstone)
|
exec.tombstoneObj.SetType(object.TypeTombstone)
|
||||||
exec.tombstoneObj.SetPayload(payload)
|
exec.tombstoneObj.SetPayload(payload)
|
||||||
|
|
||||||
a := object.NewAttribute()
|
var a object.Attribute
|
||||||
a.SetKey(objectV2.SysAttributeExpEpoch)
|
a.SetKey(objectV2.SysAttributeExpEpoch)
|
||||||
a.SetValue(strconv.FormatUint(exec.tombstone.ExpirationEpoch(), 10))
|
a.SetValue(strconv.FormatUint(exec.tombstone.ExpirationEpoch(), 10))
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ func (exec *execCtx) formTombstone() (ok bool) {
|
||||||
exec.tombstone.SetExpirationEpoch(
|
exec.tombstone.SetExpirationEpoch(
|
||||||
exec.svc.netInfo.CurrentEpoch() + tsLifetime,
|
exec.svc.netInfo.CurrentEpoch() + tsLifetime,
|
||||||
)
|
)
|
||||||
exec.addMembers([]*oidSDK.ID{exec.address().ObjectID()})
|
exec.addMembers([]oidSDK.ID{*exec.address().ObjectID()})
|
||||||
|
|
||||||
exec.log.Debug("forming split info...")
|
exec.log.Debug("forming split info...")
|
||||||
|
|
||||||
|
|
|
@ -40,14 +40,14 @@ type cfg struct {
|
||||||
// must return (nil, nil) for PHY objects
|
// must return (nil, nil) for PHY objects
|
||||||
splitInfo(*execCtx) (*object.SplitInfo, error)
|
splitInfo(*execCtx) (*object.SplitInfo, error)
|
||||||
|
|
||||||
children(*execCtx) ([]*oidSDK.ID, error)
|
children(*execCtx) ([]oidSDK.ID, error)
|
||||||
|
|
||||||
// must return (nil, nil) for 1st object in chain
|
// must return (nil, nil) for 1st object in chain
|
||||||
previous(*execCtx, *oidSDK.ID) (*oidSDK.ID, error)
|
previous(*execCtx, *oidSDK.ID) (*oidSDK.ID, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
searcher interface {
|
searcher interface {
|
||||||
splitMembers(*execCtx) ([]*oidSDK.ID, error)
|
splitMembers(*execCtx) ([]oidSDK.ID, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
placer interface {
|
placer interface {
|
||||||
|
|
|
@ -18,7 +18,7 @@ type searchSvcWrapper searchsvc.Service
|
||||||
type putSvcWrapper putsvc.Service
|
type putSvcWrapper putsvc.Service
|
||||||
|
|
||||||
type simpleIDWriter struct {
|
type simpleIDWriter struct {
|
||||||
ids []*oidSDK.ID
|
ids []oidSDK.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *headSvcWrapper) headAddress(exec *execCtx, addr *addressSDK.Address) (*object.Object, error) {
|
func (w *headSvcWrapper) headAddress(exec *execCtx, addr *addressSDK.Address) (*object.Object, error) {
|
||||||
|
@ -53,7 +53,7 @@ func (w *headSvcWrapper) splitInfo(exec *execCtx) (*object.SplitInfo, error) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *headSvcWrapper) children(exec *execCtx) ([]*oidSDK.ID, error) {
|
func (w *headSvcWrapper) children(exec *execCtx) ([]oidSDK.ID, error) {
|
||||||
a := exec.newAddress(exec.splitInfo.Link())
|
a := exec.newAddress(exec.splitInfo.Link())
|
||||||
|
|
||||||
linking, err := w.headAddress(exec, a)
|
linking, err := w.headAddress(exec, a)
|
||||||
|
@ -75,7 +75,7 @@ func (w *headSvcWrapper) previous(exec *execCtx, id *oidSDK.ID) (*oidSDK.ID, err
|
||||||
return h.PreviousID(), nil
|
return h.PreviousID(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *searchSvcWrapper) splitMembers(exec *execCtx) ([]*oidSDK.ID, error) {
|
func (w *searchSvcWrapper) splitMembers(exec *execCtx) ([]oidSDK.ID, error) {
|
||||||
fs := object.SearchFilters{}
|
fs := object.SearchFilters{}
|
||||||
fs.AddSplitIDFilter(object.MatchStringEqual, exec.splitInfo.SplitID())
|
fs.AddSplitIDFilter(object.MatchStringEqual, exec.splitInfo.SplitID())
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ func (w *searchSvcWrapper) splitMembers(exec *execCtx) ([]*oidSDK.ID, error) {
|
||||||
return wr.ids, nil
|
return wr.ids, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *simpleIDWriter) WriteIDs(ids []*oidSDK.ID) error {
|
func (s *simpleIDWriter) WriteIDs(ids []oidSDK.ID) error {
|
||||||
s.ids = append(s.ids, ids...)
|
s.ids = append(s.ids, ids...)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -40,7 +40,7 @@ func (exec *execCtx) assemble() {
|
||||||
// * if size > MAX => go right-to-left with HEAD and back with GET
|
// * if size > MAX => go right-to-left with HEAD and back with GET
|
||||||
// * else go right-to-left with GET and compose in single object before writing
|
// * else go right-to-left with GET and compose in single object before writing
|
||||||
|
|
||||||
if ok := exec.overtakePayloadInReverse(children[len(children)-1]); ok {
|
if ok := exec.overtakePayloadInReverse(&children[len(children)-1]); ok {
|
||||||
// payload of all children except the last are written, write last payload
|
// payload of all children except the last are written, write last payload
|
||||||
exec.writeObjectPayload(exec.collectedObject)
|
exec.writeObjectPayload(exec.collectedObject)
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,7 @@ func (exec *execCtx) assemble() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (exec *execCtx) initFromChild(id *oidSDK.ID) (prev *oidSDK.ID, children []*oidSDK.ID) {
|
func (exec *execCtx) initFromChild(id *oidSDK.ID) (prev *oidSDK.ID, children []oidSDK.ID) {
|
||||||
log := exec.log.With(zap.Stringer("child ID", id))
|
log := exec.log.With(zap.Stringer("child ID", id))
|
||||||
|
|
||||||
log.Debug("starting assembling from child")
|
log.Debug("starting assembling from child")
|
||||||
|
@ -120,16 +120,16 @@ func (exec *execCtx) initFromChild(id *oidSDK.ID) (prev *oidSDK.ID, children []*
|
||||||
return child.PreviousID(), child.Children()
|
return child.PreviousID(), child.Children()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (exec *execCtx) overtakePayloadDirectly(children []*oidSDK.ID, rngs []*objectSDK.Range, checkRight bool) {
|
func (exec *execCtx) overtakePayloadDirectly(children []oidSDK.ID, rngs []objectSDK.Range, checkRight bool) {
|
||||||
withRng := len(rngs) > 0 && exec.ctxRange() != nil
|
withRng := len(rngs) > 0 && exec.ctxRange() != nil
|
||||||
|
|
||||||
for i := range children {
|
for i := range children {
|
||||||
var r *objectSDK.Range
|
var r *objectSDK.Range
|
||||||
if withRng {
|
if withRng {
|
||||||
r = rngs[i]
|
r = &rngs[i]
|
||||||
}
|
}
|
||||||
|
|
||||||
child, ok := exec.getChild(children[i], r, !withRng && checkRight)
|
child, ok := exec.getChild(&children[i], r, !withRng && checkRight)
|
||||||
if !ok {
|
if !ok {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -165,10 +165,10 @@ func (exec *execCtx) overtakePayloadInReverse(prev *oidSDK.ID) bool {
|
||||||
return exec.status == statusOK
|
return exec.status == statusOK
|
||||||
}
|
}
|
||||||
|
|
||||||
func (exec *execCtx) buildChainInReverse(prev *oidSDK.ID) ([]*oidSDK.ID, []*objectSDK.Range, bool) {
|
func (exec *execCtx) buildChainInReverse(prev *oidSDK.ID) ([]oidSDK.ID, []objectSDK.Range, bool) {
|
||||||
var (
|
var (
|
||||||
chain = make([]*oidSDK.ID, 0)
|
chain = make([]oidSDK.ID, 0)
|
||||||
rngs = make([]*objectSDK.Range, 0)
|
rngs = make([]objectSDK.Range, 0)
|
||||||
seekRng = exec.ctxRange()
|
seekRng = exec.ctxRange()
|
||||||
from = seekRng.GetOffset()
|
from = seekRng.GetOffset()
|
||||||
to = from + seekRng.GetLength()
|
to = from + seekRng.GetLength()
|
||||||
|
@ -201,15 +201,15 @@ func (exec *execCtx) buildChainInReverse(prev *oidSDK.ID) ([]*oidSDK.ID, []*obje
|
||||||
sz = to - off - exec.curOff
|
sz = to - off - exec.curOff
|
||||||
}
|
}
|
||||||
|
|
||||||
r := objectSDK.NewRange()
|
index := len(rngs)
|
||||||
r.SetOffset(off)
|
rngs = append(rngs, objectSDK.Range{})
|
||||||
r.SetLength(sz)
|
rngs[index].SetOffset(off)
|
||||||
|
rngs[index].SetLength(sz)
|
||||||
|
|
||||||
rngs = append(rngs, r)
|
chain = append(chain, *head.ID())
|
||||||
chain = append(chain, head.ID())
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
chain = append(chain, head.ID())
|
chain = append(chain, *head.ID())
|
||||||
}
|
}
|
||||||
|
|
||||||
prev = head.PreviousID()
|
prev = head.PreviousID()
|
||||||
|
|
|
@ -37,7 +37,7 @@ func (s *Service) GetRangeHash(ctx context.Context, prm RangeHashPrm) (*RangeHas
|
||||||
commonPrm: prm.commonPrm,
|
commonPrm: prm.commonPrm,
|
||||||
}
|
}
|
||||||
|
|
||||||
rngPrm.SetRange(rng)
|
rngPrm.SetRange(&rng)
|
||||||
rngPrm.SetChunkWriter(&hasherWrapper{
|
rngPrm.SetChunkWriter(&hasherWrapper{
|
||||||
hash: util.NewSaltingWriter(h, prm.salt),
|
hash: util.NewSaltingWriter(h, prm.salt),
|
||||||
})
|
})
|
||||||
|
|
|
@ -194,7 +194,7 @@ func generateAddress() *addressSDK.Address {
|
||||||
return addr
|
return addr
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateObject(addr *addressSDK.Address, prev *oidSDK.ID, payload []byte, children ...*oidSDK.ID) *objectSDK.Object {
|
func generateObject(addr *addressSDK.Address, prev *oidSDK.ID, payload []byte, children ...oidSDK.ID) *objectSDK.Object {
|
||||||
obj := objectSDK.New()
|
obj := objectSDK.New()
|
||||||
obj.SetContainerID(addr.ContainerID())
|
obj.SetContainerID(addr.ContainerID())
|
||||||
obj.SetID(addr.ObjectID())
|
obj.SetID(addr.ObjectID())
|
||||||
|
@ -427,7 +427,7 @@ func testNodeMatrix(t testing.TB, dim []int) ([]netmap.Nodes, [][]string) {
|
||||||
return mNodes, mAddr
|
return mNodes, mAddr
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateChain(ln int, cid *cid.ID) ([]*objectSDK.Object, []*oidSDK.ID, []byte) {
|
func generateChain(ln int, cid *cid.ID) ([]*objectSDK.Object, []oidSDK.ID, []byte) {
|
||||||
curID := generateID()
|
curID := generateID()
|
||||||
var prevID *oidSDK.ID
|
var prevID *oidSDK.ID
|
||||||
|
|
||||||
|
@ -435,11 +435,11 @@ func generateChain(ln int, cid *cid.ID) ([]*objectSDK.Object, []*oidSDK.ID, []by
|
||||||
addr.SetContainerID(cid)
|
addr.SetContainerID(cid)
|
||||||
|
|
||||||
res := make([]*objectSDK.Object, 0, ln)
|
res := make([]*objectSDK.Object, 0, ln)
|
||||||
ids := make([]*oidSDK.ID, 0, ln)
|
ids := make([]oidSDK.ID, 0, ln)
|
||||||
payload := make([]byte, 0, ln*10)
|
payload := make([]byte, 0, ln*10)
|
||||||
|
|
||||||
for i := 0; i < ln; i++ {
|
for i := 0; i < ln; i++ {
|
||||||
ids = append(ids, curID)
|
ids = append(ids, *curID)
|
||||||
addr.SetObjectID(curID)
|
addr.SetObjectID(curID)
|
||||||
|
|
||||||
payloadPart := make([]byte, 10)
|
payloadPart := make([]byte, 10)
|
||||||
|
@ -760,11 +760,11 @@ func TestGetRemoteSmall(t *testing.T) {
|
||||||
|
|
||||||
child1Addr := addressSDK.NewAddress()
|
child1Addr := addressSDK.NewAddress()
|
||||||
child1Addr.SetContainerID(cid)
|
child1Addr.SetContainerID(cid)
|
||||||
child1Addr.SetObjectID(childIDs[0])
|
child1Addr.SetObjectID(&childIDs[0])
|
||||||
|
|
||||||
child2Addr := addressSDK.NewAddress()
|
child2Addr := addressSDK.NewAddress()
|
||||||
child2Addr.SetContainerID(cid)
|
child2Addr.SetContainerID(cid)
|
||||||
child2Addr.SetObjectID(childIDs[1])
|
child2Addr.SetObjectID(&childIDs[1])
|
||||||
|
|
||||||
c1 := newTestClient()
|
c1 := newTestClient()
|
||||||
c1.addResult(addr, nil, errors.New("any error"))
|
c1.addResult(addr, nil, errors.New("any error"))
|
||||||
|
@ -836,11 +836,11 @@ func TestGetRemoteSmall(t *testing.T) {
|
||||||
|
|
||||||
child1Addr := addressSDK.NewAddress()
|
child1Addr := addressSDK.NewAddress()
|
||||||
child1Addr.SetContainerID(cid)
|
child1Addr.SetContainerID(cid)
|
||||||
child1Addr.SetObjectID(childIDs[0])
|
child1Addr.SetObjectID(&childIDs[0])
|
||||||
|
|
||||||
child2Addr := addressSDK.NewAddress()
|
child2Addr := addressSDK.NewAddress()
|
||||||
child2Addr.SetContainerID(cid)
|
child2Addr.SetContainerID(cid)
|
||||||
child2Addr.SetObjectID(childIDs[1])
|
child2Addr.SetObjectID(&childIDs[1])
|
||||||
|
|
||||||
c1 := newTestClient()
|
c1 := newTestClient()
|
||||||
c1.addResult(addr, nil, errors.New("any error"))
|
c1.addResult(addr, nil, errors.New("any error"))
|
||||||
|
|
|
@ -27,7 +27,7 @@ type RangeHashPrm struct {
|
||||||
|
|
||||||
hashGen func() hash.Hash
|
hashGen func() hash.Hash
|
||||||
|
|
||||||
rngs []*object.Range
|
rngs []object.Range
|
||||||
|
|
||||||
salt []byte
|
salt []byte
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ func (p *RangePrm) SetRange(rng *object.Range) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetRangeList sets list of object payload ranges.
|
// SetRangeList sets list of object payload ranges.
|
||||||
func (p *RangeHashPrm) SetRangeList(rngs []*object.Range) {
|
func (p *RangeHashPrm) SetRangeList(rngs []object.Range) {
|
||||||
p.rngs = rngs
|
p.rngs = rngs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -275,10 +275,10 @@ func (s *Service) toHashRangePrm(req *objectV2.GetRangeHashRequest) (*getsvc.Ran
|
||||||
p.WithAddress(addressSDK.NewAddressFromV2(body.GetAddress()))
|
p.WithAddress(addressSDK.NewAddressFromV2(body.GetAddress()))
|
||||||
|
|
||||||
rngsV2 := body.GetRanges()
|
rngsV2 := body.GetRanges()
|
||||||
rngs := make([]*object.Range, 0, len(rngsV2))
|
rngs := make([]object.Range, len(rngsV2))
|
||||||
|
|
||||||
for i := range rngsV2 {
|
for i := range rngsV2 {
|
||||||
rngs = append(rngs, object.NewRangeFromV2(rngsV2[i]))
|
rngs[i] = *object.NewRangeFromV2(&rngsV2[i])
|
||||||
}
|
}
|
||||||
|
|
||||||
p.SetRangeList(rngs)
|
p.SetRangeList(rngs)
|
||||||
|
|
|
@ -474,11 +474,11 @@ func (x *SearchObjectsPrm) SetFilters(fs object.SearchFilters) {
|
||||||
|
|
||||||
// SearchObjectsRes groups resulting values of SearchObjects operation.
|
// SearchObjectsRes groups resulting values of SearchObjects operation.
|
||||||
type SearchObjectsRes struct {
|
type SearchObjectsRes struct {
|
||||||
ids []*oidSDK.ID
|
ids []oidSDK.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
// IDList returns identifiers of the matched objects.
|
// IDList returns identifiers of the matched objects.
|
||||||
func (x SearchObjectsRes) IDList() []*oidSDK.ID {
|
func (x SearchObjectsRes) IDList() []oidSDK.ID {
|
||||||
return x.ids
|
return x.ids
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -510,7 +510,7 @@ func SearchObjects(prm SearchObjectsPrm) (*SearchObjectsRes, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
buf := make([]oidSDK.ID, 10)
|
buf := make([]oidSDK.ID, 10)
|
||||||
var ids []*oidSDK.ID
|
var ids []oidSDK.ID
|
||||||
var n int
|
var n int
|
||||||
var ok bool
|
var ok bool
|
||||||
|
|
||||||
|
@ -519,7 +519,7 @@ func SearchObjects(prm SearchObjectsPrm) (*SearchObjectsRes, error) {
|
||||||
if n > 0 {
|
if n > 0 {
|
||||||
for i := range buf[:n] {
|
for i := range buf[:n] {
|
||||||
v := buf[i]
|
v := buf[i]
|
||||||
ids = append(ids, &v)
|
ids = append(ids, v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -133,7 +133,7 @@ func (exec execCtx) remoteClient(info client.NodeInfo) (searchClient, bool) {
|
||||||
return nil, false
|
return nil, false
|
||||||
}
|
}
|
||||||
|
|
||||||
func (exec *execCtx) writeIDList(ids []*oidSDK.ID) {
|
func (exec *execCtx) writeIDList(ids []oidSDK.ID) {
|
||||||
err := exec.prm.writer.WriteIDs(ids)
|
err := exec.prm.writer.WriteIDs(ids)
|
||||||
|
|
||||||
switch {
|
switch {
|
||||||
|
|
|
@ -24,12 +24,12 @@ type Prm struct {
|
||||||
// IDListWriter is an interface of target component
|
// IDListWriter is an interface of target component
|
||||||
// to write list of object identifiers.
|
// to write list of object identifiers.
|
||||||
type IDListWriter interface {
|
type IDListWriter interface {
|
||||||
WriteIDs([]*oidSDK.ID) error
|
WriteIDs([]oidSDK.ID) error
|
||||||
}
|
}
|
||||||
|
|
||||||
// RequestForwarder is a callback for forwarding of the
|
// RequestForwarder is a callback for forwarding of the
|
||||||
// original Search requests.
|
// original Search requests.
|
||||||
type RequestForwarder func(coreclient.NodeInfo, coreclient.MultiAddressClient) ([]*oidSDK.ID, error)
|
type RequestForwarder func(coreclient.NodeInfo, coreclient.MultiAddressClient) ([]oidSDK.ID, error)
|
||||||
|
|
||||||
// SetCommonParameters sets common parameters of the operation.
|
// SetCommonParameters sets common parameters of the operation.
|
||||||
func (p *Prm) SetCommonParameters(common *util.CommonPrm) {
|
func (p *Prm) SetCommonParameters(common *util.CommonPrm) {
|
||||||
|
|
|
@ -24,7 +24,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type idsErr struct {
|
type idsErr struct {
|
||||||
ids []*oidSDK.ID
|
ids []oidSDK.ID
|
||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ type testClientCache struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type simpleIDWriter struct {
|
type simpleIDWriter struct {
|
||||||
ids []*oidSDK.ID
|
ids []oidSDK.ID
|
||||||
}
|
}
|
||||||
|
|
||||||
type testEpochReceiver uint64
|
type testEpochReceiver uint64
|
||||||
|
@ -55,7 +55,7 @@ func (e testEpochReceiver) currentEpoch() (uint64, error) {
|
||||||
return uint64(e), nil
|
return uint64(e), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *simpleIDWriter) WriteIDs(ids []*oidSDK.ID) error {
|
func (s *simpleIDWriter) WriteIDs(ids []oidSDK.ID) error {
|
||||||
s.ids = append(s.ids, ids...)
|
s.ids = append(s.ids, ids...)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
@ -95,7 +95,7 @@ func (c *testClientCache) get(info clientcore.NodeInfo) (searchClient, error) {
|
||||||
return v, nil
|
return v, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *testStorage) search(exec *execCtx) ([]*oidSDK.ID, error) {
|
func (s *testStorage) search(exec *execCtx) ([]oidSDK.ID, error) {
|
||||||
v, ok := s.items[exec.containerID().String()]
|
v, ok := s.items[exec.containerID().String()]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
@ -104,7 +104,7 @@ func (s *testStorage) search(exec *execCtx) ([]*oidSDK.ID, error) {
|
||||||
return v.ids, v.err
|
return v.ids, v.err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *testStorage) searchObjects(exec *execCtx, _ clientcore.NodeInfo) ([]*oidSDK.ID, error) {
|
func (c *testStorage) searchObjects(exec *execCtx, _ clientcore.NodeInfo) ([]oidSDK.ID, error) {
|
||||||
v, ok := c.items[exec.containerID().String()]
|
v, ok := c.items[exec.containerID().String()]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
|
@ -113,7 +113,7 @@ func (c *testStorage) searchObjects(exec *execCtx, _ clientcore.NodeInfo) ([]*oi
|
||||||
return v.ids, v.err
|
return v.ids, v.err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *testStorage) addResult(addr *cid.ID, ids []*oidSDK.ID, err error) {
|
func (c *testStorage) addResult(addr *cid.ID, ids []oidSDK.ID, err error) {
|
||||||
c.items[addr.String()] = idsErr{
|
c.items[addr.String()] = idsErr{
|
||||||
ids: ids,
|
ids: ids,
|
||||||
err: err,
|
err: err,
|
||||||
|
@ -125,11 +125,10 @@ func testSHA256() (cs [sha256.Size]byte) {
|
||||||
return cs
|
return cs
|
||||||
}
|
}
|
||||||
|
|
||||||
func generateIDs(num int) []*oidSDK.ID {
|
func generateIDs(num int) []oidSDK.ID {
|
||||||
res := make([]*oidSDK.ID, num)
|
res := make([]oidSDK.ID, num)
|
||||||
|
|
||||||
for i := 0; i < num; i++ {
|
for i := 0; i < num; i++ {
|
||||||
res[i] = oidSDK.NewID()
|
|
||||||
res[i].SetSHA256(testSHA256())
|
res[i].SetSHA256(testSHA256())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -227,12 +226,9 @@ func TestGetRemoteSmall(t *testing.T) {
|
||||||
|
|
||||||
placementDim := []int{2}
|
placementDim := []int{2}
|
||||||
|
|
||||||
rs := make([]*netmap.Replica, 0, len(placementDim))
|
rs := make([]netmap.Replica, len(placementDim))
|
||||||
for i := range placementDim {
|
for i := range placementDim {
|
||||||
r := netmap.NewReplica()
|
rs[i].SetCount(uint32(placementDim[i]))
|
||||||
r.SetCount(uint32(placementDim[i]))
|
|
||||||
|
|
||||||
rs = append(rs, r)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pp := netmap.NewPlacementPolicy()
|
pp := netmap.NewPlacementPolicy()
|
||||||
|
@ -315,13 +311,10 @@ func TestGetFromPastEpoch(t *testing.T) {
|
||||||
|
|
||||||
placementDim := []int{2, 2}
|
placementDim := []int{2, 2}
|
||||||
|
|
||||||
rs := make([]*netmap.Replica, 0, len(placementDim))
|
rs := make([]netmap.Replica, len(placementDim))
|
||||||
|
|
||||||
for i := range placementDim {
|
for i := range placementDim {
|
||||||
r := netmap.NewReplica()
|
rs[i].SetCount(uint32(placementDim[i]))
|
||||||
r.SetCount(uint32(placementDim[i]))
|
|
||||||
|
|
||||||
rs = append(rs, r)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pp := netmap.NewPlacementPolicy()
|
pp := netmap.NewPlacementPolicy()
|
||||||
|
@ -393,7 +386,7 @@ func TestGetFromPastEpoch(t *testing.T) {
|
||||||
commonPrm := new(util.CommonPrm)
|
commonPrm := new(util.CommonPrm)
|
||||||
p.SetCommonParameters(commonPrm)
|
p.SetCommonParameters(commonPrm)
|
||||||
|
|
||||||
assertContains := func(idsList ...[]*oidSDK.ID) {
|
assertContains := func(idsList ...[]oidSDK.ID) {
|
||||||
var sz int
|
var sz int
|
||||||
|
|
||||||
for _, ids := range idsList {
|
for _, ids := range idsList {
|
||||||
|
|
|
@ -25,7 +25,7 @@ type Service struct {
|
||||||
type Option func(*cfg)
|
type Option func(*cfg)
|
||||||
|
|
||||||
type searchClient interface {
|
type searchClient interface {
|
||||||
searchObjects(*execCtx, client.NodeInfo) ([]*oidSDK.ID, error)
|
searchObjects(*execCtx, client.NodeInfo) ([]oidSDK.ID, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
type ClientConstructor interface {
|
type ClientConstructor interface {
|
||||||
|
@ -36,7 +36,7 @@ type cfg struct {
|
||||||
log *logger.Logger
|
log *logger.Logger
|
||||||
|
|
||||||
localStorage interface {
|
localStorage interface {
|
||||||
search(*execCtx) ([]*oidSDK.ID, error)
|
search(*execCtx) ([]oidSDK.ID, error)
|
||||||
}
|
}
|
||||||
|
|
||||||
clientConstructor interface {
|
clientConstructor interface {
|
||||||
|
|
|
@ -45,7 +45,7 @@ func newUniqueAddressWriter(w IDListWriter) IDListWriter {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (w *uniqueIDWriter) WriteIDs(list []*oidSDK.ID) error {
|
func (w *uniqueIDWriter) WriteIDs(list []oidSDK.ID) error {
|
||||||
w.mtx.Lock()
|
w.mtx.Lock()
|
||||||
|
|
||||||
for i := 0; i < len(list); i++ { // don't use range, slice mutates in body
|
for i := 0; i < len(list); i++ { // don't use range, slice mutates in body
|
||||||
|
@ -80,7 +80,7 @@ func (c *clientConstructorWrapper) get(info client.NodeInfo) (searchClient, erro
|
||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *clientWrapper) searchObjects(exec *execCtx, info client.NodeInfo) ([]*oidSDK.ID, error) {
|
func (c *clientWrapper) searchObjects(exec *execCtx, info client.NodeInfo) ([]oidSDK.ID, error) {
|
||||||
if exec.prm.forwarder != nil {
|
if exec.prm.forwarder != nil {
|
||||||
return exec.prm.forwarder(info, c.client)
|
return exec.prm.forwarder(info, c.client)
|
||||||
}
|
}
|
||||||
|
@ -111,7 +111,7 @@ func (c *clientWrapper) searchObjects(exec *execCtx, info client.NodeInfo) ([]*o
|
||||||
return res.IDList(), nil
|
return res.IDList(), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (e *storageEngineWrapper) search(exec *execCtx) ([]*oidSDK.ID, error) {
|
func (e *storageEngineWrapper) search(exec *execCtx) ([]oidSDK.ID, error) {
|
||||||
r, err := (*engine.StorageEngine)(e).Select(new(engine.SelectPrm).
|
r, err := (*engine.StorageEngine)(e).Select(new(engine.SelectPrm).
|
||||||
WithFilters(exec.searchFilters()).
|
WithFilters(exec.searchFilters()).
|
||||||
WithContainerID(exec.containerID()),
|
WithContainerID(exec.containerID()),
|
||||||
|
@ -123,11 +123,11 @@ func (e *storageEngineWrapper) search(exec *execCtx) ([]*oidSDK.ID, error) {
|
||||||
return idsFromAddresses(r.AddressList()), nil
|
return idsFromAddresses(r.AddressList()), nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func idsFromAddresses(addrs []*addressSDK.Address) []*oidSDK.ID {
|
func idsFromAddresses(addrs []*addressSDK.Address) []oidSDK.ID {
|
||||||
ids := make([]*oidSDK.ID, len(addrs))
|
ids := make([]oidSDK.ID, len(addrs))
|
||||||
|
|
||||||
for i := range addrs {
|
for i := range addrs {
|
||||||
ids[i] = addrs[i].ObjectID()
|
ids[i] = *addrs[i].ObjectID()
|
||||||
}
|
}
|
||||||
|
|
||||||
return ids
|
return ids
|
||||||
|
|
|
@ -11,16 +11,16 @@ type streamWriter struct {
|
||||||
stream objectSvc.SearchStream
|
stream objectSvc.SearchStream
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *streamWriter) WriteIDs(ids []*oidSDK.ID) error {
|
func (s *streamWriter) WriteIDs(ids []oidSDK.ID) error {
|
||||||
r := new(object.SearchResponse)
|
r := new(object.SearchResponse)
|
||||||
|
|
||||||
body := new(object.SearchResponseBody)
|
body := new(object.SearchResponseBody)
|
||||||
r.SetBody(body)
|
r.SetBody(body)
|
||||||
|
|
||||||
idsV2 := make([]*refs.ObjectID, len(ids))
|
idsV2 := make([]refs.ObjectID, len(ids))
|
||||||
|
|
||||||
for i := range ids {
|
for i := range ids {
|
||||||
idsV2[i] = ids[i].ToV2()
|
idsV2[i] = *ids[i].ToV2()
|
||||||
}
|
}
|
||||||
|
|
||||||
body.SetIDList(idsV2)
|
body.SetIDList(idsV2)
|
||||||
|
|
|
@ -45,7 +45,7 @@ func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStre
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
p.SetRequestForwarder(groupAddressRequestForwarder(func(addr network.Address, c client.MultiAddressClient, pubkey []byte) ([]*oidSDK.ID, error) {
|
p.SetRequestForwarder(groupAddressRequestForwarder(func(addr network.Address, c client.MultiAddressClient, pubkey []byte) ([]oidSDK.ID, error) {
|
||||||
var err error
|
var err error
|
||||||
|
|
||||||
// once compose and resign forwarding request
|
// once compose and resign forwarding request
|
||||||
|
@ -77,7 +77,7 @@ func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStre
|
||||||
// code below is copy-pasted from c.SearchObjects implementation,
|
// code below is copy-pasted from c.SearchObjects implementation,
|
||||||
// perhaps it is worth highlighting the utility function in neofs-api-go
|
// perhaps it is worth highlighting the utility function in neofs-api-go
|
||||||
var (
|
var (
|
||||||
searchResult []*oidSDK.ID
|
searchResult []oidSDK.ID
|
||||||
resp = new(objectV2.SearchResponse)
|
resp = new(objectV2.SearchResponse)
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -104,7 +104,7 @@ func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStre
|
||||||
|
|
||||||
chunk := resp.GetBody().GetIDList()
|
chunk := resp.GetBody().GetIDList()
|
||||||
for i := range chunk {
|
for i := range chunk {
|
||||||
searchResult = append(searchResult, oidSDK.NewIDFromV2(chunk[i]))
|
searchResult = append(searchResult, *oidSDK.NewIDFromV2(&chunk[i]))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -119,11 +119,11 @@ func (s *Service) toPrm(req *objectV2.SearchRequest, stream objectSvc.SearchStre
|
||||||
return p, nil
|
return p, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func groupAddressRequestForwarder(f func(network.Address, client.MultiAddressClient, []byte) ([]*oidSDK.ID, error)) searchsvc.RequestForwarder {
|
func groupAddressRequestForwarder(f func(network.Address, client.MultiAddressClient, []byte) ([]oidSDK.ID, error)) searchsvc.RequestForwarder {
|
||||||
return func(info client.NodeInfo, c client.MultiAddressClient) ([]*oidSDK.ID, error) {
|
return func(info client.NodeInfo, c client.MultiAddressClient) ([]oidSDK.ID, error) {
|
||||||
var (
|
var (
|
||||||
firstErr error
|
firstErr error
|
||||||
res []*oidSDK.ID
|
res []oidSDK.ID
|
||||||
|
|
||||||
key = info.PublicKey()
|
key = info.PublicKey()
|
||||||
)
|
)
|
||||||
|
|
|
@ -40,7 +40,7 @@ func copyVectors(v []netmap.Nodes) []netmap.Nodes {
|
||||||
|
|
||||||
func testPlacement(t *testing.T, ss, rs []int) ([]netmap.Nodes, *container.Container) {
|
func testPlacement(t *testing.T, ss, rs []int) ([]netmap.Nodes, *container.Container) {
|
||||||
nodes := make([]netmap.Nodes, 0, len(rs))
|
nodes := make([]netmap.Nodes, 0, len(rs))
|
||||||
replicas := make([]*netmap.Replica, 0, len(rs))
|
replicas := make([]netmap.Replica, 0, len(rs))
|
||||||
num := uint32(0)
|
num := uint32(0)
|
||||||
|
|
||||||
for i := range ss {
|
for i := range ss {
|
||||||
|
@ -53,7 +53,7 @@ func testPlacement(t *testing.T, ss, rs []int) ([]netmap.Nodes, *container.Conta
|
||||||
|
|
||||||
nodes = append(nodes, netmap.NodesFromInfo(ns))
|
nodes = append(nodes, netmap.NodesFromInfo(ns))
|
||||||
|
|
||||||
s := new(netmap.Replica)
|
var s netmap.Replica
|
||||||
s.SetCount(uint32(rs[i]))
|
s.SetCount(uint32(rs[i]))
|
||||||
|
|
||||||
replicas = append(replicas, s)
|
replicas = append(replicas, s)
|
||||||
|
|
|
@ -23,13 +23,13 @@ type payloadSizeLimiter struct {
|
||||||
|
|
||||||
currentHashers, parentHashers []*payloadChecksumHasher
|
currentHashers, parentHashers []*payloadChecksumHasher
|
||||||
|
|
||||||
previous []*oidSDK.ID
|
previous []oidSDK.ID
|
||||||
|
|
||||||
chunkWriter io.Writer
|
chunkWriter io.Writer
|
||||||
|
|
||||||
splitID *object.SplitID
|
splitID *object.SplitID
|
||||||
|
|
||||||
parAttrs []*object.Attribute
|
parAttrs []object.Attribute
|
||||||
}
|
}
|
||||||
|
|
||||||
type payloadChecksumHasher struct {
|
type payloadChecksumHasher struct {
|
||||||
|
@ -79,7 +79,7 @@ func (s *payloadSizeLimiter) initialize() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// set previous object to the last previous identifier
|
// set previous object to the last previous identifier
|
||||||
s.current.SetPreviousID(s.previous[ln-1])
|
s.current.SetPreviousID(&s.previous[ln-1])
|
||||||
}
|
}
|
||||||
|
|
||||||
s.initializeCurrent()
|
s.initializeCurrent()
|
||||||
|
@ -187,7 +187,7 @@ func (s *payloadSizeLimiter) release(close bool) (*AccessIdentifiers, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// save identifier of the released object
|
// save identifier of the released object
|
||||||
s.previous = append(s.previous, ids.SelfID())
|
s.previous = append(s.previous, *ids.SelfID())
|
||||||
|
|
||||||
if withParent {
|
if withParent {
|
||||||
// generate and release linking object
|
// generate and release linking object
|
||||||
|
|
|
@ -21,7 +21,7 @@ var (
|
||||||
|
|
||||||
// ParseV2Attributes parses strings like "K1:V1/K2:V2/K3:V3" into netmap
|
// ParseV2Attributes parses strings like "K1:V1/K2:V2/K3:V3" into netmap
|
||||||
// attributes. Supports escaped symbols "\:", "\/" and "\\".
|
// attributes. Supports escaped symbols "\:", "\/" and "\\".
|
||||||
func ParseV2Attributes(attrs []string, excl []string) ([]*netmap.NodeAttribute, error) {
|
func ParseV2Attributes(attrs []string, excl []string) ([]netmap.NodeAttribute, error) {
|
||||||
restricted := make(map[string]struct{}, len(excl))
|
restricted := make(map[string]struct{}, len(excl))
|
||||||
for i := range excl {
|
for i := range excl {
|
||||||
restricted[excl[i]] = struct{}{}
|
restricted[excl[i]] = struct{}{}
|
||||||
|
@ -82,7 +82,12 @@ func ParseV2Attributes(attrs []string, excl []string) ([]*netmap.NodeAttribute,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result, nil
|
nresult := make([]netmap.NodeAttribute, len(result))
|
||||||
|
for i := range result {
|
||||||
|
nresult[i] = *result[i]
|
||||||
|
}
|
||||||
|
|
||||||
|
return nresult, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func replaceEscaping(target string, rollback bool) (s string) {
|
func replaceEscaping(target string, rollback bool) (s string) {
|
||||||
|
|
Loading…
Reference in a new issue