using ceph::bufferlist;
using ceph::HeartbeatMap;
+#ifdef WITH_SEASTAR
+CephContext::CephContext()
+ : _conf{ceph::common::local_conf()},
+ _crypto_random{std::make_unique<CryptoRandom>()}
+{}
+
+// define the dtor in .cc as CryptoRandom is an incomplete type in the header
+CephContext::~CephContext()
+{}
+
+CryptoRandom* CephContext::random() const
+{
+ return _crypto_random.get();
+}
+
+CephContext* CephContext::get()
+{
+ ++nref;
+ return this;
+}
+
+void CephContext::put()
+{
+ if (--nref == 0) {
+ delete this;
+ }
+}
+
+PerfCountersCollection* CephContext::get_perfcounters_collection()
+{
+ throw std::runtime_error("not yet implemented");
+}
+
+#else // WITH_SEASTAR
namespace {
class LockdepObs : public md_config_obs_t {
for (auto &&t : _fork_watchers)
t->handle_post_fork();
}
+#endif // WITH_SEASTAR
#include "common/cmdparse.h"
#include "common/code_environment.h"
+#ifdef WITH_SEASTAR
+#include "crimson/common/config_proxy.h"
+#else
#include "common/config_proxy.h"
-
#include "include/spinlock.h"
+#endif
+
#include "crush/CrushLocation.h"
}
}
+#ifdef WITH_SEASTAR
+class CephContext {
+public:
+ CephContext();
+ CephContext(uint32_t,
+ code_environment_t=CODE_ENVIRONMENT_UTILITY,
+ int = 0)
+ : CephContext{}
+ {}
+ ~CephContext();
+
+ CryptoRandom* random() const;
+ PerfCountersCollection* get_perfcounters_collection();
+ ceph::common::ConfigProxy& _conf;
+
+ CephContext* get();
+ void put();
+private:
+ std::unique_ptr<CryptoRandom> _crypto_random;
+ unsigned nref;
+};
+#else
/* A CephContext represents the context held by a single library user.
* There can be multiple CephContexts in the same process.
*
friend class CephContextServiceThread;
CephContextServiceThread *_service_thread;
+ using md_config_obs_t = ceph::md_config_obs_impl<ConfigProxy>;
+
md_config_obs_t *_log_obs;
/* The admin socket associated with this context */
friend class CephContextObs;
};
+#endif // WITH_SEASTAR
#endif
#define _STR(x) #x
#define STRINGIFY(x) _STR(x)
+#ifndef WITH_SEASTAR
CephContext *common_preinit(const CephInitParameters &iparams,
enum code_environment_t code_env, int flags)
{
return cct;
}
+#endif // #ifndef WITH_SEASTAR
void complain_about_parse_errors(CephContext *cct,
std::deque<std::string> *parse_errors)
}
}
+#ifndef WITH_SEASTAR
+
/* Please be sure that this can safely be called multiple times by the
* same application. */
void common_init_finish(CephContext *cct)
}
}
}
+
+#endif // #ifndef WITH_SEASTAR
#include "common/code_environment.h"
class CephContext;
-class CephInitParameters;
enum common_init_flags_t {
// Set up defaults that make sense for an unprivileged daemon
CINIT_FLAG_NO_MON_CONFIG = 0x20,
};
+#ifndef WITH_SEASTAR
+class CephInitParameters;
+
/*
* NOTE: If you are writing a Ceph daemon, ignore this function and call
* global_init instead. It will call common_preinit for you.
*/
CephContext *common_preinit(const CephInitParameters &iparams,
enum code_environment_t code_env, int flags);
+#endif // #ifndef WITH_SEASTAR
/* Print out some parse errors. */
void complain_about_parse_errors(CephContext *cct,
std::deque<std::string> *parse_errors);
+#ifndef WITH_SEASTAR
/* This function is called after you have done your last
* fork. When you make this call, the system will initialize everything that
* cannot be initialized before a fork.
* the Ceph libraries would be destroyed by a fork().
*/
void common_init_finish(CephContext *cct);
+#endif // #ifndef WITH_SEASTAR
#endif
*/
CephContext *g_ceph_context = NULL;
ConfigProxy& g_conf() {
+#ifdef WITH_SEASTAR
+ return ceph::common::local_conf();
+#else
return g_ceph_context->_conf;
+#endif
}
const char *g_assert_file = 0;