diff options
author | Yehuda Sadeh <yehuda@inktank.com> | 2013-06-18 20:45:42 -0700 |
---|---|---|
committer | Yehuda Sadeh <yehuda@inktank.com> | 2013-06-18 20:45:42 -0700 |
commit | d628109fded061eccbffa5d8d15cb5c2d8bc741e (patch) | |
tree | 9aa0e348f40ac779d5a860ea9b823dfa9b7838bb | |
parent | 13e030216e0d0a7143fd527ac51dd66059cb4a0f (diff) | |
download | ceph-d628109fded061eccbffa5d8d15cb5c2d8bc741e.tar.gz |
rgw: specialized obj zone copy state for statelog
Signed-off-by: Yehuda Sadeh <yehuda@inktank.com>
-rw-r--r-- | src/common/config_opts.h | 1 | ||||
-rw-r--r-- | src/rgw/rgw_rados.cc | 46 | ||||
-rw-r--r-- | src/rgw/rgw_rados.h | 39 |
3 files changed, 85 insertions, 1 deletions
diff --git a/src/common/config_opts.h b/src/common/config_opts.h index ed52297bd78..d95724fce8f 100644 --- a/src/common/config_opts.h +++ b/src/common/config_opts.h @@ -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 diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index d90b35401c1..61f7b3a45ef 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -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(); diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index fcfb64e49a8..544743dccf1 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -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 |