From: David Zafman Date: Fri, 22 Feb 2013 01:59:17 +0000 (-0800) Subject: Add listwatchers command to rados X-Git-Tag: v0.59~146^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=1c3241e3bfb41572933c06fabd8d6de5eab02f42;p=ceph.git Add listwatchers command to rados Signed-off-by: David Zafman --- diff --git a/src/rados.cc b/src/rados.cc index d3de74a810b5..bbd3badc0822 100644 --- a/src/rados.cc +++ b/src/rados.cc @@ -15,6 +15,7 @@ #include "include/types.h" #include "include/rados/librados.hpp" +#include "include/rados/rados_types.h" #include "rados_sync.h" using namespace librados; @@ -95,6 +96,7 @@ void usage(ostream& out) " rmomapkey \n" " getomapheader \n" " setomapheader \n" +" listwatchers list the watchers of this object\n" "\n" "IMPORT AND EXPORT\n" " import [options] \n" @@ -2001,6 +2003,25 @@ static int rados_tool_common(const std::map < std::string, std::string > &opts, formatter = new JSONFormatter(pretty_format); } ret = do_lock_cmd(nargs, opts, &io_ctx, formatter); + } else if (strcmp(nargs[0], "listwatchers") == 0) { + if (!pool_name || nargs.size() < 2) + usage_exit(); + + string oid(nargs[1]); + std::list lw; + + ret = io_ctx.list_watchers(oid, &lw); + if (ret < 0) { + cerr << "error listing watchers " << pool_name << "/" << oid << ": " << strerror_r(-ret, buf, sizeof(buf)) << std::endl; + return 1; + } + else + ret = 0; + + std::list::iterator i; + for (i = lw.begin(); i != lw.end(); i++) { + cout << "watcher=client." << i->watcher_id << " cookie=" << i->cookie << std::endl; + } } else { cerr << "unrecognized command " << nargs[0] << std::endl; usage_exit();