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.

38 lines
1.2 KiB

7 years ago
7 years ago
  1. package operation
  2. import (
  3. "context"
  4. "net/url"
  5. "github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
  6. . "github.com/chrislusf/seaweedfs/weed/storage/types"
  7. "github.com/chrislusf/seaweedfs/weed/util"
  8. )
  9. func GetVolumeSyncStatus(server string, vid uint32) (resp *volume_server_pb.VolumeSyncStatusResponse, err error) {
  10. WithVolumeServerClient(server, func(client volume_server_pb.VolumeServerClient) error {
  11. resp, err = client.VolumeSyncStatus(context.Background(), &volume_server_pb.VolumeSyncStatusRequest{
  12. VolumdId: vid,
  13. })
  14. return nil
  15. })
  16. return
  17. }
  18. func GetVolumeIdxEntries(server string, vid string, eachEntryFn func(key NeedleId, offset Offset, size uint32)) error {
  19. values := make(url.Values)
  20. values.Add("volume", vid)
  21. line := make([]byte, NeedleEntrySize)
  22. err := util.GetBufferStream("http://"+server+"/admin/sync/index", values, line, func(bytes []byte) {
  23. key := BytesToNeedleId(line[:NeedleIdSize])
  24. offset := BytesToOffset(line[NeedleIdSize : NeedleIdSize+OffsetSize])
  25. size := util.BytesToUint32(line[NeedleIdSize+OffsetSize : NeedleIdSize+OffsetSize+SizeSize])
  26. eachEntryFn(key, offset, size)
  27. })
  28. if err != nil {
  29. return err
  30. }
  31. return nil
  32. }