From: Yehuda Sadeh Date: Fri, 18 Mar 2016 22:15:47 +0000 (-0700) Subject: rgw_admin: new command to get bilog status X-Git-Tag: v10.1.1~128^2~5 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f6408ec4e06581aff7f9babc405cd1998b173a5e;p=ceph.git rgw_admin: new command to get bilog status Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index fccc8023398a..b4f2b93a55b5 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -331,6 +331,7 @@ enum { OPT_SYNC_ERROR_LIST, OPT_BILOG_LIST, OPT_BILOG_TRIM, + OPT_BILOG_STATUS, OPT_DATA_SYNC_STATUS, OPT_DATA_SYNC_INIT, OPT_DATA_SYNC_RUN, @@ -681,6 +682,8 @@ static int get_cmd(const char *cmd, const char *prev_cmd, const char *prev_prev_ return OPT_BILOG_LIST; if (strcmp(cmd, "trim") == 0) return OPT_BILOG_TRIM; + if (strcmp(cmd, "status") == 0) + return OPT_BILOG_STATUS; } else if (strcmp(prev_cmd, "data") == 0) { if (strcmp(cmd, "sync") == 0) { *need_more = true; @@ -5224,6 +5227,29 @@ next: } } + if (opt_cmd == OPT_BILOG_STATUS) { + if (bucket_name.empty()) { + cerr << "ERROR: bucket not specified" << std::endl; + return -EINVAL; + } + RGWBucketInfo bucket_info; + int ret = init_bucket(tenant, bucket_name, bucket_id, bucket_info, bucket); + if (ret < 0) { + cerr << "ERROR: could not init bucket: " << cpp_strerror(-ret) << std::endl; + return -ret; + } + map markers; + ret = store->get_bi_log_status(bucket, shard_id, markers); + if (ret < 0) { + cerr << "ERROR: trim_bi_log_entries(): " << cpp_strerror(-ret) << std::endl; + return -ret; + } + formatter->open_object_section("entries"); + encode_json("markers", markers, formatter); + formatter->close_section(); + formatter->flush(cout); + } + if (opt_cmd == OPT_DATALOG_LIST) { formatter->open_array_section("entries"); bool truncated; diff --git a/src/rgw/rgw_rados.cc b/src/rgw/rgw_rados.cc index 6af2440868ad..7d9228dd6193 100644 --- a/src/rgw/rgw_rados.cc +++ b/src/rgw/rgw_rados.cc @@ -10060,6 +10060,30 @@ int RGWRados::get_bucket_stats(rgw_bucket& bucket, int shard_id, string *bucket_ return 0; } +int RGWRados::get_bi_log_status(rgw_bucket& bucket, int shard_id, + map& markers) +{ + map headers; + map bucket_instance_ids; + int r = cls_bucket_head(bucket, shard_id, headers, &bucket_instance_ids); + if (r < 0) + return r; + + assert(headers.size() == bucket_instance_ids.size()); + + map::iterator iter = headers.begin(); + map::iterator viter = bucket_instance_ids.begin(); + + for(; iter != headers.end(); ++iter, ++viter) { + if (shard_id >= 0) { + markers[shard_id] = iter->second.max_marker; + } else { + markers[viter->first] = iter->second.max_marker; + } + } + return 0; +} + class RGWGetBucketStatsContext : public RGWGetDirHeader_CB { RGWGetBucketStats_CB *cb; uint32_t pendings; diff --git a/src/rgw/rgw_rados.h b/src/rgw/rgw_rados.h index 0735ad21b3b6..092ba5ceff01 100644 --- a/src/rgw/rgw_rados.h +++ b/src/rgw/rgw_rados.h @@ -2747,6 +2747,7 @@ public: int cls_bucket_head_async(rgw_bucket& bucket, int shard_id, RGWGetDirHeader_CB *ctx, int *num_aio); int list_bi_log_entries(rgw_bucket& bucket, int shard_id, string& marker, uint32_t max, std::list& result, bool *truncated); int trim_bi_log_entries(rgw_bucket& bucket, int shard_id, string& marker, string& end_marker); + int get_bi_log_status(rgw_bucket& bucket, int shard_id, map& max_marker); int bi_get_instance(rgw_obj& obj, rgw_bucket_dir_entry *dirent); int bi_get(rgw_bucket& bucket, rgw_obj& obj, BIIndexType index_type, rgw_cls_bi_entry *entry);