|
@ -58,6 +58,7 @@ func (c *commandVolumeFixReplication) Do(args []string, commandEnv *CommandEnv, |
|
|
volFixReplicationCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError) |
|
|
volFixReplicationCommand := flag.NewFlagSet(c.Name(), flag.ContinueOnError) |
|
|
c.collectionPattern = volFixReplicationCommand.String("collectionPattern", "", "match with wildcard characters '*' and '?'") |
|
|
c.collectionPattern = volFixReplicationCommand.String("collectionPattern", "", "match with wildcard characters '*' and '?'") |
|
|
skipChange := volFixReplicationCommand.Bool("n", false, "skip the changes") |
|
|
skipChange := volFixReplicationCommand.Bool("n", false, "skip the changes") |
|
|
|
|
|
retryCount := volFixReplicationCommand.Int("retry", 0, "how many times to retry") |
|
|
if err = volFixReplicationCommand.Parse(args); err != nil { |
|
|
if err = volFixReplicationCommand.Parse(args); err != nil { |
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
@ -100,7 +101,7 @@ func (c *commandVolumeFixReplication) Do(args []string, commandEnv *CommandEnv, |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// find the most under populated data nodes
|
|
|
// find the most under populated data nodes
|
|
|
return c.fixUnderReplicatedVolumes(commandEnv, writer, takeAction, underReplicatedVolumeIds, volumeReplicas, allLocations) |
|
|
|
|
|
|
|
|
return c.fixUnderReplicatedVolumes(commandEnv, writer, takeAction, underReplicatedVolumeIds, volumeReplicas, allLocations, *retryCount) |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -154,16 +155,16 @@ func (c *commandVolumeFixReplication) fixOverReplicatedVolumes(commandEnv *Comma |
|
|
return nil |
|
|
return nil |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (c *commandVolumeFixReplication) fixUnderReplicatedVolumes(commandEnv *CommandEnv, writer io.Writer, takeAction bool, underReplicatedVolumeIds []uint32, volumeReplicas map[uint32][]*VolumeReplica, allLocations []location) error { |
|
|
|
|
|
|
|
|
func (c *commandVolumeFixReplication) fixUnderReplicatedVolumes(commandEnv *CommandEnv, writer io.Writer, takeAction bool, underReplicatedVolumeIds []uint32, volumeReplicas map[uint32][]*VolumeReplica, allLocations []location, retryCount int) (err error) { |
|
|
|
|
|
|
|
|
for _, vid := range underReplicatedVolumeIds { |
|
|
for _, vid := range underReplicatedVolumeIds { |
|
|
err := c.fixOneUnderReplicatedVolume(commandEnv, writer, takeAction, volumeReplicas, vid, allLocations) |
|
|
|
|
|
if err != nil { |
|
|
|
|
|
return err |
|
|
|
|
|
|
|
|
for i:=0;i<retryCount+1;i++{ |
|
|
|
|
|
if err = c.fixOneUnderReplicatedVolume(commandEnv, writer, takeAction, volumeReplicas, vid, allLocations); err == nil { |
|
|
|
|
|
continue |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
return nil |
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
return |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func (c *commandVolumeFixReplication) fixOneUnderReplicatedVolume(commandEnv *CommandEnv, writer io.Writer, takeAction bool, volumeReplicas map[uint32][]*VolumeReplica, vid uint32, allLocations []location) error { |
|
|
func (c *commandVolumeFixReplication) fixOneUnderReplicatedVolume(commandEnv *CommandEnv, writer io.Writer, takeAction bool, volumeReplicas map[uint32][]*VolumeReplica, vid uint32, allLocations []location) error { |
|
|