return -EOPNOTSUPP;
}
+void IoCtx::set_namespace(const std::string& nspace) {
+ TestIoCtxImpl *ctx = reinterpret_cast<TestIoCtxImpl*>(io_ctx_impl);
+ ctx->set_namespace(nspace);
+}
+
static int save_operation_result(int result, int *pval) {
if (pval != NULL) {
*pval = result;
class TestCluster {
public:
+ struct ObjectLocator {
+ std::string nspace;
+ std::string name;
+
+ ObjectLocator(const std::string& nspace, const std::string& name)
+ : nspace(nspace), name(name) {
+ }
+
+ bool operator<(const ObjectLocator& rhs) const {
+ if (nspace != rhs.nspace) {
+ return nspace < rhs.nspace;
+ }
+ return name < rhs.name;
+ }
+ };
+
struct ObjectHandler {
virtual ~ObjectHandler() {}
virtual TestRadosClient *create_rados_client(CephContext *cct) = 0;
- virtual int register_object_handler(int64_t pool_id, const std::string& o,
+ virtual int register_object_handler(int64_t pool_id,
+ const ObjectLocator& locator,
ObjectHandler* object_handler) = 0;
- virtual void unregister_object_handler(int64_t pool_id, const std::string& o,
+ virtual void unregister_object_handler(int64_t pool_id,
+ const ObjectLocator& locator,
ObjectHandler* object_handler) = 0;
TestWatchNotify *get_watch_notify() {
: m_client(rhs.m_client),
m_pool_id(rhs.m_pool_id),
m_pool_name(rhs.m_pool_name),
+ m_namespace_name(rhs.m_namespace_name),
m_snap_seq(rhs.m_snap_seq)
{
m_client->get();
m_pending_ops++;
c->get();
C_AioNotify *ctx = new C_AioNotify(this, c);
- m_client->get_watch_notify()->aio_notify(m_client, m_pool_id, oid, bl,
- timeout_ms, pbl, ctx);
+ m_client->get_watch_notify()->aio_notify(m_client, m_pool_id, get_namespace(),
+ oid, bl, timeout_ms, pbl, ctx);
}
int TestIoCtxImpl::aio_operate(const std::string& oid, TestObjectOperationImpl &ops,
if (m_client->is_blacklisted()) {
m_client->get_aio_finisher()->queue(ctx, -EBLACKLISTED);
} else {
- m_client->get_watch_notify()->aio_watch(m_client, m_pool_id, o,
+ m_client->get_watch_notify()->aio_watch(m_client, m_pool_id,
+ get_namespace(), o,
get_instance_id(), handle, nullptr,
watch_ctx, ctx);
}
return -EBLACKLISTED;
}
- return m_client->get_watch_notify()->list_watchers(m_pool_id, o,
- out_watchers);
+ return m_client->get_watch_notify()->list_watchers(m_pool_id, get_namespace(),
+ o, out_watchers);
}
int TestIoCtxImpl::notify(const std::string& o, bufferlist& bl,
return -EBLACKLISTED;
}
- return m_client->get_watch_notify()->notify(m_client, m_pool_id, o, bl,
+ return m_client->get_watch_notify()->notify(m_client, m_pool_id,
+ get_namespace(), o, bl,
timeout_ms, pbl);
}
void TestIoCtxImpl::notify_ack(const std::string& o, uint64_t notify_id,
uint64_t handle, bufferlist& bl) {
- m_client->get_watch_notify()->notify_ack(m_client, m_pool_id, o, notify_id,
- handle, m_client->get_instance_id(),
- bl);
+ m_client->get_watch_notify()->notify_ack(m_client, m_pool_id, get_namespace(),
+ o, notify_id, handle,
+ m_client->get_instance_id(), bl);
}
int TestIoCtxImpl::operate(const std::string& oid, TestObjectOperationImpl &ops) {
return -EBLACKLISTED;
}
- return m_client->get_watch_notify()->watch(m_client, m_pool_id, o,
+ return m_client->get_watch_notify()->watch(m_client, m_pool_id,
+ get_namespace(), o,
get_instance_id(), handle, ctx,
ctx2);
}
return -EBLACKLISTED;
}
- TestRadosClient::Transaction transaction(m_client, oid);
+ TestRadosClient::Transaction transaction(m_client, get_namespace(), oid);
return operation(this, oid);
}
if (m_client->is_blacklisted()) {
ret = -EBLACKLISTED;
} else {
- TestRadosClient::Transaction transaction(m_client, oid);
+ TestRadosClient::Transaction transaction(m_client, get_namespace(), oid);
for (ObjectOperations::iterator it = ops->ops.begin();
it != ops->ops.end(); ++it) {
ret = (*it)(this, oid, pbl, snapc);
virtual int64_t get_id();
virtual uint64_t get_last_version();
virtual std::string get_pool_name();
+
+ inline void set_namespace(const std::string& namespace_name) {
+ m_namespace_name = namespace_name;
+ }
+ inline std::string get_namespace() const {
+ return m_namespace_name;
+ }
+
snap_t get_snap_read() const {
return m_snap_seq;
}
TestRadosClient *m_client;
int64_t m_pool_id = 0;
std::string m_pool_name;
+ std::string m_namespace_name;
+
snap_t m_snap_seq = 0;
SnapContext m_snapc;
std::atomic<uint64_t> m_refcount = { 0 };
}
int TestMemCluster::register_object_handler(int64_t pool_id,
- const std::string& o,
+ const ObjectLocator& locator,
ObjectHandler* object_handler) {
Mutex::Locker locker(m_lock);
auto pool = get_pool(m_lock, pool_id);
}
RWLock::WLocker pool_locker(pool->file_lock);
- auto file_it = pool->files.find(o);
+ auto file_it = pool->files.find(locator);
if (file_it == pool->files.end()) {
return -ENOENT;
}
- auto& object_handlers = pool->file_handlers[o];
+ auto& object_handlers = pool->file_handlers[locator];
auto it = object_handlers.find(object_handler);
assert(it == object_handlers.end());
}
void TestMemCluster::unregister_object_handler(int64_t pool_id,
- const std::string& o,
+ const ObjectLocator& locator,
ObjectHandler* object_handler) {
Mutex::Locker locker(m_lock);
auto pool = get_pool(m_lock, pool_id);
}
RWLock::WLocker pool_locker(pool->file_lock);
- auto handlers_it = pool->file_handlers.find(o);
+ auto handlers_it = pool->file_handlers.find(locator);
if (handlers_it == pool->file_handlers.end()) {
return;
}
m_blacklist.insert(nonce);
}
-void TestMemCluster::transaction_start(const std::string &oid) {
+void TestMemCluster::transaction_start(const ObjectLocator& locator) {
Mutex::Locker locker(m_lock);
- while (m_transactions.count(oid)) {
+ while (m_transactions.count(locator)) {
m_transaction_cond.Wait(m_lock);
}
- std::pair<std::set<std::string>::iterator, bool> result =
- m_transactions.insert(oid);
+ auto result = m_transactions.insert(locator);
assert(result.second);
}
-void TestMemCluster::transaction_finish(const std::string &oid) {
+void TestMemCluster::transaction_finish(const ObjectLocator& locator) {
Mutex::Locker locker(m_lock);
- size_t count = m_transactions.erase(oid);
+ size_t count = m_transactions.erase(locator);
assert(count == 1);
m_transaction_cond.Signal();
}
class TestMemCluster : public TestCluster {
public:
typedef std::map<std::string, bufferlist> OMap;
- typedef std::map<std::string, OMap> FileOMaps;
- typedef std::map<std::string, bufferlist> FileTMaps;
+ typedef std::map<ObjectLocator, OMap> FileOMaps;
+ typedef std::map<ObjectLocator, bufferlist> FileTMaps;
typedef std::map<std::string, bufferlist> XAttrs;
- typedef std::map<std::string, XAttrs> FileXAttrs;
+ typedef std::map<ObjectLocator, XAttrs> FileXAttrs;
typedef std::set<ObjectHandler*> ObjectHandlers;
- typedef std::map<std::string, ObjectHandlers> FileHandlers;
+ typedef std::map<ObjectLocator, ObjectHandlers> FileHandlers;
struct File {
File();
typedef boost::shared_ptr<File> SharedFile;
typedef std::list<SharedFile> FileSnapshots;
- typedef std::map<std::string, FileSnapshots> Files;
+ typedef std::map<ObjectLocator, FileSnapshots> Files;
typedef std::set<uint64_t> SnapSeqs;
struct Pool : public RefCountedObject {
TestRadosClient *create_rados_client(CephContext *cct) override;
- int register_object_handler(int64_t pool_id, const std::string& o,
+ int register_object_handler(int64_t pool_id, const ObjectLocator& locator,
ObjectHandler* object_handler) override;
- void unregister_object_handler(int64_t pool_id, const std::string& o,
+ void unregister_object_handler(int64_t pool_id, const ObjectLocator& locator,
ObjectHandler* object_handler) override;
int pool_create(const std::string &pool_name);
bool is_blacklisted(uint32_t nonce) const;
void blacklist(uint32_t nonce);
- void transaction_start(const std::string &oid);
- void transaction_finish(const std::string &oid);
+ void transaction_start(const ObjectLocator& locator);
+ void transaction_finish(const ObjectLocator& locator);
private:
Blacklist m_blacklist;
Cond m_transaction_cond;
- std::set<std::string> m_transactions;
+ std::set<ObjectLocator> m_transactions;
Pool *get_pool(const Mutex& lock, int64_t pool_id);
out_snaps->clones.clear();
RWLock::RLocker l(m_pool->file_lock);
- TestMemCluster::Files::iterator it = m_pool->files.find(oid);
+ TestMemCluster::Files::iterator it = m_pool->files.find(
+ {get_namespace(), oid});
if (it == m_pool->files.end()) {
return -ENOENT;
}
out_vals->clear();
RWLock::RLocker l(file->lock);
- TestMemCluster::FileOMaps::iterator o_it = m_pool->file_omaps.find(oid);
+ TestMemCluster::FileOMaps::iterator o_it = m_pool->file_omaps.find(
+ {get_namespace(), oid});
if (o_it == m_pool->file_omaps.end()) {
if (pmore) {
*pmore = false;
RWLock::WLocker l(file->lock);
for (std::set<std::string>::iterator it = keys.begin();
it != keys.end(); ++it) {
- m_pool->file_omaps[oid].erase(*it);
+ m_pool->file_omaps[{get_namespace(), oid}].erase(*it);
}
return 0;
}
it != map.end(); ++it) {
bufferlist bl;
bl.append(it->second);
- m_pool->file_omaps[oid][it->first] = bl;
+ m_pool->file_omaps[{get_namespace(), oid}][it->first] = bl;
}
return 0;
file->exists = false;
}
- TestMemCluster::Files::iterator it = m_pool->files.find(oid);
+ TestCluster::ObjectLocator locator(get_namespace(), oid);
+ TestMemCluster::Files::iterator it = m_pool->files.find(locator);
assert(it != m_pool->files.end());
if (*it->second.rbegin() == file) {
TestMemCluster::ObjectHandlers object_handlers;
- std::swap(object_handlers, m_pool->file_handlers[oid]);
- m_pool->file_handlers.erase(oid);
+ std::swap(object_handlers, m_pool->file_handlers[locator]);
+ m_pool->file_handlers.erase(locator);
for (auto object_handler : object_handlers) {
object_handler->handle_removed(m_client);
if (it->second.size() == 1) {
m_pool->files.erase(it);
- m_pool->file_omaps.erase(oid);
+ m_pool->file_omaps.erase(locator);
}
return 0;
}
RWLock::WLocker l(m_pool->file_lock);
TestMemCluster::SharedFile file;
- TestMemCluster::Files::iterator f_it = m_pool->files.find(oid);
+ TestMemCluster::Files::iterator f_it = m_pool->files.find(
+ {get_namespace(), oid});
if (f_it == m_pool->files.end()) {
return 0;
}
TestMemCluster::SharedFile file;
RWLock::RLocker l(m_pool->file_lock);
- TestMemCluster::FileXAttrs::iterator it = m_pool->file_xattrs.find(oid);
+ TestMemCluster::FileXAttrs::iterator it = m_pool->file_xattrs.find(
+ {get_namespace(), oid});
if (it == m_pool->file_xattrs.end()) {
return -ENODATA;
}
}
RWLock::WLocker l(m_pool->file_lock);
- m_pool->file_xattrs[oid][name] = bl;
+ m_pool->file_xattrs[{get_namespace(), oid}][name] = bl;
return 0;
}
assert(!write || m_pool->file_lock.is_wlocked());
TestMemCluster::SharedFile file;
- TestMemCluster::Files::iterator it = m_pool->files.find(oid);
+ TestMemCluster::Files::iterator it = m_pool->files.find(
+ {get_namespace(), oid});
if (it != m_pool->files.end()) {
file = it->second.back();
} else if (!write) {
if (new_version) {
file->snap_id = snapc.seq;
file->mtime = ceph_clock_now().sec();
- m_pool->files[oid].push_back(file);
+ m_pool->files[{get_namespace(), oid}].push_back(file);
}
return file;
}
RWLock::RLocker file_locker(pool->file_lock);
for (auto &file_pair : pool->files) {
Object obj;
- obj.oid = file_pair.first;
+ obj.oid = file_pair.first.name;
list->push_back(obj);
}
}
return 0;
}
-void TestMemRadosClient::transaction_start(const std::string &oid) {
- m_mem_cluster->transaction_start(oid);
+void TestMemRadosClient::transaction_start(const std::string& nspace,
+ const std::string &oid) {
+ m_mem_cluster->transaction_start({nspace, oid});
}
-void TestMemRadosClient::transaction_finish(const std::string &oid) {
- m_mem_cluster->transaction_finish(oid);
+void TestMemRadosClient::transaction_finish(const std::string& nspace,
+ const std::string &oid) {
+ m_mem_cluster->transaction_finish({nspace, oid});
}
} // namespace librados
}
protected:
- void transaction_start(const std::string &oid) override;
- void transaction_finish(const std::string &oid) override;
+ void transaction_start(const std::string& nspace,
+ const std::string &oid) override;
+ void transaction_finish(const std::string& nspace,
+ const std::string &oid) override;
private:
TestMemCluster *m_mem_cluster;
class Transaction {
public:
- Transaction(TestRadosClient *rados_client, const std::string &oid)
- : rados_client(rados_client), oid(oid) {
- rados_client->transaction_start(oid);
+ Transaction(TestRadosClient *rados_client, const std::string& nspace,
+ const std::string &oid)
+ : rados_client(rados_client), nspace(nspace), oid(oid) {
+ rados_client->transaction_start(nspace, oid);
}
~Transaction() {
- rados_client->transaction_finish(oid);
+ rados_client->transaction_finish(nspace, oid);
}
private:
TestRadosClient *rados_client;
+ std::string nspace;
std::string oid;
};
protected:
virtual ~TestRadosClient();
- virtual void transaction_start(const std::string &oid) = 0;
- virtual void transaction_finish(const std::string &oid) = 0;
+ virtual void transaction_start(const std::string& nspace,
+ const std::string &oid) = 0;
+ virtual void transaction_finish(const std::string& nspace,
+ const std::string &oid) = 0;
private:
struct TestWatchNotify::ObjectHandler : public TestCluster::ObjectHandler {
TestWatchNotify* test_watch_notify;
int64_t pool_id;
+ std::string nspace;
std::string oid;
ObjectHandler(TestWatchNotify* test_watch_notify, int64_t pool_id,
- const std::string& oid)
+ const std::string& nspace, const std::string& oid)
: test_watch_notify(test_watch_notify), pool_id(pool_id),
- oid(oid) {
+ nspace(nspace), oid(oid) {
}
void handle_removed(TestRadosClient* test_rados_client) override {
// copy member variables since this object might be deleted
auto _test_watch_notify = test_watch_notify;
auto _pool_id = pool_id;
+ auto _nspace = nspace;
auto _oid = oid;
- auto ctx = new FunctionContext([_test_watch_notify, _pool_id, _oid](int r) {
- _test_watch_notify->handle_object_removed(_pool_id, _oid);
+ auto ctx = new FunctionContext([_test_watch_notify, _pool_id, _nspace, _oid](int r) {
+ _test_watch_notify->handle_object_removed(_pool_id, _nspace, _oid);
});
test_rados_client->get_aio_finisher()->queue(ctx);
}
ctx.wait();
}
-int TestWatchNotify::list_watchers(int64_t pool_id, const std::string& o,
+int TestWatchNotify::list_watchers(int64_t pool_id, const std::string& nspace,
+ const std::string& o,
std::list<obj_watch_t> *out_watchers) {
Mutex::Locker lock(m_lock);
- SharedWatcher watcher = get_watcher(pool_id, o);
+ SharedWatcher watcher = get_watcher(pool_id, nspace, o);
if (!watcher) {
return -ENOENT;
}
}
int TestWatchNotify::watch(TestRadosClient *rados_client, int64_t pool_id,
- const std::string& o, uint64_t gid, uint64_t *handle,
+ const std::string& nspace, const std::string& o,
+ uint64_t gid, uint64_t *handle,
librados::WatchCtx *ctx, librados::WatchCtx2 *ctx2) {
C_SaferCond cond;
- aio_watch(rados_client, pool_id, o, gid, handle, ctx, ctx2, &cond);
+ aio_watch(rados_client, pool_id, nspace, o, gid, handle, ctx, ctx2, &cond);
return cond.wait();
}
void TestWatchNotify::aio_watch(TestRadosClient *rados_client, int64_t pool_id,
- const std::string& o, uint64_t gid,
- uint64_t *handle,
+ const std::string& nspace, const std::string& o,
+ uint64_t gid, uint64_t *handle,
librados::WatchCtx *watch_ctx,
librados::WatchCtx2 *watch_ctx2,
Context *on_finish) {
auto ctx = new FunctionContext([=](int) {
- execute_watch(rados_client, pool_id, o, gid, handle, watch_ctx,
+ execute_watch(rados_client, pool_id, nspace, o, gid, handle, watch_ctx,
watch_ctx2, on_finish);
});
rados_client->get_aio_finisher()->queue(ctx);
}
void TestWatchNotify::aio_notify(TestRadosClient *rados_client, int64_t pool_id,
+ const std::string& nspace,
const std::string& oid, const bufferlist& bl,
uint64_t timeout_ms, bufferlist *pbl,
Context *on_notify) {
auto ctx = new FunctionContext([=](int) {
- execute_notify(rados_client, pool_id, oid, bl, pbl, on_notify);
+ execute_notify(rados_client, pool_id, nspace, oid, bl, pbl, on_notify);
});
rados_client->get_aio_finisher()->queue(ctx);
}
int TestWatchNotify::notify(TestRadosClient *rados_client, int64_t pool_id,
- const std::string& oid, bufferlist& bl,
- uint64_t timeout_ms, bufferlist *pbl) {
+ const std::string& nspace, const std::string& oid,
+ bufferlist& bl, uint64_t timeout_ms,
+ bufferlist *pbl) {
C_SaferCond cond;
- aio_notify(rados_client, pool_id, oid, bl, timeout_ms, pbl, &cond);
+ aio_notify(rados_client, pool_id, nspace, oid, bl, timeout_ms, pbl, &cond);
return cond.wait();
}
void TestWatchNotify::notify_ack(TestRadosClient *rados_client, int64_t pool_id,
+ const std::string& nspace,
const std::string& o, uint64_t notify_id,
uint64_t handle, uint64_t gid,
bufferlist& bl) {
<< ", gid=" << gid << dendl;
Mutex::Locker lock(m_lock);
WatcherID watcher_id = std::make_pair(gid, handle);
- ack_notify(rados_client, pool_id, o, notify_id, watcher_id, bl);
- finish_notify(rados_client, pool_id, o, notify_id);
+ ack_notify(rados_client, pool_id, nspace, o, notify_id, watcher_id, bl);
+ finish_notify(rados_client, pool_id, nspace, o, notify_id);
}
void TestWatchNotify::execute_watch(TestRadosClient *rados_client,
- int64_t pool_id, const std::string& o,
- uint64_t gid, uint64_t *handle,
- librados::WatchCtx *ctx,
+ int64_t pool_id, const std::string& nspace,
+ const std::string& o, uint64_t gid,
+ uint64_t *handle, librados::WatchCtx *ctx,
librados::WatchCtx2 *ctx2,
Context* on_finish) {
CephContext *cct = rados_client->cct();
m_lock.Lock();
- SharedWatcher watcher = get_watcher(pool_id, o);
+ SharedWatcher watcher = get_watcher(pool_id, nspace, o);
if (!watcher) {
m_lock.Unlock();
on_finish->complete(-ENOENT);
}
TestWatchNotify::SharedWatcher TestWatchNotify::get_watcher(
- int64_t pool_id, const std::string& oid) {
+ int64_t pool_id, const std::string& nspace, const std::string& oid) {
assert(m_lock.is_locked());
- auto it = m_file_watchers.find({pool_id, oid});
+ auto it = m_file_watchers.find({pool_id, nspace, oid});
if (it == m_file_watchers.end()) {
- SharedWatcher watcher(new Watcher(pool_id, oid));
+ SharedWatcher watcher(new Watcher(pool_id, nspace, oid));
watcher->object_handler.reset(new ObjectHandler(
- this, pool_id, oid));
+ this, pool_id, nspace, oid));
int r = m_test_cluster->register_object_handler(
- pool_id, oid, watcher->object_handler.get());
+ pool_id, {nspace, oid}, watcher->object_handler.get());
if (r < 0) {
// object doesn't exist
return SharedWatcher();
}
- m_file_watchers[{pool_id, oid}] = watcher;
+ m_file_watchers[{pool_id, nspace, oid}] = watcher;
return watcher;
}
// TODO
if (watcher->watch_handles.empty() && watcher->notify_handles.empty()) {
auto pool_id = watcher->pool_id;
+ auto& nspace = watcher->nspace;
auto& oid = watcher->oid;
if (watcher->object_handler) {
- m_test_cluster->unregister_object_handler(pool_id, oid,
+ m_test_cluster->unregister_object_handler(pool_id, {nspace, oid},
watcher->object_handler.get());
watcher->object_handler.reset();
}
- m_file_watchers.erase({pool_id, oid});
+ m_file_watchers.erase({pool_id, nspace, oid});
}
}
void TestWatchNotify::execute_notify(TestRadosClient *rados_client,
- int64_t pool_id, const std::string &oid,
+ int64_t pool_id, const std::string& nspace,
+ const std::string &oid,
const bufferlist &bl, bufferlist *pbl,
Context *on_notify) {
CephContext *cct = rados_client->cct();
m_lock.Lock();
uint64_t notify_id = ++m_notify_id;
- SharedWatcher watcher = get_watcher(pool_id, oid);
+ SharedWatcher watcher = get_watcher(pool_id, nspace, oid);
if (!watcher) {
ldout(cct, 1) << "oid=" << oid << ": not found" << dendl;
m_lock.Unlock();
m_async_op_tracker.start_op();
uint64_t notifier_id = rados_client->get_instance_id();
watch_handle.rados_client->get_aio_finisher()->queue(new FunctionContext(
- [this, pool_id, oid, bl, notify_id, watch_handle, notifier_id](int r) {
+ [this, pool_id, nspace, oid, bl, notify_id, watch_handle, notifier_id](int r) {
bufferlist notify_bl;
notify_bl.append(bl);
watch_handle.watch_ctx->notify(0, 0, notify_bl);
// auto ack old-style watch/notify clients
- ack_notify(watch_handle.rados_client, pool_id, oid, notify_id,
+ ack_notify(watch_handle.rados_client, pool_id, nspace, oid, notify_id,
{watch_handle.gid, watch_handle.handle}, bufferlist());
}
}
watcher->notify_handles[notify_id] = notify_handle;
- finish_notify(rados_client, pool_id, oid, notify_id);
+ finish_notify(rados_client, pool_id, nspace, oid, notify_id);
m_lock.Unlock();
}
void TestWatchNotify::ack_notify(TestRadosClient *rados_client, int64_t pool_id,
+ const std::string& nspace,
const std::string &oid, uint64_t notify_id,
const WatcherID &watcher_id,
const bufferlist &bl) {
CephContext *cct = rados_client->cct();
assert(m_lock.is_locked());
- SharedWatcher watcher = get_watcher(pool_id, oid);
+ SharedWatcher watcher = get_watcher(pool_id, nspace, oid);
if (!watcher) {
ldout(cct, 1) << "oid=" << oid << ": not found" << dendl;
return;
}
void TestWatchNotify::finish_notify(TestRadosClient *rados_client,
- int64_t pool_id, const std::string &oid,
+ int64_t pool_id, const std::string& nspace,
+ const std::string &oid,
uint64_t notify_id) {
CephContext *cct = rados_client->cct();
ldout(cct, 20) << "oid=" << oid << ", notify_id=" << notify_id << dendl;
assert(m_lock.is_locked());
- SharedWatcher watcher = get_watcher(pool_id, oid);
+ SharedWatcher watcher = get_watcher(pool_id, nspace, oid);
assert(watcher);
NotifyHandles::iterator it = watcher->notify_handles.find(notify_id);
}
void TestWatchNotify::handle_object_removed(int64_t pool_id,
+ const std::string& nspace,
const std::string& oid) {
Mutex::Locker locker(m_lock);
- auto it = m_file_watchers.find({pool_id, oid});
+ auto it = m_file_watchers.find({pool_id, nspace, oid});
if (it == m_file_watchers.end()) {
return;
}
typedef boost::shared_ptr<ObjectHandler> SharedObjectHandler;
struct Watcher {
- Watcher(int64_t pool_id, const std::string& oid)
- : pool_id(pool_id), oid(oid) {
+ Watcher(int64_t pool_id, const std::string& nspace, const std::string& oid)
+ : pool_id(pool_id), nspace(nspace), oid(oid) {
}
int64_t pool_id;
+ std::string nspace;
std::string oid;
SharedObjectHandler object_handler;
TestWatchNotify(TestCluster* test_cluster);
- int list_watchers(int64_t pool_id, const std::string& o,
- std::list<obj_watch_t> *out_watchers);
+ int list_watchers(int64_t pool_id, const std::string& nspace,
+ const std::string& o, std::list<obj_watch_t> *out_watchers);
void aio_flush(TestRadosClient *rados_client, Context *on_finish);
void aio_watch(TestRadosClient *rados_client, int64_t pool_id,
- const std::string& o, uint64_t gid, uint64_t *handle,
- librados::WatchCtx *watch_ctx, librados::WatchCtx2 *watch_ctx2,
- Context *on_finish);
+ const std::string& nspace, const std::string& o, uint64_t gid,
+ uint64_t *handle, librados::WatchCtx *watch_ctx,
+ librados::WatchCtx2 *watch_ctx2, Context *on_finish);
void aio_unwatch(TestRadosClient *rados_client, uint64_t handle,
Context *on_finish);
void aio_notify(TestRadosClient *rados_client, int64_t pool_id,
- const std::string& oid, const bufferlist& bl,
- uint64_t timeout_ms, bufferlist *pbl, Context *on_notify);
+ const std::string& nspace, const std::string& oid,
+ const bufferlist& bl, uint64_t timeout_ms, bufferlist *pbl,
+ Context *on_notify);
void flush(TestRadosClient *rados_client);
int notify(TestRadosClient *rados_client, int64_t pool_id,
- const std::string& o, bufferlist& bl, uint64_t timeout_ms,
- bufferlist *pbl);
+ const std::string& nspace, const std::string& o, bufferlist& bl,
+ uint64_t timeout_ms, bufferlist *pbl);
void notify_ack(TestRadosClient *rados_client, int64_t pool_id,
- const std::string& o, uint64_t notify_id, uint64_t handle,
- uint64_t gid, bufferlist& bl);
+ const std::string& nspace, const std::string& o,
+ uint64_t notify_id, uint64_t handle, uint64_t gid,
+ bufferlist& bl);
int watch(TestRadosClient *rados_client, int64_t pool_id,
- const std::string& o, uint64_t gid, uint64_t *handle,
- librados::WatchCtx *ctx, librados::WatchCtx2 *ctx2);
+ const std::string& nspace, const std::string& o, uint64_t gid,
+ uint64_t *handle, librados::WatchCtx *ctx,
+ librados::WatchCtx2 *ctx2);
int unwatch(TestRadosClient *rados_client, uint64_t handle);
void blacklist(uint32_t nonce);
private:
- typedef std::pair<int64_t, std::string> PoolFile;
+ typedef std::tuple<int64_t, std::string, std::string> PoolFile;
typedef std::map<PoolFile, SharedWatcher> FileWatchers;
TestCluster *m_test_cluster;
FileWatchers m_file_watchers;
- SharedWatcher get_watcher(int64_t pool_id, const std::string& oid);
+ SharedWatcher get_watcher(int64_t pool_id, const std::string& nspace,
+ const std::string& oid);
void maybe_remove_watcher(SharedWatcher shared_watcher);
void execute_watch(TestRadosClient *rados_client, int64_t pool_id,
- const std::string& o, uint64_t gid, uint64_t *handle,
+ const std::string& nspace, const std::string& o,
+ uint64_t gid, uint64_t *handle,
librados::WatchCtx *watch_ctx,
librados::WatchCtx2 *watch_ctx2,
Context *on_finish);
Context *on_finish);
void execute_notify(TestRadosClient *rados_client, int64_t pool_id,
- const std::string &oid, const bufferlist &bl,
- bufferlist *pbl, Context *on_notify);
+ const std::string& nspace, const std::string &oid,
+ const bufferlist &bl, bufferlist *pbl,
+ Context *on_notify);
void ack_notify(TestRadosClient *rados_client, int64_t pool_id,
- const std::string &oid, uint64_t notify_id,
- const WatcherID &watcher_id, const bufferlist &bl);
+ const std::string& nspace, const std::string &oid,
+ uint64_t notify_id, const WatcherID &watcher_id,
+ const bufferlist &bl);
void finish_notify(TestRadosClient *rados_client, int64_t pool_id,
- const std::string &oid, uint64_t notify_id);
+ const std::string& nspace, const std::string &oid,
+ uint64_t notify_id);
- void handle_object_removed(int64_t pool_id, const std::string& oid);
+ void handle_object_removed(int64_t pool_id, const std::string& nspace,
+ const std::string& oid);
};
} // namespace librados