40 lines
1,005 B
Go
40 lines
1,005 B
Go
package policer
|
|
|
|
import "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
|
|
|
|
type nodeProcessStatus int8
|
|
|
|
const (
|
|
nodeNotProcessed nodeProcessStatus = iota
|
|
nodeDoesNotHoldObject
|
|
nodeHoldsObject
|
|
nodeStatusUnknown
|
|
)
|
|
|
|
func (st nodeProcessStatus) Processed() bool {
|
|
return st != nodeNotProcessed
|
|
}
|
|
|
|
// nodeCache tracks Policer's check progress.
|
|
type nodeCache map[uint64]nodeProcessStatus
|
|
|
|
func newNodeCache() nodeCache {
|
|
return make(map[uint64]nodeProcessStatus)
|
|
}
|
|
|
|
func (n nodeCache) set(node netmap.NodeInfo, val nodeProcessStatus) {
|
|
n[node.Hash()] = val
|
|
}
|
|
|
|
// processStatus returns current processing status of the storage node.
|
|
func (n nodeCache) processStatus(node netmap.NodeInfo) nodeProcessStatus {
|
|
return n[node.Hash()]
|
|
}
|
|
|
|
// SubmitSuccessfulReplication marks given storage node as a current object
|
|
// replica holder.
|
|
//
|
|
// SubmitSuccessfulReplication implements replicator.TaskResult.
|
|
func (n nodeCache) SubmitSuccessfulReplication(node netmap.NodeInfo) {
|
|
n.set(node, nodeHoldsObject)
|
|
}
|