[#939] cli/put: Add support buffer pool
Some checks failed
DCO action / DCO (pull_request) Successful in 1m24s
Build / Build Components (1.21) (pull_request) Failing after 2m14s
Build / Build Components (1.20) (pull_request) Failing after 2m26s
Vulncheck / Vulncheck (pull_request) Failing after 3m1s
Tests and linters / Staticcheck (pull_request) Failing after 3m46s
Tests and linters / Lint (pull_request) Failing after 4m25s
Tests and linters / Tests (1.21) (pull_request) Failing after 4m24s
Tests and linters / Tests (1.20) (pull_request) Failing after 4m40s
Tests and linters / Tests with -race (pull_request) Failing after 5m57s

Signed-off-by: Alexander Chuprov <a.chuprov@yadro.com>
This commit is contained in:
Alexander Chuprov 2024-02-01 12:07:36 +03:00
parent df055fead5
commit 27fcf868d8
2 changed files with 17 additions and 0 deletions

View file

@ -9,6 +9,7 @@ import (
"sort" "sort"
"strings" "strings"
buffPool "git.frostfs.info/TrueCloudLab/frostfs-api-go/v2/util/pool"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/accounting" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/accounting"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/checksum" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/checksum"
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client" "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
@ -356,6 +357,8 @@ type PutObjectPrm struct {
headerCallback func(*objectSDK.Object) headerCallback func(*objectSDK.Object)
prepareLocally bool prepareLocally bool
objSize uint64
} }
// SetHeader sets object header. // SetHeader sets object header.
@ -363,6 +366,10 @@ func (x *PutObjectPrm) SetHeader(hdr *objectSDK.Object) {
x.hdr = hdr x.hdr = hdr
} }
func (x *PutObjectPrm) SetObjSize(size uint64) {
x.objSize = size
}
// SetPayloadReader sets reader of the object payload. // SetPayloadReader sets reader of the object payload.
func (x *PutObjectPrm) SetPayloadReader(rdr io.Reader) { func (x *PutObjectPrm) SetPayloadReader(rdr io.Reader) {
x.rdr = rdr x.rdr = rdr
@ -402,6 +409,11 @@ func (x *PutObjectPrm) convertToSDKPrm(ctx context.Context) (client.PrmObjectPut
putPrm.MaxSize = res.Info().MaxObjectSize() putPrm.MaxSize = res.Info().MaxObjectSize()
putPrm.EpochSource = epochSource(res.Info().CurrentEpoch()) putPrm.EpochSource = epochSource(res.Info().CurrentEpoch())
putPrm.WithoutHomomorphHash = res.Info().HomomorphicHashingDisabled() putPrm.WithoutHomomorphHash = res.Info().HomomorphicHashingDisabled()
if x.objSize > 2*res.Info().MaxObjectSize() {
pool := buffPool.NewBufferPool(uint32(res.Info().MaxObjectSize()))
putPrm.Pool = &pool
}
} else { } else {
putPrm.Session = x.sessionToken putPrm.Session = x.sessionToken
} }

View file

@ -130,6 +130,11 @@ func putObject(cmd *cobra.Command, _ []string) {
commonCmd.ExitOnErr(cmd, "can't parse object copies numbers information: %w", err) commonCmd.ExitOnErr(cmd, "can't parse object copies numbers information: %w", err)
prm.SetCopiesNumberByVectors(parseCopyNumber(cmd, copyNum)) prm.SetCopiesNumberByVectors(parseCopyNumber(cmd, copyNum))
fi, err := f.Stat()
if err == nil {
prm.SetObjSize(uint64(fi.Size()))
}
res, err := internalclient.PutObject(cmd.Context(), prm) res, err := internalclient.PutObject(cmd.Context(), prm)
if p != nil { if p != nil {
p.Finish() p.Finish()