Exemple #1
0
// PingMonitor sends a ping to a monitor and returns the reply.
func (c *Conn) PingMonitor(id string) (string, error) {
	c_id := C.CString(id)
	defer C.free(unsafe.Pointer(c_id))

	var strlen C.size_t
	var strout *C.char

	ret := C.rados_ping_monitor(c.cluster, c_id, &strout, &strlen)
	defer C.rados_buffer_free(strout)

	if ret == 0 {
		reply := C.GoStringN(strout, (C.int)(strlen))
		return reply, nil
	} else {
		return "", RadosError(int(ret))
	}
}
Exemple #2
0
// PingMonitor will query the given monitor to check it's status
// TODO: Make struct for result
func (cluster *Cluster) PingMonitor(monitorId string) (string, error) {
	monId := C.CString(monitorId)
	defer freeString(monId)

	var outLen C.size_t
	var out *C.char

	ret := C.rados_ping_monitor(cluster.handle, monId, &out, &outLen)
	defer C.rados_buffer_free(out)

	if err := toRadosError(ret); err != nil {
		err.Message = "Unable to ping monitor"
		return "", err
	}

	result := C.GoStringN(out, (C.int)(outLen))
	return result, nil
}