设为首页 加入收藏

TOP

【分析】Ceph编程实例接口Librbd(C++)--映像创建与数据读写(二)
2018-03-02 06:56:54 】 浏览:403
Tags:【分析 Ceph 编程 实例 接口 Librbd 映像 创建 数据 读写
d::cerr << "couldn't create rbd image! err " << ret << std::endl; ret = EXIT_FAILURE; io_ctx.close(); //关闭I/O上下文 rados.shutdown(); //断开集群连接 return EXIT_FAILURE; } else { std::cout << "We just created an rbd image" << std::endl; }

打开rbd映像

librbd::RBD rbd; const char *image_name = "rumboo"; librbd::Image image; ret = rbd.open(io_ctx, image, image_name); if (ret < 0) { std::cerr << "couldn't open rbd image! err " << ret << std::endl; ret = EXIT_FAILURE; io_ctx.close(); //关闭I/O上下文 rados.shutdown(); //断开集群连接 return EXIT_FAILURE; } else { std::cout << "We just opened an rbd image" << std::endl; }

查看映像大小

uint64_t size = 0; ret = image.size(&size); if (ret < 0) { std::cerr << "couldn't get image size! err " << ret << std::endl; ret = EXIT_FAILURE; return EXIT_FAILURE; } else { std::cout << "The size of the image is " << size << std::endl; }

调整映像大小

size = (uint64_t) 500 * 1024 * 1024; //调整映像大小500MB ret = image.resize(size); if (ret < 0) { std::cerr << "couldn't change the size of the image! err " << ret << std::endl; ret = EXIT_FAILURE; return EXIT_FAILURE; } else { std::cout << "We just change the size of the image" << std::endl; }

查看映像ID

std::string id; ret = image.get_id(&id); if (ret < 0) { std::cerr << "couldn't get image ID! err " << ret << std::endl; ret = EXIT_FAILURE; return EXIT_FAILURE; } else { std::cout << "The ID of the image is " << id << std::endl; }

查看映像features

features = 0; ret = image.features(&features); if (ret < 0) { std::cerr << "couldn't get image features! err " << ret << std::endl; ret = EXIT_FAILURE; return EXIT_FAILURE; } else { std::cout << "The features of the image are " << features << std::endl; }

查看映像状态信息

librbd::image_info_t info; ret = image.stat(info, sizeof(info)); if (ret < 0) { std::cerr << "couldn't get image stat_info! err " << ret << std::endl; ret = EXIT_FAILURE; return EXIT_FAILURE; } else { std::cout << "info.size is " << info.size << std::endl; std::cout << "info.obj_size is " << info.obj_size << std::endl; std::cout << "info.num_objs is " << info.num_objs << std::endl; std::cout << "info.order is " << info.order << std::endl; std::cout << "info.block_name_prefix is " << info.block_name_prefix << std::endl; }

查看存储池ID

std::cout << "data pool id is " << image.get_data_pool_id() << std::endl;
  • 1

    查看block_name_prefix

    std::cout << "block name prefix is " << image.get_block_name_prefix() << std::endl;

    查看flags

    uint64_t flags = 0; ret = image.get_flags(&flags); if (ret < 0) { std::cerr << "couldn't get image flags! err " << ret << std::endl; ret = EXIT_FAILURE; return EXIT_FAILURE; } else { std::cout << "image flags is " << flags << std::endl; }

    查看条带化参数

    std::cout << "image stripe unit is " << image.get_stripe_unit() << std::endl; std::cout << &q
首页 上一页 1 2 3 4 下一页 尾页 2/4/4
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇C++中struct和class的区别介绍 下一篇C++中的类和对象实例讲解

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目