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
|
@ -27,32 +27,40 @@ type cfg struct {
|
|||
blzInitWorkerCount int
|
||||
blzMoveBatchSize int
|
||||
createDBInAdvance bool
|
||||
// TTL for blobovnicza's cache
|
||||
openedCacheTTL time.Duration
|
||||
// Interval for deletion expired blobovnicza's
|
||||
openedCacheExpInterval time.Duration
|
||||
}
|
||||
|
||||
type Option func(*cfg)
|
||||
|
||||
const (
|
||||
defaultPerm = 0o700
|
||||
defaultOpenedCacheSize = 50
|
||||
defaultBlzShallowDepth = 2
|
||||
defaultBlzShallowWidth = 16
|
||||
defaultWaitBeforeDropDB = 10 * time.Second
|
||||
defaultBlzInitWorkerCount = 5
|
||||
defaulBlzMoveBatchSize = 10000
|
||||
defaultPerm = 0o700
|
||||
defaultOpenedCacheSize = 50
|
||||
defaultOpenedCacheTTL = 0 // means expiring is off
|
||||
defaultOpenedCacheInterval = 15 * time.Second
|
||||
defaultBlzShallowDepth = 2
|
||||
defaultBlzShallowWidth = 16
|
||||
defaultWaitBeforeDropDB = 10 * time.Second
|
||||
defaultBlzInitWorkerCount = 5
|
||||
defaulBlzMoveBatchSize = 10000
|
||||
)
|
||||
|
||||
func initConfig(c *cfg) {
|
||||
*c = cfg{
|
||||
log: &logger.Logger{Logger: zap.L()},
|
||||
perm: defaultPerm,
|
||||
openedCacheSize: defaultOpenedCacheSize,
|
||||
blzShallowDepth: defaultBlzShallowDepth,
|
||||
blzShallowWidth: defaultBlzShallowWidth,
|
||||
reportError: func(string, error) {},
|
||||
metrics: &noopMetrics{},
|
||||
waitBeforeDropDB: defaultWaitBeforeDropDB,
|
||||
blzInitWorkerCount: defaultBlzInitWorkerCount,
|
||||
blzMoveBatchSize: defaulBlzMoveBatchSize,
|
||||
log: &logger.Logger{Logger: zap.L()},
|
||||
perm: defaultPerm,
|
||||
openedCacheSize: defaultOpenedCacheSize,
|
||||
openedCacheTTL: defaultOpenedCacheTTL,
|
||||
openedCacheExpInterval: defaultOpenedCacheInterval,
|
||||
blzShallowDepth: defaultBlzShallowDepth,
|
||||
blzShallowWidth: defaultBlzShallowWidth,
|
||||
reportError: func(string, error) {},
|
||||
metrics: &noopMetrics{},
|
||||
waitBeforeDropDB: defaultWaitBeforeDropDB,
|
||||
blzInitWorkerCount: defaultBlzInitWorkerCount,
|
||||
blzMoveBatchSize: defaulBlzMoveBatchSize,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -105,6 +113,18 @@ func WithOpenedCacheSize(sz int) Option {
|
|||
}
|
||||
}
|
||||
|
||||
func WithOpenedCacheTTL(ttl time.Duration) Option {
|
||||
return func(c *cfg) {
|
||||
c.openedCacheTTL = ttl
|
||||
}
|
||||
}
|
||||
|
||||
func WithOpenedCacheExpInterval(expInterval time.Duration) Option {
|
||||
return func(c *cfg) {
|
||||
c.openedCacheExpInterval = expInterval
|
||||
}
|
||||
}
|
||||
|
||||
func WithObjectSizeLimit(sz uint64) Option {
|
||||
return func(c *cfg) {
|
||||
c.blzOpts = append(c.blzOpts, blobovnicza.WithObjectSizeLimit(sz))
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue