]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
journal: output operators for journal types
authorMykola Golub <mgolub@mirantis.com>
Thu, 3 Sep 2015 18:12:12 +0000 (21:12 +0300)
committerMykola Golub <mgolub@mirantis.com>
Wed, 11 Nov 2015 14:43:56 +0000 (16:43 +0200)
They are going to be used for diagnostic.

Signed-off-by: Mykola Golub <mgolub@mirantis.com>
src/cls/journal/cls_journal_types.cc
src/cls/journal/cls_journal_types.h
src/journal/JournalMetadata.cc
src/journal/JournalMetadata.h
src/journal/Journaler.cc
src/journal/Journaler.h

index eea018b7f0760ea3337fda02c8cf8cfdd559f9fd..58d1ea75fbaa633b87fc3a10b2ebcccbac0a2475 100644 (file)
@@ -145,5 +145,11 @@ std::ostream &operator<<(std::ostream &os,
   return os;
 }
 
+std::ostream &operator<<(std::ostream &os, const Client &client) {
+  os << "[id=" << client.id << ", description=" << client.description
+     << ", commit_position=" << client.commit_position << "]";
+  return os;
+}
+
 } // namespace journal
 } // namespace cls
index 2b50ac61413a99685958eefb9e5bd7226f2ba6c8..54339b998f7eabe264b1d0a30a6d9ad331b8c349 100644 (file)
@@ -97,6 +97,8 @@ std::ostream &operator<<(std::ostream &os,
                          const EntryPosition &entry_position);
 std::ostream &operator<<(std::ostream &os,
                          const ObjectSetPosition &object_set_position);
+std::ostream &operator<<(std::ostream &os,
+                        const Client &client);
 
 } // namespace journal
 } // namespace cls
index d1e26df03fbcf326f3e44ff9bbbdcb54c1eb858e..0da06ed6be59323e60273464b2328a3cd61fa852 100644 (file)
@@ -461,4 +461,32 @@ void JournalMetadata::handle_notified(int r) {
   ldout(m_cct, 10) << "notified journal header update: r=" << r << dendl;
 }
 
+std::ostream &operator<<(std::ostream &os,
+                        const JournalMetadata::RegisteredClients &clients) {
+  os << "[";
+  for (JournalMetadata::RegisteredClients::const_iterator c = clients.begin();
+       c != clients.end(); c++) {
+    os << (c == clients.begin() ? "" : ", " ) << *c;
+  }
+  os << "]";
+  return os;
+}
+
+std::ostream &operator<<(std::ostream &os,
+                        const JournalMetadata &jm) {
+  Mutex::Locker locker(jm.m_lock);
+  os << "[oid=" << jm.m_oid << ", "
+     << "initialized=" << jm.m_initialized << ", "
+     << "order=" << (int)jm.m_order << ", "
+     << "splay_width=" << (int)jm.m_splay_width << ", "
+     << "minimum_set=" << jm.m_minimum_set << ", "
+     << "active_set=" << jm.m_active_set << ", "
+     << "client_id=" << jm.m_client_id << ", "
+     << "commit_tid=" << jm.m_commit_tid << ", "
+     << "commit_interval=" << jm.m_commit_interval << ", "
+     << "commit_position=" << jm.m_commit_position << ", "
+     << "registered_clients=" << jm.m_registered_clients << "]";
+  return os;
+}
+
 } // namespace journal
index ea477c73911ecbeb6a0997d9cb332982b909a303..76ab695ab1d783f7e7cd24b44dfd22985800d98b 100644 (file)
@@ -304,8 +304,17 @@ private:
   void handle_watch_notify(uint64_t notify_id, uint64_t cookie);
   void handle_watch_error(int err);
   void handle_notified(int r);
+
+  friend std::ostream &operator<<(std::ostream &os,
+                                 const JournalMetadata &journal_metadata);
 };
 
+std::ostream &operator<<(std::ostream &os,
+                        const JournalMetadata::RegisteredClients &clients);
+
+std::ostream &operator<<(std::ostream &os,
+                        const JournalMetadata &journal_metadata);
+
 } // namespace journal
 
 #endif // CEPH_JOURNAL_JOURNAL_METADATA_H
index eaa4ce15d9cf87dc06f5dcac8683ac0b9f85898f..d758690881aa16fd0e830a8ceab4f4936ec3e113 100644 (file)
@@ -191,4 +191,16 @@ void Journaler::create_player(ReplayHandler *replay_handler) {
                                replay_handler);
 }
 
+std::ostream &operator<<(std::ostream &os,
+                        const Journaler &journaler) {
+  os << "[metadata=";
+  if (journaler.m_metadata != NULL) {
+    os << *journaler.m_metadata;
+  } else {
+    os << "NULL";
+  }
+  os << "]";
+  return os;
+}
+
 } // namespace journal
index 4b4959a879831382da67b1827ece4ea28752602f..676e994a5df7893ec97946c893e61c28506c7d62 100644 (file)
@@ -66,8 +66,14 @@ private:
   JournalTrimmer *m_trimmer;
 
   void create_player(ReplayHandler *replay_handler);
+
+  friend std::ostream &operator<<(std::ostream &os,
+                                 const Journaler &journaler);
 };
 
+std::ostream &operator<<(std::ostream &os,
+                        const Journaler &journaler);
+
 } // namespace journal
 
 #endif // CEPH_JOURNAL_JOURNALER_H