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

5 years ago
5 years ago
  1. package weed_server
  2. import (
  3. "context"
  4. "fmt"
  5. "os"
  6. "github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
  7. "github.com/chrislusf/seaweedfs/weed/storage/backend"
  8. "github.com/chrislusf/seaweedfs/weed/storage/needle"
  9. )
  10. // VolumeTierCopyDatToRemote copy dat file to a remote tier
  11. func (vs *VolumeServer) VolumeTierCopyDatToRemote(ctx context.Context, req *volume_server_pb.VolumeTierCopyDatToRemoteRequest) (*volume_server_pb.VolumeTierCopyDatToRemoteResponse, error) {
  12. v := vs.store.GetVolume(needle.VolumeId(req.VolumeId))
  13. if v == nil {
  14. return nil, fmt.Errorf("volume %d not found", req.VolumeId)
  15. }
  16. if v.Collection != req.Collection {
  17. return nil, fmt.Errorf("existing collection:%v unexpected input: %v", v.Collection, req.Collection)
  18. }
  19. diskFile, ok := v.DataBackend.(*backend.DiskFile)
  20. if !ok {
  21. return nil, fmt.Errorf("volume %d is not on local disk", req.VolumeId)
  22. }
  23. err := uploadFileToRemote(ctx, req, diskFile.File)
  24. return &volume_server_pb.VolumeTierCopyDatToRemoteResponse{}, err
  25. }
  26. func uploadFileToRemote(ctx context.Context, req *volume_server_pb.VolumeTierCopyDatToRemoteRequest, f *os.File) error {
  27. println("copying dat file of", f.Name(), "to remote")
  28. return nil
  29. }