From: Joao Eduardo Luis Date: Wed, 4 Feb 2015 17:46:28 +0000 (+0000) Subject: mon: MonOpRequest: have the monitor dealing with operations X-Git-Tag: v9.1.0~535^2~44 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=203cb6ad45cce8f7c7843e4e0a441b6c3b5d643a;p=ceph.git mon: MonOpRequest: have the monitor dealing with operations Deal with op requests throughout the monitor state machine, instead of Messages. These op requests implement TrackedOp, which will be trackable by the monitor via a OpTracker. This will allow us to follow the operation's life cycle, for the duration of any given operation. Signed-off-by: Joao Eduardo Luis --- diff --git a/src/mon/Makefile.am b/src/mon/Makefile.am index e622be124956..ee6542d42d51 100644 --- a/src/mon/Makefile.am +++ b/src/mon/Makefile.am @@ -39,6 +39,7 @@ noinst_HEADERS += \ mon/MonMap.h \ mon/Monitor.h \ mon/MonitorDBStore.h \ + mon/MonOpRequest.h \ mon/OSDMonitor.h \ mon/PGMap.h \ mon/PGMonitor.h \ diff --git a/src/mon/MonOpRequest.h b/src/mon/MonOpRequest.h new file mode 100644 index 000000000000..810158467bf4 --- /dev/null +++ b/src/mon/MonOpRequest.h @@ -0,0 +1,100 @@ +// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- +// vim: ts=8 sw=2 smarttab +/* + * Ceph - scalable distributed file system + * + * Copyright (C) 2015 Red Hat + * + * This is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License version 2.1, as published by the Free Software + * Foundation. See file COPYING. + */ + +#ifndef MON_OPREQUEST_H_ +#define MON_OPREQUEST_H_ +#include +#include + +#include "common/TrackedOp.h" +#include "include/memory.h" +#include "mon/Session.h" +#include "msg/Message.h" + +struct MonOpRequest : public TrackedOp { + friend class OpTracker; + +private: + Message *request; + utime_t dequeued_time; + MonSession *session; + ConnectionRef con; + + MonOpRequest(Message *req, OpTracker *tracker) : + TrackedOp(tracker, req->get_recv_stamp()), + request(req->get()), + session(NULL), + con(NULL) + { + tracker->mark_event(this, "header_read", request->get_recv_stamp()); + tracker->mark_event(this, "throttled", request->get_throttle_stamp()); + tracker->mark_event(this, "all_read", request->get_recv_complete_stamp()); + tracker->mark_event(this, "dispatched", request->get_dispatch_stamp()); + + if (req) { + con = req->get_connection(); + if (con) { + session = static_cast(con->get_priv()); + } + } + } + +protected: + void _dump_op_descriptor_unlocked(ostream& stream) const { + get_req()->print(stream); + } + +public: + ~MonOpRequest() { + request->put(); + // certain ops may not have a session (e.g., AUTH or PING) + if (session) + session->put(); + } + + MonSession *get_session() const { + if (!session) + return NULL; + return (MonSession*)session->get(); + } + + template + T *get_req() const { return static_cast(request); } + + Message *get_req() const { return get_req(); } + + ConnectionRef get_connection() { return con; } + + void set_session(MonSession *s) { + if (session) { + // we will be rewriting the existing session; drop the ref. + session->put(); + } + + if (s == NULL) { + session = NULL; + } else { + session = static_cast(s->get()); + } + } + + bool is_src_mon() const { + return (con && con->get_peer_type() & CEPH_ENTITY_TYPE_MON); + } + + typedef ceph::shared_ptr Ref; +}; + +typedef MonOpRequest::Ref MonOpRequestRef; + +#endif /* MON_OPREQUEST_H_ */