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.

32 lines
863 B

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