From: Sage Weil Date: Mon, 30 Jan 2012 21:28:44 +0000 (-0800) Subject: msg: go const-crazy on messages X-Git-Tag: v0.44~93^2~43 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=9987f8f95cf2e6f9d7619e50a8b7742762d974ee;p=ceph.git msg: go const-crazy on messages - get_type_name() - print() and all the random crap they call. Signed-off-by: Sage Weil --- diff --git a/src/messages/MAuth.h b/src/messages/MAuth.h index d7922ebe35db..40a7fa5e3ea4 100644 --- a/src/messages/MAuth.h +++ b/src/messages/MAuth.h @@ -29,8 +29,8 @@ private: ~MAuth() {} public: - const char *get_type_name() { return "auth"; } - void print(ostream& out) { + const char *get_type_name() const { return "auth"; } + void print(ostream& out) const { out << "auth(proto " << protocol << " " << auth_payload.length() << " bytes" << " epoch " << monmap_epoch << ")"; } diff --git a/src/messages/MAuthReply.h b/src/messages/MAuthReply.h index 31c1f993a356..8704346dc760 100644 --- a/src/messages/MAuthReply.h +++ b/src/messages/MAuthReply.h @@ -36,8 +36,8 @@ private: ~MAuthReply() {} public: - const char *get_type_name() { return "auth_reply"; } - void print(ostream& o) { + const char *get_type_name() const { return "auth_reply"; } + void print(ostream& o) const { char buf[80]; o << "auth_reply(proto " << protocol << " " << result << " " << strerror_r(-result, buf, sizeof(buf)); if (result_msg.length()) diff --git a/src/messages/MCacheExpire.h b/src/messages/MCacheExpire.h index db6eda4559e1..c88583a19524 100644 --- a/src/messages/MCacheExpire.h +++ b/src/messages/MCacheExpire.h @@ -53,7 +53,7 @@ private: ~MCacheExpire() {} public: - virtual const char *get_type_name() { return "cache_expire";} + virtual const char *get_type_name() const { return "cache_expire";} void add_inode(dirfrag_t r, vinodeno_t vino, int nonce) { realms[r].inodes[vino] = nonce; diff --git a/src/messages/MClientCapRelease.h b/src/messages/MClientCapRelease.h index 1843b1849a40..5258c5d970f7 100644 --- a/src/messages/MClientCapRelease.h +++ b/src/messages/MClientCapRelease.h @@ -31,8 +31,8 @@ private: ~MClientCapRelease() {} public: - const char *get_type_name() { return "client_cap_release";} - void print(ostream& out) { + const char *get_type_name() const { return "client_cap_release";} + void print(ostream& out) const { out << "client_cap_release(" << head.num << ")"; } diff --git a/src/messages/MClientCaps.h b/src/messages/MClientCaps.h index 3aecfe2b235b..d515304f93e6 100644 --- a/src/messages/MClientCaps.h +++ b/src/messages/MClientCaps.h @@ -106,8 +106,8 @@ private: ~MClientCaps() {} public: - const char *get_type_name() { return "Cfcap";} - void print(ostream& out) { + const char *get_type_name() const { return "Cfcap";} + void print(ostream& out) const { out << "client_caps(" << ceph_cap_op_name(head.op) << " ino " << inodeno_t(head.ino) << " " << head.cap_id diff --git a/src/messages/MClientLease.h b/src/messages/MClientLease.h index 0470ad9f67a5..2b80c2ad234e 100644 --- a/src/messages/MClientLease.h +++ b/src/messages/MClientLease.h @@ -22,12 +22,12 @@ struct MClientLease : public Message { struct ceph_mds_lease h; string dname; - int get_action() { return h.action; } - ceph_seq_t get_seq() { return h.seq; } - int get_mask() { return h.mask; } - inodeno_t get_ino() { return inodeno_t(h.ino); } - snapid_t get_first() { return snapid_t(h.first); } - snapid_t get_last() { return snapid_t(h.last); } + int get_action() const { return h.action; } + ceph_seq_t get_seq() const { return h.seq; } + int get_mask() const { return h.mask; } + inodeno_t get_ino() const { return inodeno_t(h.ino); } + snapid_t get_first() const { return snapid_t(h.first); } + snapid_t get_last() const { return snapid_t(h.last); } MClientLease() : Message(CEPH_MSG_CLIENT_LEASE) {} MClientLease(int ac, ceph_seq_t seq, int m, uint64_t i, uint64_t sf, uint64_t sl) : @@ -55,8 +55,8 @@ private: ~MClientLease() {} public: - const char *get_type_name() { return "client_lease"; } - void print(ostream& out) { + const char *get_type_name() const { return "client_lease"; } + void print(ostream& out) const { out << "client_lease(a=" << ceph_lease_op_name(get_action()) << " seq " << get_seq() << " mask " << get_mask(); diff --git a/src/messages/MClientReconnect.h b/src/messages/MClientReconnect.h index 175aff0b1b19..aef97ee46df6 100644 --- a/src/messages/MClientReconnect.h +++ b/src/messages/MClientReconnect.h @@ -30,8 +30,8 @@ private: ~MClientReconnect() {} public: - const char *get_type_name() { return "client_reconnect"; } - void print(ostream& out) { + const char *get_type_name() const { return "client_reconnect"; } + void print(ostream& out) const { out << "client_reconnect(" << caps.size() << " caps)"; } diff --git a/src/messages/MClientReply.h b/src/messages/MClientReply.h index 05d96cb36759..ee3dbb92a4fb 100644 --- a/src/messages/MClientReply.h +++ b/src/messages/MClientReply.h @@ -186,18 +186,18 @@ public: bufferlist snapbl; public: - int get_op() { return head.op; } + int get_op() const { return head.op; } void set_mdsmap_epoch(epoch_t e) { head.mdsmap_epoch = e; } - epoch_t get_mdsmap_epoch() { return head.mdsmap_epoch; } + epoch_t get_mdsmap_epoch() const { return head.mdsmap_epoch; } - int get_result() { return (__s32)(__u32)head.result; } + int get_result() const { return (__s32)(__u32)head.result; } void set_result(int r) { head.result = r; } void set_unsafe() { head.safe = 0; } - bool is_safe() { return head.safe; } + bool is_safe() const { return head.safe; } MClientReply() {} MClientReply(MClientRequest *req, int result = 0) : @@ -212,8 +212,8 @@ private: ~MClientReply() {} public: - const char *get_type_name() { return "creply"; } - void print(ostream& o) { + const char *get_type_name() const { return "creply"; } + void print(ostream& o) const { o << "client_reply(???:" << get_tid(); o << " = " << get_result(); if (get_result() <= 0) { diff --git a/src/messages/MClientRequest.h b/src/messages/MClientRequest.h index 2e27382a7399..4e61fa48c35b 100644 --- a/src/messages/MClientRequest.h +++ b/src/messages/MClientRequest.h @@ -104,7 +104,7 @@ public: (head.op == CEPH_MDS_OP_CREATE); } - int get_flags() { + int get_flags() const { return head.flags; } bool is_replay() { @@ -127,17 +127,17 @@ public: head.flags = head.flags | CEPH_MDS_FLAG_REPLAY; } - tid_t get_oldest_client_tid() { return head.oldest_client_tid; } - int get_num_fwd() { return head.num_fwd; } - int get_retry_attempt() { return head.num_retry; } - int get_op() { return head.op; } - unsigned get_caller_uid() { return head.caller_uid; } - unsigned get_caller_gid() { return head.caller_gid; } - - const string& get_path() { return path.get_path(); } - filepath& get_filepath() { return path; } - const string& get_path2() { return path2.get_path(); } - filepath& get_filepath2() { return path2; } + tid_t get_oldest_client_tid() const { return head.oldest_client_tid; } + int get_num_fwd() const { return head.num_fwd; } + int get_retry_attempt() const { return head.num_retry; } + int get_op() const { return head.op; } + unsigned get_caller_uid() const { return head.caller_uid; } + unsigned get_caller_gid() const { return head.caller_gid; } + + const string& get_path() const { return path.get_path(); } + const filepath& get_filepath() const { return path; } + const string& get_path2() const { return path2.get_path(); } + const filepath& get_filepath2() const { return path2; } int get_dentry_wanted() { return get_flags() & CEPH_MDS_FLAG_WANT_DENTRY; } @@ -157,8 +157,8 @@ public: ::encode_nohead(releases, payload); } - const char *get_type_name() { return "creq"; } - void print(ostream& out) { + const char *get_type_name() const { return "creq"; } + void print(ostream& out) const { out << "client_request(" << get_orig_source() << ":" << get_tid() << " " << ceph_mds_op_name(get_op()); diff --git a/src/messages/MClientRequestForward.h b/src/messages/MClientRequestForward.h index 814534cc6da9..c212a4a30e99 100644 --- a/src/messages/MClientRequestForward.h +++ b/src/messages/MClientRequestForward.h @@ -37,8 +37,8 @@ public: int get_num_fwd() { return num_fwd; } bool must_resend() { return client_must_resend; } - const char *get_type_name() { return "client_request_forward"; } - void print(ostream& o) { + const char *get_type_name() const { return "client_request_forward"; } + void print(ostream& o) const { o << "client_request_forward(" << get_tid() << " to mds." << dest_mds << " num_fwd=" << num_fwd diff --git a/src/messages/MClientSession.h b/src/messages/MClientSession.h index cd516495c673..4b98a983b0f1 100644 --- a/src/messages/MClientSession.h +++ b/src/messages/MClientSession.h @@ -21,11 +21,11 @@ class MClientSession : public Message { public: ceph_mds_session_head head; - int get_op() { return head.op; } - version_t get_seq() { return head.seq; } - utime_t get_stamp() { return utime_t(head.stamp); } - int get_max_caps() { return head.max_caps; } - int get_max_leases() { return head.max_leases; } + int get_op() const { return head.op; } + version_t get_seq() const { return head.seq; } + utime_t get_stamp() const { return utime_t(head.stamp); } + int get_max_caps() const { return head.max_caps; } + int get_max_leases() const { return head.max_leases; } MClientSession() : Message(CEPH_MSG_CLIENT_SESSION) { } MClientSession(int o, version_t s=0) : @@ -45,8 +45,8 @@ private: ~MClientSession() {} public: - const char *get_type_name() { return "client_session"; } - void print(ostream& out) { + const char *get_type_name() const { return "client_session"; } + void print(ostream& out) const { out << "client_session(" << ceph_session_op_name(get_op()); if (get_seq()) out << " seq " << get_seq(); diff --git a/src/messages/MClientSnap.h b/src/messages/MClientSnap.h index d7d0383d6a9f..7f7283e3405e 100644 --- a/src/messages/MClientSnap.h +++ b/src/messages/MClientSnap.h @@ -34,8 +34,8 @@ private: ~MClientSnap() {} public: - const char *get_type_name() { return "client_snap"; } - void print(ostream& out) { + const char *get_type_name() const { return "client_snap"; } + void print(ostream& out) const { out << "client_snap(" << ceph_snap_op_name(head.op); if (head.split) out << " split=" << inodeno_t(head.split); diff --git a/src/messages/MCommand.h b/src/messages/MCommand.h index 4d2af0473b55..e2fe0752f34f 100644 --- a/src/messages/MCommand.h +++ b/src/messages/MCommand.h @@ -35,8 +35,8 @@ private: ~MCommand() {} public: - const char *get_type_name() { return "command"; } - void print(ostream& o) { + const char *get_type_name() const { return "command"; } + void print(ostream& o) const { o << "command(tid " << get_tid() << ": "; for (unsigned i=0; i& get_dir_rep_by() { return dir_rep_by; } - bool should_discover() { return discover > 0; } - filepath& get_path() { return path; } + int get_source_mds() const { return from_mds; } + dirfrag_t get_dirfrag() const { return dirfrag; } + int get_dir_rep() const { return dir_rep; } + const set& get_dir_rep_by() const { return dir_rep_by; } + bool should_discover() const { return discover > 0; } + const filepath& get_path() const { return path; } void tried_discover() { if (discover) discover--; @@ -57,8 +57,8 @@ private: ~MDirUpdate() {} public: - const char *get_type_name() { return "dir_update"; } - void print(ostream& out) { + const char *get_type_name() const { return "dir_update"; } + void print(ostream& out) const { out << "dir_update(" << get_dirfrag() << ")"; } diff --git a/src/messages/MDiscover.h b/src/messages/MDiscover.h index b993c82eea09..937b51ec92f0 100644 --- a/src/messages/MDiscover.h +++ b/src/messages/MDiscover.h @@ -69,8 +69,8 @@ private: ~MDiscover() {} public: - const char *get_type_name() { return "Dis"; } - void print(ostream &out) { + const char *get_type_name() const { return "Dis"; } + void print(ostream &out) const { out << "discover(" << header.tid << " " << base_ino << "." << base_dir_frag << " " << want; if (want_ino) diff --git a/src/messages/MDiscoverReply.h b/src/messages/MDiscoverReply.h index 4d3c60e55054..0b424157a68e 100644 --- a/src/messages/MDiscoverReply.h +++ b/src/messages/MDiscoverReply.h @@ -146,8 +146,8 @@ private: ~MDiscoverReply() {} public: - const char *get_type_name() { return "discover_reply"; } - void print(ostream& out) { + const char *get_type_name() const { return "discover_reply"; } + void print(ostream& out) const { out << "discover_reply(" << header.tid << " " << base_ino << ")"; } diff --git a/src/messages/MExportCaps.h b/src/messages/MExportCaps.h index 167af27cbe45..dcb2298eebb3 100644 --- a/src/messages/MExportCaps.h +++ b/src/messages/MExportCaps.h @@ -31,8 +31,8 @@ private: ~MExportCaps() {} public: - const char *get_type_name() { return "export_caps"; } - void print(ostream& o) { + const char *get_type_name() const { return "export_caps"; } + void print(ostream& o) const { o << "export_caps(" << ino << ")"; } diff --git a/src/messages/MExportCapsAck.h b/src/messages/MExportCapsAck.h index 623fb2b7a145..b8fcf1fa9caa 100644 --- a/src/messages/MExportCapsAck.h +++ b/src/messages/MExportCapsAck.h @@ -31,8 +31,8 @@ private: ~MExportCapsAck() {} public: - const char *get_type_name() { return "export_caps_ack"; } - void print(ostream& o) { + const char *get_type_name() const { return "export_caps_ack"; } + void print(ostream& o) const { o << "export_caps_ack(" << ino << ")"; } diff --git a/src/messages/MExportDir.h b/src/messages/MExportDir.h index c8542985a205..4f74e7a926ee 100644 --- a/src/messages/MExportDir.h +++ b/src/messages/MExportDir.h @@ -35,8 +35,8 @@ private: ~MExportDir() {} public: - const char *get_type_name() { return "Ex"; } - void print(ostream& o) { + const char *get_type_name() const { return "Ex"; } + void print(ostream& o) const { o << "export(" << dirfrag << ")"; } diff --git a/src/messages/MExportDirAck.h b/src/messages/MExportDirAck.h index 13ff47d21e1f..8ad79d9f9618 100644 --- a/src/messages/MExportDirAck.h +++ b/src/messages/MExportDirAck.h @@ -30,8 +30,8 @@ private: ~MExportDirAck() {} public: - const char *get_type_name() { return "ExAck"; } - void print(ostream& o) { + const char *get_type_name() const { return "ExAck"; } + void print(ostream& o) const { o << "export_ack(" << dirfrag << ")"; } diff --git a/src/messages/MExportDirCancel.h b/src/messages/MExportDirCancel.h index e87775436cef..52f7b124fa94 100644 --- a/src/messages/MExportDirCancel.h +++ b/src/messages/MExportDirCancel.h @@ -32,8 +32,8 @@ private: ~MExportDirCancel() {} public: - const char *get_type_name() { return "ExCancel"; } - void print(ostream& o) { + const char *get_type_name() const { return "ExCancel"; } + void print(ostream& o) const { o << "export_cancel(" << dirfrag << ")"; } diff --git a/src/messages/MExportDirDiscover.h b/src/messages/MExportDirDiscover.h index e8276f97ba0d..7602bd91ee97 100644 --- a/src/messages/MExportDirDiscover.h +++ b/src/messages/MExportDirDiscover.h @@ -45,8 +45,8 @@ private: ~MExportDirDiscover() {} public: - const char *get_type_name() { return "ExDis"; } - void print(ostream& o) { + const char *get_type_name() const { return "ExDis"; } + void print(ostream& o) const { o << "export_discover(" << dirfrag << " " << path << ")"; } diff --git a/src/messages/MExportDirDiscoverAck.h b/src/messages/MExportDirDiscoverAck.h index 79cd6c74fe02..2aafc7400b8b 100644 --- a/src/messages/MExportDirDiscoverAck.h +++ b/src/messages/MExportDirDiscoverAck.h @@ -36,8 +36,8 @@ private: ~MExportDirDiscoverAck() {} public: - const char *get_type_name() { return "ExDisA"; } - void print(ostream& o) { + const char *get_type_name() const { return "ExDisA"; } + void print(ostream& o) const { o << "export_discover_ack(" << dirfrag; if (success) o << " success)"; diff --git a/src/messages/MExportDirFinish.h b/src/messages/MExportDirFinish.h index b97902de9322..6d05885f3e0b 100644 --- a/src/messages/MExportDirFinish.h +++ b/src/messages/MExportDirFinish.h @@ -32,8 +32,8 @@ private: ~MExportDirFinish() {} public: - const char *get_type_name() { return "ExFin"; } - void print(ostream& o) { + const char *get_type_name() const { return "ExFin"; } + void print(ostream& o) const { o << "export_finish(" << dirfrag << ")"; } diff --git a/src/messages/MExportDirNotify.h b/src/messages/MExportDirNotify.h index 4b141ba1144f..a209901d48b4 100644 --- a/src/messages/MExportDirNotify.h +++ b/src/messages/MExportDirNotify.h @@ -40,8 +40,8 @@ private: ~MExportDirNotify() {} public: - const char *get_type_name() { return "ExNot"; } - void print(ostream& o) { + const char *get_type_name() const { return "ExNot"; } + void print(ostream& o) const { o << "export_notify(" << base; o << " " << old_auth << " -> " << new_auth; if (ack) diff --git a/src/messages/MExportDirNotifyAck.h b/src/messages/MExportDirNotifyAck.h index a3d91366ddf7..35a6956185be 100644 --- a/src/messages/MExportDirNotifyAck.h +++ b/src/messages/MExportDirNotifyAck.h @@ -34,8 +34,8 @@ private: ~MExportDirNotifyAck() {} public: - const char *get_type_name() { return "ExNotA"; } - void print(ostream& o) { + const char *get_type_name() const { return "ExNotA"; } + void print(ostream& o) const { o << "export_notify_ack(" << dirfrag << ")"; } diff --git a/src/messages/MExportDirPrep.h b/src/messages/MExportDirPrep.h index c45236d20d53..12f358ece037 100644 --- a/src/messages/MExportDirPrep.h +++ b/src/messages/MExportDirPrep.h @@ -48,8 +48,8 @@ private: ~MExportDirPrep() {} public: - const char *get_type_name() { return "ExP"; } - void print(ostream& o) { + const char *get_type_name() const { return "ExP"; } + void print(ostream& o) const { o << "export_prep(" << dirfrag << ")"; } diff --git a/src/messages/MExportDirPrepAck.h b/src/messages/MExportDirPrepAck.h index 0593fc5aa73e..b5d180d5765b 100644 --- a/src/messages/MExportDirPrepAck.h +++ b/src/messages/MExportDirPrepAck.h @@ -32,8 +32,8 @@ private: ~MExportDirPrepAck() {} public: - const char *get_type_name() { return "ExPAck"; } - void print(ostream& o) { + const char *get_type_name() const { return "ExPAck"; } + void print(ostream& o) const { o << "export_prep_ack(" << dirfrag << ")"; } diff --git a/src/messages/MForward.h b/src/messages/MForward.h index 77f71b5086d9..34a800408f2d 100644 --- a/src/messages/MForward.h +++ b/src/messages/MForward.h @@ -61,8 +61,8 @@ public: msg = (PaxosServiceMessage *)decode_message(NULL, p); } - const char *get_type_name() { return "forward"; } - void print(ostream& o) { + const char *get_type_name() const { return "forward"; } + void print(ostream& o) const { if (msg) o << "forward(" << *msg << ") to leader"; else o << "forward(??? ) to leader"; diff --git a/src/messages/MGenericMessage.h b/src/messages/MGenericMessage.h index 13ce98eb6e4d..e042bef00c8b 100644 --- a/src/messages/MGenericMessage.h +++ b/src/messages/MGenericMessage.h @@ -30,7 +30,7 @@ class MGenericMessage : public Message { //void set_pcid(long pcid) { this->pcid = pcid; } //long get_pcid() { return pcid; } - const char *get_type_name() { return tname; } + const char *get_type_name() const { return tname; } void decode_payload() { } void encode_payload(uint64_t features) { } diff --git a/src/messages/MGetPoolStats.h b/src/messages/MGetPoolStats.h index c773487a58ec..acf9637e4c51 100644 --- a/src/messages/MGetPoolStats.h +++ b/src/messages/MGetPoolStats.h @@ -36,8 +36,8 @@ private: ~MGetPoolStats() {} public: - const char *get_type_name() { return "getpoolstats"; } - void print(ostream& out) { + const char *get_type_name() const { return "getpoolstats"; } + void print(ostream& out) const { out << "getpoolstats(" << get_tid() << " " << pools << " v" << version << ")"; } diff --git a/src/messages/MGetPoolStatsReply.h b/src/messages/MGetPoolStatsReply.h index 2cda83d16d74..26f9e13ab708 100644 --- a/src/messages/MGetPoolStatsReply.h +++ b/src/messages/MGetPoolStatsReply.h @@ -34,8 +34,8 @@ private: ~MGetPoolStatsReply() {} public: - const char *get_type_name() { return "getpoolstats"; } - void print(ostream& out) { + const char *get_type_name() const { return "getpoolstats"; } + void print(ostream& out) const { out << "getpoolstatsreply(" << get_tid() << " v" << version << ")"; } diff --git a/src/messages/MHeartbeat.h b/src/messages/MHeartbeat.h index 848509fd1c29..bddffc0b0014 100644 --- a/src/messages/MHeartbeat.h +++ b/src/messages/MHeartbeat.h @@ -46,7 +46,7 @@ private: ~MHeartbeat() {} public: - const char *get_type_name() { return "HB"; } + const char *get_type_name() const { return "HB"; } void encode_payload(uint64_t features) { ::encode(load, payload); diff --git a/src/messages/MInodeFileCaps.h b/src/messages/MInodeFileCaps.h index 5399598f6ad6..b5fc0ddd3461 100644 --- a/src/messages/MInodeFileCaps.h +++ b/src/messages/MInodeFileCaps.h @@ -34,8 +34,8 @@ private: ~MInodeFileCaps() {} public: - const char *get_type_name() { return "inode_file_caps";} - void print(ostream& out) { + const char *get_type_name() const { return "inode_file_caps";} + void print(ostream& out) const { out << "inode_file_caps(" << ino << " " << ccap_string(caps) << ")"; } diff --git a/src/messages/MLock.h b/src/messages/MLock.h index 3bda13f8ac56..0d66a001e24e 100644 --- a/src/messages/MLock.h +++ b/src/messages/MLock.h @@ -59,8 +59,8 @@ private: ~MLock() {} public: - const char *get_type_name() { return "ILock"; } - void print(ostream& out) { + const char *get_type_name() const { return "ILock"; } + void print(ostream& out) const { out << "lock(a=" << get_lock_action_name(action) << " " << get_lock_type_name(lock_type) << " " << object_info diff --git a/src/messages/MLog.h b/src/messages/MLog.h index 3c4dfc94f85b..61ca18b69448 100644 --- a/src/messages/MLog.h +++ b/src/messages/MLog.h @@ -34,8 +34,8 @@ private: ~MLog() {} public: - const char *get_type_name() { return "log"; } - void print(ostream& out) { + const char *get_type_name() const { return "log"; } + void print(ostream& out) const { out << "log("; if (entries.size()) out << entries.size() << " entries"; diff --git a/src/messages/MLogAck.h b/src/messages/MLogAck.h index f1ce5246fd36..8022e7ced572 100644 --- a/src/messages/MLogAck.h +++ b/src/messages/MLogAck.h @@ -28,8 +28,8 @@ private: ~MLogAck() {} public: - const char *get_type_name() { return "log_ack"; } - void print(ostream& out) { + const char *get_type_name() const { return "log_ack"; } + void print(ostream& out) const { out << "log(last " << last << ")"; } diff --git a/src/messages/MMDSBeacon.h b/src/messages/MMDSBeacon.h index c77a27aaf9af..e1c950d250b5 100644 --- a/src/messages/MMDSBeacon.h +++ b/src/messages/MMDSBeacon.h @@ -51,7 +51,7 @@ public: epoch_t get_last_epoch_seen() { return version; } int get_state() { return state; } version_t get_seq() { return seq; } - const char *get_type_name() { return "mdsbeacon"; } + const char *get_type_name() const { return "mdsbeacon"; } int get_standby_for_rank() { return standby_for_rank; } const string& get_standby_for_name() { return standby_for_name; } @@ -62,7 +62,7 @@ public: void set_standby_for_name(string& n) { standby_for_name = n; } void set_standby_for_name(const char* c) { standby_for_name.assign(c); } - void print(ostream& out) { + void print(ostream& out) const { out << "mdsbeacon(" << global_id << "/" << name << " " << ceph_mds_state_name(state) << " seq " << seq << " v" << version << ")"; } diff --git a/src/messages/MMDSCacheRejoin.h b/src/messages/MMDSCacheRejoin.h index 0052b3e5c63c..e5a86ee45cb0 100644 --- a/src/messages/MMDSCacheRejoin.h +++ b/src/messages/MMDSCacheRejoin.h @@ -196,8 +196,8 @@ private: ~MMDSCacheRejoin() {} public: - const char *get_type_name() { return "cache_rejoin"; } - void print(ostream& out) { + const char *get_type_name() const { return "cache_rejoin"; } + void print(ostream& out) const { out << "cache_rejoin " << get_opname(op); } diff --git a/src/messages/MMDSFindIno.h b/src/messages/MMDSFindIno.h index 3e291de05913..d8eddcb49b84 100644 --- a/src/messages/MMDSFindIno.h +++ b/src/messages/MMDSFindIno.h @@ -25,8 +25,8 @@ struct MMDSFindIno : public Message { MMDSFindIno() : Message(MSG_MDS_FINDINO) {} MMDSFindIno(tid_t t, inodeno_t i) : Message(MSG_MDS_FINDINO), tid(t), ino(i) {} - const char *get_type_name() { return "findino"; } - void print(ostream &out) { + const char *get_type_name() const { return "findino"; } + void print(ostream &out) const { out << "findino(" << tid << " " << ino << ")"; } diff --git a/src/messages/MMDSFindInoReply.h b/src/messages/MMDSFindInoReply.h index 64b48cae6c1a..3d6ec6c6ce6b 100644 --- a/src/messages/MMDSFindInoReply.h +++ b/src/messages/MMDSFindInoReply.h @@ -25,8 +25,8 @@ struct MMDSFindInoReply : public Message { MMDSFindInoReply() : Message(MSG_MDS_FINDINOREPLY) {} MMDSFindInoReply(tid_t t) : Message(MSG_MDS_FINDINOREPLY), tid(t) {} - const char *get_type_name() { return "findinoreply"; } - void print(ostream &out) { + const char *get_type_name() const { return "findinoreply"; } + void print(ostream &out) const { out << "findinoreply(" << tid << " " << path << ")"; } diff --git a/src/messages/MMDSFragmentNotify.h b/src/messages/MMDSFragmentNotify.h index 922f0093c80d..10eb0c7d4029 100644 --- a/src/messages/MMDSFragmentNotify.h +++ b/src/messages/MMDSFragmentNotify.h @@ -39,8 +39,8 @@ private: ~MMDSFragmentNotify() {} public: - const char *get_type_name() { return "fragment_notify"; } - void print(ostream& o) { + const char *get_type_name() const { return "fragment_notify"; } + void print(ostream& o) const { o << "fragment_notify(" << ino << "." << basefrag << " " << (int)bits << ")"; } diff --git a/src/messages/MMDSLoadTargets.h b/src/messages/MMDSLoadTargets.h index 0aeb6b63b5d3..4022f32e36b3 100644 --- a/src/messages/MMDSLoadTargets.h +++ b/src/messages/MMDSLoadTargets.h @@ -36,8 +36,8 @@ private: ~MMDSLoadTargets() {} public: - const char* get_type_name() { return "mds_load_targets"; } - void print(ostream& o) { + const char* get_type_name() const { return "mds_load_targets"; } + void print(ostream& o) const { o << "mds_load_targets(" << global_id << " " << targets << ")"; } diff --git a/src/messages/MMDSMap.h b/src/messages/MMDSMap.h index ae6ed9a34d05..b5558493746c 100644 --- a/src/messages/MMDSMap.h +++ b/src/messages/MMDSMap.h @@ -67,8 +67,8 @@ private: ~MMDSMap() {} public: - const char *get_type_name() { return "mdsmap"; } - void print(ostream& out) { + const char *get_type_name() const { return "mdsmap"; } + void print(ostream& out) const { out << "mdsmap(e " << epoch << ")"; } diff --git a/src/messages/MMDSResolve.h b/src/messages/MMDSResolve.h index 9b929ef68f98..551ca991a479 100644 --- a/src/messages/MMDSResolve.h +++ b/src/messages/MMDSResolve.h @@ -30,9 +30,9 @@ private: ~MMDSResolve() {} public: - const char *get_type_name() { return "mds_resolve"; } + const char *get_type_name() const { return "mds_resolve"; } - void print(ostream& out) { + void print(ostream& out) const { out << "mds_resolve(" << subtrees.size() << "+" << ambiguous_imports.size() << " subtrees +" << slave_requests.size() << " slave requests)"; diff --git a/src/messages/MMDSResolveAck.h b/src/messages/MMDSResolveAck.h index 9fcee3e0b4fa..2118abaaf499 100644 --- a/src/messages/MMDSResolveAck.h +++ b/src/messages/MMDSResolveAck.h @@ -30,8 +30,8 @@ private: ~MMDSResolveAck() {} public: - const char *get_type_name() { return "resolve_ack"; } - /*void print(ostream& out) { + const char *get_type_name() const { return "resolve_ack"; } + /*void print(ostream& out) const { out << "resolve_ack.size() << "+" << ambiguous_imap.size() << " imports +" << slave_requests.size() << " slave requests)"; diff --git a/src/messages/MMDSSlaveRequest.h b/src/messages/MMDSSlaveRequest.h index 628374eed702..4f2bb5948bdf 100644 --- a/src/messages/MMDSSlaveRequest.h +++ b/src/messages/MMDSSlaveRequest.h @@ -161,8 +161,8 @@ public: ::decode(stray, p); } - const char *get_type_name() { return "slave_request"; } - void print(ostream& out) { + const char *get_type_name() const { return "slave_request"; } + void print(ostream& out) const { out << "slave_request(" << reqid << "." << attempt << " " << get_opname(op) diff --git a/src/messages/MMDSTableRequest.h b/src/messages/MMDSTableRequest.h index 3ce95173fa9c..fcbfcb8638e3 100644 --- a/src/messages/MMDSTableRequest.h +++ b/src/messages/MMDSTableRequest.h @@ -36,8 +36,8 @@ private: ~MMDSTableRequest() {} public: - virtual const char *get_type_name() { return "mds_table_request"; } - void print(ostream& o) { + virtual const char *get_type_name() const { return "mds_table_request"; } + void print(ostream& o) const { o << "mds_table_request(" << get_mdstable_name(table) << " " << get_mdstableserver_opname(op); if (reqid) o << " " << reqid; diff --git a/src/messages/MMonCommand.h b/src/messages/MMonCommand.h index 26629d720670..c011596ad52a 100644 --- a/src/messages/MMonCommand.h +++ b/src/messages/MMonCommand.h @@ -34,8 +34,8 @@ private: ~MMonCommand() {} public: - const char *get_type_name() { return "mon_command"; } - void print(ostream& o) { + const char *get_type_name() const { return "mon_command"; } + void print(ostream& o) const { o << "mon_command("; for (unsigned i=0; i incremental_maps; epoch_t oldest_map, newest_map; - epoch_t get_first() { + epoch_t get_first() const { epoch_t e = 0; - map::iterator i = maps.begin(); + map::const_iterator i = maps.begin(); if (i != maps.end()) e = i->first; i = incremental_maps.begin(); if (i != incremental_maps.end() && (e == 0 || i->first < e)) e = i->first; return e; } - epoch_t get_last() { + epoch_t get_last() const { epoch_t e = 0; - map::reverse_iterator i = maps.rbegin(); + map::const_reverse_iterator i = maps.rbegin(); if (i != maps.rend()) e = i->first; i = incremental_maps.rbegin(); if (i != incremental_maps.rend() && @@ -123,8 +123,8 @@ public: } } - const char *get_type_name() { return "omap"; } - void print(ostream& out) { + const char *get_type_name() const { return "omap"; } + void print(ostream& out) const { out << "osd_map(" << get_first() << ".." << get_last(); if (oldest_map || newest_map) out << " src has " << oldest_map << ".." << newest_map; diff --git a/src/messages/MOSDOp.h b/src/messages/MOSDOp.h index b08ef5fc5a6a..1bca186f1acf 100644 --- a/src/messages/MOSDOp.h +++ b/src/messages/MOSDOp.h @@ -60,13 +60,18 @@ public: snapid_t get_snapid() { return snapid; } void set_snapid(snapid_t s) { snapid = s; } // writ - snapid_t get_snap_seq() { return snap_seq; } - vector &get_snaps() { return snaps; } + snapid_t get_snap_seq() const { return snap_seq; } + const vector &get_snaps() const { return snaps; } + void set_snaps(const vector& i) { + snaps = i; + } void set_snap_seq(snapid_t s) { snap_seq = s; } - osd_reqid_t get_reqid() { return osd_reqid_t(get_orig_source(), - client_inc, - header.tid); } + osd_reqid_t get_reqid() const { + return osd_reqid_t(get_orig_source(), + client_inc, + header.tid); + } int get_client_inc() { return client_inc; } tid_t get_client_tid() { return header.tid; } @@ -358,8 +363,8 @@ struct ceph_osd_request_head { } - const char *get_type_name() { return "osd_op"; } - void print(ostream& out) { + const char *get_type_name() const { return "osd_op"; } + void print(ostream& out) const { out << "osd_op(" << get_reqid(); out << " " << oid; diff --git a/src/messages/MOSDOpReply.h b/src/messages/MOSDOpReply.h index 17b0270a11f2..c60f834b69b1 100644 --- a/src/messages/MOSDOpReply.h +++ b/src/messages/MOSDOpReply.h @@ -40,18 +40,18 @@ class MOSDOpReply : public Message { int32_t retry_attempt; public: - object_t get_oid() { return oid; } - pg_t get_pg() { return pgid; } - int get_flags() { return flags; } + object_t get_oid() const { return oid; } + pg_t get_pg() const { return pgid; } + int get_flags() const { return flags; } - bool is_ondisk() { return get_flags() & CEPH_OSD_FLAG_ONDISK; } - bool is_onnvram() { return get_flags() & CEPH_OSD_FLAG_ONNVRAM; } + bool is_ondisk() const { return get_flags() & CEPH_OSD_FLAG_ONDISK; } + bool is_onnvram() const { return get_flags() & CEPH_OSD_FLAG_ONNVRAM; } - int get_result() { return result; } + int get_result() const { return result; } eversion_t get_version() { return reassert_version; } - bool may_read() { return flags & CEPH_OSD_FLAG_READ; } - bool may_write() { return flags & CEPH_OSD_FLAG_WRITE; } + bool may_read() const { return flags & CEPH_OSD_FLAG_READ; } + bool may_write() const { return flags & CEPH_OSD_FLAG_WRITE; } void set_result(int r) { result = r; } void set_version(eversion_t v) { reassert_version = v; } @@ -190,9 +190,9 @@ public: } } - const char *get_type_name() { return "osd_op_reply"; } + const char *get_type_name() const { return "osd_op_reply"; } - void print(ostream& out) { + void print(ostream& out) const { out << "osd_op_reply(" << get_tid() << " " << oid << " " << ops; if (may_write()) { diff --git a/src/messages/MOSDPGBackfill.h b/src/messages/MOSDPGBackfill.h index 44afdf149cdc..7e6c45e1e9a7 100644 --- a/src/messages/MOSDPGBackfill.h +++ b/src/messages/MOSDPGBackfill.h @@ -25,7 +25,7 @@ public: OP_BACKFILL_FINISH = 3, OP_BACKFILL_FINISH_ACK = 4, }; - const char *get_op_name(int o) { + const char *get_op_name(int o) const { switch (o) { case OP_BACKFILL_PROGRESS: return "progress"; case OP_BACKFILL_FINISH: return "finish"; @@ -70,8 +70,8 @@ private: ~MOSDPGBackfill() {} public: - const char *get_type_name() { return "pg_backfill"; } - void print(ostream& out) { + const char *get_type_name() const { return "pg_backfill"; } + void print(ostream& out) const { out << "pg_backfill(" << get_op_name(op) << " " << pgid << " e " << map_epoch << "/" << query_epoch diff --git a/src/messages/MOSDPGCreate.h b/src/messages/MOSDPGCreate.h index 3dc6494ac5ad..0efcb0145af0 100644 --- a/src/messages/MOSDPGCreate.h +++ b/src/messages/MOSDPGCreate.h @@ -52,7 +52,7 @@ private: ~MOSDPGCreate() {} public: - const char *get_type_name() { return "pg_create"; } + const char *get_type_name() const { return "pg_create"; } void encode_payload(uint64_t features) { ::encode(epoch, payload); @@ -64,9 +64,9 @@ public: ::decode(mkpg, p); } - void print(ostream& out) { + void print(ostream& out) const { out << "osd pg create("; - for (map::iterator i = mkpg.begin(); + for (map::const_iterator i = mkpg.begin(); i != mkpg.end(); ++i) { out << "pg" << i->first << "," << i->second.created << "; "; diff --git a/src/messages/MOSDPGInfo.h b/src/messages/MOSDPGInfo.h index cd58e02aa1d6..19ee76673d17 100644 --- a/src/messages/MOSDPGInfo.h +++ b/src/messages/MOSDPGInfo.h @@ -34,8 +34,8 @@ private: ~MOSDPGInfo() {} public: - const char *get_type_name() { return "pg_info"; } - void print(ostream& out) { + const char *get_type_name() const { return "pg_info"; } + void print(ostream& out) const { out << "pg_info(" << pg_info.size() << " pgs e" << epoch << ")"; } diff --git a/src/messages/MOSDPGLog.h b/src/messages/MOSDPGLog.h index 9b3cd8539655..774e1357ae9d 100644 --- a/src/messages/MOSDPGLog.h +++ b/src/messages/MOSDPGLog.h @@ -46,8 +46,8 @@ private: ~MOSDPGLog() {} public: - const char *get_type_name() { return "PGlog"; } - void print(ostream& out) { + const char *get_type_name() const { return "PGlog"; } + void print(ostream& out) const { out << "pg_log(" << info.pgid << " epoch " << epoch << " query_epoch " << query_epoch << ")"; } diff --git a/src/messages/MOSDPGMissing.h b/src/messages/MOSDPGMissing.h index 8173b2d8f41c..17b6bdb8f82b 100644 --- a/src/messages/MOSDPGMissing.h +++ b/src/messages/MOSDPGMissing.h @@ -36,8 +36,8 @@ private: ~MOSDPGMissing() {} public: - const char *get_type_name() { return "pg_missing"; } - void print(ostream& out) { + const char *get_type_name() const { return "pg_missing"; } + void print(ostream& out) const { out << "pg_missing(" << info.pgid << " e" << epoch << ")"; } diff --git a/src/messages/MOSDPGNotify.h b/src/messages/MOSDPGNotify.h index 9cc12cb26e26..3ea09b97adbb 100644 --- a/src/messages/MOSDPGNotify.h +++ b/src/messages/MOSDPGNotify.h @@ -47,7 +47,7 @@ private: ~MOSDPGNotify() {} public: - const char *get_type_name() { return "PGnot"; } + const char *get_type_name() const { return "PGnot"; } void encode_payload(uint64_t features) { header.version = 2; @@ -63,9 +63,9 @@ public: ::decode(query_epoch, p); } } - void print(ostream& out) { + void print(ostream& out) const { out << "pg_notify("; - for (vector::iterator i = pg_list.begin(); + for (vector::const_iterator i = pg_list.begin(); i != pg_list.end(); ++i) { if (i != pg_list.begin()) diff --git a/src/messages/MOSDPGQuery.h b/src/messages/MOSDPGQuery.h index 9a46932f5aba..8e8a84b1cf13 100644 --- a/src/messages/MOSDPGQuery.h +++ b/src/messages/MOSDPGQuery.h @@ -39,10 +39,10 @@ private: ~MOSDPGQuery() {} public: - const char *get_type_name() { return "pg_query"; } - void print(ostream& out) { + const char *get_type_name() const { return "pg_query"; } + void print(ostream& out) const { out << "pg_query("; - for (map::iterator p = pg_list.begin(); p != pg_list.end(); ++p) { + for (map::const_iterator p = pg_list.begin(); p != pg_list.end(); ++p) { if (p != pg_list.begin()) out << ","; out << p->first; diff --git a/src/messages/MOSDPGRemove.h b/src/messages/MOSDPGRemove.h index 333201ceb86a..bc8a343db0d1 100644 --- a/src/messages/MOSDPGRemove.h +++ b/src/messages/MOSDPGRemove.h @@ -37,7 +37,7 @@ private: ~MOSDPGRemove() {} public: - const char *get_type_name() { return "PGrm"; } + const char *get_type_name() const { return "PGrm"; } void encode_payload(uint64_t features) { ::encode(epoch, payload); @@ -48,9 +48,9 @@ public: ::decode(epoch, p); ::decode(pg_list, p); } - void print(ostream& out) { + void print(ostream& out) const { out << "osd pg remove(" << "epoch " << epoch << "; "; - for (vector::iterator i = pg_list.begin(); + for (vector::const_iterator i = pg_list.begin(); i != pg_list.end(); ++i) { out << "pg" << *i << "; "; diff --git a/src/messages/MOSDPGScan.h b/src/messages/MOSDPGScan.h index 4ed1d91c6bf7..cc69b92e170b 100644 --- a/src/messages/MOSDPGScan.h +++ b/src/messages/MOSDPGScan.h @@ -24,7 +24,7 @@ public: OP_SCAN_GET_DIGEST = 1, // just objects and versions OP_SCAN_DIGEST = 2, // result }; - const char *get_op_name(int o) { + const char *get_op_name(int o) const { switch (o) { case OP_SCAN_GET_DIGEST: return "get_digest"; case OP_SCAN_DIGEST: return "digest"; @@ -68,8 +68,8 @@ private: ~MOSDPGScan() {} public: - const char *get_type_name() { return "pg_scan"; } - void print(ostream& out) { + const char *get_type_name() const { return "pg_scan"; } + void print(ostream& out) const { out << "pg_scan(" << get_op_name(op) << " " << pgid << " " << begin << "-" << end diff --git a/src/messages/MOSDPGTemp.h b/src/messages/MOSDPGTemp.h index 5eb5a557d274..fe5908ce0673 100644 --- a/src/messages/MOSDPGTemp.h +++ b/src/messages/MOSDPGTemp.h @@ -42,8 +42,8 @@ public: ::decode(pg_temp, p); } - const char *get_type_name() { return "osd_pgtemp"; } - void print(ostream &out) { + const char *get_type_name() const { return "osd_pgtemp"; } + void print(ostream &out) const { out << "osd_pgtemp(e" << map_epoch << " " << pg_temp << " v" << version << ")"; } diff --git a/src/messages/MOSDPGTrim.h b/src/messages/MOSDPGTrim.h index 702cb5e5310e..ad1efa3ac594 100644 --- a/src/messages/MOSDPGTrim.h +++ b/src/messages/MOSDPGTrim.h @@ -33,8 +33,8 @@ private: ~MOSDPGTrim() {} public: - const char *get_type_name() { return "pg_trim"; } - void print(ostream& out) { + const char *get_type_name() const { return "pg_trim"; } + void print(ostream& out) const { out << "pg_trim(" << pgid << " to " << trim_to << " e" << epoch << ")"; } diff --git a/src/messages/MOSDPing.h b/src/messages/MOSDPing.h index 7bdc8ef65fb5..9956ef25ad95 100644 --- a/src/messages/MOSDPing.h +++ b/src/messages/MOSDPing.h @@ -29,7 +29,7 @@ class MOSDPing : public Message { YOU_DIED = 2, STOP_HEARTBEAT = 3, }; - const char *get_op_name(int op) { + const char *get_op_name(int op) const { switch (op) { case HEARTBEAT: return "heartbeat"; case START_HEARTBEAT: return "start_heartbeat"; @@ -69,8 +69,8 @@ public: ::encode(peer_stat, payload); } - const char *get_type_name() { return "osd_ping"; } - void print(ostream& out) { + const char *get_type_name() const { return "osd_ping"; } + void print(ostream& out) const { out << "osd_ping(" << get_op_name(op) << " e" << map_epoch << " as_of " << peer_as_of_epoch << ")"; } }; diff --git a/src/messages/MOSDRepScrub.h b/src/messages/MOSDRepScrub.h index 9837f287e18b..522bfb22b21d 100644 --- a/src/messages/MOSDRepScrub.h +++ b/src/messages/MOSDRepScrub.h @@ -41,8 +41,8 @@ private: ~MOSDRepScrub() {} public: - const char *get_type_name() { return "replica scrub"; } - void print(ostream& out) { + const char *get_type_name() const { return "replica scrub"; } + void print(ostream& out) const { out << "replica scrub(pg: "; out << pgid << ",from:" << scrub_from << ",to:" << scrub_to << "epoch:" << map_epoch; diff --git a/src/messages/MOSDScrub.h b/src/messages/MOSDScrub.h index 2f814e7d6149..67633e82d14f 100644 --- a/src/messages/MOSDScrub.h +++ b/src/messages/MOSDScrub.h @@ -38,8 +38,8 @@ private: ~MOSDScrub() {} public: - const char *get_type_name() { return "scrub"; } - void print(ostream& out) { + const char *get_type_name() const { return "scrub"; } + void print(ostream& out) const { out << "scrub("; if (scrub_pgs.empty()) out << "osd"; diff --git a/src/messages/MOSDSubOp.h b/src/messages/MOSDSubOp.h index f7596e953e5e..81aba7f3366d 100644 --- a/src/messages/MOSDSubOp.h +++ b/src/messages/MOSDSubOp.h @@ -170,8 +170,8 @@ private: ~MOSDSubOp() {} public: - const char *get_type_name() { return "osd_sub_op"; } - void print(ostream& out) { + const char *get_type_name() const { return "osd_sub_op"; } + void print(ostream& out) const { out << "osd_sub_op(" << reqid << " " << pgid << " " << poid diff --git a/src/messages/MOSDSubOpReply.h b/src/messages/MOSDSubOpReply.h index 920fe78ac645..aa186372bbbe 100644 --- a/src/messages/MOSDSubOpReply.h +++ b/src/messages/MOSDSubOpReply.h @@ -124,9 +124,9 @@ private: ~MOSDSubOpReply() {} public: - const char *get_type_name() { return "osd_op_reply"; } + const char *get_type_name() const { return "osd_op_reply"; } - void print(ostream& out) { + void print(ostream& out) const { out << "osd_sub_op_reply(" << reqid << " " << pgid << " " << poid << " " << ops; diff --git a/src/messages/MPGStats.h b/src/messages/MPGStats.h index e5af677070bb..633800aad152 100644 --- a/src/messages/MPGStats.h +++ b/src/messages/MPGStats.h @@ -34,8 +34,8 @@ private: ~MPGStats() {}; public: - const char *get_type_name() { return "pg_stats"; } - void print(ostream& out) { + const char *get_type_name() const { return "pg_stats"; } + void print(ostream& out) const { out << "pg_stats(" << pg_stat.size() << " pgs tid " << get_tid() << " v " << version << ")"; } diff --git a/src/messages/MPGStatsAck.h b/src/messages/MPGStatsAck.h index 045ad4bfe16c..f268b68f9b8b 100644 --- a/src/messages/MPGStatsAck.h +++ b/src/messages/MPGStatsAck.h @@ -27,8 +27,8 @@ private: ~MPGStatsAck() {} public: - const char *get_type_name() { return "pg_stats_ack"; } - void print(ostream& out) { + const char *get_type_name() const { return "pg_stats_ack"; } + void print(ostream& out) const { out << "pg_stats_ack(" << pg_stat.size() << " pgs tid " << get_tid() << ")"; } diff --git a/src/messages/MPing.h b/src/messages/MPing.h index 005f11c786bf..3cd051497eaa 100644 --- a/src/messages/MPing.h +++ b/src/messages/MPing.h @@ -29,7 +29,7 @@ private: public: void decode_payload() { } void encode_payload(uint64_t features) { } - const char *get_type_name() { return "ping"; } + const char *get_type_name() const { return "ping"; } }; #endif diff --git a/src/messages/MPoolOp.h b/src/messages/MPoolOp.h index 5ed45944bab9..c4ec9d863444 100644 --- a/src/messages/MPoolOp.h +++ b/src/messages/MPoolOp.h @@ -45,8 +45,8 @@ private: ~MPoolOp() {} public: - const char *get_type_name() { return "poolop"; } - void print(ostream& out) { + const char *get_type_name() const { return "poolop"; } + void print(ostream& out) const { out << "pool_op(" << ceph_pool_op_name(op) << " pool " << pool << " auid " << auid << " tid " << get_tid() diff --git a/src/messages/MPoolOpReply.h b/src/messages/MPoolOpReply.h index b3002289c62b..702fdf757d95 100644 --- a/src/messages/MPoolOpReply.h +++ b/src/messages/MPoolOpReply.h @@ -44,9 +44,9 @@ public: response_data.claim(*blp); } - const char *get_type_name() { return "poolopreply"; } + const char *get_type_name() const { return "poolopreply"; } - void print(ostream& out) { + void print(ostream& out) const { out << "pool_op_reply(tid " << get_tid() << " " << cpp_strerror(-replyCode) << " v" << version << ")"; diff --git a/src/messages/MRemoveSnaps.h b/src/messages/MRemoveSnaps.h index 21fffc05cf5d..6568ffaeb078 100644 --- a/src/messages/MRemoveSnaps.h +++ b/src/messages/MRemoveSnaps.h @@ -30,8 +30,8 @@ private: ~MRemoveSnaps() {} public: - const char *get_type_name() { return "remove_snaps"; } - void print(ostream& out) { + const char *get_type_name() const { return "remove_snaps"; } + void print(ostream& out) const { out << "remove_snaps(" << snaps << " v" << version << ")"; } diff --git a/src/messages/MRoute.h b/src/messages/MRoute.h index 050e265ef453..7efa13683add 100644 --- a/src/messages/MRoute.h +++ b/src/messages/MRoute.h @@ -51,8 +51,8 @@ public: encode_message(msg, features, payload); } - const char *get_type_name() { return "route"; } - void print(ostream& o) { + const char *get_type_name() const { return "route"; } + void print(ostream& o) const { if (msg) o << "route(" << *msg; else diff --git a/src/messages/MStatfs.h b/src/messages/MStatfs.h index dac147f442e6..61370a943442 100644 --- a/src/messages/MStatfs.h +++ b/src/messages/MStatfs.h @@ -33,8 +33,8 @@ private: ~MStatfs() {} public: - const char *get_type_name() { return "statfs"; } - void print(ostream& out) { + const char *get_type_name() const { return "statfs"; } + void print(ostream& out) const { out << "statfs(" << get_tid() << " v" << version << ")"; } diff --git a/src/messages/MStatfsReply.h b/src/messages/MStatfsReply.h index bdf52664d230..8ceec9c7b10e 100644 --- a/src/messages/MStatfsReply.h +++ b/src/messages/MStatfsReply.h @@ -27,8 +27,8 @@ public: h.version = epoch; } - const char *get_type_name() { return "statfs_reply"; } - void print(ostream& out) { + const char *get_type_name() const { return "statfs_reply"; } + void print(ostream& out) const { out << "statfs_reply(" << header.tid << ")"; } diff --git a/src/messages/MWatchNotify.h b/src/messages/MWatchNotify.h index d39fc99b936e..66632f72002b 100644 --- a/src/messages/MWatchNotify.h +++ b/src/messages/MWatchNotify.h @@ -55,8 +55,8 @@ public: ::encode(bl, payload); } - const char *get_type_name() { return "watch-notify"; } - void print(ostream& out) { + const char *get_type_name() const { return "watch-notify"; } + void print(ostream& out) const { out << "watch-notify(c=" << cookie << " v=" << ver << " i=" << notify_id << " opcode=" << (int)opcode << ")"; } }; diff --git a/src/messages/PaxosServiceMessage.h b/src/messages/PaxosServiceMessage.h index 88c908d253f2..341a0b3f308c 100644 --- a/src/messages/PaxosServiceMessage.h +++ b/src/messages/PaxosServiceMessage.h @@ -56,7 +56,7 @@ class PaxosServiceMessage : public Message { return session; } - const char *get_type_name() { return "PaxosServiceMessage"; } + const char *get_type_name() const { return "PaxosServiceMessage"; } }; #endif diff --git a/src/msg/Message.h b/src/msg/Message.h index 6159b9d4bbfa..53d216a46789 100644 --- a/src/msg/Message.h +++ b/src/msg/Message.h @@ -380,7 +380,7 @@ public: off_t get_data_len() { return data.length(); } void set_recv_stamp(utime_t t) { recv_stamp = t; } - utime_t get_recv_stamp() { return recv_stamp; } + utime_t get_recv_stamp() const { return recv_stamp; } void calc_header_crc() { header.crc = ceph_crc32c_le(0, (unsigned char*)&header, @@ -395,47 +395,47 @@ public: } // type - int get_type() { return header.type; } + int get_type() const { return header.type; } void set_type(int t) { header.type = t; } - uint64_t get_tid() { return header.tid; } + uint64_t get_tid() const { return header.tid; } void set_tid(uint64_t t) { header.tid = t; } - unsigned get_seq() { return header.seq; } + unsigned get_seq() const { return header.seq; } void set_seq(unsigned s) { header.seq = s; } - unsigned get_priority() { return header.priority; } + unsigned get_priority() const { return header.priority; } void set_priority(__s16 p) { header.priority = p; } // source/dest - entity_inst_t get_source_inst() { + entity_inst_t get_source_inst() const { return entity_inst_t(get_source(), get_source_addr()); } - entity_name_t get_source() { + entity_name_t get_source() const { return entity_name_t(header.src); } - entity_addr_t get_source_addr() { + entity_addr_t get_source_addr() const { if (connection) return connection->get_peer_addr(); return entity_addr_t(); } // forwarded? - entity_inst_t get_orig_source_inst() { + entity_inst_t get_orig_source_inst() const { return get_source_inst(); } - entity_name_t get_orig_source() { + entity_name_t get_orig_source() const { return get_orig_source_inst().name; } - entity_addr_t get_orig_source_addr() { + entity_addr_t get_orig_source_addr() const { return get_orig_source_inst().addr; } // virtual bits virtual void decode_payload() = 0; virtual void encode_payload(uint64_t features) = 0; - virtual const char *get_type_name() = 0; - virtual void print(ostream& out) { + virtual const char *get_type_name() const = 0; + virtual void print(ostream& out) const { out << get_type_name(); } diff --git a/src/osdc/Objecter.cc b/src/osdc/Objecter.cc index eb70aea2aa17..cd357af627e3 100644 --- a/src/osdc/Objecter.cc +++ b/src/osdc/Objecter.cc @@ -1082,7 +1082,7 @@ void Objecter::send_op(Op *op) m->set_snapid(op->snapid); m->set_snap_seq(op->snapc.seq); - m->get_snaps() = op->snapc.snaps; + m->set_snaps(op->snapc.snaps); m->ops = op->ops; m->set_mtime(op->mtime);