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
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();
};
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;
}
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