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

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