forked from TrueCloudLab/frostfs-node
[#108] services: Implement Policer service
Implement Policer service that performs background work to check compliance with the placement policy for local objects in the container. In the initial implementation, the selection of the working queue of objects is simplified, and there is no transfer of the result to the replicator. Signed-off-by: Leonard Lyubich <leonard@nspcc.ru>
This commit is contained in:
parent
f6e56aa956
commit
0dab4b7581
4 changed files with 385 additions and 0 deletions
28
pkg/services/policer/queue.go
Normal file
28
pkg/services/policer/queue.go
Normal file
|
@ -0,0 +1,28 @@
|
|||
package policer
|
||||
|
||||
import (
|
||||
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
||||
"github.com/nspcc-dev/neofs-node/pkg/local_object_storage/localstore"
|
||||
)
|
||||
|
||||
type jobQueue struct {
|
||||
localStorage *localstore.Storage
|
||||
}
|
||||
|
||||
func (q *jobQueue) Select(limit int) ([]*object.Address, error) {
|
||||
// TODO: optimize the logic for selecting objects
|
||||
// We can prioritize objects for migration, newly arrived objects, etc.
|
||||
// It is recommended to make changes after updating the metabase
|
||||
|
||||
res := make([]*object.Address, 0, limit)
|
||||
|
||||
if err := q.localStorage.Iterate(nil, func(meta *localstore.ObjectMeta) bool {
|
||||
res = append(res, meta.Head().Address())
|
||||
|
||||
return len(res) >= limit
|
||||
}); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return res, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue