forked from TrueCloudLab/frostfs-node
[#1004] blobovnicza: Use TTL for blobovnicza tree cache
Signed-off-by: Anton Nikiforov <an.nikiforov@yadro.com>
This commit is contained in:
parent
112a7c690f
commit
411a8d0245
26 changed files with 203 additions and 65 deletions
|
@ -185,13 +185,15 @@ type subStorageCfg struct {
|
|||
noSync bool
|
||||
|
||||
// blobovnicza-specific
|
||||
size uint64
|
||||
width uint64
|
||||
leafWidth uint64
|
||||
openedCacheSize int
|
||||
initWorkerCount int
|
||||
initInAdvance bool
|
||||
rebuildDropTimeout time.Duration
|
||||
size uint64
|
||||
width uint64
|
||||
leafWidth uint64
|
||||
openedCacheSize int
|
||||
initWorkerCount int
|
||||
initInAdvance bool
|
||||
rebuildDropTimeout time.Duration
|
||||
openedCacheTTL time.Duration
|
||||
openedCacheExpInterval time.Duration
|
||||
}
|
||||
|
||||
// readConfig fills applicationConfiguration with raw configuration values
|
||||
|
@ -313,6 +315,8 @@ func (a *applicationConfiguration) setShardStorageConfig(newConfig *shardCfg, ol
|
|||
sCfg.width = sub.ShallowWidth()
|
||||
sCfg.leafWidth = sub.LeafWidth()
|
||||
sCfg.openedCacheSize = sub.OpenedCacheSize()
|
||||
sCfg.openedCacheTTL = sub.OpenedCacheTTL()
|
||||
sCfg.openedCacheExpInterval = sub.OpenedCacheExpInterval()
|
||||
sCfg.initWorkerCount = sub.InitWorkerCount()
|
||||
sCfg.initInAdvance = sub.InitInAdvance()
|
||||
sCfg.rebuildDropTimeout = sub.RebuildDropTimeout()
|
||||
|
@ -846,11 +850,11 @@ type shardOptsWithID struct {
|
|||
shOpts []shard.Option
|
||||
}
|
||||
|
||||
func (c *cfg) shardOpts() []shardOptsWithID {
|
||||
func (c *cfg) shardOpts(ctx context.Context) []shardOptsWithID {
|
||||
shards := make([]shardOptsWithID, 0, len(c.EngineCfg.shards))
|
||||
|
||||
for _, shCfg := range c.EngineCfg.shards {
|
||||
shards = append(shards, c.getShardOpts(shCfg))
|
||||
shards = append(shards, c.getShardOpts(ctx, shCfg))
|
||||
}
|
||||
|
||||
return shards
|
||||
|
@ -891,7 +895,7 @@ func (c *cfg) getPiloramaOpts(shCfg shardCfg) []pilorama.Option {
|
|||
return piloramaOpts
|
||||
}
|
||||
|
||||
func (c *cfg) getSubstorageOpts(shCfg shardCfg) []blobstor.SubStorage {
|
||||
func (c *cfg) getSubstorageOpts(ctx context.Context, shCfg shardCfg) []blobstor.SubStorage {
|
||||
var ss []blobstor.SubStorage
|
||||
for _, sRead := range shCfg.subStorages {
|
||||
switch sRead.typ {
|
||||
|
@ -904,6 +908,8 @@ func (c *cfg) getSubstorageOpts(shCfg shardCfg) []blobstor.SubStorage {
|
|||
blobovniczatree.WithBlobovniczaShallowWidth(sRead.width),
|
||||
blobovniczatree.WithBlobovniczaLeafWidth(sRead.leafWidth),
|
||||
blobovniczatree.WithOpenedCacheSize(sRead.openedCacheSize),
|
||||
blobovniczatree.WithOpenedCacheTTL(sRead.openedCacheTTL),
|
||||
blobovniczatree.WithOpenedCacheExpInterval(sRead.openedCacheExpInterval),
|
||||
blobovniczatree.WithInitWorkerCount(sRead.initWorkerCount),
|
||||
blobovniczatree.WithInitInAdvance(sRead.initInAdvance),
|
||||
blobovniczatree.WithWaitBeforeDropDB(sRead.rebuildDropTimeout),
|
||||
|
@ -919,7 +925,7 @@ func (c *cfg) getSubstorageOpts(shCfg shardCfg) []blobstor.SubStorage {
|
|||
)
|
||||
}
|
||||
ss = append(ss, blobstor.SubStorage{
|
||||
Storage: blobovniczatree.NewBlobovniczaTree(blobTreeOpts...),
|
||||
Storage: blobovniczatree.NewBlobovniczaTree(ctx, blobTreeOpts...),
|
||||
Policy: func(_ *objectSDK.Object, data []byte) bool {
|
||||
return uint64(len(data)) < shCfg.smallSizeObjectLimit
|
||||
},
|
||||
|
@ -954,10 +960,10 @@ func (c *cfg) getSubstorageOpts(shCfg shardCfg) []blobstor.SubStorage {
|
|||
return ss
|
||||
}
|
||||
|
||||
func (c *cfg) getShardOpts(shCfg shardCfg) shardOptsWithID {
|
||||
func (c *cfg) getShardOpts(ctx context.Context, shCfg shardCfg) shardOptsWithID {
|
||||
writeCacheOpts := c.getWriteCacheOpts(shCfg)
|
||||
piloramaOpts := c.getPiloramaOpts(shCfg)
|
||||
ss := c.getSubstorageOpts(shCfg)
|
||||
ss := c.getSubstorageOpts(ctx, shCfg)
|
||||
|
||||
blobstoreOpts := []blobstor.Option{
|
||||
blobstor.WithCompressObjects(shCfg.compress),
|
||||
|
@ -1049,7 +1055,7 @@ func initLocalStorage(ctx context.Context, c *cfg) {
|
|||
c.cfgObject.getSvc = new(getsvc.Service)
|
||||
|
||||
var shardsAttached int
|
||||
for _, optsWithMeta := range c.shardOpts() {
|
||||
for _, optsWithMeta := range c.shardOpts(ctx) {
|
||||
id, err := ls.AddShard(ctx, append(optsWithMeta.shOpts, shard.WithTombstoneSource(c.createTombstoneSource()))...)
|
||||
if err != nil {
|
||||
c.log.Error(logs.FrostFSNodeFailedToAttachShardToEngine, zap.Error(err))
|
||||
|
@ -1289,7 +1295,7 @@ func (c *cfg) reloadConfig(ctx context.Context) {
|
|||
// Storage Engine
|
||||
|
||||
var rcfg engine.ReConfiguration
|
||||
for _, optsWithID := range c.shardOpts() {
|
||||
for _, optsWithID := range c.shardOpts(ctx) {
|
||||
rcfg.AddShard(optsWithID.configID, append(optsWithID.shOpts, shard.WithTombstoneSource(c.createTombstoneSource())))
|
||||
}
|
||||
|
||||
|
|
|
@ -25,6 +25,12 @@ const (
|
|||
// 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
|
||||
|
||||
|
@ -106,6 +112,38 @@ func (x *Config) OpenedCacheSize() int {
|
|||
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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue