Skip to content

Commit

Permalink
neorados: allow changing underlying RadosClient
Browse files Browse the repository at this point in the history
Allow to change the RadosClient member standing behind a (neo)RADOS handle.
This will be used for re-directing a librbd ImageCtx to migrate from an external ceph cluster.

Signed-off-by: Or Ozeri <[email protected]>
  • Loading branch information
orozery committed Jan 14, 2022
1 parent e28c26d commit 1221525
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/include/neorados/RADOS.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,8 @@ class RADOS final

~RADOS();

void dup_from_librados(librados::Rados& rados);

CephContext* cct();

using executor_type = boost::asio::io_context::executor_type;
Expand Down
4 changes: 4 additions & 0 deletions src/neorados/RADOS.cc
Original file line number Diff line number Diff line change
Expand Up @@ -789,6 +789,10 @@ RADOS& RADOS::operator =(RADOS&&) = default;

RADOS::~RADOS() = default;

void RADOS::dup_from_librados(librados::Rados& rados) {
impl.reset(new detail::RadosClient(rados.client));
}

RADOS::executor_type RADOS::get_executor() const {
return impl->ioctx.get_executor();
}
Expand Down
6 changes: 6 additions & 0 deletions src/test/librados_test_stub/NeoradosTestStub.cc
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,12 @@ RADOS RADOS::make_with_librados(librados::Rados& rados) {
return RADOS{std::make_unique<detail::Client>(test_rados_client)};
}

void RADOS::dup_from_librados(librados::Rados& rados) {
auto test_rados_client = reinterpret_cast<librados::TestRadosClient*>(
rados.client);
impl.reset(new detail::Client(test_rados_client));
}

CephContext* neorados::RADOS::cct() {
return impl->test_rados_client->cct();
}
Expand Down

0 comments on commit 1221525

Please sign in to comment.