]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: specialized obj zone copy state for statelog
authorYehuda Sadeh <yehuda@inktank.com>
Wed, 19 Jun 2013 03:45:42 +0000 (20:45 -0700)
committerYehuda Sadeh <yehuda@inktank.com>
Wed, 19 Jun 2013 03:45:42 +0000 (20:45 -0700)
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
src/common/config_opts.h
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h

index ed52297bd784a00524be26f694f0be231e0f3288..d95724fce8ff4e1ccef5e2b9f6055d3b105487d8 100644 (file)
@@ -602,6 +602,7 @@ OPTION(rgw_get_obj_max_req_size, OPT_INT, 4 << 20) // max length of a single get
 OPTION(rgw_relaxed_s3_bucket_names, OPT_BOOL, false) // enable relaxed bucket name rules for US region buckets
 OPTION(rgw_list_buckets_max_chunk, OPT_INT, 1000) // max buckets to retrieve in a single op when listing user buckets
 OPTION(rgw_md_log_max_shards, OPT_INT, 64) // max shards for metadata log
+OPTION(rgw_num_zone_copy_state_shards, OPT_INT, 128) // max shards for keeping inter-region copy progress info
 
 OPTION(rgw_data_log_window, OPT_INT, 30) // data log entries window (in seconds)
 OPTION(rgw_data_log_changes_size, OPT_INT, 1000) // number of in-memory entries to hold for data changes log
index d90b35401c166701c0c59e27033b4741e0fbc6c2..61f7b3a45efba8c991ac6c6b0ec39c6cf72fc9fd 100644 (file)
@@ -5318,6 +5318,52 @@ void RGWStateLog::dump_entry(const cls_statelog_entry& entry, Formatter *f)
   f->close_section();
 }
 
+RGWObjZoneCopyState::RGWObjZoneCopyState(RGWRados *_store) : RGWStateLog(_store, _store->ctx()->_conf->rgw_num_zone_copy_state_shards, string("obj_zone_copy"))
+{
+}
+
+bool RGWObjZoneCopyState::dump_entry_internal(const cls_statelog_entry& entry, Formatter *f)
+{
+  string s;
+  switch ((CopyState)entry.state) {
+    case CS_UNKNOWN:
+      s = "unknown";
+      break;
+    case CS_IN_PROGRESS:
+      s = "in-progress";
+      break;
+    case CS_COMPLETE:
+      s = "complete";
+      break;
+    case CS_ERROR:
+      s = "error";
+      break;
+    case CS_ABORT:
+      s = "abort";
+      break;
+    case CS_CANCELLED:
+      s = "cancelled";
+      break;
+    default:
+      s = "invalid";
+  }
+  f->dump_string("state", s);
+  return true;
+}
+
+int RGWObjZoneCopyState::set_state(const string& client_id, const string& op_id, const string& object, CopyState state)
+{
+  uint32_t s = (uint32_t)state;
+  return store_entry(client_id, op_id, object, s, NULL, NULL);
+}
+
+int RGWObjZoneCopyState::renew_state(const string& client_id, const string& op_id, const string& object, CopyState state)
+{
+  uint32_t s = (uint32_t)state;
+  return store_entry(client_id, op_id, object, s, NULL, &s);
+}
+
+
 uint64_t RGWRados::instance_id()
 {
   return rados->get_instance_id();
index fcfb64e49a8573d42265e00bd4807d024353d393..544743dccf109219bf722de21205293f9a1b0b2b 100644 (file)
@@ -586,7 +586,7 @@ class RGWStateLog {
   };
 
 protected:
-  virtual int dump_entry_internal(const cls_statelog_entry& entry, Formatter *f) {
+  virtual bool dump_entry_internal(const cls_statelog_entry& entry, Formatter *f) {
     return false;
   }
 
@@ -606,7 +606,44 @@ public:
   void finish_list_entries(void *handle);
 
   virtual void dump_entry(const cls_statelog_entry& entry, Formatter *f);
+};
+
+/*
+ * state transitions:
+ *
+ * unknown -> in-progress -> complete
+ *                        -> error
+ *
+ * user can try setting the 'abort' state, and it can only succeed if state is
+ * in-progress.
+ *
+ * state renewal cannot switch state (stays in the same state)
+ *
+ * rgw can switch from in-progress to complete
+ * rgw can switch from in-progress to error
+ *
+ * rgw can switch from abort to cancelled
+ *
+ */
+
+class RGWObjZoneCopyState : public RGWStateLog {
+protected:
+  bool dump_entry_internal(const cls_statelog_entry& entry, Formatter *f);
+public:
+
+  enum CopyState {
+    CS_UNKNOWN     = 0,
+    CS_IN_PROGRESS = 1,
+    CS_COMPLETE    = 2,
+    CS_ERROR       = 3,
+    CS_ABORT       = 4,
+    CS_CANCELLED   = 5,
+  };
+
+  RGWObjZoneCopyState(RGWRados *_store);
 
+  int set_state(const string& client_id, const string& op_id, const string& object, CopyState state);
+  int renew_state(const string& client_id, const string& op_id, const string& object, CopyState state);
 };
 
 class RGWRados