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.

44 lines
1.4 KiB

6 years ago
6 years ago
3 years ago
3 years ago
  1. package topology
  2. import (
  3. "context"
  4. "github.com/seaweedfs/seaweedfs/weed/operation"
  5. "github.com/seaweedfs/seaweedfs/weed/pb/volume_server_pb"
  6. "github.com/seaweedfs/seaweedfs/weed/storage/needle"
  7. "google.golang.org/grpc"
  8. )
  9. type AllocateVolumeResult struct {
  10. Error string
  11. }
  12. func AllocateVolume(dn *DataNode, grpcDialOption grpc.DialOption, vid needle.VolumeId, option *VolumeGrowOption) error {
  13. return operation.WithVolumeServerClient(false, dn.ServerAddress(), grpcDialOption, func(client volume_server_pb.VolumeServerClient) error {
  14. _, allocateErr := client.AllocateVolume(context.Background(), &volume_server_pb.AllocateVolumeRequest{
  15. VolumeId: uint32(vid),
  16. Collection: option.Collection,
  17. Replication: option.ReplicaPlacement.String(),
  18. Ttl: option.Ttl.String(),
  19. Preallocate: option.Preallocate,
  20. MemoryMapMaxSizeMb: option.MemoryMapMaxSizeMb,
  21. DiskType: string(option.DiskType),
  22. })
  23. return allocateErr
  24. })
  25. }
  26. func DeleteVolume(dn *DataNode, grpcDialOption grpc.DialOption, vid needle.VolumeId) error {
  27. return operation.WithVolumeServerClient(false, dn.ServerAddress(), grpcDialOption, func(client volume_server_pb.VolumeServerClient) error {
  28. _, allocateErr := client.VolumeDelete(context.Background(), &volume_server_pb.VolumeDeleteRequest{
  29. VolumeId: uint32(vid),
  30. })
  31. return allocateErr
  32. })
  33. }