allocate_volume.go 935 B

12345678910111213141516171819202122232425262728293031
  1. package topology
  2. import (
  3. "context"
  4. "github.com/chrislusf/seaweedfs/weed/operation"
  5. "github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
  6. "github.com/chrislusf/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(dn.Url(), grpcDialOption, func(client volume_server_pb.VolumeServerClient) error {
  14. _, deleteErr := 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.Prealloacte,
  20. MemoryMapMaxSizeMb: option.MemoryMapMaxSizeMb,
  21. })
  22. return deleteErr
  23. })
  24. }