* @len length to zero
*/
void rados_write_op_zero(rados_write_op_t write_op,
- uint64_t offset,
- uint64_t len);
+ uint64_t offset,
+ uint64_t len);
+
+/**
+ * Execute an OSD class method on an object
+ * See rados_exec() for general description.
+ *
+ * @param write_op operation to add this action to
+ * @param cls the name of the class
+ * @param method the name of the method
+ * @param in_buf where to find input
+ * @param in_len length of in_buf in bytes
+ * @param prval where to store the return value from the method
+ */
+void rados_write_op_exec(rados_write_op_t write_op,
+ const char *cls,
+ const char *method,
+ const char *in_buf,
+ size_t in_len,
+ int *prval);
+
/**
* Perform a write operation synchronously
* @param write_op operation to perform
((::ObjectOperation *)write_op)->zero(offset, len);
}
+extern "C" void rados_write_op_exec(rados_write_op_t write_op,
+ const char *cls,
+ const char *method,
+ const char *in_buf,
+ size_t in_len,
+ int *prval)
+{
+ bufferlist inbl;
+ inbl.append(in_buf, in_len);
+ ((::ObjectOperation *)write_op)->call(cls, method, inbl, NULL, NULL, prval);
+}
+
extern "C" int rados_write_op_operate(rados_write_op_t write_op,
rados_ioctx_t io,
const char *oid,
ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
}
+
+TEST(LibRadosCWriteOps, Exec) {
+ rados_t cluster;
+ rados_ioctx_t ioctx;
+ std::string pool_name = get_temp_pool_name();
+ ASSERT_EQ("", create_one_pool(pool_name, &cluster));
+ rados_ioctx_create(cluster, pool_name.c_str(), &ioctx);
+
+ int rval = 1;
+ rados_write_op_t op = rados_create_write_op();
+ rados_write_op_exec(op, "hello", "record_hello", "test", 4, &rval);
+ ASSERT_EQ(0, rados_write_op_operate(op, ioctx, "test", NULL, 0));
+ rados_release_write_op(op);
+ ASSERT_EQ(0, rval);
+
+ char hi[100];
+ ASSERT_EQ(12, rados_read(ioctx, "test", hi, 100, 0));
+ hi[12] = '\0';
+ ASSERT_EQ(0, strcmp("Hello, test!", hi));
+
+ ASSERT_EQ(0, destroy_one_pool(pool_name, &cluster));
+}