]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
cls_replica_log: add ops for new class
authorGreg Farnum <greg@inktank.com>
Fri, 14 Jun 2013 23:28:07 +0000 (16:28 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Thu, 20 Jun 2013 21:10:31 +0000 (14:10 -0700)
Signed-off-by: Greg Farnum <greg@inktank.com>
src/Makefile.am
src/cls/replica_log/cls_replica_log_ops.cc [new file with mode: 0644]
src/cls/replica_log/cls_replica_log_ops.h [new file with mode: 0644]
src/test/encoding/types.h

index cda590e9e8381228dd004474a2b9b4bd42717676..df61ca6d780411178b50dca2f5a3151cd6b283e6 100644 (file)
@@ -617,7 +617,8 @@ libcls_statelog_client_a_SOURCES =  \
 noinst_LIBRARIES += libcls_statelog_client.a
 
 libcls_replica_log_client_a_SOURCES = \
-       cls/replica_log/cls_replica_log_types.cc
+       cls/replica_log/cls_replica_log_types.cc \
+       cls/replica_log/cls_replica_log_ops.cc
 noinst_LIBRARIES += libcls_replica_log_client.a
 
 libcls_rgw_client_a_SOURCES =  \
diff --git a/src/cls/replica_log/cls_replica_log_ops.cc b/src/cls/replica_log/cls_replica_log_ops.cc
new file mode 100644 (file)
index 0000000..7d653b6
--- /dev/null
@@ -0,0 +1,81 @@
+/*
+ * Ceph - scalable distributed file system
+ *
+ * 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.
+ * 
+ */
+
+#include "cls_replica_log_ops.h"
+#include "common/Formatter.h"
+#include "common/ceph_json.h"
+
+void cls_replica_log_delete_marker_op::dump(Formatter *f) const
+{
+  f->dump_string("entity_id", entity_id);
+}
+
+void cls_replica_log_delete_marker_op::
+generate_test_instances(std::list<cls_replica_log_delete_marker_op*>& ls)
+{
+  ls.push_back(new cls_replica_log_delete_marker_op);
+  ls.push_back(new cls_replica_log_delete_marker_op);
+  ls.back()->entity_id = "test_entity_1";
+}
+
+void cls_replica_log_set_marker_op::dump(Formatter *f) const
+{
+  encode_json("marker", marker, f);
+}
+
+void cls_replica_log_set_marker_op::
+generate_test_instances(std::list<cls_replica_log_set_marker_op*>& ls)
+{
+  std::list<cls_replica_log_progress_marker*> samples;
+  cls_replica_log_progress_marker::generate_test_instances(samples);
+  std::list<cls_replica_log_progress_marker*>::iterator i;
+  for (i = samples.begin(); i != samples.end(); ++i) {
+    ls.push_back(new cls_replica_log_set_marker_op(*(*i)));
+  }
+}
+
+void cls_replica_log_get_bounds_op::dump(Formatter *f) const
+{
+  f->dump_string("contents", "empty");
+}
+
+void cls_replica_log_get_bounds_op::
+generate_test_instances(std::list<cls_replica_log_get_bounds_op*>& ls)
+{
+  ls.push_back(new cls_replica_log_get_bounds_op);
+}
+
+void cls_replica_log_get_bounds_ret::dump(Formatter *f) const
+{
+  f->dump_string("position_marker", position_marker);
+  oldest_time.gmtime(f->dump_stream("oldest_time"));
+  encode_json("entity_markers", markers, f);
+}
+
+void cls_replica_log_get_bounds_ret::
+generate_test_instances(std::list<cls_replica_log_get_bounds_ret*>& ls)
+{
+  std::list<cls_replica_log_progress_marker*> samples;
+  cls_replica_log_progress_marker::generate_test_instances(samples);
+  std::list<cls_replica_log_progress_marker> samples_whole;
+  std::list<cls_replica_log_progress_marker*>::iterator i;
+  int count = 0;
+  for (i = samples.begin(); i != samples.end(); ++i) {
+    ls.push_back(new cls_replica_log_get_bounds_ret());
+    ls.back()->markers.push_back(*(*i));
+    ls.back()->oldest_time.set_from_double(1000*count);
+    ls.back()->position_marker = ls.back()->markers.front().position_marker;
+    samples_whole.push_back(*(*i));
+  }
+  ls.push_back(new cls_replica_log_get_bounds_ret());
+  ls.back()->markers = samples_whole;
+  ls.back()->oldest_time = samples_whole.back().position_time;
+  ls.back()->position_marker = samples_whole.back().position_marker;
+}
diff --git a/src/cls/replica_log/cls_replica_log_ops.h b/src/cls/replica_log/cls_replica_log_ops.h
new file mode 100644 (file)
index 0000000..0905bb9
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * Ceph - scalable distributed file system
+ *
+ * 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 CLS_REPLICA_LOG_OPS_H_
+#define CLS_REPLICA_LOG_OPS_H_
+
+#include "include/types.h"
+#include "cls_replica_log_types.h"
+
+struct cls_replica_log_delete_marker_op {
+  string entity_id;
+  cls_replica_log_delete_marker_op() {}
+  cls_replica_log_delete_marker_op(const string& id) : entity_id(id) {}
+
+  void encode(bufferlist& bl) const {
+    ENCODE_START(1, 1, bl);
+    ::encode(entity_id, bl);
+    ENCODE_FINISH(bl);
+  }
+
+  void decode(bufferlist::iterator& bl) {
+    DECODE_START(1, bl);
+    ::decode(entity_id, bl);
+    DECODE_FINISH(bl);
+  }
+
+  void dump(Formatter *f) const;
+  static void generate_test_instances(std::list<cls_replica_log_delete_marker_op*>& ls);
+
+};
+WRITE_CLASS_ENCODER(cls_replica_log_delete_marker_op)
+
+struct cls_replica_log_set_marker_op {
+  cls_replica_log_progress_marker marker;
+  cls_replica_log_set_marker_op() {}
+  cls_replica_log_set_marker_op(const cls_replica_log_progress_marker& m) :
+    marker(m) {}
+
+  void encode(bufferlist& bl) const {
+    ENCODE_START(1, 1, bl);
+    ::encode(marker, bl);
+    ENCODE_FINISH(bl);
+  }
+
+  void decode(bufferlist::iterator& bl) {
+    DECODE_START(1, bl);
+    ::decode(marker, bl);
+    DECODE_FINISH(bl);
+  }
+
+  void dump(Formatter *f) const;
+  static void generate_test_instances(std::list<cls_replica_log_set_marker_op*>& ls);
+};
+WRITE_CLASS_ENCODER(cls_replica_log_set_marker_op)
+
+struct cls_replica_log_get_bounds_op {
+  cls_replica_log_get_bounds_op() {}
+
+  void encode(bufferlist& bl) const {
+    ENCODE_START(1, 1, bl);
+    ENCODE_FINISH(bl);
+  }
+
+  void decode(bufferlist::iterator& bl) {
+    DECODE_START(1, bl);
+    DECODE_FINISH(bl);
+  }
+
+  void dump(Formatter *f) const;
+  static void generate_test_instances(std::list<cls_replica_log_get_bounds_op*>& ls);
+};
+WRITE_CLASS_ENCODER(cls_replica_log_get_bounds_op)
+
+struct cls_replica_log_get_bounds_ret {
+  string position_marker; // oldest log listing position on the master
+  utime_t oldest_time; // oldest timestamp associated with position or an item
+  std::list<cls_replica_log_progress_marker> markers;
+
+  cls_replica_log_get_bounds_ret() {}
+  cls_replica_log_get_bounds_ret(const string& pos_marker,
+    const utime_t& time,
+    const std::list<cls_replica_log_progress_marker>& m) :
+    position_marker(pos_marker), oldest_time(time), markers(m)
+  {}
+  void encode(bufferlist& bl) const {
+    ENCODE_START(1, 1, bl);
+    ::encode(position_marker, bl);
+    ::encode(oldest_time, bl);
+    ::encode(markers, bl);
+    ENCODE_FINISH(bl);
+  }
+
+  void decode(bufferlist::iterator& bl) {
+    DECODE_START(1, bl);
+    ::decode(position_marker, bl);
+    ::decode(oldest_time, bl);
+    ::decode(markers, bl);
+    DECODE_FINISH(bl);
+  }
+
+  void dump(Formatter *f) const;
+  static void generate_test_instances(std::list<cls_replica_log_get_bounds_ret*>& ls);
+};
+WRITE_CLASS_ENCODER(cls_replica_log_get_bounds_ret)
+
+#endif /* CLS_REPLICA_LOG_OPS_H_ */
index 263c774addc6352a84bc49158bdc4bb233855dd9..969f43d0cb05990435be78b34969659e6446cfa5 100644 (file)
@@ -240,7 +240,11 @@ TYPE(cls_lock_list_locks_reply)
 TYPE(cls_replica_log_item_marker)
 TYPE(cls_replica_log_progress_marker)
 TYPE(cls_replica_log_bound)
-
+#include "cls/replica_log/cls_replica_log_ops.h"
+TYPE(cls_replica_log_delete_marker_op)
+TYPE(cls_replica_log_set_marker_op)
+TYPE(cls_replica_log_get_bounds_op)
+TYPE(cls_replica_log_get_bounds_ret)
 
 // --- messages ---
 #include "messages/MAuth.h"