From 84e1599997c3d4674c418556dccbeaeb1d2414ed Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Thu, 16 Jan 2025 15:52:21 +0300 Subject: [PATCH] [#1604] policer: Remove one-line helpers Signed-off-by: Evgenii Stratonikov --- pkg/services/policer/check.go | 6 +++--- pkg/services/policer/check_test.go | 4 ++-- pkg/services/policer/nodecache.go | 13 +------------ 3 files changed, 6 insertions(+), 17 deletions(-) diff --git a/pkg/services/policer/check.go b/pkg/services/policer/check.go index bdfc4344bf..9335a75d8a 100644 --- a/pkg/services/policer/check.go +++ b/pkg/services/policer/check.go @@ -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++ diff --git a/pkg/services/policer/check_test.go b/pkg/services/policer/check_test.go index d4c7ccbf98..69879c439f 100644 --- a/pkg/services/policer/check_test.go +++ b/pkg/services/policer/check_test.go @@ -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) } diff --git a/pkg/services/policer/nodecache.go b/pkg/services/policer/nodecache.go index 410ef7d86d..7a82178586 100644 --- a/pkg/services/policer/nodecache.go +++ b/pkg/services/policer/nodecache.go @@ -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) }