From: Yehuda Sadeh Date: Wed, 28 Sep 2016 19:54:47 +0000 (-0700) Subject: rgw: bucket resharding, adjust logging X-Git-Tag: v0.94.10~8^2~4 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=4f605ebf3f415943e8c151364dadfdce3b69cde5;p=ceph.git rgw: bucket resharding, adjust logging Signed-off-by: Yehuda Sadeh --- diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index e23ac470d18..a08ccda9e1a 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -1351,6 +1351,8 @@ int main(int argc, char **argv) int bypass_gc = false; int inconsistent_index = false; + int verbose = false; + std::string val; std::ostringstream errs; string err; @@ -1414,6 +1416,8 @@ int main(int argc, char **argv) // do nothing } else if (ceph_argparse_binary_flag(args, i, &system, NULL, "--system", (char*)NULL)) { system_specified = true; + } else if (ceph_argparse_binary_flag(args, i, &verbose, NULL, "--verbose", (char*)NULL)) { + // do nothing } else if (ceph_argparse_withlonglong(args, i, &tmp, &errs, "-a", "--auth-uid", (char*)NULL)) { if (!errs.str().empty()) { cerr << errs.str() << std::endl; @@ -2710,10 +2714,14 @@ next: RGWBucketInfo new_bucket_info(bucket_info); store->create_bucket_id(&new_bucket_info.bucket.bucket_id); new_bucket_info.bucket.oid.clear(); - new_bucket_info.num_shards = num_shards; new_bucket_info.objv_tracker.clear(); + cout << "*** NOTICE: operation will not remove old bucket index objects ***" << std::endl; + cout << "*** these will need to be removed manually ***" << std::endl; + cout << "old bucket instance id: " << bucket_info.bucket.bucket_id << std::endl; + cout << "new bucket instance id: " << new_bucket_info.bucket.bucket_id << std::endl; + ret = store->init_bucket_index(new_bucket_info.bucket, new_bucket_info.num_shards); if (ret < 0) { cerr << "ERROR: failed to init new bucket indexes: " << cpp_strerror(-ret) << std::endl; @@ -2734,10 +2742,16 @@ next: int num_target_shards = (new_bucket_info.num_shards > 0 ? new_bucket_info.num_shards : 1); BucketReshardManager target_shards_mgr(store, new_bucket_info, num_target_shards); - formatter->open_array_section("entries"); + if (verbose) { + formatter->open_array_section("entries"); + } uint64_t total_entries = 0; + if (!verbose) { + cout << "total entries:"; + } + for (int i = 0; i < num_source_shards; ++i) { bool is_truncated = true; marker.clear(); @@ -2751,14 +2765,17 @@ next: list::iterator iter; for (iter = entries.begin(); iter != entries.end(); ++iter) { - formatter->open_object_section("entry"); + rgw_cls_bi_entry& entry = *iter; + + if (verbose) { + formatter->open_object_section("entry"); - encode_json("shard_id", i, formatter); - encode_json("num_entry", total_entries, formatter); + encode_json("shard_id", i, formatter); + encode_json("num_entry", total_entries, formatter); + encode_json("entry", entry, formatter); + } total_entries++; - rgw_cls_bi_entry& entry = *iter; - encode_json("entry", entry, formatter); marker = entry.idx; int target_shard_id; @@ -2781,13 +2798,21 @@ next: cerr << "ERROR: target_shards.add_entry(" << key << ") returned error: " << cpp_strerror(-ret) << std::endl; return ret; } - formatter->close_section(); - formatter->flush(cout); + if (verbose) { + formatter->close_section(); + formatter->flush(cout); + } else if (!(total_entries % 1000)) { + cout << " " << total_entries; + } } } } - formatter->close_section(); - formatter->flush(cout); + if (verbose) { + formatter->close_section(); + formatter->flush(cout); + } else { + cout << " " << total_entries << std::endl; + } ret = target_shards_mgr.finish(); if (ret < 0) {