]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw: translate source_zone param into source zone id
authorYehuda Sadeh <yehuda@redhat.com>
Fri, 13 Nov 2015 18:48:19 +0000 (10:48 -0800)
committerYehuda Sadeh <yehuda@redhat.com>
Fri, 12 Feb 2016 00:13:32 +0000 (16:13 -0800)
operations are done using the zone id, not the zone name

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

index c5da69b7fe49bf64cfa34ea5035e93d7ea0f1215..9d22dc2fe02d640d79a5863ac57b76681c5ea337 100644 (file)
@@ -1591,7 +1591,8 @@ int main(int argc, char **argv)
   string err;
   long long tmp = 0;
 
-  string source_zone;
+  string source_zone_name;
+  string source_zone; /* zone id */
 
   for (std::vector<const char*>::iterator i = args.begin(); i != args.end(); ) {
     if (ceph_argparse_double_dash(args, i)) {
@@ -1851,7 +1852,7 @@ int main(int argc, char **argv)
       list<string>::iterator iter;
       get_str_list(val, endpoints);
     } else if (ceph_argparse_witharg(args, i, &val, "--source-zone", (char*)NULL)) {
-      source_zone = val;
+      source_zone_name = val;
     } else if (strncmp(*i, "-", 1) == 0) {
       cerr << "ERROR: invalid flag " << *i << std::endl;
       return EINVAL;
@@ -1968,6 +1969,13 @@ int main(int argc, char **argv)
     return 5; //EIO
   }
 
+  if (!source_zone_name.empty()) {
+    if (!store->find_zone_id_by_name(source_zone_name, &source_zone)) {
+      cerr << "WARNING: cannot find source zone id for name=" << source_zone_name << std::endl;
+      source_zone = source_zone_name;
+    }
+  }
+
   rgw_user_init(store);
   rgw_bucket_init(store->meta_mgr);
 
index ac8b1362d4b73aeba089b6be750ef356d5ff8a6c..4aaf9125489c25b2f7c00fa3e5984ddad2f5e17f 100644 (file)
@@ -356,12 +356,13 @@ int RGWRemoteDataLog::init(const string& _source_zone, RGWRESTConn *_conn)
     return 0;
   }
 
+  source_zone = _source_zone;
+
   CephContext *cct = store->ctx();
   async_rados = new RGWAsyncRadosProcessor(store, cct->_conf->rgw_num_async_rados_threads);
   async_rados->start();
 
   conn = _conn;
-  source_zone = _source_zone;
 
   int ret = http_manager.set_threaded();
   if (ret < 0) {
@@ -1274,7 +1275,7 @@ int RGWRemoteDataLog::run_sync(int num_shards, rgw_data_sync_status& sync_status
 
 int RGWDataSyncStatusManager::init()
 {
-  conn = store->get_zone_conn_by_name(source_zone);
+  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;
     return -EINVAL;
@@ -2310,7 +2311,7 @@ RGWCoroutine *RGWRemoteBucketLog::run_sync_cr()
 
 int RGWBucketSyncStatusManager::init()
 {
-  conn = store->get_zone_conn_by_name(source_zone);
+  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;
     return -EINVAL;
index aa9e23dc34353d2608debf29e0d778e2c21f5030..8440d3ff81407cb1d407a6156f283aa98dfca632 100644 (file)
@@ -3340,6 +3340,7 @@ int RGWRados::init_complete()
 
     Mutex::Locker dl(data_sync_thread_lock);
     for (map<string, RGWRESTConn *>::iterator iter = zone_conn_map.begin(); iter != zone_conn_map.end(); ++iter) {
+      ldout(cct, 5) << "starting data sync thread for zone " << iter->first << dendl;
       RGWDataSyncProcessorThread *thread = new RGWDataSyncProcessorThread(this, iter->first);
       ret = thread->init();
       if (ret < 0) {
index 4ba659093c8a9a8c848c799708b88ade28057fcb..dcdbc9ea40de145f26a71290523b8616951a196c 100644 (file)
@@ -1847,6 +1847,15 @@ public:
     return get_zone_conn_by_id(i->second);
   }
 
+  bool find_zone_id_by_name(const string& name, string *id) {
+    auto i = zone_id_by_name.find(name);
+    if (i == zone_id_by_name.end()) {
+      return false;
+    }
+    *id = i->second; 
+    return true;
+  }
+
   int get_zonegroup(const string& id, RGWZoneGroup& zonegroup) {
     int ret = 0;
     if (id == get_zonegroup().get_id()) {