#include "include/common_fwd.h"
#include "include/buffer.h"
+#include "include/rados/librados_fwd.hpp"
#include "common/ceph_time.h"
return init.result.get();
}
+ static RADOS make_with_librados(librados::Rados& rados);
+
RADOS(const RADOS&) = delete;
RADOS& operator =(const RADOS&) = delete;
class RadosStriper;
}
+namespace neorados { class RADOS; }
+
namespace librados {
using ceph::bufferlist;
callback_t cb_safe)
__attribute__ ((deprecated));
static AioCompletion *aio_create_completion(void *cb_arg, callback_t cb_complete);
-
+
friend std::ostream& operator<<(std::ostream &oss, const Rados& r);
private:
+ friend class neorados::RADOS;
+
// We don't allow assignment or copying
Rados(const Rados& rhs);
const Rados& operator=(const Rados& rhs);
class Messenger;
class AioCompletionImpl;
+namespace neorados { namespace detail { class RadosClient; }}
+
class librados::RadosClient : public Dispatcher,
public md_config_obs_t
{
+ friend neorados::detail::RadosClient;
public:
using Dispatcher::cct;
private:
}
}
+RADOS RADOS::make_with_librados(librados::Rados& rados) {
+ return RADOS{std::make_unique<detail::RadosClient>(rados.client)};
+}
RADOS::RADOS() = default;
* Foundation. See file COPYING.
*
*/
-#ifndef CEPH_LIBRADOS_RADOSCLIENT_H
-#define CEPH_LIBRADOS_RADOSCLIENT_H
+#ifndef CEPH_NEORADOS_RADOSIMPL_H
+#define CEPH_NEORADOS_RADOSIMPL_H
#include <functional>
#include <memory>
#include "common/ceph_context.h"
#include "common/ceph_mutex.h"
+#include "librados/RadosClient.h"
+
#include "mon/MonClient.h"
#include "mgr/MgrClient.h"
mon_feature_t get_required_monitor_features() const {
return monclient.with_monmap(std::mem_fn(&MonMap::get_required_features));
}
- int get_instance_id() const {
- return instance_id;
- }
};
class Client {
}
int get_instance_id() const override {
- return rados->get_instance_id();
+ return rados->instance_id;
}
private:
std::unique_ptr<RADOS> rados;
};
+class RadosClient : public Client {
+public:
+ RadosClient(librados::RadosClient* rados_client)
+ : Client(rados_client->poolctx, {rados_client->cct},
+ rados_client->monclient, rados_client->objecter),
+ rados_client(rados_client) {
+ }
+
+ int get_instance_id() const override {
+ return rados_client->instance_id;
+ }
+
+public:
+ librados::RadosClient* rados_client;
+};
+
} // namespace detail
} // namespace neorados
+
+add_executable(ceph_test_neorados test_neorados.cc)
+target_link_libraries(ceph_test_neorados global libneorados
+ ${unittest_libs}
+ radostest
+ radostest-cxx
+ librados
+ GTest::GTest)
+
add_executable(ceph_test_neorados_start_stop start_stop.cc)
target_link_libraries(ceph_test_neorados_start_stop global libneorados
${unittest_libs})
--- /dev/null
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
+// vim: ts=8 sw=2 smarttab
+
+#include "include/rados/librados.hpp"
+#include "include/neorados/RADOS.hpp"
+#include "common/async/blocked_completion.h"
+#include "test/librados/test_cxx.h"
+#include "gtest/gtest.h"
+#include <iostream>
+
+namespace neorados {
+
+class TestNeoRADOS : public ::testing::Test {
+public:
+ TestNeoRADOS() {
+ }
+};
+
+TEST_F(TestNeoRADOS, MakeWithLibRADOS) {
+ librados::Rados paleo_rados;
+ auto result = connect_cluster_pp(paleo_rados);
+ ASSERT_EQ("", result);
+
+ auto rados = RADOS::make_with_librados(paleo_rados);
+
+ ReadOp op;
+ bufferlist bl;
+ op.read(0, 0, &bl);
+
+ // provide pool that doesn't exists -- just testing round-trip
+ ASSERT_THROW(
+ rados.execute({"dummy-obj"}, std::numeric_limits<int64_t>::max(),
+ std::move(op), nullptr, ceph::async::use_blocked),
+ boost::system::system_error);
+}
+
+} // namespace neorados
+
+int main(int argc, char **argv) {
+ ::testing::InitGoogleTest(&argc, argv);
+
+ int seed = getpid();
+ std::cout << "seed " << seed << std::endl;
+ srand(seed);
+
+ return RUN_ALL_TESTS();
+}