#include "objclass/objclass.h"
#include "osd/ReplicatedPG.h"
+#include "osd/osd_types.h"
#include "osd/ClassHandler.h"
return (*pctx)->pg->do_osd_ops(*pctx, ops);
}
+int cls_cxx_list_watchers(cls_method_context_t hctx,
+ obj_list_watch_response_t *watchers)
+{
+ ReplicatedPG::OpContext **pctx = (ReplicatedPG::OpContext **)hctx;
+ vector<OSDOp> nops(1);
+ OSDOp& op = nops[0];
+ int r;
+
+ op.op.op = CEPH_OSD_OP_LIST_WATCHERS;
+ r = (*pctx)->pg->do_osd_ops(*pctx, nops);
+ if (r < 0)
+ return r;
+
+ bufferlist::iterator iter = op.outdata.begin();
+ try {
+ ::decode(*watchers, iter);
+ } catch (buffer::error& err) {
+ return -EIO;
+ }
+ return 0;
+}
+
int cls_gen_random_bytes(char *buf, int size)
{
return get_random_bytes(buf, size);
#include "common/hobject.h"
#include "common/ceph_time.h"
+struct obj_list_watch_response_t;
+
extern "C" {
#endif
extern int cls_cxx_map_remove_key(cls_method_context_t hctx, const string &key);
extern int cls_cxx_map_update(cls_method_context_t hctx, bufferlist *inbl);
+extern int cls_cxx_list_watchers(cls_method_context_t hctx,
+ obj_list_watch_response_t *watchers);
+
/* utility functions */
extern int cls_gen_random_bytes(char *buf, int size);
extern int cls_gen_rand_base64(char *dest, int size); /* size should be the required string size + 1 */
#include "test/librados_test_stub/TestRadosClient.h"
#include "test/librados_test_stub/TestMemRadosClient.h"
#include "objclass/objclass.h"
+#include "osd/osd_types.h"
#include <boost/bind.hpp>
#include <boost/shared_ptr.hpp>
#include <deque>
return ctx->io_ctx_impl->write_full(ctx->oid, *inbl, ctx->snapc);
}
+int cls_cxx_list_watchers(cls_method_context_t hctx,
+ obj_list_watch_response_t *watchers) {
+ librados::TestClassHandler::MethodContext *ctx =
+ reinterpret_cast<librados::TestClassHandler::MethodContext*>(hctx);
+
+ std::list<obj_watch_t> obj_watchers;
+ int r = ctx->io_ctx_impl->list_watchers(ctx->oid, &obj_watchers);
+ if (r < 0) {
+ return r;
+ }
+
+ for (auto &w : obj_watchers) {
+ watch_item_t watcher;
+ watcher.name = entity_name_t::CLIENT(w.watcher_id);
+ watcher.cookie = w.cookie;
+ watcher.timeout_seconds = w.timeout_seconds;
+ watcher.addr.parse(w.addr, 0);
+ watchers->entries.push_back(watcher);
+ }
+
+ return 0;
+}
+
int cls_log(int level, const char *format, ...) {
int size = 256;
va_list ap;