[#109] services/policer: Assign tasks to Replicator
Make Policer to call AddTask method of Replicator when an insufficient number of copies of an object is detected in the container. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
2d46baa4a5
commit
f66c7958e7
2 changed files with 17 additions and 1 deletions
|
@ -8,6 +8,7 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/network"
|
"github.com/nspcc-dev/neofs-node/pkg/network"
|
||||||
headsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/head"
|
headsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/head"
|
||||||
|
"github.com/nspcc-dev/neofs-node/pkg/services/replicator"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -98,6 +99,11 @@ func (p *Policer) processNodes(ctx context.Context, addr *object.Address, nodes
|
||||||
p.log.Info("shortage of object copies detected",
|
p.log.Info("shortage of object copies detected",
|
||||||
zap.Uint32("shortage", shortage),
|
zap.Uint32("shortage", shortage),
|
||||||
)
|
)
|
||||||
// TODO: send task to replicator
|
|
||||||
|
p.replicator.AddTask(new(replicator.Task).
|
||||||
|
WithObjectAddress(addr).
|
||||||
|
WithNodes(nodes).
|
||||||
|
WithCopiesNumber(shortage),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,6 +9,7 @@ import (
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/network"
|
"github.com/nspcc-dev/neofs-node/pkg/network"
|
||||||
headsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/head"
|
headsvc "github.com/nspcc-dev/neofs-node/pkg/services/object/head"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement"
|
"github.com/nspcc-dev/neofs-node/pkg/services/object_manager/placement"
|
||||||
|
"github.com/nspcc-dev/neofs-node/pkg/services/replicator"
|
||||||
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
|
"github.com/nspcc-dev/neofs-node/pkg/util/logger"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
)
|
)
|
||||||
|
@ -42,6 +43,8 @@ type cfg struct {
|
||||||
remoteHeader *headsvc.RemoteHeader
|
remoteHeader *headsvc.RemoteHeader
|
||||||
|
|
||||||
localAddrSrc network.LocalAddressSource
|
localAddrSrc network.LocalAddressSource
|
||||||
|
|
||||||
|
replicator *replicator.Replicator
|
||||||
}
|
}
|
||||||
|
|
||||||
func defaultCfg() *cfg {
|
func defaultCfg() *cfg {
|
||||||
|
@ -138,3 +141,10 @@ func WithLocalAddressSource(v network.LocalAddressSource) Option {
|
||||||
c.localAddrSrc = v
|
c.localAddrSrc = v
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WithReplicator returns option to set object replicator of Policer.
|
||||||
|
func WithReplicator(v *replicator.Replicator) Option {
|
||||||
|
return func(c *cfg) {
|
||||||
|
c.replicator = v
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue