Skip to content

Commit

Permalink
add list v1 log
Browse files Browse the repository at this point in the history
  • Loading branch information
Hitenjain14 committed Aug 20, 2024
1 parent b4171a5 commit 136e549
Show file tree
Hide file tree
Showing 5 changed files with 1,753 additions and 28 deletions.
7 changes: 6 additions & 1 deletion cmd/bucket-listobjects-handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ package cmd
import (
"context"
"fmt"
"log"
"net/http"
"strconv"
"strings"
Expand Down Expand Up @@ -421,22 +422,26 @@ func (api objectAPIHandlers) ListObjectsV1Handler(w http.ResponseWriter, r *http
// Inititate a list objects operation based on the input params.
// On success would return back ListObjectsInfo object to be
// marshaled into S3 compatible XML header.
now := time.Now()
listObjectsInfo, err := listObjects(ctx, bucket, prefix, marker, delimiter, maxKeys)
elapsedBackendList := time.Since(now)
listObjectsInfoCache, errC := listObjectsCache(ctx, bucket, prefix, marker, delimiter, maxKeys)
if err != nil || errC != nil {
writeErrorResponse(ctx, w, toAPIError(ctx, err), r.URL)
return
}
elapsedCacheList := time.Since(now) - elapsedBackendList
mergeObjects := mergeListObjects(listObjectsInfo.Objects, listObjectsInfoCache.Objects)
mergePrefixes := mergePrefixes(listObjectsInfo.Prefixes, listObjectsInfoCache.Prefixes)
elapsedMerge := time.Since(now) - elapsedCacheList - elapsedBackendList

listObjectsInfo.Objects = mergeObjects
listObjectsInfo.Prefixes = mergePrefixes

concurrentDecryptETag(ctx, listObjectsInfo.Objects)

response := generateListObjectsV1Response(bucket, prefix, marker, delimiter, encodingType, maxKeys, listObjectsInfo)

log.Println("listObjectsV1 ", "elapsedBackendList", elapsedBackendList.Milliseconds(), " elapsedCacheList", elapsedCacheList.Milliseconds(), " elapsedMerge", elapsedMerge.Milliseconds())
// Write success response.
writeSuccessResponseXML(w, encodeResponse(response))
}
25 changes: 0 additions & 25 deletions cmd/gateway/zcn/gateway-zcn.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import (
"github.com/minio/minio/internal/logger"
"github.com/minio/pkg/mimedb"
"github.com/mitchellh/go-homedir"
"golang.org/x/sync/semaphore"

"github.com/0chain/gosdk/zboxcore/sdk"
"github.com/minio/cli"
Expand Down Expand Up @@ -121,11 +120,6 @@ func (z *ZCN) Name() string {
return minio.ZCNBAckendGateway
}

var (
contentMap map[string]*semaphore.Weighted
contentLock sync.Mutex
)

// NewGatewayLayer initializes 0chain gosdk and return zcnObjects
func (z *ZCN) NewGatewayLayer(creds madmin.Credentials) (minio.ObjectLayer, error) {
err := initializeSDK(configDir, allocationID, nonce)
Expand Down Expand Up @@ -156,7 +150,6 @@ func (z *ZCN) NewGatewayLayer(creds madmin.Credentials) (minio.ObjectLayer, erro
if err != nil {
return nil, err
}
contentMap = make(map[string]*semaphore.Weighted)
ctx, cancel := context.WithCancel(context.Background())
zob.ctxCancel = cancel
IntiBatchUploadWorkers(ctx, allocation, serverConfig.BatchWaitTime, serverConfig.MaxBatchSize, serverConfig.BatchWorkers)
Expand Down Expand Up @@ -834,24 +827,6 @@ func (zob *zcnObjects) StorageInfo(ctx context.Context) (si minio.StorageInfo, _
return
}

func lockPath(ctx context.Context, path string) error {
contentLock.Lock()
defer contentLock.Unlock()
if _, ok := contentMap[path]; !ok {
contentMap[path] = semaphore.NewWeighted(1)
}
return contentMap[path].Acquire(ctx, 1)
}

func unlockPath(path string) {
contentLock.Lock()
defer contentLock.Unlock()
if sem, ok := contentMap[path]; ok {
sem.Release(1)
delete(contentMap, path)
}
}

/*
//Unfortunately share file is done by minio client which does't need to communicate with server. It generates share url with access key id and
//secret key
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ toolchain go1.21.6
require (
cloud.google.com/go/storage v1.27.0
github.com/0chain/errors v1.0.3
github.com/0chain/gosdk v1.16.3-0.20240808182737-94ef0df2e786
github.com/0chain/gosdk v1.17.0-RC3.0.20240816052054-a9a39a9098d8
github.com/Azure/azure-pipeline-go v0.2.2
github.com/Azure/azure-storage-blob-go v0.10.0
github.com/Shopify/sarama v1.28.0
Expand Down Expand Up @@ -91,7 +91,6 @@ require (
go.uber.org/zap v1.24.0
golang.org/x/crypto v0.17.0
golang.org/x/oauth2 v0.5.0
golang.org/x/sync v0.5.0
golang.org/x/sys v0.15.0
golang.org/x/time v0.3.0
google.golang.org/api v0.110.0
Expand Down Expand Up @@ -250,6 +249,7 @@ require (
go.opencensus.io v0.24.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
golang.org/x/net v0.19.0 // indirect
golang.org/x/sync v0.5.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ github.com/0chain/errors v1.0.3 h1:QQZPFxTfnMcRdt32DXbzRQIfGWmBsKoEdszKQDb0rRM=
github.com/0chain/errors v1.0.3/go.mod h1:xymD6nVgrbgttWwkpSCfLLEJbFO6iHGQwk/yeSuYkIc=
github.com/0chain/gosdk v1.16.3-0.20240808182737-94ef0df2e786 h1:IY+jgWVXHFcTzO4x8qOdiw9fW6lHXu05OpElra4kTAg=
github.com/0chain/gosdk v1.16.3-0.20240808182737-94ef0df2e786/go.mod h1:y7Ucdmv40VltqulZnncMNjNQ4piX5Dta5ujNmPmXnxg=
github.com/0chain/gosdk v1.17.0-RC3.0.20240816052054-a9a39a9098d8 h1:dy6dF1QtQ1ifTfE7T2smOmabXrWkCkVQecGR2DtmZm0=
github.com/0chain/gosdk v1.17.0-RC3.0.20240816052054-a9a39a9098d8/go.mod h1:y7Ucdmv40VltqulZnncMNjNQ4piX5Dta5ujNmPmXnxg=
github.com/Azure/azure-amqp-common-go/v2 v2.1.0/go.mod h1:R8rea+gJRuJR6QxTir/XuEd+YuKoUiazDC/N96FiDEU=
github.com/Azure/azure-pipeline-go v0.2.1/go.mod h1:UGSo8XybXnIGZ3epmeBw7Jdz+HiUVpqIlpz/HKHylF4=
github.com/Azure/azure-pipeline-go v0.2.2 h1:6oiIS9yaG6XCCzhgAgKFfIWyo4LLCiDhZot6ltoThhY=
Expand Down
Loading

0 comments on commit 136e549

Please sign in to comment.