本文整理汇总了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))
}
}
开发者ID:noahdesu,项目名称:go-zlog,代码行数:21,代码来源:zlog.go
示例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
}
开发者ID:kallax,项目名称:go-ceph-1,代码行数:39,代码来源:rbd.go
示例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
}
开发者ID:kallax,项目名称:go-ceph-1,代码行数:29,代码来源:rbd.go
示例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
}
}
开发者ID:kallax,项目名称:go-ceph-1,代码行数:23,代码来源:rbd.go
示例5: goceph_shutdownContext
// goceph_shutdownContext will destroy any non-default ioctx
func (d *cephRBDVolumeDriver) goceph_shutdownContext(ioctx *rados.IOContext) {
if ioctx != nil {
ioctx.Destroy()
}
}
开发者ID:porcupie,项目名称:rbd-docker-plugin,代码行数:6,代码来源:driver.go
示例6: shutdownContext
// shutdownContext will destroy any non-default ioctx
func (d *cephRBDVolumeDriver) shutdownContext(ioctx *rados.IOContext) {
if ioctx != nil && ioctx != d.defaultIoctx {
ioctx.Destroy()
}
}
开发者ID:yangyimincn,项目名称:rbd-docker-plugin,代码行数:6,代码来源:driver.go
注:本文中的github.com/ceph/go-ceph/rados.IOContext类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论