forked from TrueCloudLab/frostfs-node
[#1057] node/config: Add shard mode config param
Signed-off-by: Pavel Karpy <carpawell@nspcc.ru>
This commit is contained in:
parent
93bd6be743
commit
8b8a815fb3
5 changed files with 36 additions and 0 deletions
|
@ -9,6 +9,7 @@ import (
|
|||
engineconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine"
|
||||
shardconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine/shard"
|
||||
configtest "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/test"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
@ -31,6 +32,7 @@ func TestEngineSection(t *testing.T) {
|
|||
require.False(t, handlerCalled)
|
||||
|
||||
require.EqualValues(t, engineconfig.ShardPoolSizeDefault, engineconfig.ShardPoolSize(empty))
|
||||
require.EqualValues(t, shard.ModeReadWrite, shardconfig.From(empty).Mode())
|
||||
})
|
||||
|
||||
const path = "../../../../config/example/node"
|
||||
|
@ -80,6 +82,7 @@ func TestEngineSection(t *testing.T) {
|
|||
require.Equal(t, 2*time.Minute, gc.RemoverSleepInterval())
|
||||
|
||||
require.Equal(t, false, sc.RefillMetabase())
|
||||
require.Equal(t, shard.ModeReadOnly, sc.Mode())
|
||||
case 1:
|
||||
require.Equal(t, true, sc.UseWriteCache())
|
||||
|
||||
|
@ -108,6 +111,7 @@ func TestEngineSection(t *testing.T) {
|
|||
require.Equal(t, 5*time.Minute, gc.RemoverSleepInterval())
|
||||
|
||||
require.Equal(t, true, sc.RefillMetabase())
|
||||
require.Equal(t, shard.ModeReadWrite, sc.Mode())
|
||||
}
|
||||
})
|
||||
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
package shardconfig
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/nspcc-dev/neofs-node/cmd/neofs-node/config"
|
||||
blobstorconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine/shard/blobstor"
|
||||
gcconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine/shard/gc"
|
||||
metabaseconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine/shard/metabase"
|
||||
writecacheconfig "github.com/nspcc-dev/neofs-node/cmd/neofs-node/config/engine/shard/writecache"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/shard"
|
||||
)
|
||||
|
||||
// Config is a wrapper over the config section
|
||||
|
@ -68,3 +71,25 @@ func (x *Config) RefillMetabase() bool {
|
|||
"resync_metabase",
|
||||
)
|
||||
}
|
||||
|
||||
// Mode return value of "mode" config parameter.
|
||||
//
|
||||
// Panics if read value is not one of predefined
|
||||
// shard modes.
|
||||
func (x *Config) Mode() (m shard.Mode) {
|
||||
s := config.StringSafe(
|
||||
(*config.Config)(x),
|
||||
"mode",
|
||||
)
|
||||
|
||||
switch s {
|
||||
case "read-write", "":
|
||||
m = shard.ModeReadWrite
|
||||
case "read-only":
|
||||
m = shard.ModeReadOnly
|
||||
default:
|
||||
panic(fmt.Sprintf("unknown shard mode: %s", s))
|
||||
}
|
||||
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue