示例#1
0
func (c *Collection) GetOrCreateVolumeLayout(rp *storage.ReplicaPlacement) *VolumeLayout {
	replicaPlacementIndex := rp.GetReplicationLevelIndex()
	if c.replicaType2VolumeLayout[replicaPlacementIndex] == nil {
		glog.V(0).Infoln("collection", c.Name, "adding replication type", rp)
		c.replicaType2VolumeLayout[replicaPlacementIndex] = NewVolumeLayout(rp, c.volumeSizeLimit)
	}
	return c.replicaType2VolumeLayout[replicaPlacementIndex]
}
示例#2
0
func (c *Collection) GetOrCreateVolumeLayout(rp *storage.ReplicaPlacement, ttl *storage.TTL) *VolumeLayout {
	keyString := rp.String()
	if ttl != nil {
		keyString += ttl.String()
	}
	if c.storageType2VolumeLayout[keyString] == nil {
		c.storageType2VolumeLayout[keyString] = NewVolumeLayout(rp, ttl, c.volumeSizeLimit)
	}
	return c.storageType2VolumeLayout[keyString]
}
示例#3
0
func AllocateVolume(dn *DataNode, vid storage.VolumeId, collection string, rp *storage.ReplicaPlacement) error {
	values := make(url.Values)
	values.Add("volume", vid.String())
	values.Add("collection", collection)
	values.Add("replication", rp.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
}