]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: define zone tier type, sync from appropriate tiers only
authorYehuda Sadeh <yehuda@redhat.com>
Tue, 2 Aug 2016 22:42:21 +0000 (15:42 -0700)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 7 Oct 2016 16:58:19 +0000 (09:58 -0700)
Can only sync from tiers that can export data.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
src/rgw/rgw_admin.cc
src/rgw/rgw_data_sync.cc
src/rgw/rgw_data_sync.h
src/rgw/rgw_json_enc.cc
src/rgw/rgw_rados.cc
src/rgw/rgw_rados.h
src/rgw/rgw_sync_module.h

index a7a732f22f1df93f2d47f07f993bb76193a103b1..4dbac39ac1c8ea263eca68a52a0fdc273a9ea856 100644 (file)
@@ -1955,9 +1955,9 @@ static void sync_status(Formatter *formatter)
     string zone_name;
     string source_str = "source: ";
     string s = source_str + source_id;
-    auto siter = store->zone_name_by_id.find(source_id);
-    if (siter != store->zone_name_by_id.end()) {
-      s += string(" (") + siter->second + ")";
+    auto siter = store->zone_by_id.find(source_id);
+    if (siter != store->zone_by_id.end()) {
+      s += string(" (") + siter->second.name + ")";
     }
     data_status.push_back(s);
     get_data_sync_status(source_id, data_status, source_str.size());
index 97e3cc235b873d0ac11e1b424d8a8a168c0fd9fb..b23467a8951f41bf0de77b2ea83c66148eb4537c 100644 (file)
@@ -1597,6 +1597,27 @@ int RGWRemoteDataLog::run_sync(int num_shards)
 
 int RGWDataSyncStatusManager::init()
 {
+  auto zone_def_iter = store->zone_by_id.find(source_zone);
+  if (zone_def_iter == store->zone_by_id.end()) {
+    ldout(store->ctx(), 0) << "ERROR: failed to find zone config info for zone=" << source_zone << dendl;
+    return -EIO;
+  }
+
+  auto& zone_def = zone_def_iter->second;
+
+  map<string, string> sync_module_config;
+
+  if (!store->get_sync_modules_manager()->supports_data_export(zone_def.tier_type)) {
+    return -ENOTSUP;
+  }
+
+  int r = store->get_sync_modules_manager()->create_instance(zone_def.tier_type, sync_module_config, &sync_module);
+  if (r < 0) {
+    lderr(store->ctx()) << "ERROR: failed to init sync module instance, r=" << r << dendl;
+    finalize();
+    return r;
+  }
+
   conn = store->get_zone_conn_by_id(source_zone);
   if (!conn) {
     ldout(store->ctx(), 0) << "connection object to zone " << source_zone << " does not exist" << dendl;
@@ -1605,7 +1626,7 @@ int RGWDataSyncStatusManager::init()
 
   const char *log_pool = store->get_zone_params().log_pool.name.c_str();
   librados::Rados *rados = store->get_rados_handle();
-  int r = rados->ioctx_create(log_pool, ioctx);
+  r = rados->ioctx_create(log_pool, ioctx);
   if (r < 0) {
     lderr(store->ctx()) << "ERROR: failed to open log pool (" << store->get_zone_params().log_pool.name << " ret=" << r << dendl;
     return r;
@@ -1615,14 +1636,6 @@ int RGWDataSyncStatusManager::init()
 
   error_logger = new RGWSyncErrorLogger(store, RGW_SYNC_ERROR_LOG_SHARD_PREFIX, ERROR_LOGGER_SHARDS);
 
-  map<string, string> sync_module_config;
-  r = store->get_sync_modules_manager()->create_instance("default", sync_module_config, &sync_module);
-  if (r < 0) {
-    lderr(store->ctx()) << "ERROR: failed to init sync module instance, r=" << r << dendl;
-    finalize();
-    return r;
-  }
-
   r = source_log.init(source_zone, conn, error_logger, sync_module);
   if (r < 0) {
     lderr(store->ctx()) << "ERROR: failed to init remote log, r=" << r << dendl;
index 78201d8b559ad8a00ae702591db8686ea8acbf02..d8c419511dcbd88d6f0637ed39b479c9e28a5611 100644 (file)
@@ -524,6 +524,7 @@ public:
 class RGWDefaultSyncModule : public RGWSyncModule {
 public:
   RGWDefaultSyncModule() {}
+  bool supports_data_export() override { return true; }
   int create_instance(map<string, string>& config, RGWSyncModuleInstanceRef *instance) override;
 };
 
index 0d6af4cf062b382d0cf5b429cadb4a2e5c1dc7af..b368e1562c85af1505ff3dc1b4343c1d374033ec 100644 (file)
@@ -916,6 +916,7 @@ void RGWZone::dump(Formatter *f) const
   encode_json("log_data", log_data, f);
   encode_json("bucket_index_max_shards", bucket_index_max_shards, f);
   encode_json("read_only", read_only, f);
+  encode_json("tier_type", tier_type, f);
 }
 
 void RGWZone::decode_json(JSONObj *obj)
@@ -930,6 +931,7 @@ void RGWZone::decode_json(JSONObj *obj)
   JSONDecoder::decode_json("log_data", log_data, obj);
   JSONDecoder::decode_json("bucket_index_max_shards", bucket_index_max_shards, obj);
   JSONDecoder::decode_json("read_only", read_only, obj);
+  JSONDecoder::decode_json("tier_type", tier_type, obj);
 }
 
 void RGWZoneGroupPlacementTarget::dump(Formatter *f) const
index 4a04aeee31a6fef90583bbca055dcfbcc261b777..6c41f7d8cebfd0e65220d6ec760dd463db3dee91 100644 (file)
@@ -3295,7 +3295,7 @@ int RGWRados::init_rados()
   sync_modules_manager = new RGWSyncModulesManager();
 
   RGWSyncModuleRef default_module(new RGWDefaultSyncModule());
-  sync_modules_manager->register_module("default", default_module);
+  sync_modules_manager->register_module("rgw", default_module, true);
 
   auto crs = std::unique_ptr<RGWCoroutinesManagerRegistry>{
     new RGWCoroutinesManagerRegistry(cct)};
@@ -3810,7 +3810,7 @@ int RGWRados::init_complete()
     const string& id = ziter->first;
     RGWZone& z = ziter->second;
     zone_id_by_name[z.name] = id;
-    zone_name_by_id[id] = z.name;
+    zone_by_id[id] = z;
     if (id != zone_id()) {
       if (!z.endpoints.empty()) {
         ldout(cct, 20) << "generating connection object for zone " << z.name << " id " << z.id << dendl;
index 4aa2976c823b285c7c6b8b95570baab208d757e1..024c22516b792d5b9ba5e21374eede8e9818639d 100644 (file)
@@ -1002,6 +1002,7 @@ struct RGWZone {
   bool log_meta;
   bool log_data;
   bool read_only;
+  string tier_type;
 
 /**
  * Represents the number of shards for the bucket index object, a value of zero
@@ -1015,7 +1016,7 @@ struct RGWZone {
   RGWZone() : log_meta(false), log_data(false), read_only(false), bucket_index_max_shards(0) {}
 
   void encode(bufferlist& bl) const {
-    ENCODE_START(4, 1, bl);
+    ENCODE_START(5, 1, bl);
     ::encode(name, bl);
     ::encode(endpoints, bl);
     ::encode(log_meta, bl);
@@ -1023,11 +1024,12 @@ struct RGWZone {
     ::encode(bucket_index_max_shards, bl);
     ::encode(id, bl);
     ::encode(read_only, bl);
+    ::encode(tier_type, bl);
     ENCODE_FINISH(bl);
   }
 
   void decode(bufferlist::iterator& bl) {
-    DECODE_START(4, bl);
+    DECODE_START(5, bl);
     ::decode(name, bl);
     if (struct_v < 4) {
       id = name;
@@ -1044,6 +1046,9 @@ struct RGWZone {
       ::decode(id, bl);
       ::decode(read_only, bl);
     }
+    if (struct_v >= 5) {
+      ::decode(tier_type, bl);
+    }
     DECODE_FINISH(bl);
   }
   void dump(Formatter *f) const;
@@ -1954,7 +1959,7 @@ public:
   map<string, RGWRESTConn *> zonegroup_conn_map;
 
   map<string, string> zone_id_by_name;
-  map<string, string> zone_name_by_id;
+  map<string, RGWZone> zone_by_id;
 
   RGWRESTConn *get_zone_conn_by_id(const string& id) {
     auto citer = zone_conn_map.find(id);
index 06a9e8452fa31b98f1b161ee8a1d4ae36bac4d23..abf6eb1c270bb8ec4647330d08fdd91878560521 100644 (file)
@@ -37,6 +37,7 @@ public:
   RGWSyncModule() {}
   virtual ~RGWSyncModule() {}
 
+  virtual bool supports_data_export() = 0;
   virtual int create_instance(map<string, string>& config, RGWSyncModuleInstanceRef *instance) = 0;
 };
 
@@ -50,9 +51,12 @@ class RGWSyncModulesManager {
 public:
   RGWSyncModulesManager() : lock("RGWSyncModulesManager") {}
 
-  void register_module(const string& name, RGWSyncModuleRef& module) {
+  void register_module(const string& name, RGWSyncModuleRef& module, bool is_default = false) {
     Mutex::Locker l(lock);
     modules[name] = module;
+    if (is_default) {
+      modules[string()] = module;
+    }
   }
 
   bool get_module(const string& name, RGWSyncModuleRef *module) {
@@ -66,6 +70,15 @@ public:
   }
 
 
+  int supports_data_export(const string& name) {
+    RGWSyncModuleRef module;
+    if (!get_module(name, &module)) {
+      return -ENOENT;
+    }
+
+    return module.get()->supports_data_export();
+  }
+
   int create_instance(const string& name, map<string, string>& config, RGWSyncModuleInstanceRef *instance) {
     RGWSyncModuleRef module;
     if (!get_module(name, &module)) {