]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
add SequencerPosition type
authorSage Weil <sage.weil@dreamhost.com>
Sun, 4 Mar 2012 21:43:18 +0000 (13:43 -0800)
committerSage Weil <sage@newdream.net>
Sat, 10 Mar 2012 00:32:22 +0000 (16:32 -0800)
Signed-off-by: Sage Weil <sage.weil@dreamhost.com>
src/Makefile.am
src/os/SequencerPosition.h [new file with mode: 0644]
src/test/encoding/types.h

index 063e7a7271940ca69db3ead1d5b699f45e1d4d35..5001fc1ab39fd548264ac181a8dffd7505fe77b9 100644 (file)
@@ -1454,6 +1454,7 @@ noinst_HEADERS = \
         os/JournalingObjectStore.h\
        os/LFNIndex.h\
         os/ObjectStore.h\
+       os/SequencerPosition.h\
         osd/Ager.h\
        osd/ClassHandler.h\
         osd/OSD.h\
diff --git a/src/os/SequencerPosition.h b/src/os/SequencerPosition.h
new file mode 100644 (file)
index 0000000..38f11f0
--- /dev/null
@@ -0,0 +1,59 @@
+// -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*- 
+// vim: ts=8 sw=2 smarttab
+
+#ifndef __CEPH_OS_SEQUENCERPOSITION_H
+#define __CEPH_OS_SEQUENCERPOSITION_H
+
+#include "include/types.h"
+#include "include/cmp.h"
+#include "include/encoding.h"
+#include "common/Formatter.h"
+
+#include <ostream>
+
+/**
+ * transaction and op offset
+ */
+struct SequencerPosition {
+  uint64_t seq;  ///< seq
+  uint32_t trans; ///< transaction in that seq (0-based)
+  uint32_t op;    ///< op in that transaction (0-based)
+
+  SequencerPosition(uint64_t s=0, int32_t t=0, int32_t o=0) : seq(s), trans(t), op(o) {}
+
+  void encode(bufferlist& bl) const {
+    ENCODE_START(1, 1, bl);
+    ::encode(seq, bl);
+    ::encode(trans, bl);
+    ::encode(op, bl);
+    ENCODE_FINISH(bl);
+  }
+  void decode(bufferlist::iterator& p) {
+    DECODE_START(1, p);
+    ::decode(seq, p);
+    ::decode(trans, p);
+    ::decode(op, p);
+    DECODE_FINISH(p);
+  }
+  void dump(Formatter *f) const {
+    f->dump_unsigned("seq", seq);
+    f->dump_unsigned("trans", trans);
+    f->dump_unsigned("op", op);
+  }
+  static void generate_test_instances(list<SequencerPosition*>& o) {
+    o.push_back(new SequencerPosition);
+    o.push_back(new SequencerPosition(1, 2, 3));
+    o.push_back(new SequencerPosition(4, 5, 6));
+  }
+};
+WRITE_CLASS_ENCODER(SequencerPosition)
+
+inline ostream& operator<<(ostream& out, const SequencerPosition& t) {
+  return out << t.seq << "." << t.trans << "." << t.op;
+}
+
+WRITE_EQ_OPERATORS_3(SequencerPosition, seq, trans, op)
+WRITE_CMP_OPERATORS_3(SequencerPosition, seq, trans, op)
+
+
+#endif
index af9f2bc0cbeba144863696d7977de5c43fc2cfd9..fa17d10e8506185f081128050fcfc50d48927662 100644 (file)
@@ -63,6 +63,9 @@ TYPE(osd_peer_stat_t)
 #include "os/ObjectStore.h"
 TYPE(ObjectStore::Transaction)
 
+#include "os/SequencerPosition.h"
+TYPE(SequencerPosition)
+
 #include "os/hobject.h"
 TYPE(hobject_t)