diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index 648968f18d..f638798099 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -417,7 +417,7 @@ func initShardOptions(c *cfg) { gcCfg := sc.GC() metaPath := metabaseCfg.Path() - metaPerm := metabaseCfg.Perm() + metaPerm := metabaseCfg.BoltDB().Perm() fatalOnErr(util.MkdirAllX(filepath.Dir(metaPath), metaPerm)) gcEventChannel := make(chan shard.Event) diff --git a/cmd/neofs-node/config/engine/config_test.go b/cmd/neofs-node/config/engine/config_test.go index 9e7aef07b1..a7476b6c20 100644 --- a/cmd/neofs-node/config/engine/config_test.go +++ b/cmd/neofs-node/config/engine/config_test.go @@ -67,7 +67,7 @@ func TestEngineSection(t *testing.T) { require.EqualValues(t, 3221225472, wc.SizeLimit()) require.Equal(t, "tmp/0/meta", meta.Path()) - require.Equal(t, fs.FileMode(0644), meta.Perm()) + require.Equal(t, fs.FileMode(0644), meta.BoltDB().Perm()) require.Equal(t, "tmp/0/blob", blob.Path()) require.EqualValues(t, 0644, blob.Perm()) @@ -97,7 +97,7 @@ func TestEngineSection(t *testing.T) { require.EqualValues(t, 4294967296, wc.SizeLimit()) require.Equal(t, "tmp/1/meta", meta.Path()) - require.Equal(t, fs.FileMode(0644), meta.Perm()) + require.Equal(t, fs.FileMode(0644), meta.BoltDB().Perm()) require.Equal(t, "tmp/1/blob", blob.Path()) require.EqualValues(t, 0644, blob.Perm()) diff --git a/cmd/neofs-node/config/engine/shard/blobstor/blobovnicza/config.go b/cmd/neofs-node/config/engine/shard/blobstor/blobovnicza/config.go index a854b6d62a..1cb571b91c 100644 --- a/cmd/neofs-node/config/engine/shard/blobstor/blobovnicza/config.go +++ b/cmd/neofs-node/config/engine/shard/blobstor/blobovnicza/config.go @@ -2,6 +2,7 @@ package blobovniczaconfig import ( "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config" + boltdbconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine/shard/boltdb" ) // Config is a wrapper over the config section @@ -91,3 +92,8 @@ func (x *Config) OpenedCacheSize() int { return OpenedCacheSizeDefault } + +// BoltDB returns config instance for querying bolt db specific parameters. +func (x *Config) BoltDB() *boltdbconfig.Config { + return (*boltdbconfig.Config)(x) +} diff --git a/cmd/neofs-node/config/engine/shard/boltdb/boltdb.go b/cmd/neofs-node/config/engine/shard/boltdb/boltdb.go new file mode 100644 index 0000000000..b337daccb0 --- /dev/null +++ b/cmd/neofs-node/config/engine/shard/boltdb/boltdb.go @@ -0,0 +1,63 @@ +package boltdbconfig + +import ( + "io/fs" + "time" + + "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config" +) + +// Config is a wrapper over the config section +// which provides access to boltdb specific parameters. +type Config config.Config + +// config defaults +const ( + // PermDefault is a default permission bits for metabase file. + PermDefault = 0660 +) + +// Perm returns the value of "perm" config parameter as a fs.FileMode. +// +// Returns PermDefault if the value is not a positive number. +func (x *Config) Perm() fs.FileMode { + p := config.UintSafe( + (*config.Config)(x), + "perm", + ) + + if p == 0 { + p = PermDefault + } + + return fs.FileMode(p) +} + +// MaxBatchDelay returns the value of "max_batch_delay" config parameter. +// +// Returns 0 if the value is not a positive number. +func (x *Config) MaxBatchDelay() time.Duration { + d := config.DurationSafe((*config.Config)(x), "max_batch_delay") + if d < 0 { + d = 0 + } + return d +} + +// MaxBatchSize returns the value of "max_batch_size" config parameter. +// +// Returns 0 if the value is not a positive number. +func (x *Config) MaxBatchSize() int { + s := int(config.IntSafe((*config.Config)(x), "max_batch_size")) + if s < 0 { + s = 0 + } + return s +} + +// NoSync returns the value of "no_sync" config parameter. +// +// Returns false if the value is not a boolean. +func (x *Config) NoSync() bool { + return config.BoolSafe((*config.Config)(x), "no_sync") +} diff --git a/cmd/neofs-node/config/engine/shard/metabase/config.go b/cmd/neofs-node/config/engine/shard/metabase/config.go index f9b048d7dc..ec684e0177 100644 --- a/cmd/neofs-node/config/engine/shard/metabase/config.go +++ b/cmd/neofs-node/config/engine/shard/metabase/config.go @@ -1,21 +1,14 @@ package metabaseconfig import ( - "io/fs" - "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config" + boltdbconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine/shard/boltdb" ) // Config is a wrapper over the config section // which provides access to Metabase configurations. type Config config.Config -// config defaults -const ( - // PermDefault is a default permission bits for metabase file. - PermDefault = 0660 -) - // From wraps config section into Config. func From(c *config.Config) *Config { return (*Config)(c) @@ -37,18 +30,7 @@ func (x *Config) Path() string { return p } -// Perm returns the value of "perm" config parameter as a fs.FileMode. -// -// Returns PermDefault if the value is not a positive number. -func (x *Config) Perm() fs.FileMode { - p := config.UintSafe( - (*config.Config)(x), - "perm", - ) - - if p == 0 { - p = PermDefault - } - - return fs.FileMode(p) +// BoltDB returns config instance for querying bolt db specific parameters. +func (x *Config) BoltDB() *boltdbconfig.Config { + return (*boltdbconfig.Config)(x) } diff --git a/cmd/neofs-node/config/engine/shard/writecache/config.go b/cmd/neofs-node/config/engine/shard/writecache/config.go index 7a9f31fe18..4e45dedbc7 100644 --- a/cmd/neofs-node/config/engine/shard/writecache/config.go +++ b/cmd/neofs-node/config/engine/shard/writecache/config.go @@ -2,6 +2,7 @@ package writecacheconfig import ( "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config" + boltdbconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine/shard/boltdb" ) // Config is a wrapper over the config section @@ -133,3 +134,8 @@ func (x *Config) SizeLimit() uint64 { return SizeLimitDefault } + +// BoltDB returns config instance for querying bolt db specific parameters. +func (x *Config) BoltDB() *boltdbconfig.Config { + return (*boltdbconfig.Config)(x) +}