policer: Use status instead of bool value in node cache
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
436d65d784
commit
b8113bcb36
1 changed files with 6 additions and 13 deletions
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue