[#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
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:
parent
df055fead5
commit
27fcf868d8
2 changed files with 17 additions and 0 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
"sort"
|
||||
"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/checksum"
|
||||
"git.frostfs.info/TrueCloudLab/frostfs-sdk-go/client"
|
||||
|
@ -356,6 +357,8 @@ type PutObjectPrm struct {
|
|||
headerCallback func(*objectSDK.Object)
|
||||
|
||||
prepareLocally bool
|
||||
|
||||
objSize uint64
|
||||
}
|
||||
|
||||
// SetHeader sets object header.
|
||||
|
@ -363,6 +366,10 @@ func (x *PutObjectPrm) SetHeader(hdr *objectSDK.Object) {
|
|||
x.hdr = hdr
|
||||
}
|
||||
|
||||
func (x *PutObjectPrm) SetObjSize(size uint64) {
|
||||
x.objSize = size
|
||||
}
|
||||
|
||||
// SetPayloadReader sets reader of the object payload.
|
||||
func (x *PutObjectPrm) SetPayloadReader(rdr io.Reader) {
|
||||
x.rdr = rdr
|
||||
|
@ -402,6 +409,11 @@ func (x *PutObjectPrm) convertToSDKPrm(ctx context.Context) (client.PrmObjectPut
|
|||
putPrm.MaxSize = res.Info().MaxObjectSize()
|
||||
putPrm.EpochSource = epochSource(res.Info().CurrentEpoch())
|
||||
putPrm.WithoutHomomorphHash = res.Info().HomomorphicHashingDisabled()
|
||||
|
||||
if x.objSize > 2*res.Info().MaxObjectSize() {
|
||||
pool := buffPool.NewBufferPool(uint32(res.Info().MaxObjectSize()))
|
||||
putPrm.Pool = &pool
|
||||
}
|
||||
} else {
|
||||
putPrm.Session = x.sessionToken
|
||||
}
|
||||
|
|
|
@ -130,6 +130,11 @@ func putObject(cmd *cobra.Command, _ []string) {
|
|||
commonCmd.ExitOnErr(cmd, "can't parse object copies numbers information: %w", err)
|
||||
prm.SetCopiesNumberByVectors(parseCopyNumber(cmd, copyNum))
|
||||
|
||||
fi, err := f.Stat()
|
||||
if err == nil {
|
||||
prm.SetObjSize(uint64(fi.Size()))
|
||||
}
|
||||
|
||||
res, err := internalclient.PutObject(cmd.Context(), prm)
|
||||
if p != nil {
|
||||
p.Finish()
|
||||
|
|
Loading…
Reference in a new issue