[#149] pool: Configure homomorphic hash and buffer size

Signed-off-by: Denis Kirillov <d.kirillov@yadro.com>
This commit is contained in:
Denis Kirillov 2023-08-25 09:36:08 +03:00
parent 202412230a
commit 46a214d065
2 changed files with 26 additions and 9 deletions

View file

@ -20,7 +20,6 @@ type logger interface {
type PrmObjectPutClientCutInit struct { type PrmObjectPutClientCutInit struct {
PrmObjectPut PrmObjectPut
withoutHomomorphicHash bool
} }
func (c *clientWrapper) objectPutInitTransformer(prm PrmObjectPutClientCutInit) (*objectWriterTransformer, error) { func (c *clientWrapper) objectPutInitTransformer(prm PrmObjectPutClientCutInit) (*objectWriterTransformer, error) {

View file

@ -634,6 +634,10 @@ func (c *clientWrapper) networkInfo(ctx context.Context, _ prmNetworkInfo) (netm
// objectPut writes object to FrostFS. // objectPut writes object to FrostFS.
func (c *clientWrapper) objectPut(ctx context.Context, prm PrmObjectPut) (oid.ID, error) { func (c *clientWrapper) objectPut(ctx context.Context, prm PrmObjectPut) (oid.ID, error) {
if prm.bufferMaxSize == 0 {
prm.bufferMaxSize = defaultBufferMaxSizeForPut
}
if prm.clientCut { if prm.clientCut {
return c.objectPutClientCut(ctx, prm) return c.objectPutClientCut(ctx, prm)
} }
@ -679,10 +683,8 @@ func (c *clientWrapper) objectPutServerCut(ctx context.Context, prm PrmObjectPut
} }
if prm.payload != nil { if prm.payload != nil {
const defaultBufferSizePut = 3 << 20 // default grpc message size, configure? if sz == 0 || sz > prm.bufferMaxSize {
sz = prm.bufferMaxSize
if sz == 0 || sz > defaultBufferSizePut {
sz = defaultBufferSizePut
} }
buf := make([]byte, sz) buf := make([]byte, sz)
@ -748,10 +750,8 @@ func (c *clientWrapper) objectPutClientCut(ctx context.Context, prm PrmObjectPut
} }
if prm.payload != nil { if prm.payload != nil {
const defaultBufferSizePut = 64 * 1024 // it's buffer size in s3-gw, configure? if sz == 0 || sz > prm.bufferMaxSize {
sz = prm.bufferMaxSize
if sz == 0 || sz > defaultBufferSizePut {
sz = defaultBufferSizePut
} }
buf := make([]byte, sz) buf := make([]byte, sz)
@ -1409,6 +1409,10 @@ type PrmObjectPut struct {
clientCut bool clientCut bool
networkInfo netmap.NetworkInfo networkInfo netmap.NetworkInfo
withoutHomomorphicHash bool
bufferMaxSize uint64
} }
// SetHeader specifies header of the object. // SetHeader specifies header of the object.
@ -1443,6 +1447,18 @@ func (x *PrmObjectPut) SetClientCut(clientCut bool) {
x.clientCut = clientCut x.clientCut = clientCut
} }
// WithoutHomomorphicHash if set to true do not use Tillich-Zémor hash for payload.
func (x *PrmObjectPut) WithoutHomomorphicHash(v bool) {
x.withoutHomomorphicHash = v
}
// SetBufferMaxSize sets max buffer size to read payload.
// This value isn't used if object size is set explicitly and less than this value.
// Default value 3MB.
func (x *PrmObjectPut) SetBufferMaxSize(size uint64) {
x.bufferMaxSize = size
}
func (x *PrmObjectPut) setNetworkInfo(ni netmap.NetworkInfo) { func (x *PrmObjectPut) setNetworkInfo(ni netmap.NetworkInfo) {
x.networkInfo = ni x.networkInfo = ni
} }
@ -1760,6 +1776,8 @@ const (
defaultHealthcheckTimeout = 4 * time.Second defaultHealthcheckTimeout = 4 * time.Second
defaultDialTimeout = 5 * time.Second defaultDialTimeout = 5 * time.Second
defaultStreamTimeout = 10 * time.Second defaultStreamTimeout = 10 * time.Second
defaultBufferMaxSizeForPut = 3 * 1024 * 1024 // 3 MB
) )
// NewPool creates connection pool using parameters. // NewPool creates connection pool using parameters.