aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoruser <ekhvalov@gmail.com>2021-11-11 17:36:26 +0900
committeruser <ekhvalov@gmail.com>2021-11-11 17:45:17 +0900
commitdbb8003ce3cb0891eb78c117ad1e7d64dc7f5e4d (patch)
treea32e8f905e8f8cae2817a3ea600469016be72782
parentc387fe957b1be5342e2188bf258c440815fb98d0 (diff)
downloadseaweedfs-dbb8003ce3cb0891eb78c117ad1e7d64dc7f5e4d.tar.xz
seaweedfs-dbb8003ce3cb0891eb78c117ad1e7d64dc7f5e4d.zip
Volume filter function added.
-rw-r--r--weed/shell/command_volume_configure_replication.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/weed/shell/command_volume_configure_replication.go b/weed/shell/command_volume_configure_replication.go
index 00eab2c85..591e88b45 100644
--- a/weed/shell/command_volume_configure_replication.go
+++ b/weed/shell/command_volume_configure_replication.go
@@ -55,7 +55,6 @@ func (c *commandVolumeConfigureReplication) Do(args []string, commandEnv *Comman
if err != nil {
return fmt.Errorf("replication format: %v", err)
}
- replicaPlacementInt32 := uint32(replicaPlacement.Byte())
// collect topology information
topologyInfo, _, err := collectTopologyInfo(commandEnv)
@@ -64,6 +63,7 @@ func (c *commandVolumeConfigureReplication) Do(args []string, commandEnv *Comman
}
vid := needle.VolumeId(*volumeIdInt)
+ volumeFilter := getVolumeFilter(replicaPlacement, uint32(vid))
// find all data nodes with volumes that needs replication change
var allLocations []location
@@ -71,7 +71,7 @@ func (c *commandVolumeConfigureReplication) Do(args []string, commandEnv *Comman
loc := newLocation(dc, string(rack), dn)
for _, diskInfo := range dn.DiskInfos {
for _, v := range diskInfo.VolumeInfos {
- if v.Id == uint32(vid) && v.ReplicaPlacement != replicaPlacementInt32 {
+ if volumeFilter(v) {
allLocations = append(allLocations, loc)
continue
}
@@ -106,3 +106,10 @@ func (c *commandVolumeConfigureReplication) Do(args []string, commandEnv *Comman
return nil
}
+
+func getVolumeFilter(replicaPlacement *super_block.ReplicaPlacement, volumeId uint32) func(message *master_pb.VolumeInformationMessage) bool {
+ replicaPlacementInt32 := uint32(replicaPlacement.Byte())
+ return func(v *master_pb.VolumeInformationMessage) bool {
+ return v.Id == volumeId && v.ReplicaPlacement != replicaPlacementInt32
+ }
+}