2020-12-22 00:25:26 +00:00
|
|
|
package audit
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/pkg/audit"
|
|
|
|
"github.com/nspcc-dev/neofs-api-go/pkg/container"
|
2020-12-23 09:47:40 +00:00
|
|
|
"github.com/nspcc-dev/neofs-api-go/pkg/object"
|
2020-12-22 00:25:26 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// Report tracks the progress of auditing container data.
|
|
|
|
type Report struct {
|
|
|
|
res *audit.Result
|
|
|
|
}
|
|
|
|
|
|
|
|
// Reporter is an interface of the entity that records
|
|
|
|
// the data audit report.
|
|
|
|
type Reporter interface {
|
|
|
|
WriteReport(r *Report) error
|
|
|
|
}
|
|
|
|
|
|
|
|
// NewReport creates and returns blank Report instance.
|
|
|
|
func NewReport(cid *container.ID) *Report {
|
|
|
|
rep := &Report{
|
|
|
|
res: audit.NewResult(),
|
|
|
|
}
|
|
|
|
|
|
|
|
rep.res.SetContainerID(cid)
|
|
|
|
|
|
|
|
return rep
|
|
|
|
}
|
|
|
|
|
|
|
|
// Result forms the structure of the data audit result.
|
|
|
|
func (r *Report) Result() *audit.Result {
|
|
|
|
return r.res
|
|
|
|
}
|
2020-12-22 08:08:31 +00:00
|
|
|
|
|
|
|
// Complete completes audit report.
|
|
|
|
func (r *Report) Complete() {
|
|
|
|
r.res.SetComplete(true)
|
|
|
|
}
|
2020-12-23 09:47:40 +00:00
|
|
|
|
|
|
|
// PassedPoR updates list of passed storage groups.
|
|
|
|
func (r *Report) PassedPoR(sg *object.ID) {
|
|
|
|
r.res.SetPassSG(append(r.res.PassSG(), sg))
|
|
|
|
}
|
|
|
|
|
|
|
|
// FailedPoR updates list of failed storage groups.
|
|
|
|
func (r *Report) FailedPoR(sg *object.ID) {
|
|
|
|
r.res.SetFailSG(append(r.res.FailSG(), sg))
|
|
|
|
}
|
2020-12-23 08:56:49 +00:00
|
|
|
|
|
|
|
// SetPlacementCounters sets counters of compliance with placement.
|
|
|
|
func (r *Report) SetPlacementCounters(hit, miss, fail uint32) {
|
|
|
|
r.res.SetHit(hit)
|
|
|
|
r.res.SetMiss(miss)
|
|
|
|
r.res.SetFail(fail)
|
|
|
|
}
|
2020-12-23 16:53:11 +00:00
|
|
|
|
|
|
|
// SetPDPResults sets lists of nodes according to their PDP results.
|
|
|
|
func (r *Report) SetPDPResults(passed, failed [][]byte) {
|
|
|
|
r.res.SetPassNodes(passed)
|
|
|
|
r.res.SetFailNodes(failed)
|
|
|
|
}
|
2020-12-24 10:22:14 +00:00
|
|
|
|
|
|
|
// SetPoRCounters sets amounts of head requests and retries at PoR audit stage.
|
|
|
|
func (r *Report) SetPoRCounters(requests, retries uint32) {
|
|
|
|
r.res.SetRequests(requests)
|
|
|
|
r.res.SetRetries(retries)
|
|
|
|
}
|