mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
b9aee2defb
The volume TTL and file TTL are not necessarily the same. as long as file TTL is smaller than volume TTL, it'll be fine. volume TTL is used when assigning file id, e.g. http://.../dir/assign?ttl=3h file TTL is used when uploading
34 lines
785 B
Go
34 lines
785 B
Go
package topology
|
|
|
|
import (
|
|
"code.google.com/p/weed-fs/go/storage"
|
|
"code.google.com/p/weed-fs/go/util"
|
|
"encoding/json"
|
|
"errors"
|
|
"net/url"
|
|
)
|
|
|
|
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.PublicUrl+"/admin/assign_volume", values)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
var ret AllocateVolumeResult
|
|
if err := json.Unmarshal(jsonBlob, &ret); err != nil {
|
|
return err
|
|
}
|
|
if ret.Error != "" {
|
|
return errors.New(ret.Error)
|
|
}
|
|
return nil
|
|
}
|