mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-10-21 17:27:23 +08:00
s3
This commit is contained in:
38
weed/server/volume_grpc_tier.go
Normal file
38
weed/server/volume_grpc_tier.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package weed_server
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
|
||||
"github.com/chrislusf/seaweedfs/weed/storage/backend"
|
||||
"github.com/chrislusf/seaweedfs/weed/storage/needle"
|
||||
)
|
||||
|
||||
// VolumeTierCopyDatToRemote copy dat file to a remote tier
|
||||
func (vs *VolumeServer) VolumeTierCopyDatToRemote(ctx context.Context, req *volume_server_pb.VolumeTierCopyDatToRemoteRequest) (*volume_server_pb.VolumeTierCopyDatToRemoteResponse, error) {
|
||||
|
||||
v := vs.store.GetVolume(needle.VolumeId(req.VolumeId))
|
||||
if v == nil {
|
||||
return nil, fmt.Errorf("volume %d not found", req.VolumeId)
|
||||
}
|
||||
|
||||
if v.Collection != req.Collection {
|
||||
return nil, fmt.Errorf("existing collection:%v unexpected input: %v", v.Collection, req.Collection)
|
||||
}
|
||||
|
||||
diskFile, ok := v.DataBackend.(*backend.DiskFile)
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("volume %d is not on local disk", req.VolumeId)
|
||||
}
|
||||
err := uploadFileToRemote(ctx, req, diskFile.File)
|
||||
|
||||
return &volume_server_pb.VolumeTierCopyDatToRemoteResponse{}, err
|
||||
}
|
||||
|
||||
func uploadFileToRemote(ctx context.Context, req *volume_server_pb.VolumeTierCopyDatToRemoteRequest, f *os.File) error {
|
||||
println("copying dat file of", f.Name(), "to remote")
|
||||
|
||||
return nil
|
||||
}
|
Reference in New Issue
Block a user