From 6925fb4c5961783502296cd9d5549408a89e2086 Mon Sep 17 00:00:00 2001 From: Dmitrii Stepanov Date: Mon, 27 Feb 2023 16:39:15 +0300 Subject: [PATCH] [TrueCloudLab/hrw#2] node: Use typed HRW methods Update HRW lib and use typed HRW methods to sort shards and nodes Signed-off-by: Dmitrii Stepanov --- CHANGELOG.md | 1 + go.mod | 2 +- go.sum | 2 ++ pkg/local_object_storage/engine/evacuate.go | 2 +- pkg/local_object_storage/engine/shards.go | 2 +- pkg/services/reputation/common/managers.go | 2 +- 6 files changed, 7 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9228226d..9bf7ee9b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -53,6 +53,7 @@ Changelog for FrostFS Node - `golang.org/x/term` to `v0.3.0` - `google.golang.org/grpc` to `v1.51.0` - `github.com/nats-io/nats.go` to `v1.22.1` +- `github.com/TrueCloudLab/hrw` to `v.1.1.1` - Minimum go version to v1.18 ### Updating from v0.35.0 diff --git a/go.mod b/go.mod index b7758b92..cf21b902 100644 --- a/go.mod +++ b/go.mod @@ -6,7 +6,7 @@ require ( github.com/TrueCloudLab/frostfs-api-go/v2 v2.0.0-20221212144048-1351b6656d68 github.com/TrueCloudLab/frostfs-contract v0.0.0-20221213081248-6c805c1b4e42 github.com/TrueCloudLab/frostfs-sdk-go v0.0.0-20221214065929-4c779423f556 - github.com/TrueCloudLab/hrw v1.1.0 + github.com/TrueCloudLab/hrw v1.1.1-0.20230227111858-79b208bebf52 github.com/TrueCloudLab/tzhash v1.7.0 github.com/cheggaaa/pb v1.0.29 github.com/chzyer/readline v1.5.1 diff --git a/go.sum b/go.sum index 1d85e41c..b81b444f 100644 --- a/go.sum +++ b/go.sum @@ -52,6 +52,8 @@ github.com/TrueCloudLab/frostfs-sdk-go v0.0.0-20221214065929-4c779423f556 h1:Cc1 github.com/TrueCloudLab/frostfs-sdk-go v0.0.0-20221214065929-4c779423f556/go.mod h1:4ZiG4jNLzrqeJbmZUrPI7wDZhQVPaf0zEIWa/eBsqBg= github.com/TrueCloudLab/hrw v1.1.0 h1:2U69PpUX1UtMWgh/RAg6D8mQW+/WsxbLNE+19EUhLhY= github.com/TrueCloudLab/hrw v1.1.0/go.mod h1:Pzi8Hy3qx12cew+ajVxgbtDVM4sRG9/gJnJLcL/yRyY= +github.com/TrueCloudLab/hrw v1.1.1-0.20230227111858-79b208bebf52 h1:fBeG0EkL7Pa2D0SIiZt3yQYGpP/IvrXg4xEPAZ4Jjys= +github.com/TrueCloudLab/hrw v1.1.1-0.20230227111858-79b208bebf52/go.mod h1:BG6NztCuNc0UFr6MWJ4MM1sUl9lxx6PBRwLmTxdre20= github.com/TrueCloudLab/rfc6979 v0.3.0 h1:0SYMAfQWh/TjnofqYQHy+s3rmQ5gi0fvOaDbqd60/Ic= github.com/TrueCloudLab/rfc6979 v0.3.0/go.mod h1:qylxFXFQ/sMvpZC/8JyWp+mfzk5Zj/KDT5FAbekhobc= github.com/TrueCloudLab/tzhash v1.7.0 h1:btGORepc7Dg+n4MxgJxv73c9eYhwSBI5HqsqUBRmJiw= diff --git a/pkg/local_object_storage/engine/evacuate.go b/pkg/local_object_storage/engine/evacuate.go index abe43927..6ff61ed0 100644 --- a/pkg/local_object_storage/engine/evacuate.go +++ b/pkg/local_object_storage/engine/evacuate.go @@ -151,7 +151,7 @@ mainLoop: return res, err } - hrw.SortSliceByWeightValue(shards, weights, hrw.Hash([]byte(addr.EncodeToString()))) + hrw.SortHasherSliceByWeightValue(shards, weights, hrw.Hash([]byte(addr.EncodeToString()))) for j := range shards { if _, ok := shardMap[shards[j].ID().String()]; ok { continue diff --git a/pkg/local_object_storage/engine/shards.go b/pkg/local_object_storage/engine/shards.go index 9341be9f..2b8226e7 100644 --- a/pkg/local_object_storage/engine/shards.go +++ b/pkg/local_object_storage/engine/shards.go @@ -216,7 +216,7 @@ func (e *StorageEngine) sortShardsByWeight(objAddr interface{ EncodeToString() s weights = append(weights, e.shardWeight(sh.Shard)) } - hrw.SortSliceByWeightValue(shards, weights, hrw.Hash([]byte(objAddr.EncodeToString()))) + hrw.SortHasherSliceByWeightValue(shards, weights, hrw.Hash([]byte(objAddr.EncodeToString()))) return shards } diff --git a/pkg/services/reputation/common/managers.go b/pkg/services/reputation/common/managers.go index e4f1842c..ce43994c 100644 --- a/pkg/services/reputation/common/managers.go +++ b/pkg/services/reputation/common/managers.go @@ -93,7 +93,7 @@ func (mb *managerBuilder) BuildManagers(epoch uint64, p apireputation.PeerID) ([ copy(nodes, nmNodes) - hrw.SortSliceByValue(nodes, epoch) + hrw.SortHasherSliceByValue(nodes, epoch) for i := range nodes { if apireputation.ComparePeerKey(p, nodes[i].PublicKey()) {