]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
rgw-admin: update callers of get_log
authorCasey Bodley <cbodley@redhat.com>
Wed, 3 Feb 2016 15:00:30 +0000 (10:00 -0500)
committerYehuda Sadeh <yehuda@redhat.com>
Thu, 18 Feb 2016 22:04:20 +0000 (14:04 -0800)
Signed-off-by: Casey Bodley <cbodley@redhat.com>
src/rgw/rgw_admin.cc

index 9c2857b9b7dfa1595a24a4753677c4e85311f3a6..cb4730b1a7770b336e3504dac1b946aefb0d7218 100644 (file)
@@ -4393,9 +4393,22 @@ next:
 
     int i = (specified_shard_id ? shard_id : 0);
 
+    if (period_id.empty()) {
+      // read current_period from the realm
+      RGWRealm realm(realm_id, realm_name);
+      ret = realm.init(g_ceph_context, store);
+      if (ret < 0) {
+        std::cerr << "failed to init realm: " << cpp_strerror(-ret) << std::endl;
+        return -ret;
+      }
+      period_id = realm.get_current_period();
+      std::cerr << "No --period given, using current period="
+          << period_id << std::endl;
+    }
+    RGWMetadataLog *meta_log = store->meta_mgr->get_log(period_id);
+
     formatter->open_array_section("entries");
     for (; i < g_ceph_context->_conf->rgw_md_log_max_shards; i++) {
-      RGWMetadataLog *meta_log = store->meta_mgr->get_log();
       void *handle;
       list<cls_log_entry> entries;
 
@@ -4431,11 +4444,23 @@ next:
   if (opt_cmd == OPT_MDLOG_STATUS) {
     int i = (specified_shard_id ? shard_id : 0);
 
-    RGWMetadataLog *meta_log = store->meta_mgr->get_log();
+    if (period_id.empty()) {
+      // read current_period from the realm
+      RGWRealm realm(realm_id, realm_name);
+      int ret = realm.init(g_ceph_context, store);
+      if (ret < 0) {
+        std::cerr << "failed to init realm: " << cpp_strerror(-ret) << std::endl;
+        return ret;
+      }
+      period_id = realm.get_current_period();
+      std::cerr << "No --period given, using current period="
+          << period_id << std::endl;
+    }
+    RGWMetadataLog *meta_log = store->meta_mgr->get_log(period_id);
+
     formatter->open_array_section("entries");
-    for (; i < g_ceph_context->_conf->rgw_md_log_max_shards; i++) {
-      list<cls_log_entry> entries;
 
+    for (; i < g_ceph_context->_conf->rgw_md_log_max_shards; i++) {
       RGWMetadataLogInfo info;
       meta_log->get_info(i, &info);
 
@@ -4466,7 +4491,11 @@ next:
     if (ret < 0)
       return -ret;
 
-    RGWMetadataLog *meta_log = store->meta_mgr->get_log();
+    if (period_id.empty()) {
+      std::cerr << "missing --period argument" << std::endl;
+      return EINVAL;
+    }
+    RGWMetadataLog *meta_log = store->meta_mgr->get_log(period_id);
 
     ret = meta_log->trim(shard_id, start_time, end_time, start_marker, end_marker);
     if (ret < 0) {