From db94a41f9e28e620b7527d9cca51f9a052a81184 Mon Sep 17 00:00:00 2001 From: Chris Lu Date: Sat, 25 May 2019 23:23:19 -0700 Subject: mount/unmount ec shards --- weed/shell/command_ec_encode.go | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) (limited to 'weed/shell/command_ec_encode.go') 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 { -- cgit v1.2.3