#include "common/errno.h"
#include "include/buffer.h"
#include "include/stringify.h"
+#include "include/util.h"
#include "messages/MLog.h"
#include "msg/Messenger.h"
monclient.sub_want("mgrmap", 0, 0);
monclient.renew_subs();
+ if (service_daemon) {
+ ldout(cct, 10) << __func__ << " registering as " << service_name << "."
+ << daemon_name << dendl;
+ mgrclient.service_daemon_register(service_name, daemon_name,
+ daemon_metadata);
+ }
mgrclient.init();
objecter->set_client_incarnation(0);
const bufferlist &inbl,
bufferlist *outbl, string *outs)
{
- Mutex mylock("RadosClient::mon_command::mylock");
- Cond cond;
- bool done;
- int rval;
+ C_SaferCond ctx;
+ mon_command_async(cmd, inbl, outbl, outs, &ctx);
+ return ctx.wait();
+}
+
+void librados::RadosClient::mon_command_async(const vector<string>& cmd,
+ const bufferlist &inbl,
+ bufferlist *outbl, string *outs,
+ Context *on_finish)
+{
lock.Lock();
- monclient.start_mon_command(cmd, inbl, outbl, outs,
- new C_SafeCond(&mylock, &cond, &done, &rval));
+ monclient.start_mon_command(cmd, inbl, outbl, outs, on_finish);
lock.Unlock();
- mylock.Lock();
- while (!done)
- cond.Wait(mylock);
- mylock.Unlock();
- return rval;
}
-
int librados::RadosClient::mgr_command(const vector<string>& cmd,
const bufferlist &inbl,
bufferlist *outbl, string *outs)
stamp.tv_sec, stamp.tv_nsec,
e.seq, level.c_str(), e.msg.c_str());
if (log_cb2)
- log_cb2(log_cb_arg, line.c_str(), who.c_str(), name.c_str(),
+ log_cb2(log_cb_arg, line.c_str(),
+ e.channel.c_str(),
+ who.c_str(), name.c_str(),
stamp.tv_sec, stamp.tv_nsec,
e.seq, level.c_str(), e.msg.c_str());
}
m->put();
}
+
+int librados::RadosClient::service_daemon_register(
+ const std::string& service, ///< service name (e.g., 'rgw')
+ const std::string& name, ///< daemon name (e.g., 'gwfoo')
+ const std::map<std::string,std::string>& metadata)
+{
+ if (service_daemon) {
+ return -EEXIST;
+ }
+ if (service == "osd" ||
+ service == "mds" ||
+ service == "client" ||
+ service == "mon" ||
+ service == "mgr") {
+ // normal ceph entity types are not allowed!
+ return -EINVAL;
+ }
+ if (service.empty() || name.empty()) {
+ return -EINVAL;
+ }
+
+ collect_sys_info(&daemon_metadata, cct);
+
+ ldout(cct,10) << __func__ << " " << service << "." << name << dendl;
+ service_daemon = true;
+ service_name = service;
+ daemon_name = name;
+ daemon_metadata.insert(metadata.begin(), metadata.end());
+
+ if (state == DISCONNECTED) {
+ return 0;
+ }
+ if (state == CONNECTING) {
+ return -EBUSY;
+ }
+ mgrclient.service_daemon_register(service_name, daemon_name,
+ daemon_metadata);
+ return 0;
+}
+
+int librados::RadosClient::service_daemon_update_status(
+ const std::map<std::string,std::string>& status)
+{
+ if (state != CONNECTED) {
+ return -ENOTCONN;
+ }
+ return mgrclient.service_daemon_update_status(status);
+}
+
+mon_feature_t librados::RadosClient::get_required_monitor_features() const
+{
+ return monclient.monmap.get_required_features();
+}