[#1840] neofs-node: Use blobstor paths to identify shard

Signed-off-by: Evgenii Stratonikov <evgeniy@morphbits.ru>
This commit is contained in:
Evgenii Stratonikov 2022-10-05 15:53:42 +03:00 committed by fyrchik
parent 4b005d3178
commit 2d43892fc9
3 changed files with 52 additions and 25 deletions

View file

@ -8,6 +8,8 @@ import (
"net"
"os"
"os/signal"
"path/filepath"
"strings"
"sync"
atomicstd "sync/atomic"
"syscall"
@ -135,6 +137,18 @@ type shardCfg struct {
}
}
// id returns persistent id of a shard. It is different from the ID used in runtime
// and is primarily used to identify shards in the configuration.
func (c *shardCfg) id() string {
// This calculation should be kept in sync with
// pkg/local_object_storage/engine/control.go file.
var sb strings.Builder
for i := range c.subStorages {
sb.WriteString(filepath.Clean(c.subStorages[i].path))
}
return sb.String()
}
type subStorageCfg struct {
// common for all storages
typ string
@ -594,13 +608,13 @@ func (c *cfg) engineOpts() []engine.Option {
return opts
}
type shardOptsWithMetaPath struct {
metaPath string
type shardOptsWithID struct {
configID string
shOpts []shard.Option
}
func (c *cfg) shardOpts() []shardOptsWithMetaPath {
shards := make([]shardOptsWithMetaPath, 0, len(c.EngineCfg.shards))
func (c *cfg) shardOpts() []shardOptsWithID {
shards := make([]shardOptsWithID, 0, len(c.EngineCfg.shards))
for _, shCfg := range c.EngineCfg.shards {
var writeCacheOpts []writecache.Option
@ -663,8 +677,8 @@ func (c *cfg) shardOpts() []shardOptsWithMetaPath {
}
}
var sh shardOptsWithMetaPath
sh.metaPath = shCfg.metaCfg.path
var sh shardOptsWithID
sh.configID = shCfg.id()
sh.shOpts = []shard.Option{
shard.WithLogger(c.log),
shard.WithRefillMetabase(shCfg.refillMetabase),
@ -831,8 +845,8 @@ func (c *cfg) configWatcher(ctx context.Context) {
}
var rcfg engine.ReConfiguration
for _, optsWithMeta := range c.shardOpts() {
rcfg.AddShard(optsWithMeta.metaPath, optsWithMeta.shOpts)
for _, optsWithID := range c.shardOpts() {
rcfg.AddShard(optsWithID.configID, optsWithID.shOpts)
}
err = c.cfgObject.cfgLocalStorage.localStorage.Reload(rcfg)