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.

33 lines
937 B

  1. package topology
  2. import (
  3. "context"
  4. "google.golang.org/grpc"
  5. "time"
  6. "github.com/chrislusf/seaweedfs/weed/operation"
  7. "github.com/chrislusf/seaweedfs/weed/pb/volume_server_pb"
  8. "github.com/chrislusf/seaweedfs/weed/storage"
  9. )
  10. type AllocateVolumeResult struct {
  11. Error string
  12. }
  13. func AllocateVolume(dn *DataNode, grpcDialOption grpc.DialOption, vid storage.VolumeId, option *VolumeGrowOption) error {
  14. return operation.WithVolumeServerClient(dn.Url(), grpcDialOption, func(client volume_server_pb.VolumeServerClient) error {
  15. ctx, cancel := context.WithTimeout(context.Background(), time.Duration(5*time.Second))
  16. defer cancel()
  17. _, deleteErr := client.AssignVolume(ctx, &volume_server_pb.AssignVolumeRequest{
  18. VolumdId: uint32(vid),
  19. Collection: option.Collection,
  20. Replication: option.ReplicaPlacement.String(),
  21. Ttl: option.Ttl.String(),
  22. Preallocate: option.Prealloacte,
  23. })
  24. return deleteErr
  25. })
  26. }