mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-12-01 07:49:02 +08:00
5ce6bbf076
glide has its own requirements. My previous workaround caused me some code checkin errors. Need to fix this.
36 lines
885 B
Go
36 lines
885 B
Go
package topology
|
|
|
|
import (
|
|
"encoding/json"
|
|
"errors"
|
|
"fmt"
|
|
"net/url"
|
|
|
|
"github.com/chrislusf/seaweedfs/weed/storage"
|
|
"github.com/chrislusf/seaweedfs/weed/util"
|
|
)
|
|
|
|
type AllocateVolumeResult struct {
|
|
Error string
|
|
}
|
|
|
|
func AllocateVolume(dn *DataNode, vid storage.VolumeId, option *VolumeGrowOption) error {
|
|
values := make(url.Values)
|
|
values.Add("volume", vid.String())
|
|
values.Add("collection", option.Collection)
|
|
values.Add("replication", option.ReplicaPlacement.String())
|
|
values.Add("ttl", option.Ttl.String())
|
|
jsonBlob, err := util.Post("http://"+dn.Url()+"/admin/assign_volume", values)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
var ret AllocateVolumeResult
|
|
if err := json.Unmarshal(jsonBlob, &ret); err != nil {
|
|
return fmt.Errorf("Invalid JSON result for %s: %s", "/admin/assign_volum", string(jsonBlob))
|
|
}
|
|
if ret.Error != "" {
|
|
return errors.New(ret.Error)
|
|
}
|
|
return nil
|
|
}
|