From 334e0e6f0fd98a767b906182f4fd6b5227483400 Mon Sep 17 00:00:00 2001 From: Leonard Lyubich Date: Wed, 21 Oct 2020 14:51:20 +0300 Subject: [PATCH] [#109] cmd/neofs-node: Activate Replicator Signed-off-by: Leonard Lyubich --- cmd/neofs-node/config.go | 4 ++++ cmd/neofs-node/object.go | 15 +++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/cmd/neofs-node/config.go b/cmd/neofs-node/config.go index 2906d215e..e2c5c5c94 100644 --- a/cmd/neofs-node/config.go +++ b/cmd/neofs-node/config.go @@ -84,6 +84,8 @@ const ( cfgPolicerWorkScope = "policer.work_scope" cfgPolicerExpRate = "policer.expansion_rate" cfgPolicerHeadTimeout = "policer.head_timeout" + + cfgReplicatorPutTimeout = "replicator.put_timeout" ) const ( @@ -328,6 +330,8 @@ func defaultConfiguration(v *viper.Viper) { v.SetDefault(cfgPolicerWorkScope, 100) v.SetDefault(cfgPolicerExpRate, 10) // in % v.SetDefault(cfgPolicerHeadTimeout, 5*time.Second) + + v.SetDefault(cfgReplicatorPutTimeout, 5*time.Second) } func (c *cfg) LocalAddress() *network.Address { diff --git a/cmd/neofs-node/object.go b/cmd/neofs-node/object.go index 94d9c21e6..f1a86db5c 100644 --- a/cmd/neofs-node/object.go +++ b/cmd/neofs-node/object.go @@ -35,6 +35,7 @@ import ( "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/gc" "github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement" "github.com/nspcc-dev/neofs-node/pkg/services/policer" + "github.com/nspcc-dev/neofs-node/pkg/services/replicator" "github.com/panjf2000/ants/v2" "go.uber.org/zap" ) @@ -190,6 +191,19 @@ func initObjectService(c *cfg) { c.workers = append(c.workers, objGC) + repl := replicator.New( + replicator.WithLogger(c.log), + replicator.WithPutTimeout( + c.viper.GetDuration(cfgReplicatorPutTimeout), + ), + replicator.WithLocalStorage(ls), + replicator.WithRemoteSender( + putsvc.NewRemoteSender(keyStorage), + ), + ) + + c.workers = append(c.workers, repl) + ch := make(chan *policer.Task, 1) pol := policer.New( @@ -213,6 +227,7 @@ func initObjectService(c *cfg) { policer.WithHeadTimeout( c.viper.GetDuration(cfgPolicerHeadTimeout), ), + policer.WithReplicator(repl), ) addNewEpochNotificationHandler(c, func(ev event.Event) {