1 #include "rados/librados.hpp"
2 #include "radosstriper/libradosstriper.hpp"
7 int main(int argc, char* argv[])
11 std::cout <<"Please put in correct params\n"<<
16 "Pool Name:"<< std::endl;
19 uint32_t strip_count = std::stoi(argv[1]);
20 uint32_t obj_size = std::stoi(argv[2]);
21 std::string fname = argv[3];
22 std::string obj_name = argv[4];
23 std::string pool_name = argv[5];
25 librados::IoCtx io_ctx;
26 librados::Rados cluster;
27 libradosstriper::RadosStriper* rs = new libradosstriper::RadosStriper;
29 // make sure the keyring file is in /etc/ceph/ and is world readable
30 ret = cluster.init2("client.admin","ceph",0);
33 std::cerr << "Couldn't init cluster "<< ret << std::endl;
36 // make sure ceph.conf is in /etc/ceph/ and is world readable
37 ret = cluster.conf_read_file("ceph.conf");
40 std::cerr << "Couldn't read conf file "<< ret << std::endl;
42 ret = cluster.connect();
45 std::cerr << "Couldn't connect to cluster "<< ret << std::endl;
49 std::cout << "Connected to Cluster"<< std::endl;
52 ret = cluster.ioctx_create(pool_name.c_str(), io_ctx);
56 std::cerr << "Couldn't Create IO_CTX"<< ret << std::endl;
58 ret = libradosstriper::RadosStriper::striper_create(io_ctx,rs);
61 std::cerr << "Couldn't Create RadosStriper"<< ret << std::endl;
64 uint64_t alignment = 0;
65 ret = io_ctx.pool_required_alignment2(&alignment);
68 std::cerr << "IO_CTX didn't give alignment "<< ret
69 << "\n Is this an erasure coded pool? "<< std::endl;
76 std::cout << "Pool alignment: "<< alignment << std::endl;
77 rs->set_object_layout_stripe_unit(alignment);
78 // how many objects are we striping across?
79 rs->set_object_layout_stripe_count(strip_count);
80 // how big should each object be?
81 rs->set_object_layout_object_size(obj_size);
83 std::string err = "no_err";
84 librados::bufferlist bl;
85 bl.read_file(fname.c_str(),&err);
88 std::cout << "Error reading file into bufferlist: "<< err << std::endl;
95 std::cout << "Writing: " << fname << "\nas: "<< obj_name << std::endl;
96 rs->write_full(obj_name,bl);
97 std::cout << "done with: " << fname << std::endl;