From 02edcdd905d28708e25324dcf2ea189cc452cb88 Mon Sep 17 00:00:00 2001 From: Casey Bodley Date: Wed, 3 Feb 2016 10:00:30 -0500 Subject: [PATCH] rgw-admin: update callers of get_log Signed-off-by: Casey Bodley --- src/rgw/rgw_admin.cc | 39 ++++++++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index 9c2857b9b7df..cb4730b1a777 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -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 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 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) { -- 2.47.3