forked from TrueCloudLab/frostfs-node
[#2165] services/tree: Allow to set custom synchronization interval
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
6a4e5e6f0a
commit
d3054e577a
6 changed files with 37 additions and 7 deletions
|
@ -63,3 +63,11 @@ func (c TreeConfig) ReplicationChannelCapacity() int {
|
||||||
func (c TreeConfig) ReplicationWorkerCount() int {
|
func (c TreeConfig) ReplicationWorkerCount() int {
|
||||||
return int(config.IntSafe(c.cfg, "replication_worker_count"))
|
return int(config.IntSafe(c.cfg, "replication_worker_count"))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// SyncInterval returns the value of "sync_interval"
|
||||||
|
// config parameter from the "tree" section.
|
||||||
|
//
|
||||||
|
// Returns 0 if config value is not specified.
|
||||||
|
func (c TreeConfig) SyncInterval() time.Duration {
|
||||||
|
return config.DurationSafe(c.cfg, "sync_interval")
|
||||||
|
}
|
||||||
|
|
|
@ -33,6 +33,7 @@ func TestTreeSection(t *testing.T) {
|
||||||
require.Equal(t, 32, treeSec.ReplicationChannelCapacity())
|
require.Equal(t, 32, treeSec.ReplicationChannelCapacity())
|
||||||
require.Equal(t, 32, treeSec.ReplicationWorkerCount())
|
require.Equal(t, 32, treeSec.ReplicationWorkerCount())
|
||||||
require.Equal(t, 5*time.Second, treeSec.ReplicationTimeout())
|
require.Equal(t, 5*time.Second, treeSec.ReplicationTimeout())
|
||||||
|
require.Equal(t, time.Hour, treeSec.SyncInterval())
|
||||||
}
|
}
|
||||||
|
|
||||||
configtest.ForEachFileType(path, fileConfigTest)
|
configtest.ForEachFileType(path, fileConfigTest)
|
||||||
|
|
|
@ -3,6 +3,7 @@ package main
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
|
"time"
|
||||||
|
|
||||||
treeconfig "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/tree"
|
treeconfig "github.com/TrueCloudLab/frostfs-node/cmd/frostfs-node/config/tree"
|
||||||
"github.com/TrueCloudLab/frostfs-node/pkg/core/container"
|
"github.com/TrueCloudLab/frostfs-node/pkg/core/container"
|
||||||
|
@ -63,12 +64,29 @@ func initTreeService(c *cfg) {
|
||||||
c.treeService.Start(ctx)
|
c.treeService.Start(ctx)
|
||||||
}))
|
}))
|
||||||
|
|
||||||
addNewEpochNotificationHandler(c, func(_ event.Event) {
|
if d := treeConfig.SyncInterval(); d == 0 {
|
||||||
err := c.treeService.SynchronizeAll()
|
addNewEpochNotificationHandler(c, func(_ event.Event) {
|
||||||
if err != nil {
|
err := c.treeService.SynchronizeAll()
|
||||||
c.log.Error("could not synchronize Tree Service", zap.Error(err))
|
if err != nil {
|
||||||
}
|
c.log.Error("could not synchronize Tree Service", zap.Error(err))
|
||||||
})
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
go func() {
|
||||||
|
tick := time.NewTicker(d)
|
||||||
|
defer tick.Stop()
|
||||||
|
|
||||||
|
for range tick.C {
|
||||||
|
err := c.treeService.SynchronizeAll()
|
||||||
|
if err != nil {
|
||||||
|
c.log.Error("could not synchronize Tree Service", zap.Error(err))
|
||||||
|
if errors.Is(err, tree.ErrShuttingDown) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
}
|
||||||
|
|
||||||
subscribeToContainerRemoval(c, func(e event.Event) {
|
subscribeToContainerRemoval(c, func(e event.Event) {
|
||||||
ev := e.(containerEvent.DeleteSuccess)
|
ev := e.(containerEvent.DeleteSuccess)
|
||||||
|
|
|
@ -35,6 +35,7 @@ NEOFS_TREE_CACHE_SIZE=15
|
||||||
NEOFS_TREE_REPLICATION_CHANNEL_CAPACITY=32
|
NEOFS_TREE_REPLICATION_CHANNEL_CAPACITY=32
|
||||||
NEOFS_TREE_REPLICATION_WORKER_COUNT=32
|
NEOFS_TREE_REPLICATION_WORKER_COUNT=32
|
||||||
NEOFS_TREE_REPLICATION_TIMEOUT=5s
|
NEOFS_TREE_REPLICATION_TIMEOUT=5s
|
||||||
|
NEOFS_TREE_SYNC_INTERVAL=1h
|
||||||
|
|
||||||
# gRPC section
|
# gRPC section
|
||||||
## 0 server
|
## 0 server
|
||||||
|
|
|
@ -80,7 +80,8 @@
|
||||||
"cache_size": 15,
|
"cache_size": 15,
|
||||||
"replication_channel_capacity": 32,
|
"replication_channel_capacity": 32,
|
||||||
"replication_worker_count": 32,
|
"replication_worker_count": 32,
|
||||||
"replication_timeout": "5s"
|
"replication_timeout": "5s",
|
||||||
|
"sync_interval": "1h"
|
||||||
},
|
},
|
||||||
"control": {
|
"control": {
|
||||||
"authorized_keys": [
|
"authorized_keys": [
|
||||||
|
|
|
@ -65,6 +65,7 @@ tree:
|
||||||
replication_worker_count: 32
|
replication_worker_count: 32
|
||||||
replication_channel_capacity: 32
|
replication_channel_capacity: 32
|
||||||
replication_timeout: 5s
|
replication_timeout: 5s
|
||||||
|
sync_interval: 1h
|
||||||
|
|
||||||
control:
|
control:
|
||||||
authorized_keys: # list of hex-encoded public keys that have rights to use the Control Service
|
authorized_keys: # list of hex-encoded public keys that have rights to use the Control Service
|
||||||
|
|
Loading…
Reference in a new issue