[#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
|
||||
}
|
||||
|
|
|
@ -73,6 +73,8 @@ NEOFS_STORAGE_SHARD_NUM=2
|
|||
## 0 shard
|
||||
### Flag to refill Metabase from BlobStor
|
||||
NEOFS_STORAGE_SHARD_0_RESYNC_METABASE=false
|
||||
### Flag to set shard mode
|
||||
NEOFS_STORAGE_SHARD_0_MODE=read-only
|
||||
### Write cache config
|
||||
NEOFS_STORAGE_SHARD_0_USE_WRITE_CACHE=false
|
||||
NEOFS_STORAGE_SHARD_0_WRITECACHE_PATH=tmp/0/cache
|
||||
|
@ -104,6 +106,8 @@ NEOFS_STORAGE_SHARD_0_GC_REMOVER_SLEEP_INTERVAL=2m
|
|||
## 1 shard
|
||||
### Flag to refill Metabase from BlobStor
|
||||
NEOFS_STORAGE_SHARD_1_RESYNC_METABASE=true
|
||||
### Flag to set shard mode
|
||||
NEOFS_STORAGE_SHARD_1_MODE=read-write
|
||||
### Write cache config
|
||||
NEOFS_STORAGE_SHARD_1_USE_WRITE_CACHE=true
|
||||
NEOFS_STORAGE_SHARD_1_WRITECACHE_PATH=tmp/1/cache
|
||||
|
|
|
@ -117,6 +117,7 @@
|
|||
"shard_num": 2,
|
||||
"shard": {
|
||||
"0": {
|
||||
"mode": "read-only",
|
||||
"resync_metabase": false,
|
||||
"use_write_cache": false,
|
||||
"writecache": {
|
||||
|
@ -150,6 +151,7 @@
|
|||
}
|
||||
},
|
||||
"1": {
|
||||
"mode": "read-write",
|
||||
"resync_metabase": true,
|
||||
"use_write_cache": true,
|
||||
"writecache": {
|
||||
|
|
|
@ -131,6 +131,7 @@ storage:
|
|||
|
||||
shard:
|
||||
0:
|
||||
mode: "read-only" # mode of the shard, must be one of the: "read-write" (default), "read-only"
|
||||
resync_metabase: false # sync metabase with blobstor on start, expensive, leave false until complete understanding
|
||||
|
||||
use_write_cache: false # use write-cache
|
||||
|
|
Loading…
Reference in a new issue