aboutsummaryrefslogtreecommitdiff
path: root/weed/shell/command_ec_encode.go
diff options
context:
space:
mode:
authorChris Lu <chris.lu@gmail.com>2019-05-25 23:23:19 -0700
committerChris Lu <chris.lu@gmail.com>2019-05-25 23:23:19 -0700
commitdb94a41f9e28e620b7527d9cca51f9a052a81184 (patch)
tree67478c3a3a4c3f82c4eebe721b0a377a362a29a7 /weed/shell/command_ec_encode.go
parent41e8ae61f80275a2d1ba49f36553f798cf8efe3a (diff)
downloadseaweedfs-db94a41f9e28e620b7527d9cca51f9a052a81184.tar.xz
seaweedfs-db94a41f9e28e620b7527d9cca51f9a052a81184.zip
mount/unmount ec shards
Diffstat (limited to 'weed/shell/command_ec_encode.go')
-rw-r--r--weed/shell/command_ec_encode.go35
1 files changed, 24 insertions, 11 deletions
diff --git a/weed/shell/command_ec_encode.go b/weed/shell/command_ec_encode.go
index c9ec2fcd2..e0d028392 100644
--- a/weed/shell/command_ec_encode.go
+++ b/weed/shell/command_ec_encode.go
@@ -196,23 +196,36 @@ func oneServerCopyEcShardsFromSource(ctx context.Context, grpcDialOption grpc.Di
targetServer *master_pb.DataNodeInfo, startFromShardId uint32, shardCount uint32,
volumeId needle.VolumeId, collection string, existingLocation wdclient.Location) (copiedShardIds []uint32, err error) {
- if targetServer.Id == existingLocation.Url {
- return nil, nil
- }
-
for shardId := startFromShardId; shardId < startFromShardId+shardCount; shardId++ {
- fmt.Printf("copy %d.%d %s => %s\n", volumeId, shardId, existingLocation.Url, targetServer.Id)
+ fmt.Printf("allocate %d.%d %s => %s\n", volumeId, shardId, existingLocation.Url, targetServer.Id)
copiedShardIds = append(copiedShardIds, shardId)
}
err = operation.WithVolumeServerClient(targetServer.Id, grpcDialOption, func(volumeServerClient volume_server_pb.VolumeServerClient) error {
- _, copyErr := volumeServerClient.VolumeEcShardsCopy(ctx, &volume_server_pb.VolumeEcShardsCopyRequest{
- VolumeId: uint32(volumeId),
- Collection: collection,
- EcIndexes: copiedShardIds,
- SourceDataNode: existingLocation.Url,
+
+ if targetServer.Id != existingLocation.Url {
+
+ _, copyErr := volumeServerClient.VolumeEcShardsCopy(ctx, &volume_server_pb.VolumeEcShardsCopyRequest{
+ VolumeId: uint32(volumeId),
+ Collection: collection,
+ EcIndexes: copiedShardIds,
+ SourceDataNode: existingLocation.Url,
+ })
+ if copyErr != nil {
+ return copyErr
+ }
+ }
+
+ _, mountErr := volumeServerClient.VolumeEcShardsMount(ctx, &volume_server_pb.VolumeEcShardsMountRequest{
+ VolumeId: uint32(volumeId),
+ Collection: collection,
+ EcIndexes: copiedShardIds,
})
- return copyErr
+ if mountErr != nil {
+ return mountErr
+ }
+
+ return nil
})
if err != nil {