Skip to content
This repository has been archived by the owner on Jan 31, 2024. It is now read-only.

Commit

Permalink
Make stat and list calls sequential for virtual views
Browse files Browse the repository at this point in the history
  • Loading branch information
ishank011 committed Jul 27, 2021
1 parent 7abf6a0 commit 4564070
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 22 deletions.
31 changes: 11 additions & 20 deletions internal/grpc/services/gateway/storageprovider.go
Original file line number Diff line number Diff line change
Expand Up @@ -1161,13 +1161,12 @@ func (s *svc) stat(ctx context.Context, req *provider.StatRequest) (*provider.St
func (s *svc) statAcrossProviders(ctx context.Context, req *provider.StatRequest, providers []*registry.ProviderInfo) (*provider.StatResponse, error) {
infoFromProviders := make([]*provider.ResourceInfo, len(providers))
errors := make([]error, len(providers))
var wg sync.WaitGroup

for i, p := range providers {
wg.Add(1)
go s.statOnProvider(ctx, req, infoFromProviders[i], p, &errors[i], &wg)
r, e := s.statOnProvider(ctx, req, p)
infoFromProviders[i] = r
errors[i] = e
}
wg.Wait()

var totalSize uint64
for i := range providers {
Expand Down Expand Up @@ -1196,12 +1195,11 @@ func (s *svc) statAcrossProviders(ctx context.Context, req *provider.StatRequest
}, nil
}

func (s *svc) statOnProvider(ctx context.Context, req *provider.StatRequest, res *provider.ResourceInfo, p *registry.ProviderInfo, e *error, wg *sync.WaitGroup) {
defer wg.Done()
func (s *svc) statOnProvider(ctx context.Context, req *provider.StatRequest, p *registry.ProviderInfo) (*provider.ResourceInfo, error) {
c, err := s.getStorageProviderClient(ctx, p)
if err != nil {
*e = errors.Wrap(err, "error connecting to storage provider="+p.Address)
return
e := errors.Wrap(err, "error connecting to storage provider="+p.Address)
return nil, e
}

resPath := path.Clean(req.Ref.GetPath())
Expand All @@ -1211,13 +1209,10 @@ func (s *svc) statOnProvider(ctx context.Context, req *provider.StatRequest, res
}
r, err := c.Stat(ctx, &provider.StatRequest{Ref: &provider.Reference{Path: newPath}})
if err != nil {
*e = errors.Wrap(err, fmt.Sprintf("gateway: error calling Stat %s: %+v", newPath, p))
return
}
if res == nil {
res = &provider.ResourceInfo{}
e := errors.Wrap(err, fmt.Sprintf("gateway: error calling Stat %s: %+v", newPath, p))
return nil, e
}
*res = *r.Info
return r.Info, nil
}

func (s *svc) Stat(ctx context.Context, req *provider.StatRequest) (*provider.StatResponse, error) {
Expand Down Expand Up @@ -1429,13 +1424,10 @@ func (s *svc) listContainer(ctx context.Context, req *provider.ListContainerRequ
infoFromProviders := make([][]*provider.ResourceInfo, len(providers))
errors := make([]error, len(providers))
indirects := make([]bool, len(providers))
var wg sync.WaitGroup

for i, p := range providers {
wg.Add(1)
go s.listContainerOnProvider(ctx, req, &infoFromProviders[i], p, &indirects[i], &errors[i], &wg)
s.listContainerOnProvider(ctx, req, &infoFromProviders[i], p, &indirects[i], &errors[i])
}
wg.Wait()

infos := []*provider.ResourceInfo{}
nestedInfos := make(map[string][]*provider.ResourceInfo)
Expand Down Expand Up @@ -1480,8 +1472,7 @@ func (s *svc) listContainer(ctx context.Context, req *provider.ListContainerRequ
}, nil
}

func (s *svc) listContainerOnProvider(ctx context.Context, req *provider.ListContainerRequest, res *[]*provider.ResourceInfo, p *registry.ProviderInfo, ind *bool, e *error, wg *sync.WaitGroup) {
defer wg.Done()
func (s *svc) listContainerOnProvider(ctx context.Context, req *provider.ListContainerRequest, res *[]*provider.ResourceInfo, p *registry.ProviderInfo, ind *bool, e *error) {
c, err := s.getStorageProviderClient(ctx, p)
if err != nil {
*e = errors.Wrap(err, "error connecting to storage provider="+p.Address)
Expand Down
2 changes: 0 additions & 2 deletions pkg/storage/utils/eosfs/eosfs.go
Original file line number Diff line number Diff line change
Expand Up @@ -769,8 +769,6 @@ func (fs *eosfs) getMDShareFolder(ctx context.Context, p string, mdKeys []string
}

func (fs *eosfs) ListFolder(ctx context.Context, ref *provider.Reference, mdKeys []string) ([]*provider.ResourceInfo, error) {
log := appctx.GetLogger(ctx)

p, err := fs.resolve(ctx, ref)
if err != nil {
return nil, errors.Wrap(err, "eosfs: error resolving reference")
Expand Down

0 comments on commit 4564070

Please sign in to comment.