aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/command_ec_encode.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2019-06-26 23:02:22 -0700
committerChris Lu <chris.lu@gmail.com>2019-06-26 23:02:22 -0700
commit6883f9e3227ba4b7e3db69d180b15203a8578256 (patch)
tree7781beb17bb15ed290cf778d51a363f13b3e6798 /weed/shell/command_ec_encode.go
parentc2960c7a861d5e827143731274cf04e4e5c8f584 (diff)
downloadseaweedfs-6883f9e3227ba4b7e3db69d180b15203a8578256.tar.xz
seaweedfs-6883f9e3227ba4b7e3db69d180b15203a8578256.zip
mark volume readonly before ec encoding
Diffstat (limited to 'weed/shell/command_ec_encode.go')
-rw-r--r--weed/shell/command_ec_encode.go26
1 files changed, 26 insertions, 0 deletions
diff --git a/weed/shell/command_ec_encode.go b/weed/shell/command_ec_encode.go
index 492dc77eb..3ae6b9101 100644
--- a/weed/shell/command_ec_encode.go
+++ b/weed/shell/command_ec_encode.go
@@ -92,6 +92,12 @@ func doEcEncode(ctx context.Context, commandEnv *CommandEnv, collection string,
return fmt.Errorf("volume %d not found", vid)
}
+ // mark the volume as readonly
+ err = markVolumeReadonly(ctx, commandEnv.option.GrpcDialOption, needle.VolumeId(vid), locations)
+ if err != nil {
+ return fmt.Errorf("generate ec shards for volume %d on %s: %v", vid, locations[0].Url, err)
+ }
+
// generate ec shards
err = generateEcShards(ctx, commandEnv.option.GrpcDialOption, needle.VolumeId(vid), collection, locations[0].Url)
if err != nil {
@@ -107,6 +113,26 @@ func doEcEncode(ctx context.Context, commandEnv *CommandEnv, collection string,
return nil
}
+func markVolumeReadonly(ctx context.Context, grpcDialOption grpc.DialOption, volumeId needle.VolumeId, locations []wdclient.Location) error {
+
+ for _, location := range locations {
+
+ err := operation.WithVolumeServerClient(location.Url, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
+ _, markErr := volumeServerClient.VolumeMarkReadonly(ctx, &volume_server_pb.VolumeMarkReadonlyRequest{
+ VolumeId: uint32(volumeId),
+ })
+ return markErr
+ })
+
+ if err != nil {
+ return err
+ }
+
+ }
+
+ return nil
+}
+
func generateEcShards(ctx context.Context, grpcDialOption grpc.DialOption, volumeId needle.VolumeId, collection string, sourceVolumeServer string) error {
err := operation.WithVolumeServerClient(sourceVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {