@@ -124,7 +124,6 @@ void publish_commit_completion(rados_completion_t completion, void *arg) {
124124
125125class Manager : public DoutPrefixProvider {
126126 bool shutdown = false ;
127- const size_t max_queue_size;
128127 const uint32_t queues_update_period_ms;
129128 const uint32_t queues_update_retry_ms;
130129 const uint32_t queue_idle_sleep_us;
@@ -764,12 +763,11 @@ class Manager : public DoutPrefixProvider {
764763 }
765764
766765 // ctor: start all threads
767- Manager (CephContext* _cct, uint32_t _max_queue_size, uint32_t _queues_update_period_ms,
766+ Manager (CephContext* _cct, uint32_t _queues_update_period_ms,
768767 uint32_t _queues_update_retry_ms, uint32_t _queue_idle_sleep_us, u_int32_t failover_time_ms,
769768 uint32_t _stale_reservations_period_s, uint32_t _reservations_cleanup_period_s,
770769 uint32_t _worker_count, rgw::sal::RadosStore* store,
771770 const SiteConfig& site) :
772- max_queue_size (_max_queue_size),
773771 queues_update_period_ms (_queues_update_period_ms),
774772 queues_update_retry_ms (_queues_update_retry_ms),
775773 queue_idle_sleep_us (_queue_idle_sleep_us),
@@ -783,39 +781,6 @@ class Manager : public DoutPrefixProvider {
783781 site (site),
784782 rados_store (*store)
785783 {}
786-
787- int add_persistent_topic (const std::string& topic_queue, optional_yield y) {
788- if (topic_queue == Q_LIST_OBJECT_NAME) {
789- ldpp_dout (this , 1 ) << " ERROR: topic name cannot be: " << Q_LIST_OBJECT_NAME << " (conflict with queue list object name)" << dendl;
790- return -EINVAL;
791- }
792- librados::ObjectWriteOperation op;
793- op.create (true );
794- cls_2pc_queue_init (op, topic_queue, max_queue_size);
795- auto & rados_ioctx = rados_store.getRados ()->get_notif_pool_ctx ();
796- auto ret = rgw_rados_operate (this , rados_ioctx, topic_queue, &op, y);
797- if (ret == -EEXIST) {
798- // queue already exists - nothing to do
799- ldpp_dout (this , 20 ) << " INFO: queue for topic: " << topic_queue << " already exists. nothing to do" << dendl;
800- return 0 ;
801- }
802- if (ret < 0 ) {
803- // failed to create queue
804- ldpp_dout (this , 1 ) << " ERROR: failed to create queue for topic: " << topic_queue << " . error: " << ret << dendl;
805- return ret;
806- }
807-
808- bufferlist empty_bl;
809- std::map<std::string, bufferlist> new_topic{{topic_queue, empty_bl}};
810- op.omap_set (new_topic);
811- ret = rgw_rados_operate (this , rados_ioctx, Q_LIST_OBJECT_NAME, &op, y);
812- if (ret < 0 ) {
813- ldpp_dout (this , 1 ) << " ERROR: failed to add queue: " << topic_queue << " to queue list. error: " << ret << dendl;
814- return ret;
815- }
816- ldpp_dout (this , 20 ) << " INFO: queue: " << topic_queue << " added to queue list" << dendl;
817- return 0 ;
818- }
819784};
820785
821786std::unique_ptr<Manager> s_manager;
@@ -839,7 +804,7 @@ bool init(const DoutPrefixProvider* dpp, rgw::sal::RadosStore* store,
839804 return false ;
840805 }
841806 // TODO: take conf from CephContext
842- s_manager = std::make_unique<Manager>(dpp->get_cct (), MAX_QUEUE_SIZE,
807+ s_manager = std::make_unique<Manager>(dpp->get_cct (),
843808 Q_LIST_UPDATE_MSEC, Q_LIST_RETRY_MSEC,
844809 IDLE_TIMEOUT_USEC, FAILOVER_TIME_MSEC,
845810 STALE_RESERVATIONS_PERIOD_S, RESERVATIONS_CLEANUP_PERIOD_S,
@@ -856,11 +821,38 @@ void shutdown() {
856821 s_manager.reset ();
857822}
858823
859- int add_persistent_topic (const std::string& topic_name, optional_yield y) {
860- if (!s_manager) {
861- return -EAGAIN;
824+ int add_persistent_topic (const DoutPrefixProvider* dpp, librados::IoCtx& rados_ioctx,
825+ const std::string& topic_queue, optional_yield y)
826+ {
827+ if (topic_queue == Q_LIST_OBJECT_NAME) {
828+ ldpp_dout (dpp, 1 ) << " ERROR: topic name cannot be: " << Q_LIST_OBJECT_NAME << " (conflict with queue list object name)" << dendl;
829+ return -EINVAL;
862830 }
863- return s_manager->add_persistent_topic (topic_name, y);
831+ librados::ObjectWriteOperation op;
832+ op.create (true );
833+ cls_2pc_queue_init (op, topic_queue, MAX_QUEUE_SIZE);
834+ auto ret = rgw_rados_operate (dpp, rados_ioctx, topic_queue, &op, y);
835+ if (ret == -EEXIST) {
836+ // queue already exists - nothing to do
837+ ldpp_dout (dpp, 20 ) << " INFO: queue for topic: " << topic_queue << " already exists. nothing to do" << dendl;
838+ return 0 ;
839+ }
840+ if (ret < 0 ) {
841+ // failed to create queue
842+ ldpp_dout (dpp, 1 ) << " ERROR: failed to create queue for topic: " << topic_queue << " . error: " << ret << dendl;
843+ return ret;
844+ }
845+
846+ bufferlist empty_bl;
847+ std::map<std::string, bufferlist> new_topic{{topic_queue, empty_bl}};
848+ op.omap_set (new_topic);
849+ ret = rgw_rados_operate (dpp, rados_ioctx, Q_LIST_OBJECT_NAME, &op, y);
850+ if (ret < 0 ) {
851+ ldpp_dout (dpp, 1 ) << " ERROR: failed to add queue: " << topic_queue << " to queue list. error: " << ret << dendl;
852+ return ret;
853+ }
854+ ldpp_dout (dpp, 20 ) << " INFO: queue: " << topic_queue << " added to queue list" << dendl;
855+ return 0 ;
864856}
865857
866858int remove_persistent_topic (const DoutPrefixProvider* dpp, librados::IoCtx& rados_ioctx, const std::string& topic_queue, optional_yield y) {
@@ -889,13 +881,6 @@ int remove_persistent_topic(const DoutPrefixProvider* dpp, librados::IoCtx& rado
889881 return 0 ;
890882}
891883
892- int remove_persistent_topic (const std::string& topic_queue, optional_yield y) {
893- if (!s_manager) {
894- return -EAGAIN;
895- }
896- return remove_persistent_topic (s_manager.get (), s_manager->rados_store .getRados ()->get_notif_pool_ctx (), topic_queue, y);
897- }
898-
899884rgw::sal::Object* get_object_with_attributes (
900885 const reservation_t & res, rgw::sal::Object* obj) {
901886 // in case of copy obj, the tags and metadata are taken from source
0 commit comments