You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
977 B

  1. package weed_server
  2. import (
  3. "fmt"
  4. "github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb"
  5. "github.com/seaweedfs/seaweedfs/weed/storage"
  6. "github.com/seaweedfs/seaweedfs/weed/storage/needle"
  7. )
  8. func (vs *VolumeServer) ReadAllNeedles(req *volume_server_pb.ReadAllNeedlesRequest, stream volume_server_pb.VolumeServer_ReadAllNeedlesServer) (err error) {
  9. for _, vid := range req.VolumeIds {
  10. if err := vs.streaReadOneVolume(needle.VolumeId(vid), stream, err); err != nil {
  11. return err
  12. }
  13. }
  14. return nil
  15. }
  16. func (vs *VolumeServer) streaReadOneVolume(vid needle.VolumeId, stream volume_server_pb.VolumeServer_ReadAllNeedlesServer, err error) error {
  17. v := vs.store.GetVolume(vid)
  18. if v == nil {
  19. return fmt.Errorf("not found volume id %d", vid)
  20. }
  21. scanner := &storage.VolumeFileScanner4ReadAll{
  22. Stream: stream,
  23. V: v,
  24. }
  25. offset := int64(v.SuperBlock.BlockSize())
  26. err = storage.ScanVolumeFileFrom(v.Version(), v.DataBackend, offset, scanner)
  27. return err
  28. }