|
@ -4,12 +4,13 @@ import ( |
|
|
"context" |
|
|
"context" |
|
|
"flag" |
|
|
"flag" |
|
|
"fmt" |
|
|
"fmt" |
|
|
"github.com/seaweedfs/seaweedfs/weed/pb" |
|
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/wdclient" |
|
|
|
|
|
"io" |
|
|
"io" |
|
|
"log" |
|
|
"log" |
|
|
"time" |
|
|
"time" |
|
|
|
|
|
|
|
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/pb" |
|
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/wdclient" |
|
|
|
|
|
|
|
|
"github.com/seaweedfs/seaweedfs/weed/operation" |
|
|
"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" |
|
|
"github.com/seaweedfs/seaweedfs/weed/storage/needle" |
|
@ -132,6 +133,7 @@ func copyVolume(grpcDialOption grpc.DialOption, writer io.Writer, volumeId needl |
|
|
shouldMarkWritable = true |
|
|
shouldMarkWritable = true |
|
|
_, readonlyErr := volumeServerClient.VolumeMarkReadonly(context.Background(), &volume_server_pb.VolumeMarkReadonlyRequest{ |
|
|
_, readonlyErr := volumeServerClient.VolumeMarkReadonly(context.Background(), &volume_server_pb.VolumeMarkReadonlyRequest{ |
|
|
VolumeId: uint32(volumeId), |
|
|
VolumeId: uint32(volumeId), |
|
|
|
|
|
Persist: false, |
|
|
}) |
|
|
}) |
|
|
return readonlyErr |
|
|
return readonlyErr |
|
|
} |
|
|
} |
|
@ -197,7 +199,7 @@ func deleteVolume(grpcDialOption grpc.DialOption, volumeId needle.VolumeId, sour |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func markVolumeWritable(grpcDialOption grpc.DialOption, volumeId needle.VolumeId, sourceVolumeServer pb.ServerAddress, writable bool) (err error) { |
|
|
|
|
|
|
|
|
func markVolumeWritable(grpcDialOption grpc.DialOption, volumeId needle.VolumeId, sourceVolumeServer pb.ServerAddress, writable, persist bool) (err error) { |
|
|
return operation.WithVolumeServerClient(false, sourceVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error { |
|
|
return operation.WithVolumeServerClient(false, sourceVolumeServer, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error { |
|
|
if writable { |
|
|
if writable { |
|
|
_, err = volumeServerClient.VolumeMarkWritable(context.Background(), &volume_server_pb.VolumeMarkWritableRequest{ |
|
|
_, err = volumeServerClient.VolumeMarkWritable(context.Background(), &volume_server_pb.VolumeMarkWritableRequest{ |
|
@ -206,16 +208,17 @@ func markVolumeWritable(grpcDialOption grpc.DialOption, volumeId needle.VolumeId |
|
|
} else { |
|
|
} else { |
|
|
_, err = volumeServerClient.VolumeMarkReadonly(context.Background(), &volume_server_pb.VolumeMarkReadonlyRequest{ |
|
|
_, err = volumeServerClient.VolumeMarkReadonly(context.Background(), &volume_server_pb.VolumeMarkReadonlyRequest{ |
|
|
VolumeId: uint32(volumeId), |
|
|
VolumeId: uint32(volumeId), |
|
|
|
|
|
Persist: persist, |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
return err |
|
|
return err |
|
|
}) |
|
|
}) |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func markVolumeReplicasWritable(grpcDialOption grpc.DialOption, volumeId needle.VolumeId, locations []wdclient.Location, writable bool) error { |
|
|
|
|
|
|
|
|
func markVolumeReplicasWritable(grpcDialOption grpc.DialOption, volumeId needle.VolumeId, locations []wdclient.Location, writable, persist bool) error { |
|
|
for _, location := range locations { |
|
|
for _, location := range locations { |
|
|
fmt.Printf("markVolumeReadonly %d on %s ...\n", volumeId, location.Url) |
|
|
fmt.Printf("markVolumeReadonly %d on %s ...\n", volumeId, location.Url) |
|
|
if err := markVolumeWritable(grpcDialOption, volumeId, location.ServerAddress(), writable); err != nil { |
|
|
|
|
|
|
|
|
if err := markVolumeWritable(grpcDialOption, volumeId, location.ServerAddress(), writable, persist); err != nil { |
|
|
return err |
|
|
return err |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|