mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-21 22:47:24 +08:00
volume: support concurrent download data size limit
This commit is contained in:
@@ -356,9 +356,9 @@ func (s *Store) DeleteVolumeNeedle(i needle.VolumeId, n *needle.Needle) (Size, e
|
||||
return 0, fmt.Errorf("volume %d not found on %s:%d", i, s.Ip, s.Port)
|
||||
}
|
||||
|
||||
func (s *Store) ReadVolumeNeedle(i needle.VolumeId, n *needle.Needle, readOption *ReadOption) (int, error) {
|
||||
func (s *Store) ReadVolumeNeedle(i needle.VolumeId, n *needle.Needle, readOption *ReadOption, onReadSizeFn func(size Size)) (int, error) {
|
||||
if v := s.findVolume(i); v != nil {
|
||||
return v.readNeedle(n, readOption)
|
||||
return v.readNeedle(n, readOption, onReadSizeFn)
|
||||
}
|
||||
return 0, fmt.Errorf("volume %d not found", i)
|
||||
}
|
||||
|
@@ -121,7 +121,7 @@ func (s *Store) DestroyEcVolume(vid needle.VolumeId) {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *Store) ReadEcShardNeedle(vid needle.VolumeId, n *needle.Needle) (int, error) {
|
||||
func (s *Store) ReadEcShardNeedle(vid needle.VolumeId, n *needle.Needle, onReadSizeFn func(size types.Size)) (int, error) {
|
||||
for _, location := range s.Locations {
|
||||
if localEcVolume, found := location.FindEcVolume(vid); found {
|
||||
|
||||
@@ -133,6 +133,10 @@ func (s *Store) ReadEcShardNeedle(vid needle.VolumeId, n *needle.Needle) (int, e
|
||||
return 0, ErrorDeleted
|
||||
}
|
||||
|
||||
if onReadSizeFn != nil {
|
||||
onReadSizeFn(size)
|
||||
}
|
||||
|
||||
glog.V(3).Infof("read ec volume %d offset %d size %d intervals:%+v", vid, offset.ToActualOffset(), size, intervals)
|
||||
|
||||
if len(intervals) > 1 {
|
||||
|
@@ -14,7 +14,7 @@ import (
|
||||
|
||||
func (s *Store) DeleteEcShardNeedle(ecVolume *erasure_coding.EcVolume, n *needle.Needle, cookie types.Cookie) (int64, error) {
|
||||
|
||||
count, err := s.ReadEcShardNeedle(ecVolume.VolumeId, n)
|
||||
count, err := s.ReadEcShardNeedle(ecVolume.VolumeId, n, nil)
|
||||
|
||||
if err != nil {
|
||||
return 0, err
|
||||
|
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
// read fills in Needle content by looking up n.Id from NeedleMapper
|
||||
func (v *Volume) readNeedle(n *needle.Needle, readOption *ReadOption) (int, error) {
|
||||
func (v *Volume) readNeedle(n *needle.Needle, readOption *ReadOption, onReadSizeFn func(size Size)) (int, error) {
|
||||
v.dataFileAccessLock.RLock()
|
||||
defer v.dataFileAccessLock.RUnlock()
|
||||
|
||||
@@ -33,6 +33,9 @@ func (v *Volume) readNeedle(n *needle.Needle, readOption *ReadOption) (int, erro
|
||||
if readSize == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
if onReadSizeFn != nil {
|
||||
onReadSizeFn(readSize)
|
||||
}
|
||||
err := n.ReadData(v.DataBackend, nv.Offset.ToActualOffset(), readSize, v.Version())
|
||||
if err == needle.ErrorSizeMismatch && OffsetSize == 4 {
|
||||
err = n.ReadData(v.DataBackend, nv.Offset.ToActualOffset()+int64(MaxPossibleVolumeSize), readSize, v.Version())
|
||||
|
@@ -113,7 +113,7 @@ func TestCompaction(t *testing.T) {
|
||||
}
|
||||
|
||||
n := newEmptyNeedle(uint64(i))
|
||||
size, err := v.readNeedle(n, nil)
|
||||
size, err := v.readNeedle(n, nil, nil)
|
||||
if err != nil {
|
||||
t.Fatalf("read file %d: %v", i, err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user