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.

51 lines
1.2 KiB

  1. package storage
  2. import (
  3. "github.com/chrislusf/seaweedfs/weed/glog"
  4. "github.com/chrislusf/seaweedfs/weed/pb"
  5. "github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
  6. "github.com/chrislusf/seaweedfs/weed/storage/backend"
  7. _ "github.com/chrislusf/seaweedfs/weed/storage/backend/s3_backend"
  8. )
  9. func (v *Volume) GetVolumeInfo() *volume_server_pb.VolumeInfo {
  10. return v.volumeInfo
  11. }
  12. func (v *Volume) maybeLoadVolumeInfo() {
  13. var found bool
  14. v.volumeInfo, found = pb.MaybeLoadVolumeInfo(v.FileName() + ".vif")
  15. if found {
  16. glog.V(0).Infof("volume %d is tiered to %s as %s and read only", v.Id,
  17. v.volumeInfo.Files[0].BackendName(), v.volumeInfo.Files[0].Key)
  18. v.hasRemoteFile = true
  19. }
  20. }
  21. func (v *Volume) HasRemoteFile() bool {
  22. return v.hasRemoteFile
  23. }
  24. func (v *Volume) LoadRemoteFile() error {
  25. tierFile := v.volumeInfo.GetFiles()[0]
  26. backendStorage := backend.BackendStorages[tierFile.BackendName()]
  27. if v.DataBackend != nil {
  28. v.DataBackend.Close()
  29. }
  30. v.DataBackend = backendStorage.NewStorageFile(tierFile.Key, v.volumeInfo)
  31. return nil
  32. }
  33. func (v *Volume) SaveVolumeInfo() error {
  34. tierFileName := v.FileName() + ".vif"
  35. return pb.SaveVolumeInfo(tierFileName, v.volumeInfo)
  36. }