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
799 B

  1. package operation
  2. import (
  3. "code.google.com/p/weed-fs/go/storage"
  4. "code.google.com/p/weed-fs/go/topology"
  5. "code.google.com/p/weed-fs/go/util"
  6. "encoding/json"
  7. "errors"
  8. "net/url"
  9. )
  10. type AllocateVolumeResult struct {
  11. Error string
  12. }
  13. func AllocateVolume(dn *topology.DataNode, vid storage.VolumeId, collection string, repType storage.ReplicationType) error {
  14. values := make(url.Values)
  15. values.Add("volume", vid.String())
  16. values.Add("collection", collection)
  17. values.Add("replicationType", repType.String())
  18. jsonBlob, err := util.Post("http://"+dn.Url()+"/admin/assign_volume", values)
  19. if err != nil {
  20. return err
  21. }
  22. var ret AllocateVolumeResult
  23. if err := json.Unmarshal(jsonBlob, &ret); err != nil {
  24. return err
  25. }
  26. if ret.Error != "" {
  27. return errors.New(ret.Error)
  28. }
  29. return nil
  30. }