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.

80 lines
1.9 KiB

  1. package weed_server
  2. import (
  3. "context"
  4. "github.com/chrislusf/seaweedfs/weed/glog"
  5. "github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
  6. "github.com/chrislusf/seaweedfs/weed/storage"
  7. )
  8. func (vs *VolumeServer) DeleteCollection(ctx context.Context, req *volume_server_pb.DeleteCollectionRequest) (*volume_server_pb.DeleteCollectionResponse, error) {
  9. resp := &volume_server_pb.DeleteCollectionResponse{}
  10. err := vs.store.DeleteCollection(req.Collection)
  11. if err != nil {
  12. glog.Errorf("delete collection %s: %v", req.Collection, err)
  13. } else {
  14. glog.V(2).Infof("delete collection %v", req)
  15. }
  16. return resp, err
  17. }
  18. func (vs *VolumeServer) AssignVolume(ctx context.Context, req *volume_server_pb.AssignVolumeRequest) (*volume_server_pb.AssignVolumeResponse, error) {
  19. resp := &volume_server_pb.AssignVolumeResponse{}
  20. err := vs.store.AddVolume(
  21. storage.VolumeId(req.VolumdId),
  22. req.Collection,
  23. vs.needleMapKind,
  24. req.Replication,
  25. req.Ttl,
  26. req.Preallocate,
  27. )
  28. if err != nil {
  29. glog.Errorf("assign volume %v: %v", req, err)
  30. } else {
  31. glog.V(2).Infof("assign volume %v", req)
  32. }
  33. return resp, err
  34. }
  35. func (vs *VolumeServer) VolumeMount(ctx context.Context, req *volume_server_pb.VolumeMountRequest) (*volume_server_pb.VolumeMountResponse, error) {
  36. resp := &volume_server_pb.VolumeMountResponse{}
  37. err := vs.store.MountVolume(storage.VolumeId(req.VolumdId))
  38. if err != nil {
  39. glog.Errorf("volume mount %v: %v", req, err)
  40. } else {
  41. glog.V(2).Infof("volume mount %v", req)
  42. }
  43. return resp, err
  44. }
  45. func (vs *VolumeServer) VolumeUnmount(ctx context.Context, req *volume_server_pb.VolumeUnmountRequest) (*volume_server_pb.VolumeUnmountResponse, error) {
  46. resp := &volume_server_pb.VolumeUnmountResponse{}
  47. err := vs.store.UnmountVolume(storage.VolumeId(req.VolumdId))
  48. if err != nil {
  49. glog.Errorf("volume unmount %v: %v", req, err)
  50. } else {
  51. glog.V(2).Infof("volume unmount %v", req)
  52. }
  53. return resp, err
  54. }