示例#1
0
文件: conn.go 项目: Xmagicer/origin
// GetClusterStat returns statistics about the cluster associated with the
// connection.
func (c *Conn) GetClusterStats() (stat ClusterStat, err error) {
	c_stat := C.struct_rados_cluster_stat_t{}
	ret := C.rados_cluster_stat(c.cluster, &c_stat)
	if ret < 0 {
		return ClusterStat{}, RadosError(int(ret))
	} else {
		return ClusterStat{
			Kb:          uint64(c_stat.kb),
			Kb_used:     uint64(c_stat.kb_used),
			Kb_avail:    uint64(c_stat.kb_avail),
			Num_objects: uint64(c_stat.num_objects),
		}, nil
	}
}
示例#2
0
// Stat retrieves the current cluster statistics and stores them in
// the Rados structure.
func (r *Rados) Stat() error {
	var cstat C.struct_rados_cluster_stat_t

	if cerr := C.rados_cluster_stat(r.rados, &cstat); cerr < 0 {
		return radosReturnCodeError(cerr)
	}

	r.size = uint64(cstat.kb)
	r.used = uint64(cstat.kb_used)
	r.avail = uint64(cstat.kb_avail)
	r.nObjects = uint64(cstat.num_objects)

	return nil
}
示例#3
0
文件: rados.go 项目: Kimbsen/rados.go
// Stat retrieves the current cluster statistics and stores them in
// the Rados structure.
func (r *Rados) Stat() error {
	var cstat C.struct_rados_cluster_stat_t

	if cerr := C.rados_cluster_stat(r.rados, &cstat); cerr < 0 {
		return fmt.Errorf("RADOS cluster stat: %s", strerror(cerr))
	}

	r.size = uint64(cstat.kb)
	r.used = uint64(cstat.kb_used)
	r.avail = uint64(cstat.kb_avail)
	r.nObjects = uint64(cstat.num_objects)

	return nil
}
示例#4
0
// Status returns the ClusterStatus
func (cluster *Cluster) Status() (*ClusterStatus, error) {
	var clusterStat C.struct_rados_cluster_stat_t
	ret := C.rados_cluster_stat(cluster.handle, &clusterStat)
	if err := toRadosError(ret); err != nil {
		err.Message = "Unable to get cluster status."
		return nil, err
	}
	status := &ClusterStatus{
		Total:   uint64(clusterStat.kb),
		Used:    uint64(clusterStat.kb_used),
		Free:    uint64(clusterStat.kb_avail),
		Objects: uint64(clusterStat.num_objects),
	}
	return status, nil
}