本文整理汇总了Golang中github.com/ceph/go-ceph/rados.IOContext类的典型用法代码示例。如果您正苦于以下问题:Golang IOContext类的具体用法?Golang IOContext怎么用?Golang IOContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IOContext类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: OpenOrCreate
func OpenOrCreate(ioctx *rados.IOContext, name string, stripe_size int, host string, port string) (*Log, error) {
c_name := C.CString(name)
defer C.free(unsafe.Pointer(c_name))
c_host := C.CString(host)
defer C.free(unsafe.Pointer(c_host))
c_port := C.CString(port)
defer C.free(unsafe.Pointer(c_port))
log := &Log{}
ret := C.zlog_open_or_create(C.rados_ioctx_t(ioctx.Pointer()), c_name, C.int(stripe_size),
c_host, c_port, &log.log)
if ret == 0 {
return log, nil
} else {
return nil, ZlogError(int(ret))
}
}
示例2: Create
// int rbd_create(rados_ioctx_t io, const char *name, uint64_t size, int *order);
// int rbd_create2(rados_ioctx_t io, const char *name, uint64_t size,
// uint64_t features, int *order);
// int rbd_create3(rados_ioctx_t io, const char *name, uint64_t size,
// uint64_t features, int *order,
// uint64_t stripe_unit, uint64_t stripe_count);
func Create(ioctx *rados.IOContext, name string, size uint64,
args ...uint64) (image *Image, err error) {
var ret C.int
var c_order C.int
var c_name *C.char = C.CString(name)
defer C.free(unsafe.Pointer(c_name))
switch len(args) {
case 2:
ret = C.rbd_create3(C.rados_ioctx_t(ioctx.Pointer()),
c_name, C.uint64_t(size),
C.uint64_t(args[0]), &c_order,
C.uint64_t(args[1]), C.uint64_t(args[2]))
case 1:
ret = C.rbd_create2(C.rados_ioctx_t(ioctx.Pointer()),
c_name, C.uint64_t(size),
C.uint64_t(args[0]), &c_order)
case 0:
ret = C.rbd_create(C.rados_ioctx_t(ioctx.Pointer()),
c_name, C.uint64_t(size), &c_order)
default:
return nil, errors.New("Wrong number of argument")
}
if ret < 0 {
return nil, RBDError(int(ret))
}
return &Image{
ioctx: ioctx,
name: name,
}, nil
}
示例3: Clone
// int rbd_clone(rados_ioctx_t p_ioctx, const char *p_name,
// const char *p_snapname, rados_ioctx_t c_ioctx,
// const char *c_name, uint64_t features, int *c_order);
// int rbd_clone2(rados_ioctx_t p_ioctx, const char *p_name,
// const char *p_snapname, rados_ioctx_t c_ioctx,
// const char *c_name, uint64_t features, int *c_order,
// uint64_t stripe_unit, int stripe_count);
func (image *Image) Clone(snapname string, c_ioctx *rados.IOContext, c_name string, features uint64) (*Image, error) {
var c_order C.int
var c_p_name *C.char = C.CString(image.name)
var c_p_snapname *C.char = C.CString(snapname)
var c_c_name *C.char = C.CString(c_name)
defer C.free(unsafe.Pointer(c_p_name))
defer C.free(unsafe.Pointer(c_p_snapname))
defer C.free(unsafe.Pointer(c_c_name))
ret := C.rbd_clone(C.rados_ioctx_t(image.ioctx.Pointer()),
c_p_name, c_p_snapname,
C.rados_ioctx_t(c_ioctx.Pointer()),
c_c_name, C.uint64_t(features), &c_order)
if ret < 0 {
return nil, RBDError(int(ret))
}
return &Image{
ioctx: c_ioctx,
name: c_name,
}, nil
}
示例4: GetImageNames
// GetImageNames returns the list of current RBD images.
func GetImageNames(ioctx *rados.IOContext) (names []string, err error) {
buf := make([]byte, 4096)
for {
size := C.size_t(len(buf))
ret := C.rbd_list(C.rados_ioctx_t(ioctx.Pointer()),
(*C.char)(unsafe.Pointer(&buf[0])), &size)
if ret == -34 { // FIXME
buf = make([]byte, size)
continue
} else if ret < 0 {
return nil, RBDError(ret)
}
tmp := bytes.Split(buf[:size-1], []byte{0})
for _, s := range tmp {
if len(s) > 0 {
name := C.GoString((*C.char)(unsafe.Pointer(&s[0])))
names = append(names, name)
}
}
return names, nil
}
}
示例5: goceph_shutdownContext
// goceph_shutdownContext will destroy any non-default ioctx
func (d *cephRBDVolumeDriver) goceph_shutdownContext(ioctx *rados.IOContext) {
if ioctx != nil {
ioctx.Destroy()
}
}
示例6: shutdownContext
// shutdownContext will destroy any non-default ioctx
func (d *cephRBDVolumeDriver) shutdownContext(ioctx *rados.IOContext) {
if ioctx != nil && ioctx != d.defaultIoctx {
ioctx.Destroy()
}
}