volume_grpc_admin.go 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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/needle"
  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) AllocateVolume(ctx context.Context, req *volume_server_pb.AllocateVolumeRequest) (*volume_server_pb.AllocateVolumeResponse, error) {
  19. resp := &volume_server_pb.AllocateVolumeResponse{}
  20. err := vs.store.AddVolume(
  21. needle.VolumeId(req.VolumeId),
  22. req.Collection,
  23. vs.needleMapKind,
  24. req.Replication,
  25. req.Ttl,
  26. req.Preallocate,
  27. req.MemoryMapMaxSizeMb,
  28. )
  29. if err != nil {
  30. glog.Errorf("assign volume %v: %v", req, err)
  31. } else {
  32. glog.V(2).Infof("assign volume %v", req)
  33. }
  34. return resp, err
  35. }
  36. func (vs *VolumeServer) VolumeMount(ctx context.Context, req *volume_server_pb.VolumeMountRequest) (*volume_server_pb.VolumeMountResponse, error) {
  37. resp := &volume_server_pb.VolumeMountResponse{}
  38. err := vs.store.MountVolume(needle.VolumeId(req.VolumeId))
  39. if err != nil {
  40. glog.Errorf("volume mount %v: %v", req, err)
  41. } else {
  42. glog.V(2).Infof("volume mount %v", req)
  43. }
  44. return resp, err
  45. }
  46. func (vs *VolumeServer) VolumeUnmount(ctx context.Context, req *volume_server_pb.VolumeUnmountRequest) (*volume_server_pb.VolumeUnmountResponse, error) {
  47. resp := &volume_server_pb.VolumeUnmountResponse{}
  48. err := vs.store.UnmountVolume(needle.VolumeId(req.VolumeId))
  49. if err != nil {
  50. glog.Errorf("volume unmount %v: %v", req, err)
  51. } else {
  52. glog.V(2).Infof("volume unmount %v", req)
  53. }
  54. return resp, err
  55. }
  56. func (vs *VolumeServer) VolumeDelete(ctx context.Context, req *volume_server_pb.VolumeDeleteRequest) (*volume_server_pb.VolumeDeleteResponse, error) {
  57. resp := &volume_server_pb.VolumeDeleteResponse{}
  58. err := vs.store.DeleteVolume(needle.VolumeId(req.VolumeId))
  59. if err != nil {
  60. glog.Errorf("volume delete %v: %v", req, err)
  61. } else {
  62. glog.V(2).Infof("volume delete %v", req)
  63. }
  64. return resp, err
  65. }
  66. func (vs *VolumeServer) VolumeMarkReadonly(ctx context.Context, req *volume_server_pb.VolumeMarkReadonlyRequest) (*volume_server_pb.VolumeMarkReadonlyResponse, error) {
  67. resp := &volume_server_pb.VolumeMarkReadonlyResponse{}
  68. err := vs.store.MarkVolumeReadonly(needle.VolumeId(req.VolumeId))
  69. if err != nil {
  70. glog.Errorf("volume mark readonly %v: %v", req, err)
  71. } else {
  72. glog.V(2).Infof("volume mark readonly %v", req)
  73. }
  74. return resp, err
  75. }