From 6f45cc81fca376a9d815ebcc98e39f8ea5f35d77 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 20 Sep 2022 15:42:56 +0300 Subject: [PATCH] [#1764] neofs-node: Use constants for storage types Signed-off-by: Evgenii Stratonikov --- cmd/neofs-node/config.go | 4 ++-- .../config/engine/shard/blobstor/blobovnicza/config.go | 3 ++- cmd/neofs-node/config/engine/shard/blobstor/config.go | 4 +++- cmd/neofs-node/config/engine/shard/blobstor/fstree/config.go | 2 +- .../blobstor/blobovniczatree/blobovnicza.go | 5 ++++- pkg/local_object_storage/blobstor/fstree/fstree.go | 5 ++++- 6 files changed, 16 insertions(+), 7 deletions(-) diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index 3b2583ee4..d2f868d79 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -446,7 +446,7 @@ func initShardOptions(c *cfg) { var st []blobstor.SubStorage for i := range storages { switch storages[i].Type() { - case "blobovnicza": + case blobovniczatree.Type: sub := blobovniczaconfig.From((*config.Config)(storages[i])) lim := sc.SmallSizeLimit() st = append(st, blobstor.SubStorage{ @@ -462,7 +462,7 @@ func initShardOptions(c *cfg) { return uint64(len(data)) < lim }, }) - case "fstree": + case fstree.Type: sub := fstreeconfig.From((*config.Config)(storages[i])) st = append(st, blobstor.SubStorage{ Storage: fstree.New( 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 89edc5a09..dc4916175 100644 --- a/cmd/neofs-node/config/engine/shard/blobstor/blobovnicza/config.go +++ b/cmd/neofs-node/config/engine/shard/blobstor/blobovnicza/config.go @@ -3,6 +3,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" + "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/blobovniczatree" ) // Config is a wrapper over the config section @@ -31,7 +32,7 @@ func From(c *config.Config) *Config { // Type returns the storage type. func (x *Config) Type() string { - return "blobovnicza" + return blobovniczatree.Type } // Size returns the value of "size" config parameter. diff --git a/cmd/neofs-node/config/engine/shard/blobstor/config.go b/cmd/neofs-node/config/engine/shard/blobstor/config.go index e333e8857..4e6dc86c2 100644 --- a/cmd/neofs-node/config/engine/shard/blobstor/config.go +++ b/cmd/neofs-node/config/engine/shard/blobstor/config.go @@ -5,6 +5,8 @@ import ( "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config" "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine/shard/blobstor/storage" + "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/blobovniczatree" + "github.com/nspcc-dev/neofs-node/pkg/local_object_storage/blobstor/fstree" ) // Config is a wrapper over the config section @@ -26,7 +28,7 @@ func (x *Config) Storages() []*storage.Config { switch typ { case "": return ss - case "fstree", "blobovnicza": + case fstree.Type, blobovniczatree.Type: sub := storage.From((*config.Config)(x).Sub(strconv.Itoa(i))) ss = append(ss, sub) default: diff --git a/cmd/neofs-node/config/engine/shard/blobstor/fstree/config.go b/cmd/neofs-node/config/engine/shard/blobstor/fstree/config.go index 69526bb17..5b9f22af6 100644 --- a/cmd/neofs-node/config/engine/shard/blobstor/fstree/config.go +++ b/cmd/neofs-node/config/engine/shard/blobstor/fstree/config.go @@ -19,7 +19,7 @@ func From(c *config.Config) *Config { // Type returns the storage type. func (x *Config) Type() string { - return "fstree" + return fstree.Type } // Depth returns the value of "depth" config parameter. diff --git a/pkg/local_object_storage/blobstor/blobovniczatree/blobovnicza.go b/pkg/local_object_storage/blobstor/blobovniczatree/blobovnicza.go index b7e703a83..0e7806d16 100644 --- a/pkg/local_object_storage/blobstor/blobovniczatree/blobovnicza.go +++ b/pkg/local_object_storage/blobstor/blobovniczatree/blobovnicza.go @@ -229,9 +229,12 @@ func u64FromHexString(str string) uint64 { return v } +// Type is blobovniczatree storage type used in logs and configuration. +const Type = "blobovnicza" + // Type implements common.Storage. func (b *Blobovniczas) Type() string { - return "blobovnicza" + return Type } // SetCompressor implements common.Storage. diff --git a/pkg/local_object_storage/blobstor/fstree/fstree.go b/pkg/local_object_storage/blobstor/fstree/fstree.go index 06b4412b9..d2db1d8d7 100644 --- a/pkg/local_object_storage/blobstor/fstree/fstree.go +++ b/pkg/local_object_storage/blobstor/fstree/fstree.go @@ -330,9 +330,12 @@ func (t *FSTree) NumberOfObjects() (uint64, error) { return counter, nil } +// Type is fstree storage type used in logs and configuration. +const Type = "fstree" + // Type implements common.Storage. func (*FSTree) Type() string { - return "fstree" + return Type } // SetCompressor implements common.Storage.