diff options
| author | chrislu <chris.lu@gmail.com> | 2022-09-14 23:06:44 -0700 |
|---|---|---|
| committer | chrislu <chris.lu@gmail.com> | 2022-09-14 23:06:44 -0700 |
| commit | 21c058790010aa9224568248f2d9bf9c324b6747 (patch) | |
| tree | ef2e2a1693c0563f8e44c099d1fee929f40863ff /weed/shell/command_volume_tier_move.go | |
| parent | c8645fd2323d97164489e0429ed140f84002e61e (diff) | |
| download | seaweedfs-21c058790010aa9224568248f2d9bf9c324b6747.tar.xz seaweedfs-21c058790010aa9224568248f2d9bf9c324b6747.zip | |
go fmt
Diffstat (limited to 'weed/shell/command_volume_tier_move.go')
| -rw-r--r-- | weed/shell/command_volume_tier_move.go | 44 |
1 files changed, 22 insertions, 22 deletions
diff --git a/weed/shell/command_volume_tier_move.go b/weed/shell/command_volume_tier_move.go index ae9e83c2a..a59119a40 100644 --- a/weed/shell/command_volume_tier_move.go +++ b/weed/shell/command_volume_tier_move.go @@ -1,6 +1,8 @@ package shell import ( + "context" + "errors" "flag" "fmt" "github.com/seaweedfs/seaweedfs/weed/glog" @@ -12,11 +14,9 @@ import ( "path/filepath" "sync" "time" - "context" - "errors" "github.com/seaweedfs/seaweedfs/weed/operation" - "github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb" + "github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb" "github.com/seaweedfs/seaweedfs/weed/storage/needle" ) @@ -63,7 +63,7 @@ func (c *commandVolumeTierMove) Do(args []string, commandEnv *CommandEnv, writer parallelLimit := tierCommand.Int("parallelLimit", 0, "limit the number of parallel copying jobs") applyChange := tierCommand.Bool("force", false, "actually apply the changes") ioBytePerSecond := tierCommand.Int64("ioBytePerSecond", 0, "limit the speed of move") - replicationString := tierCommand.String("toReplication", "", "the new target replication setting"); + replicationString := tierCommand.String("toReplication", "", "the new target replication setting") if err = tierCommand.Parse(args); err != nil { return nil @@ -226,7 +226,7 @@ func (c *commandVolumeTierMove) doVolumeTierMove(commandEnv *CommandEnv, writer return nil } -func (c *commandVolumeTierMove) doMoveOneVolume(commandEnv *CommandEnv, writer io.Writer, vid needle.VolumeId, toDiskType types.DiskType, locations []wdclient.Location, sourceVolumeServer pb.ServerAddress, dst location, ioBytePerSecond int64, replicationString *string ) (err error) { +func (c *commandVolumeTierMove) doMoveOneVolume(commandEnv *CommandEnv, writer io.Writer, vid needle.VolumeId, toDiskType types.DiskType, locations []wdclient.Location, sourceVolumeServer pb.ServerAddress, dst location, ioBytePerSecond int64, replicationString *string) (err error) { if !commandEnv.isLocked() { return fmt.Errorf("lock is lost") @@ -247,25 +247,25 @@ func (c *commandVolumeTierMove) doMoveOneVolume(commandEnv *CommandEnv, writer i return fmt.Errorf("move volume %d %s => %s : %v", vid, locations[0].Url, dst.dataNode.Id, err) } - // If move is successful and replication is not empty, alter moved volume's replication setting - if *replicationString != "" { - err = operation.WithVolumeServerClient(false, newAddress, commandEnv.option.GrpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error { - resp, configureErr := volumeServerClient.VolumeConfigure(context.Background(), &volume_server_pb.VolumeConfigureRequest{ - VolumeId: uint32(vid), - Replication: *replicationString, - }) - if configureErr != nil { - return configureErr - } - if resp.Error != "" { - return errors.New(resp.Error) - } - return nil - }) + // If move is successful and replication is not empty, alter moved volume's replication setting + if *replicationString != "" { + err = operation.WithVolumeServerClient(false, newAddress, commandEnv.option.GrpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error { + resp, configureErr := volumeServerClient.VolumeConfigure(context.Background(), &volume_server_pb.VolumeConfigureRequest{ + VolumeId: uint32(vid), + Replication: *replicationString, + }) + if configureErr != nil { + return configureErr + } + if resp.Error != "" { + return errors.New(resp.Error) + } + return nil + }) if err != nil { - glog.Errorf("update volume %d replication on %s: %v", vid, locations[0].Url, err) + glog.Errorf("update volume %d replication on %s: %v", vid, locations[0].Url, err) } - } + } // remove the remaining replicas for _, loc := range locations { |
