read ec volume shards locations from master

This commit is contained in:
Chris Lu
2019-05-28 00:13:13 -07:00
parent 713596e781
commit 2858a954b3
5 changed files with 291 additions and 106 deletions

View File

@@ -172,6 +172,24 @@ func (s *Store) cachedLookupEcShardLocations(ctx context.Context, ecVolume *eras
defer ecVolume.ShardLocationsLock.Unlock()
err = operation.WithMasterServerClient(s.MasterAddress, s.grpcDialOption, func(masterClient master_pb.SeaweedClient) error {
req := &master_pb.LookupEcVolumeRequest{
VolumeId: uint32(ecVolume.VolumeId),
}
resp, err := masterClient.LookupEcVolume(ctx, req)
if err != nil {
return fmt.Errorf("lookup ec volume %d: %v", ecVolume.VolumeId, err)
}
ecVolume.ShardLocationsLock.Lock()
for _, shardIdLocations := range resp.ShardIdLocations {
shardId := erasure_coding.ShardId(shardIdLocations.ShardId)
ecVolume.ShardLocations[shardId] = nil
for _, loc := range shardIdLocations.Locations {
ecVolume.ShardLocations[shardId] = append(ecVolume.ShardLocations[shardId], loc.Url)
}
}
ecVolume.ShardLocationsLock.Unlock()
return nil
})
return