policer: Use status instead of bool value in node cache

Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
Evgenii Stratonikov 2025-01-16 15:08:35 +03:00
parent 436d65d784
commit b8113bcb36
Signed by: fyrchik
SSH key fingerprint: SHA256:m/TTwCzjnRkXgnzEx9X92ccxy1CcVeinOgDb3NPWWmg

View file

@ -15,37 +15,30 @@ func (st nodeProcessStatus) Processed() bool {
}
// nodeCache tracks Policer's check progress.
type nodeCache map[uint64]bool
type nodeCache map[uint64]nodeProcessStatus
func newNodeCache() nodeCache {
return make(map[uint64]bool)
return make(map[uint64]nodeProcessStatus)
}
func (n nodeCache) set(node netmap.NodeInfo, val bool) {
func (n nodeCache) set(node netmap.NodeInfo, val nodeProcessStatus) {
n[node.Hash()] = val
}
// submits storage node as a candidate to store the object replica in case of
// shortage.
func (n nodeCache) submitReplicaCandidate(node netmap.NodeInfo) {
n.set(node, false)
n.set(node, nodeDoesNotHoldObject)
}
// submits storage node as a current object replica holder.
func (n nodeCache) submitReplicaHolder(node netmap.NodeInfo) {
n.set(node, true)
n.set(node, nodeHoldsObject)
}
// processStatus returns current processing status of the storage node.
func (n nodeCache) processStatus(node netmap.NodeInfo) nodeProcessStatus {
switch val, ok := n[node.Hash()]; {
case !ok:
return nodeNotProcessed
case val:
return nodeHoldsObject
default:
return nodeDoesNotHoldObject
}
return n[node.Hash()]
}
// SubmitSuccessfulReplication marks given storage node as a current object