forked from TrueCloudLab/frostfs-node
[#1604] policer: Remove one-line helpers
Signed-off-by: Evgenii Stratonikov <e.stratonikov@yadro.com>
This commit is contained in:
parent
5a270e2e61
commit
84e1599997
3 changed files with 6 additions and 17 deletions
|
@ -143,10 +143,10 @@ func (p *Policer) processRepNodes(ctx context.Context, requirements *placementRe
|
|||
|
||||
if err == nil {
|
||||
shortage--
|
||||
checkedNodes.submitReplicaHolder(nodes[i])
|
||||
checkedNodes.set(nodes[i], nodeHoldsObject)
|
||||
} else {
|
||||
if client.IsErrObjectNotFound(err) {
|
||||
checkedNodes.submitReplicaCandidate(nodes[i])
|
||||
checkedNodes.set(nodes[i], nodeDoesNotHoldObject)
|
||||
continue
|
||||
} else if client.IsErrNodeUnderMaintenance(err) {
|
||||
shortage, uncheckedCopies = p.handleMaintenance(ctx, nodes[i], checkedNodes, shortage, uncheckedCopies)
|
||||
|
@ -174,7 +174,7 @@ func (p *Policer) processRepNodes(ctx context.Context, requirements *placementRe
|
|||
// However, additional copies should not be removed in this case,
|
||||
// because we can remove the only copy this way.
|
||||
func (p *Policer) handleMaintenance(ctx context.Context, node netmap.NodeInfo, checkedNodes nodeCache, shortage uint32, uncheckedCopies int) (uint32, int) {
|
||||
checkedNodes.submitReplicaHolder(node)
|
||||
checkedNodes.set(node, nodeHoldsObject)
|
||||
shortage--
|
||||
uncheckedCopies++
|
||||
|
||||
|
|
|
@ -16,9 +16,9 @@ func TestNodeCache(t *testing.T) {
|
|||
cache.SubmitSuccessfulReplication(node)
|
||||
require.Equal(t, cache.processStatus(node), nodeHoldsObject)
|
||||
|
||||
cache.submitReplicaCandidate(node)
|
||||
cache.set(node, nodeDoesNotHoldObject)
|
||||
require.Equal(t, cache.processStatus(node), nodeDoesNotHoldObject)
|
||||
|
||||
cache.submitReplicaHolder(node)
|
||||
cache.set(node, nodeHoldsObject)
|
||||
require.Equal(t, cache.processStatus(node), nodeHoldsObject)
|
||||
}
|
||||
|
|
|
@ -25,17 +25,6 @@ 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, nodeDoesNotHoldObject)
|
||||
}
|
||||
|
||||
// submits storage node as a current object replica holder.
|
||||
func (n nodeCache) submitReplicaHolder(node netmap.NodeInfo) {
|
||||
n.set(node, nodeHoldsObject)
|
||||
}
|
||||
|
||||
// processStatus returns current processing status of the storage node.
|
||||
func (n nodeCache) processStatus(node netmap.NodeInfo) nodeProcessStatus {
|
||||
return n[node.Hash()]
|
||||
|
@ -46,5 +35,5 @@ func (n nodeCache) processStatus(node netmap.NodeInfo) nodeProcessStatus {
|
|||
//
|
||||
// SubmitSuccessfulReplication implements replicator.TaskResult.
|
||||
func (n nodeCache) SubmitSuccessfulReplication(node netmap.NodeInfo) {
|
||||
n.submitReplicaHolder(node)
|
||||
n.set(node, nodeHoldsObject)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue