refactoring
This commit is contained in:
@@ -151,11 +151,11 @@ func (vs *VolumeServer) VolumeEcShardsUnmount(ctx context.Context, req *volume_s
|
||||
|
||||
func (vs *VolumeServer) VolumeEcShardRead(req *volume_server_pb.VolumeEcShardReadRequest, stream volume_server_pb.VolumeServer_VolumeEcShardReadServer) error {
|
||||
|
||||
ecShards, found := vs.store.HasEcShard(needle.VolumeId(req.VolumeId))
|
||||
ecVolume, found := vs.store.FindEcVolume(needle.VolumeId(req.VolumeId))
|
||||
if !found {
|
||||
return fmt.Errorf("not found ec volume id %d", req.VolumeId)
|
||||
}
|
||||
ecShard, found := ecShards.FindEcVolumeShard(erasure_coding.ShardId(req.ShardId))
|
||||
ecShard, found := ecVolume.FindEcVolumeShard(erasure_coding.ShardId(req.ShardId))
|
||||
if !found {
|
||||
return fmt.Errorf("not found ec shard %d.%d", req.VolumeId, req.ShardId)
|
||||
}
|
||||
|
||||
@@ -42,8 +42,8 @@ func (vs *VolumeServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
|
||||
|
||||
glog.V(4).Infoln("volume", volumeId, "reading", n)
|
||||
hasVolume := vs.store.HasVolume(volumeId)
|
||||
_, hasEcShard := vs.store.HasEcShard(volumeId)
|
||||
if !hasVolume && !hasEcShard {
|
||||
_, hasEcVolume := vs.store.FindEcVolume(volumeId)
|
||||
if !hasVolume && !hasEcVolume {
|
||||
if !vs.ReadRedirect {
|
||||
glog.V(2).Infoln("volume is not local:", err, r.URL.Path)
|
||||
w.WriteHeader(http.StatusNotFound)
|
||||
@@ -71,7 +71,7 @@ func (vs *VolumeServer) GetOrHeadHandler(w http.ResponseWriter, r *http.Request)
|
||||
var count int
|
||||
if hasVolume {
|
||||
count, err = vs.store.ReadVolumeNeedle(volumeId, n)
|
||||
} else if hasEcShard {
|
||||
} else if hasEcVolume {
|
||||
count, err = vs.store.ReadEcShardNeedle(context.Background(), volumeId, n)
|
||||
}
|
||||
glog.V(4).Infoln("read bytes", count, "error", err)
|
||||
|
||||
Reference in New Issue
Block a user