Skip to content

Commit

Permalink
services/object: Inline intermediate HASH service
Browse files Browse the repository at this point in the history
Continues 5d69dae. This completes
elimination of the recurrent architecture of object requests' handling.

Signed-off-by: Leonard Lyubich <[email protected]>
  • Loading branch information
cthulhu-rider committed Dec 26, 2024
1 parent be24078 commit 4c339b9
Show file tree
Hide file tree
Showing 6 changed files with 229 additions and 383 deletions.
48 changes: 28 additions & 20 deletions cmd/neofs-node/object.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ package main
import (
"bytes"
"context"
"crypto/ecdsa"
"errors"
"fmt"
"sync/atomic"

"github.com/google/uuid"
lru "github.com/hashicorp/golang-lru/v2"
"github.com/nspcc-dev/neofs-api-go/v2/object"
objectGRPC "github.com/nspcc-dev/neofs-api-go/v2/object/grpc"
replicatorconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/replicator"
coreclient "github.com/nspcc-dev/neofs-node/pkg/core/client"
Expand All @@ -22,7 +23,6 @@ import (
v2 "github.com/nspcc-dev/neofs-node/pkg/services/object/acl/v2"
deletesvc "github.com/nspcc-dev/neofs-node/pkg/services/object/delete"
getsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/get"
getsvcV2 "github.com/nspcc-dev/neofs-node/pkg/services/object/get/v2"
headsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/head"
putsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/put"
searchsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/search"
Expand All @@ -49,8 +49,7 @@ type objectSvc struct {

search *searchsvc.Service

get *getsvcV2.Service
get_ *getsvc.Service
get *getsvc.Service

delete *deletesvc.Service
}
Expand All @@ -71,27 +70,27 @@ func (s *objectSvc) Put(ctx context.Context) (*putsvc.Streamer, error) {
}

func (s *objectSvc) Head(ctx context.Context, prm getsvc.HeadPrm) error {
return s.get_.Head(ctx, prm)
return s.get.Head(ctx, prm)
}

func (s *objectSvc) Search(ctx context.Context, prm searchsvc.Prm) error {
return s.search.Search(ctx, prm)
}

func (s *objectSvc) Get(ctx context.Context, prm getsvc.Prm) error {
return s.get_.Get(ctx, prm)
return s.get.Get(ctx, prm)
}

func (s *objectSvc) Delete(ctx context.Context, prm deletesvc.Prm) error {
return s.delete.Delete(ctx, prm)
}

func (s *objectSvc) GetRange(ctx context.Context, prm getsvc.RangePrm) error {
return s.get_.GetRange(ctx, prm)
return s.get.GetRange(ctx, prm)
}

func (s *objectSvc) GetRangeHash(ctx context.Context, req *object.GetRangeHashRequest) (*object.GetRangeHashResponse, error) {
return s.get.GetRangeHash(ctx, req)
func (s *objectSvc) GetRangeHash(ctx context.Context, prm getsvc.RangeHashPrm) (*getsvc.RangeHashRes, error) {
return s.get.GetRangeHash(ctx, prm)
}

type delNetInfo struct {
Expand Down Expand Up @@ -230,11 +229,6 @@ func initObjectService(c *cfg) {

*c.cfgObject.getSvc = *sGet // need smth better

sGetV2 := getsvcV2.NewService(
getsvcV2.WithInternalService(sGet),
getsvcV2.WithKeyStorage(keyStorage),
)

cnrNodes, err := newContainerNodes(c.cfgObject.cnrSource, c.netMapSource)
fatalOnErr(err)
c.cfgObject.containerNodes = cnrNodes
Expand Down Expand Up @@ -279,8 +273,7 @@ func initObjectService(c *cfg) {
objSvc := &objectSvc{
put: sPut,
search: sSearch,
get: sGetV2,
get_: sGet,
get: sGet,
delete: sDelete,
}

Expand Down Expand Up @@ -308,7 +301,11 @@ func initObjectService(c *cfg) {
SetHeaderSource(cachedHeaderSource(sGet, cachedFirstObjectsNumber, c.log)),
)

server := objectService.New(objSvc, mNumber, fsChain, (*putObjectServiceWrapper)(sPut), c.key.PrivateKey, c.metricsCollector, aclChecker, aclSvc)
storage := storageForObjectService{
putSvc: sPut,
keys: keyStorage,
}
server := objectService.New(objSvc, mNumber, fsChain, storage, c.key.PrivateKey, c.metricsCollector, aclChecker, aclSvc)

for _, srv := range c.cfgGRPC.servers {
objectGRPC.RegisterObjectServiceServer(srv, server)
Expand Down Expand Up @@ -617,10 +614,21 @@ func (x *fsChainForObjects) IsOwnPublicKey(pubKey []byte) bool {
// maintenance now.
func (x *fsChainForObjects) LocalNodeUnderMaintenance() bool { return x.isMaintenance.Load() }

type putObjectServiceWrapper putsvc.Service
type storageForObjectService struct {
putSvc *putsvc.Service
keys *util.KeyStorage
}

func (x storageForObjectService) VerifyAndStoreObjectLocally(obj objectSDK.Object) error {
return x.putSvc.ValidateAndStoreObjectLocally(obj)
}

func (x *putObjectServiceWrapper) VerifyAndStoreObject(obj objectSDK.Object) error {
return (*putsvc.Service)(x).ValidateAndStoreObjectLocally(obj)
func (x storageForObjectService) GetSessionPrivateKey(usr user.ID, uid uuid.UUID) (ecdsa.PrivateKey, error) {
k, err := x.keys.GetKey(&util.SessionInfo{ID: uid, Owner: usr})
if err != nil {
return ecdsa.PrivateKey{}, err
}
return *k, nil
}

type objectSource struct {
Expand Down
64 changes: 0 additions & 64 deletions pkg/services/object/get/v2/service.go

This file was deleted.

Loading

0 comments on commit 4c339b9

Please sign in to comment.