From 92c95150cd03a36602eabc705adcff4e151f4749 Mon Sep 17 00:00:00 2001 From: Alex Vanin Date: Tue, 1 Dec 2020 12:26:19 +0300 Subject: [PATCH] [#222] Use write cache options in storage app Signed-off-by: Alex Vanin --- cmd/neofs-node/config.go | 14 ++++++++++++++ pkg/local_object_storage/shard/info.go | 3 +++ pkg/local_object_storage/shard/shard.go | 18 ++++++++++++++---- 3 files changed, 31 insertions(+), 4 deletions(-) diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index 9886c56e6..3e276da18 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -117,6 +117,7 @@ const ( cfgShardUseWriteCache = "use_write_cache" cfgBlobStorSection = "blobstor" + cfgWriteCacheSection = "writecache" cfgBlobStorCompress = "compress" cfgBlobStorShallowDepth = "shallow_depth" cfgBlobStorTreePath = "path" @@ -442,6 +443,15 @@ func initShardOptions(c *cfg) { configPath(prefix, cfgShardUseWriteCache), ) + writeCachePrefix := configPath(prefix, cfgWriteCacheSection) + + writeCachePath := c.viper.GetString( + configPath(writeCachePrefix, cfgBlobStorTreePath), + ) + if useCache && writeCachePath == "" { + break + } + blobPrefix := configPath(prefix, cfgBlobStorSection) blobPath := c.viper.GetString( @@ -517,10 +527,14 @@ func initShardOptions(c *cfg) { meta.WithPermissions(metaPerm), ), shard.WithWriteCache(useCache), + shard.WithWriteCacheOptions( + blobstor.WithTreeRootPath(writeCachePath), + ), }) c.log.Info("storage shard options", zap.Bool("with write cache", useCache), + zap.String("with write cache path", writeCachePath), zap.String("BLOB path", blobPath), zap.Stringer("BLOB permissions", blobPerm), zap.Bool("BLOB compress", compressObjects), diff --git a/pkg/local_object_storage/shard/info.go b/pkg/local_object_storage/shard/info.go index dba9787be..f195ee420 100644 --- a/pkg/local_object_storage/shard/info.go +++ b/pkg/local_object_storage/shard/info.go @@ -16,6 +16,9 @@ type Info struct { // Information about the BLOB storage. BlobStorInfo blobstor.Info + // Information about the Write Cache. + WriteCacheInfo blobstor.Info + // Weight parameters of the shard. WeightValues WeightValues } diff --git a/pkg/local_object_storage/shard/shard.go b/pkg/local_object_storage/shard/shard.go index 838fc0723..d245d74a1 100644 --- a/pkg/local_object_storage/shard/shard.go +++ b/pkg/local_object_storage/shard/shard.go @@ -32,6 +32,8 @@ type cfg struct { metaOpts []meta.Option + writeCacheOpts []blobstor.Option + log *logger.Logger } @@ -51,10 +53,11 @@ func New(opts ...Option) *Shard { if c.useWriteCache { writeCache = blobstor.New( - blobstor.WithBlobovniczaShallowDepth(0), - blobstor.WithBlobovniczaShallowWidth(1), - blobstor.WithLogger(c.log), - // ? what about path + append(c.blobOpts, append( + c.writeCacheOpts, + blobstor.WithBlobovniczaShallowDepth(0), + blobstor.WithBlobovniczaShallowWidth(1))..., + )..., ) } @@ -88,6 +91,13 @@ func WithMetaBaseOptions(opts ...meta.Option) Option { } } +// WithMetaBaseOptions returns option to set internal metabase options. +func WithWriteCacheOptions(opts ...blobstor.Option) Option { + return func(c *cfg) { + c.writeCacheOpts = opts + } +} + // WithLogger returns option to set Shard's logger. func WithLogger(l *logger.Logger) Option { return func(c *cfg) {