2023-06-29 12:13:01 +03:00
|
|
|
package policer
|
|
|
|
|
|
|
|
import "git.frostfs.info/TrueCloudLab/frostfs-sdk-go/netmap"
|
|
|
|
|
|
|
|
type nodeProcessStatus int8
|
|
|
|
|
|
|
|
const (
|
|
|
|
nodeNotProcessed nodeProcessStatus = iota
|
|
|
|
nodeDoesNotHoldObject
|
|
|
|
nodeHoldsObject
|
2025-01-16 15:59:17 +03:00
|
|
|
nodeStatusUnknown
|
2025-01-16 16:04:40 +03:00
|
|
|
nodeIsUnderMaintenance
|
2025-01-17 12:38:44 +03:00
|
|
|
nodeIsLocal
|
2023-06-29 12:13:01 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
func (st nodeProcessStatus) Processed() bool {
|
|
|
|
return st != nodeNotProcessed
|
|
|
|
}
|
|
|
|
|
|
|
|
// nodeCache tracks Policer's check progress.
|
2025-01-16 15:08:35 +03:00
|
|
|
type nodeCache map[uint64]nodeProcessStatus
|
2023-06-29 12:13:01 +03:00
|
|
|
|
|
|
|
func newNodeCache() nodeCache {
|
2025-01-16 15:08:35 +03:00
|
|
|
return make(map[uint64]nodeProcessStatus)
|
2023-06-29 12:13:01 +03:00
|
|
|
}
|
|
|
|
|
2025-01-16 15:08:35 +03:00
|
|
|
func (n nodeCache) set(node netmap.NodeInfo, val nodeProcessStatus) {
|
2023-06-29 12:13:01 +03:00
|
|
|
n[node.Hash()] = val
|
|
|
|
}
|
|
|
|
|
|
|
|
// processStatus returns current processing status of the storage node.
|
|
|
|
func (n nodeCache) processStatus(node netmap.NodeInfo) nodeProcessStatus {
|
2025-01-16 15:08:35 +03:00
|
|
|
return n[node.Hash()]
|
2023-06-29 12:13:01 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
// SubmitSuccessfulReplication marks given storage node as a current object
|
|
|
|
// replica holder.
|
|
|
|
//
|
|
|
|
// SubmitSuccessfulReplication implements replicator.TaskResult.
|
|
|
|
func (n nodeCache) SubmitSuccessfulReplication(node netmap.NodeInfo) {
|
2025-01-16 15:52:21 +03:00
|
|
|
n.set(node, nodeHoldsObject)
|
2023-06-29 12:13:01 +03:00
|
|
|
}
|