200 lines
4.7 KiB
Go
200 lines
4.7 KiB
Go
package blobovniczaconfig
|
|
|
|
import (
|
|
"time"
|
|
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config"
|
|
boltdbconfig "git.frostfs.info/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/engine/shard/boltdb"
|
|
"git.frostfs.info/TrueCloudLab/frostfs-node/pkg/local_object_storage/blobstor/blobovniczatree"
|
|
)
|
|
|
|
// Config is a wrapper over the config section
|
|
// which provides access to Blobovnicza configurations.
|
|
type Config config.Config
|
|
|
|
const (
|
|
// SizeDefault is a default limit of estimates of Blobovnicza size.
|
|
SizeDefault = 1 << 30
|
|
|
|
// ShallowDepthDefault is a default shallow dir depth.
|
|
ShallowDepthDefault = 2
|
|
|
|
// ShallowWidthDefault is a default shallow dir width.
|
|
ShallowWidthDefault = 16
|
|
|
|
// OpenedCacheSizeDefault is a default cache size of opened Blobovnicza's.
|
|
OpenedCacheSizeDefault = 16
|
|
|
|
// OpenedCacheTTLDefault is a default cache ttl of opened Blobovnicza's.
|
|
OpenedCacheTTLDefault = 0 // means expiring is off
|
|
|
|
// OpenedCacheExpIntervalDefault is a default cache cleanup interval for expired Blobovnicza's.
|
|
OpenedCacheExpIntervalDefault = 15 * time.Second
|
|
|
|
// InitWorkerCountDefault is a default workers count to initialize Blobovnicza's.
|
|
InitWorkerCountDefault = 5
|
|
|
|
// RebuildDropTimeoutDefault is a default timeout value to wait before drop single blobovnicza.
|
|
RebuildDropTimeoutDefault = 10 * time.Second
|
|
)
|
|
|
|
// From wraps config section into Config.
|
|
func From(c *config.Config) *Config {
|
|
return (*Config)(c)
|
|
}
|
|
|
|
// Type returns the storage type.
|
|
func (x *Config) Type() string {
|
|
return blobovniczatree.Type
|
|
}
|
|
|
|
// Size returns the value of "size" config parameter.
|
|
//
|
|
// Returns SizeDefault if the value is not a positive number.
|
|
func (x *Config) Size() uint64 {
|
|
s := config.SizeInBytesSafe(
|
|
(*config.Config)(x),
|
|
"size",
|
|
)
|
|
|
|
if s > 0 {
|
|
return s
|
|
}
|
|
|
|
return SizeDefault
|
|
}
|
|
|
|
// ShallowDepth returns the value of "depth" config parameter.
|
|
//
|
|
// Returns ShallowDepthDefault if the value is not a positive number.
|
|
func (x *Config) ShallowDepth() uint64 {
|
|
d := config.UintSafe(
|
|
(*config.Config)(x),
|
|
"depth",
|
|
)
|
|
|
|
if d > 0 {
|
|
return d
|
|
}
|
|
|
|
return ShallowDepthDefault
|
|
}
|
|
|
|
// ShallowWidth returns the value of "width" config parameter.
|
|
//
|
|
// Returns ShallowWidthDefault if the value is not a positive number.
|
|
func (x *Config) ShallowWidth() uint64 {
|
|
d := config.UintSafe(
|
|
(*config.Config)(x),
|
|
"width",
|
|
)
|
|
|
|
if d > 0 {
|
|
return d
|
|
}
|
|
|
|
return ShallowWidthDefault
|
|
}
|
|
|
|
// OpenedCacheSize returns the value of "opened_cache_capacity" config parameter.
|
|
//
|
|
// Returns OpenedCacheSizeDefault if the value is not a positive number.
|
|
func (x *Config) OpenedCacheSize() int {
|
|
d := config.IntSafe(
|
|
(*config.Config)(x),
|
|
"opened_cache_capacity",
|
|
)
|
|
|
|
if d > 0 {
|
|
return int(d)
|
|
}
|
|
|
|
return OpenedCacheSizeDefault
|
|
}
|
|
|
|
// OpenedCacheTTL returns the value of "opened_cache_ttl" config parameter.
|
|
//
|
|
// Returns OpenedCacheTTLDefault if the value is not a positive number.
|
|
func (x *Config) OpenedCacheTTL() time.Duration {
|
|
d := config.DurationSafe(
|
|
(*config.Config)(x),
|
|
"opened_cache_ttl",
|
|
)
|
|
|
|
if d > 0 {
|
|
return d
|
|
}
|
|
|
|
return OpenedCacheTTLDefault
|
|
}
|
|
|
|
// OpenedCacheExpInterval returns the value of "opened_cache_exp_interval" config parameter.
|
|
//
|
|
// Returns OpenedCacheExpIntervalDefault if the value is not a positive number.
|
|
func (x *Config) OpenedCacheExpInterval() time.Duration {
|
|
d := config.DurationSafe(
|
|
(*config.Config)(x),
|
|
"opened_cache_exp_interval",
|
|
)
|
|
|
|
if d > 0 {
|
|
return d
|
|
}
|
|
|
|
return OpenedCacheExpIntervalDefault
|
|
}
|
|
|
|
// BoltDB returns config instance for querying bolt db specific parameters.
|
|
func (x *Config) BoltDB() *boltdbconfig.Config {
|
|
return (*boltdbconfig.Config)(x)
|
|
}
|
|
|
|
// LeafWidth returns the value of "leaf_width" config parameter.
|
|
//
|
|
// Returns 0 if the value is not a positive number.
|
|
func (x *Config) LeafWidth() uint64 {
|
|
return config.UintSafe(
|
|
(*config.Config)(x),
|
|
"leaf_width",
|
|
)
|
|
}
|
|
|
|
// InitWorkerCount returns the value of "init_worker_count" config parameter.
|
|
//
|
|
// Returns InitWorkerCountDefault if the value is not a positive number.
|
|
func (x *Config) InitWorkerCount() int {
|
|
d := config.IntSafe(
|
|
(*config.Config)(x),
|
|
"init_worker_count",
|
|
)
|
|
|
|
if d > 0 {
|
|
return int(d)
|
|
}
|
|
|
|
return InitWorkerCountDefault
|
|
}
|
|
|
|
// InitInAdvance returns the value of "init_in_advance" config parameter.
|
|
//
|
|
// Returns False if the value is not defined or invalid.
|
|
func (x *Config) InitInAdvance() bool {
|
|
return config.BoolSafe(
|
|
(*config.Config)(x),
|
|
"init_in_advance",
|
|
)
|
|
}
|
|
|
|
// RebuildDropTimeout returns the value of "rebuild_drop_timeout" config parameter.
|
|
//
|
|
// Returns RebuildDropTimeoutDefault if the value is not defined or invalid.
|
|
func (x *Config) RebuildDropTimeout() time.Duration {
|
|
d := config.DurationSafe(
|
|
(*config.Config)(x),
|
|
"rebuild_drop_timeout",
|
|
)
|
|
if d > 0 {
|
|
return d
|
|
}
|
|
return RebuildDropTimeoutDefault
|
|
}
|