1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2013 eNovance SAS <licensing@enovance.com>
8 * This is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License version 2.1, as published by the Free Software
11 * Foundation. See file COPYING.
14 #include "common/ceph_json.h"
15 #include "common/strtol.h"
18 #include "rgw_rest_s3.h"
19 #include "rgw_rest_log.h"
20 #include "rgw_client_io.h"
22 #include "rgw_data_sync.h"
23 #include "rgw_common.h"
24 #include "common/errno.h"
25 #include "include/assert.h"
27 #define dout_context g_ceph_context
28 #define LOG_CLASS_LIST_MAX_ENTRIES (1000)
29 #define dout_subsys ceph_subsys_rgw
31 static int parse_date_str(string
& in
, real_time
& out
) {
36 if (utime_t::parse_date(in
, &epoch
, &nsec
) < 0) {
37 dout(5) << "Error parsing date " << in
<< dendl
;
41 out
= utime_t(epoch
, nsec
).to_real_time();
45 void RGWOp_MDLog_List::execute() {
46 string period
= s
->info
.args
.get("period");
47 string shard
= s
->info
.args
.get("id");
48 string max_entries_str
= s
->info
.args
.get("max-entries");
49 string st
= s
->info
.args
.get("start-time"),
50 et
= s
->info
.args
.get("end-time"),
51 marker
= s
->info
.args
.get("marker"),
56 unsigned shard_id
, max_entries
= LOG_CLASS_LIST_MAX_ENTRIES
;
58 shard_id
= (unsigned)strict_strtol(shard
.c_str(), 10, &err
);
60 dout(5) << "Error parsing shard_id " << shard
<< dendl
;
65 if (parse_date_str(st
, ut_st
) < 0) {
70 if (parse_date_str(et
, ut_et
) < 0) {
75 if (!max_entries_str
.empty()) {
76 max_entries
= (unsigned)strict_strtol(max_entries_str
.c_str(), 10, &err
);
78 dout(5) << "Error parsing max-entries " << max_entries_str
<< dendl
;
82 if (max_entries
> LOG_CLASS_LIST_MAX_ENTRIES
) {
83 max_entries
= LOG_CLASS_LIST_MAX_ENTRIES
;
88 ldout(s
->cct
, 5) << "Missing period id trying to use current" << dendl
;
89 period
= store
->get_current_period_id();
91 ldout(s
->cct
, 5) << "Missing period id" << dendl
;
97 RGWMetadataLog meta_log
{s
->cct
, store
, period
};
99 meta_log
.init_list_entries(shard_id
, ut_st
, ut_et
, marker
, &handle
);
101 http_ret
= meta_log
.list_entries(handle
, max_entries
, entries
,
102 &last_marker
, &truncated
);
104 meta_log
.complete_list_entries(handle
);
107 void RGWOp_MDLog_List::send_response() {
108 set_req_state_err(s
, http_ret
);
115 s
->formatter
->open_object_section("log_entries");
116 s
->formatter
->dump_string("marker", last_marker
);
117 s
->formatter
->dump_bool("truncated", truncated
);
119 s
->formatter
->open_array_section("entries");
120 for (list
<cls_log_entry
>::iterator iter
= entries
.begin();
121 iter
!= entries
.end(); ++iter
) {
122 cls_log_entry
& entry
= *iter
;
123 store
->meta_mgr
->dump_log_entry(entry
, s
->formatter
);
126 s
->formatter
->close_section();
128 s
->formatter
->close_section();
132 void RGWOp_MDLog_Info::execute() {
133 num_objects
= s
->cct
->_conf
->rgw_md_log_max_shards
;
134 period
= store
->meta_mgr
->read_oldest_log_period();
135 http_ret
= period
.get_error();
138 void RGWOp_MDLog_Info::send_response() {
139 set_req_state_err(s
, http_ret
);
143 s
->formatter
->open_object_section("mdlog");
144 s
->formatter
->dump_unsigned("num_objects", num_objects
);
146 s
->formatter
->dump_string("period", period
.get_period().get_id());
147 s
->formatter
->dump_unsigned("realm_epoch", period
.get_epoch());
149 s
->formatter
->close_section();
153 void RGWOp_MDLog_ShardInfo::execute() {
154 string period
= s
->info
.args
.get("period");
155 string shard
= s
->info
.args
.get("id");
158 unsigned shard_id
= (unsigned)strict_strtol(shard
.c_str(), 10, &err
);
160 dout(5) << "Error parsing shard_id " << shard
<< dendl
;
165 if (period
.empty()) {
166 ldout(s
->cct
, 5) << "Missing period id trying to use current" << dendl
;
167 period
= store
->get_current_period_id();
169 if (period
.empty()) {
170 ldout(s
->cct
, 5) << "Missing period id" << dendl
;
175 RGWMetadataLog meta_log
{s
->cct
, store
, period
};
177 http_ret
= meta_log
.get_info(shard_id
, &info
);
180 void RGWOp_MDLog_ShardInfo::send_response() {
181 set_req_state_err(s
, http_ret
);
185 encode_json("info", info
, s
->formatter
);
189 void RGWOp_MDLog_Delete::execute() {
190 string st
= s
->info
.args
.get("start-time"),
191 et
= s
->info
.args
.get("end-time"),
192 start_marker
= s
->info
.args
.get("start-marker"),
193 end_marker
= s
->info
.args
.get("end-marker"),
194 period
= s
->info
.args
.get("period"),
195 shard
= s
->info
.args
.get("id"),
203 shard_id
= (unsigned)strict_strtol(shard
.c_str(), 10, &err
);
205 dout(5) << "Error parsing shard_id " << shard
<< dendl
;
209 if (et
.empty() && end_marker
.empty()) { /* bounding end */
214 if (parse_date_str(st
, ut_st
) < 0) {
219 if (parse_date_str(et
, ut_et
) < 0) {
224 if (period
.empty()) {
225 ldout(s
->cct
, 5) << "Missing period id trying to use current" << dendl
;
226 period
= store
->get_current_period_id();
228 if (period
.empty()) {
229 ldout(s
->cct
, 5) << "Missing period id" << dendl
;
234 RGWMetadataLog meta_log
{s
->cct
, store
, period
};
236 http_ret
= meta_log
.trim(shard_id
, ut_st
, ut_et
, start_marker
, end_marker
);
239 void RGWOp_MDLog_Lock::execute() {
240 string period
, shard_id_str
, duration_str
, locker_id
, zone_id
;
245 period
= s
->info
.args
.get("period");
246 shard_id_str
= s
->info
.args
.get("id");
247 duration_str
= s
->info
.args
.get("length");
248 locker_id
= s
->info
.args
.get("locker-id");
249 zone_id
= s
->info
.args
.get("zone-id");
251 if (period
.empty()) {
252 ldout(s
->cct
, 5) << "Missing period id trying to use current" << dendl
;
253 period
= store
->get_current_period_id();
256 if (period
.empty() ||
257 shard_id_str
.empty() ||
258 (duration_str
.empty()) ||
261 dout(5) << "Error invalid parameter list" << dendl
;
267 shard_id
= (unsigned)strict_strtol(shard_id_str
.c_str(), 10, &err
);
269 dout(5) << "Error parsing shard_id param " << shard_id_str
<< dendl
;
274 RGWMetadataLog meta_log
{s
->cct
, store
, period
};
276 dur
= (unsigned)strict_strtol(duration_str
.c_str(), 10, &err
);
277 if (!err
.empty() || dur
<= 0) {
278 dout(5) << "invalid length param " << duration_str
<< dendl
;
282 http_ret
= meta_log
.lock_exclusive(shard_id
, make_timespan(dur
), zone_id
,
284 if (http_ret
== -EBUSY
)
285 http_ret
= -ERR_LOCKED
;
288 void RGWOp_MDLog_Unlock::execute() {
289 string period
, shard_id_str
, locker_id
, zone_id
;
294 period
= s
->info
.args
.get("period");
295 shard_id_str
= s
->info
.args
.get("id");
296 locker_id
= s
->info
.args
.get("locker-id");
297 zone_id
= s
->info
.args
.get("zone-id");
299 if (period
.empty()) {
300 ldout(s
->cct
, 5) << "Missing period id trying to use current" << dendl
;
301 period
= store
->get_current_period_id();
304 if (period
.empty() ||
305 shard_id_str
.empty() ||
308 dout(5) << "Error invalid parameter list" << dendl
;
314 shard_id
= (unsigned)strict_strtol(shard_id_str
.c_str(), 10, &err
);
316 dout(5) << "Error parsing shard_id param " << shard_id_str
<< dendl
;
321 RGWMetadataLog meta_log
{s
->cct
, store
, period
};
322 http_ret
= meta_log
.unlock(shard_id
, zone_id
, locker_id
);
325 void RGWOp_MDLog_Notify::execute() {
328 #define LARGE_ENOUGH_BUF (128 * 1024)
329 int r
= rgw_rest_read_all_input(s
, &data
, &len
, LARGE_ENOUGH_BUF
);
335 ldout(s
->cct
, 20) << __func__
<< "(): read data: " << string(data
, len
) << dendl
;
338 r
= p
.parse(data
, len
);
341 ldout(s
->cct
, 0) << "ERROR: failed to parse JSON" << dendl
;
346 set
<int> updated_shards
;
348 decode_json_obj(updated_shards
, &p
);
349 } catch (JSONDecoder::err
& err
) {
350 ldout(s
->cct
, 0) << "ERROR: failed to decode JSON" << dendl
;
355 if (store
->ctx()->_conf
->subsys
.should_gather(ceph_subsys_rgw
, 20)) {
356 for (set
<int>::iterator iter
= updated_shards
.begin(); iter
!= updated_shards
.end(); ++iter
) {
357 ldout(s
->cct
, 20) << __func__
<< "(): updated shard=" << *iter
<< dendl
;
361 store
->wakeup_meta_sync_shards(updated_shards
);
366 void RGWOp_BILog_List::execute() {
367 string tenant_name
= s
->info
.args
.get("tenant"),
368 bucket_name
= s
->info
.args
.get("bucket"),
369 marker
= s
->info
.args
.get("marker"),
370 max_entries_str
= s
->info
.args
.get("max-entries"),
371 bucket_instance
= s
->info
.args
.get("bucket-instance");
372 RGWBucketInfo bucket_info
;
373 unsigned max_entries
;
375 RGWObjectCtx
& obj_ctx
= *static_cast<RGWObjectCtx
*>(s
->obj_ctx
);
377 if (bucket_name
.empty() && bucket_instance
.empty()) {
378 dout(5) << "ERROR: neither bucket nor bucket instance specified" << dendl
;
384 http_ret
= rgw_bucket_parse_bucket_instance(bucket_instance
, &bucket_instance
, &shard_id
);
389 if (!bucket_instance
.empty()) {
390 http_ret
= store
->get_bucket_instance_info(obj_ctx
, bucket_instance
, bucket_info
, NULL
, NULL
);
392 dout(5) << "could not get bucket instance info for bucket instance id=" << bucket_instance
<< dendl
;
395 } else { /* !bucket_name.empty() */
396 http_ret
= store
->get_bucket_info(obj_ctx
, tenant_name
, bucket_name
, bucket_info
, NULL
, NULL
);
398 dout(5) << "could not get bucket info for bucket=" << bucket_name
<< dendl
;
407 max_entries
= (unsigned)strict_strtol(max_entries_str
.c_str(), 10, &err
);
409 max_entries
= LOG_CLASS_LIST_MAX_ENTRIES
;
413 list
<rgw_bi_log_entry
> entries
;
414 int ret
= store
->list_bi_log_entries(bucket_info
, shard_id
,
415 marker
, max_entries
- count
,
416 entries
, &truncated
);
418 dout(5) << "ERROR: list_bi_log_entries()" << dendl
;
422 count
+= entries
.size();
424 send_response(entries
, marker
);
425 } while (truncated
&& count
< max_entries
);
430 void RGWOp_BILog_List::send_response() {
434 set_req_state_err(s
, http_ret
);
443 s
->formatter
->open_array_section("entries");
446 void RGWOp_BILog_List::send_response(list
<rgw_bi_log_entry
>& entries
, string
& marker
)
448 for (list
<rgw_bi_log_entry
>::iterator iter
= entries
.begin(); iter
!= entries
.end(); ++iter
) {
449 rgw_bi_log_entry
& entry
= *iter
;
450 encode_json("entry", entry
, s
->formatter
);
457 void RGWOp_BILog_List::send_response_end() {
458 s
->formatter
->close_section();
462 void RGWOp_BILog_Info::execute() {
463 string tenant_name
= s
->info
.args
.get("tenant"),
464 bucket_name
= s
->info
.args
.get("bucket"),
465 bucket_instance
= s
->info
.args
.get("bucket-instance");
466 RGWBucketInfo bucket_info
;
468 RGWObjectCtx
& obj_ctx
= *static_cast<RGWObjectCtx
*>(s
->obj_ctx
);
470 if (bucket_name
.empty() && bucket_instance
.empty()) {
471 dout(5) << "ERROR: neither bucket nor bucket instance specified" << dendl
;
477 http_ret
= rgw_bucket_parse_bucket_instance(bucket_instance
, &bucket_instance
, &shard_id
);
482 if (!bucket_instance
.empty()) {
483 http_ret
= store
->get_bucket_instance_info(obj_ctx
, bucket_instance
, bucket_info
, NULL
, NULL
);
485 dout(5) << "could not get bucket instance info for bucket instance id=" << bucket_instance
<< dendl
;
488 } else { /* !bucket_name.empty() */
489 http_ret
= store
->get_bucket_info(obj_ctx
, tenant_name
, bucket_name
, bucket_info
, NULL
, NULL
);
491 dout(5) << "could not get bucket info for bucket=" << bucket_name
<< dendl
;
495 map
<RGWObjCategory
, RGWStorageStats
> stats
;
496 int ret
= store
->get_bucket_stats(bucket_info
, shard_id
, &bucket_ver
, &master_ver
, stats
, &max_marker
);
497 if (ret
< 0 && ret
!= -ENOENT
) {
503 void RGWOp_BILog_Info::send_response() {
504 set_req_state_err(s
, http_ret
);
511 s
->formatter
->open_object_section("info");
512 encode_json("bucket_ver", bucket_ver
, s
->formatter
);
513 encode_json("master_ver", master_ver
, s
->formatter
);
514 encode_json("max_marker", max_marker
, s
->formatter
);
515 s
->formatter
->close_section();
520 void RGWOp_BILog_Delete::execute() {
521 string tenant_name
= s
->info
.args
.get("tenant"),
522 bucket_name
= s
->info
.args
.get("bucket"),
523 start_marker
= s
->info
.args
.get("start-marker"),
524 end_marker
= s
->info
.args
.get("end-marker"),
525 bucket_instance
= s
->info
.args
.get("bucket-instance");
527 RGWBucketInfo bucket_info
;
529 RGWObjectCtx
& obj_ctx
= *static_cast<RGWObjectCtx
*>(s
->obj_ctx
);
532 if ((bucket_name
.empty() && bucket_instance
.empty()) ||
533 end_marker
.empty()) {
534 dout(5) << "ERROR: one of bucket and bucket instance, and also end-marker is mandatory" << dendl
;
540 http_ret
= rgw_bucket_parse_bucket_instance(bucket_instance
, &bucket_instance
, &shard_id
);
545 if (!bucket_instance
.empty()) {
546 http_ret
= store
->get_bucket_instance_info(obj_ctx
, bucket_instance
, bucket_info
, NULL
, NULL
);
548 dout(5) << "could not get bucket instance info for bucket instance id=" << bucket_instance
<< dendl
;
551 } else { /* !bucket_name.empty() */
552 http_ret
= store
->get_bucket_info(obj_ctx
, tenant_name
, bucket_name
, bucket_info
, NULL
, NULL
);
554 dout(5) << "could not get bucket info for bucket=" << bucket_name
<< dendl
;
558 http_ret
= store
->trim_bi_log_entries(bucket_info
, shard_id
, start_marker
, end_marker
);
560 dout(5) << "ERROR: trim_bi_log_entries() " << dendl
;
565 void RGWOp_DATALog_List::execute() {
566 string shard
= s
->info
.args
.get("id");
568 string st
= s
->info
.args
.get("start-time"),
569 et
= s
->info
.args
.get("end-time"),
570 max_entries_str
= s
->info
.args
.get("max-entries"),
571 marker
= s
->info
.args
.get("marker"),
575 unsigned shard_id
, max_entries
= LOG_CLASS_LIST_MAX_ENTRIES
;
577 s
->info
.args
.get_bool("extra-info", &extra_info
, false);
579 shard_id
= (unsigned)strict_strtol(shard
.c_str(), 10, &err
);
581 dout(5) << "Error parsing shard_id " << shard
<< dendl
;
586 if (parse_date_str(st
, ut_st
) < 0) {
591 if (parse_date_str(et
, ut_et
) < 0) {
596 if (!max_entries_str
.empty()) {
597 max_entries
= (unsigned)strict_strtol(max_entries_str
.c_str(), 10, &err
);
599 dout(5) << "Error parsing max-entries " << max_entries_str
<< dendl
;
603 if (max_entries
> LOG_CLASS_LIST_MAX_ENTRIES
) {
604 max_entries
= LOG_CLASS_LIST_MAX_ENTRIES
;
608 // Note that last_marker is updated to be the marker of the last
610 http_ret
= store
->data_log
->list_entries(shard_id
, ut_st
, ut_et
,
611 max_entries
, entries
, marker
,
612 &last_marker
, &truncated
);
615 void RGWOp_DATALog_List::send_response() {
616 set_req_state_err(s
, http_ret
);
623 s
->formatter
->open_object_section("log_entries");
624 s
->formatter
->dump_string("marker", last_marker
);
625 s
->formatter
->dump_bool("truncated", truncated
);
627 s
->formatter
->open_array_section("entries");
628 for (list
<rgw_data_change_log_entry
>::iterator iter
= entries
.begin();
629 iter
!= entries
.end(); ++iter
) {
630 rgw_data_change_log_entry
& entry
= *iter
;
632 encode_json("entry", entry
.entry
, s
->formatter
);
634 encode_json("entry", entry
, s
->formatter
);
638 s
->formatter
->close_section();
640 s
->formatter
->close_section();
645 void RGWOp_DATALog_Info::execute() {
646 num_objects
= s
->cct
->_conf
->rgw_data_log_num_shards
;
650 void RGWOp_DATALog_Info::send_response() {
651 set_req_state_err(s
, http_ret
);
655 s
->formatter
->open_object_section("num_objects");
656 s
->formatter
->dump_unsigned("num_objects", num_objects
);
657 s
->formatter
->close_section();
661 void RGWOp_DATALog_ShardInfo::execute() {
662 string shard
= s
->info
.args
.get("id");
665 unsigned shard_id
= (unsigned)strict_strtol(shard
.c_str(), 10, &err
);
667 dout(5) << "Error parsing shard_id " << shard
<< dendl
;
672 http_ret
= store
->data_log
->get_info(shard_id
, &info
);
675 void RGWOp_DATALog_ShardInfo::send_response() {
676 set_req_state_err(s
, http_ret
);
680 encode_json("info", info
, s
->formatter
);
684 void RGWOp_DATALog_Lock::execute() {
685 string shard_id_str
, duration_str
, locker_id
, zone_id
;
690 shard_id_str
= s
->info
.args
.get("id");
691 duration_str
= s
->info
.args
.get("length");
692 locker_id
= s
->info
.args
.get("locker-id");
693 zone_id
= s
->info
.args
.get("zone-id");
695 if (shard_id_str
.empty() ||
696 (duration_str
.empty()) ||
699 dout(5) << "Error invalid parameter list" << dendl
;
705 shard_id
= (unsigned)strict_strtol(shard_id_str
.c_str(), 10, &err
);
707 dout(5) << "Error parsing shard_id param " << shard_id_str
<< dendl
;
713 dur
= (unsigned)strict_strtol(duration_str
.c_str(), 10, &err
);
714 if (!err
.empty() || dur
<= 0) {
715 dout(5) << "invalid length param " << duration_str
<< dendl
;
719 http_ret
= store
->data_log
->lock_exclusive(shard_id
, make_timespan(dur
), zone_id
, locker_id
);
720 if (http_ret
== -EBUSY
)
721 http_ret
= -ERR_LOCKED
;
724 void RGWOp_DATALog_Unlock::execute() {
725 string shard_id_str
, locker_id
, zone_id
;
730 shard_id_str
= s
->info
.args
.get("id");
731 locker_id
= s
->info
.args
.get("locker-id");
732 zone_id
= s
->info
.args
.get("zone-id");
734 if (shard_id_str
.empty() ||
737 dout(5) << "Error invalid parameter list" << dendl
;
743 shard_id
= (unsigned)strict_strtol(shard_id_str
.c_str(), 10, &err
);
745 dout(5) << "Error parsing shard_id param " << shard_id_str
<< dendl
;
750 http_ret
= store
->data_log
->unlock(shard_id
, zone_id
, locker_id
);
753 void RGWOp_DATALog_Notify::execute() {
754 string source_zone
= s
->info
.args
.get("source-zone");
757 #define LARGE_ENOUGH_BUF (128 * 1024)
758 int r
= rgw_rest_read_all_input(s
, &data
, &len
, LARGE_ENOUGH_BUF
);
764 ldout(s
->cct
, 20) << __func__
<< "(): read data: " << string(data
, len
) << dendl
;
767 r
= p
.parse(data
, len
);
770 ldout(s
->cct
, 0) << "ERROR: failed to parse JSON" << dendl
;
775 map
<int, set
<string
> > updated_shards
;
777 decode_json_obj(updated_shards
, &p
);
778 } catch (JSONDecoder::err
& err
) {
779 ldout(s
->cct
, 0) << "ERROR: failed to decode JSON" << dendl
;
784 if (store
->ctx()->_conf
->subsys
.should_gather(ceph_subsys_rgw
, 20)) {
785 for (map
<int, set
<string
> >::iterator iter
= updated_shards
.begin(); iter
!= updated_shards
.end(); ++iter
) {
786 ldout(s
->cct
, 20) << __func__
<< "(): updated shard=" << iter
->first
<< dendl
;
787 set
<string
>& keys
= iter
->second
;
788 for (set
<string
>::iterator kiter
= keys
.begin(); kiter
!= keys
.end(); ++kiter
) {
789 ldout(s
->cct
, 20) << __func__
<< "(): modified key=" << *kiter
<< dendl
;
794 store
->wakeup_data_sync_shards(source_zone
, updated_shards
);
799 void RGWOp_DATALog_Delete::execute() {
800 string st
= s
->info
.args
.get("start-time"),
801 et
= s
->info
.args
.get("end-time"),
802 start_marker
= s
->info
.args
.get("start-marker"),
803 end_marker
= s
->info
.args
.get("end-marker"),
804 shard
= s
->info
.args
.get("id"),
812 shard_id
= (unsigned)strict_strtol(shard
.c_str(), 10, &err
);
814 dout(5) << "Error parsing shard_id " << shard
<< dendl
;
818 if (et
.empty() && end_marker
.empty()) { /* bounding end */
823 if (parse_date_str(st
, ut_st
) < 0) {
828 if (parse_date_str(et
, ut_et
) < 0) {
833 http_ret
= store
->data_log
->trim_entries(shard_id
, ut_st
, ut_et
, start_marker
, end_marker
);
836 // not in header to avoid pulling in rgw_sync.h
837 class RGWOp_MDLog_Status
: public RGWRESTOp
{
838 rgw_meta_sync_status status
;
840 int check_caps(RGWUserCaps
& caps
) override
{
841 return caps
.check_cap("mdlog", RGW_CAP_READ
);
843 int verify_permission() override
{
844 return check_caps(s
->user
->caps
);
846 void execute() override
;
847 void send_response() override
;
848 const string
name() override
{ return "get_metadata_log_status"; }
851 void RGWOp_MDLog_Status::execute()
853 auto sync
= store
->get_meta_sync_manager();
854 if (sync
== nullptr) {
855 ldout(s
->cct
, 1) << "no sync manager" << dendl
;
859 http_ret
= sync
->read_sync_status(&status
);
862 void RGWOp_MDLog_Status::send_response()
864 set_req_state_err(s
, http_ret
);
869 encode_json("status", status
, s
->formatter
);
874 // not in header to avoid pulling in rgw_data_sync.h
875 class RGWOp_DATALog_Status
: public RGWRESTOp
{
876 rgw_data_sync_status status
;
878 int check_caps(RGWUserCaps
& caps
) override
{
879 return caps
.check_cap("datalog", RGW_CAP_READ
);
881 int verify_permission() override
{
882 return check_caps(s
->user
->caps
);
884 void execute() override
;
885 void send_response() override
;
886 const string
name() override
{ return "get_data_changes_log_status"; }
889 void RGWOp_DATALog_Status::execute()
891 const auto source_zone
= s
->info
.args
.get("source-zone");
892 auto sync
= store
->get_data_sync_manager(source_zone
);
893 if (sync
== nullptr) {
894 ldout(s
->cct
, 1) << "no sync manager for source-zone " << source_zone
<< dendl
;
898 http_ret
= sync
->read_sync_status(&status
);
901 void RGWOp_DATALog_Status::send_response()
903 set_req_state_err(s
, http_ret
);
908 encode_json("status", status
, s
->formatter
);
914 RGWOp
*RGWHandler_Log::op_get() {
916 string type
= s
->info
.args
.get("type", &exists
);
922 if (type
.compare("metadata") == 0) {
923 if (s
->info
.args
.exists("id")) {
924 if (s
->info
.args
.exists("info")) {
925 return new RGWOp_MDLog_ShardInfo
;
927 return new RGWOp_MDLog_List
;
929 } else if (s
->info
.args
.exists("status")) {
930 return new RGWOp_MDLog_Status
;
932 return new RGWOp_MDLog_Info
;
934 } else if (type
.compare("bucket-index") == 0) {
935 if (s
->info
.args
.exists("info")) {
936 return new RGWOp_BILog_Info
;
938 return new RGWOp_BILog_List
;
940 } else if (type
.compare("data") == 0) {
941 if (s
->info
.args
.exists("id")) {
942 if (s
->info
.args
.exists("info")) {
943 return new RGWOp_DATALog_ShardInfo
;
945 return new RGWOp_DATALog_List
;
947 } else if (s
->info
.args
.exists("status")) {
948 return new RGWOp_DATALog_Status
;
950 return new RGWOp_DATALog_Info
;
956 RGWOp
*RGWHandler_Log::op_delete() {
958 string type
= s
->info
.args
.get("type", &exists
);
964 if (type
.compare("metadata") == 0)
965 return new RGWOp_MDLog_Delete
;
966 else if (type
.compare("bucket-index") == 0)
967 return new RGWOp_BILog_Delete
;
968 else if (type
.compare("data") == 0)
969 return new RGWOp_DATALog_Delete
;
973 RGWOp
*RGWHandler_Log::op_post() {
975 string type
= s
->info
.args
.get("type", &exists
);
981 if (type
.compare("metadata") == 0) {
982 if (s
->info
.args
.exists("lock"))
983 return new RGWOp_MDLog_Lock
;
984 else if (s
->info
.args
.exists("unlock"))
985 return new RGWOp_MDLog_Unlock
;
986 else if (s
->info
.args
.exists("notify"))
987 return new RGWOp_MDLog_Notify
;
988 } else if (type
.compare("data") == 0) {
989 if (s
->info
.args
.exists("lock"))
990 return new RGWOp_DATALog_Lock
;
991 else if (s
->info
.args
.exists("unlock"))
992 return new RGWOp_DATALog_Unlock
;
993 else if (s
->info
.args
.exists("notify"))
994 return new RGWOp_DATALog_Notify
;