diff options
| author | a <eddy@gfxlabs.io> | 2022-04-20 14:01:42 -0700 |
|---|---|---|
| committer | a <eddy@gfxlabs.io> | 2022-04-20 14:01:42 -0700 |
| commit | 1d6a9e66b608f77a0da9a6903802bb24ff0629d7 (patch) | |
| tree | 7f3e02d6e69d10913d882c5f87d9156001e1b77c /weed/shell/command_volume_fix_replication.go | |
| parent | 846858fb436cc061c40c4f2565ed3682e3758596 (diff) | |
| parent | d1fd40358215a6237f51e0918659f74cc7269ff1 (diff) | |
| download | seaweedfs-1d6a9e66b608f77a0da9a6903802bb24ff0629d7.tar.xz seaweedfs-1d6a9e66b608f77a0da9a6903802bb24ff0629d7.zip | |
Merge branch 'master' into a
Diffstat (limited to 'weed/shell/command_volume_fix_replication.go')
| -rw-r--r-- | weed/shell/command_volume_fix_replication.go | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/weed/shell/command_volume_fix_replication.go b/weed/shell/command_volume_fix_replication.go index 78285d8a5..c4bef5925 100644 --- a/weed/shell/command_volume_fix_replication.go +++ b/weed/shell/command_volume_fix_replication.go @@ -7,9 +7,9 @@ import ( "github.com/chrislusf/seaweedfs/weed/pb" "github.com/chrislusf/seaweedfs/weed/storage/needle" "github.com/chrislusf/seaweedfs/weed/storage/types" + "golang.org/x/exp/slices" "io" "path/filepath" - "sort" "strconv" "time" @@ -308,8 +308,8 @@ func (c *commandVolumeFixReplication) fixOneUnderReplicatedVolume(commandEnv *Co func keepDataNodesSorted(dataNodes []location, diskType types.DiskType) { fn := capacityByFreeVolumeCount(diskType) - sort.Slice(dataNodes, func(i, j int) bool { - return fn(dataNodes[i].dataNode) > fn(dataNodes[j].dataNode) + slices.SortFunc(dataNodes, func(a, b location) bool { + return fn(a.dataNode) > fn(b.dataNode) }) } @@ -488,9 +488,7 @@ func countReplicas(replicas []*VolumeReplica) (diffDc, diffRack, diffNode map[st } func pickOneReplicaToDelete(replicas []*VolumeReplica, replicaPlacement *super_block.ReplicaPlacement) *VolumeReplica { - - sort.Slice(replicas, func(i, j int) bool { - a, b := replicas[i], replicas[j] + slices.SortFunc(replicas, func(a, b *VolumeReplica) bool { if a.info.Size != b.info.Size { return a.info.Size < b.info.Size } |
