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.

112 lines
2.8 KiB

6 years ago
6 years ago
6 years ago
6 years ago
6 years ago
  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. )
  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(needle.VolumeId(req.VolumeId))
  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(needle.VolumeId(req.VolumeId))
  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. }
  55. func (vs *VolumeServer) VolumeDelete(ctx context.Context, req *volume_server_pb.VolumeDeleteRequest) (*volume_server_pb.VolumeDeleteResponse, error) {
  56. resp := &volume_server_pb.VolumeDeleteResponse{}
  57. err := vs.store.DeleteVolume(needle.VolumeId(req.VolumeId))
  58. if err != nil {
  59. glog.Errorf("volume delete %v: %v", req, err)
  60. } else {
  61. glog.V(2).Infof("volume delete %v", req)
  62. }
  63. return resp, err
  64. }
  65. func (vs *VolumeServer) VolumeMarkReadonly(ctx context.Context, req *volume_server_pb.VolumeMarkReadonlyRequest) (*volume_server_pb.VolumeMarkReadonlyResponse, error) {
  66. resp := &volume_server_pb.VolumeMarkReadonlyResponse{}
  67. err := vs.store.MarkVolumeReadonly(needle.VolumeId(req.VolumeId))
  68. if err != nil {
  69. glog.Errorf("volume mark readonly %v: %v", req, err)
  70. } else {
  71. glog.V(2).Infof("volume mark readonly %v", req)
  72. }
  73. return resp, err
  74. }