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
742 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, repType storage.ReplicationType) error {
  14. values := make(url.Values)
  15. values.Add("volume", vid.String())
  16. values.Add("replicationType", repType.String())
  17. jsonBlob, err := util.Post("http://"+dn.Url()+"/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. }