From a6792a2e839f4de34cf48c7fa5f79898e57728af Mon Sep 17 00:00:00 2001 From: Emelia Lei Date: Wed, 15 Jan 2025 10:16:13 -0500 Subject: [PATCH] Remove unused interface Signed-off-by: Emelia Lei --- src/groups/mqb/mqba/mqba_domainmanager.cpp | 6 +-- .../mqb/mqbblp/mqbblp_clusterqueuehelper.cpp | 16 ++++-- src/groups/mqb/mqbblp/mqbblp_domain.cpp | 51 +++++++++---------- src/groups/mqb/mqbblp/mqbblp_domain.h | 17 ++----- src/groups/mqb/mqbi/mqbi_domain.h | 9 +--- src/groups/mqb/mqbmock/mqbmock_domain.cpp | 10 ---- src/groups/mqb/mqbmock/mqbmock_domain.h | 7 --- 7 files changed, 41 insertions(+), 75 deletions(-) diff --git a/src/groups/mqb/mqba/mqba_domainmanager.cpp b/src/groups/mqb/mqba/mqba_domainmanager.cpp index 32828ecd76..9280573abb 100644 --- a/src/groups/mqb/mqba/mqba_domainmanager.cpp +++ b/src/groups/mqb/mqba/mqba_domainmanager.cpp @@ -722,7 +722,8 @@ int DomainManager::processCommand(mqbcmd::DomainsResult* result, if (!domainSp->tryRemove()) { bmqu::MemOutStream os; os << "Trying to remove the domain '" << name - << "' while there are open queue requests on the fly"; + << "' while there are open queue requests on the fly or " + "the domain is shutting down"; result->makeError().message() = os.str(); return -1; // RETURN } @@ -770,9 +771,6 @@ int DomainManager::processCommand(mqbcmd::DomainsResult* result, << " seconds. rc: " << rc << "."; return rc; } - - // 4. Mark DOMAINS REMOVE command first round as complete - domainSp->removeDomainComplete(); } // Second pass else { diff --git a/src/groups/mqb/mqbblp/mqbblp_clusterqueuehelper.cpp b/src/groups/mqb/mqbblp/mqbblp_clusterqueuehelper.cpp index 5732e6410f..a14e8c1d44 100644 --- a/src/groups/mqb/mqbblp/mqbblp_clusterqueuehelper.cpp +++ b/src/groups/mqb/mqbblp/mqbblp_clusterqueuehelper.cpp @@ -6224,6 +6224,12 @@ int ClusterQueueHelper::gcExpiredQueues(bool immediate, bool ClusterQueueHelper::hasActiveQueue(const bsl::string& domainName) { + // executed by the cluster *DISPATCHER* thread + + // PRECONDITIONS + BSLS_ASSERT_SAFE( + d_cluster_p->dispatcher()->inDispatcherThread(d_cluster_p)); + const mqbc::ClusterState::DomainStates& domainStates = d_clusterState_p->domainStates(); @@ -6239,17 +6245,17 @@ bool ClusterQueueHelper::hasActiveQueue(const bsl::string& domainName) for (UriToQueueInfoMapCIter qCit = queuesInfoPerDomain.cbegin(); qCit != queuesInfoPerDomain.cend(); ++qCit) { - QueueContextMapIter queueContextIt = d_queues.find( + QueueContextMapConstIter queueContextCIt = d_queues.find( qCit->second->uri()); - if (queueContextIt == d_queues.end()) { + if (queueContextCIt == d_queues.end()) { continue; } - if (queueContextIt->second->d_liveQInfo.d_inFlight != 0 || - queueContextIt->second->d_liveQInfo + if (queueContextCIt->second->d_liveQInfo.d_inFlight != 0 || + queueContextCIt->second->d_liveQInfo .d_numHandleCreationsInProgress != 0 || - queueContextIt->second->d_liveQInfo.d_numQueueHandles != 0) { + queueContextCIt->second->d_liveQInfo.d_numQueueHandles != 0) { return true; // RETURN } } diff --git a/src/groups/mqb/mqbblp/mqbblp_domain.cpp b/src/groups/mqb/mqbblp/mqbblp_domain.cpp index e8d2644e5f..0b307e46a1 100644 --- a/src/groups/mqb/mqbblp/mqbblp_domain.cpp +++ b/src/groups/mqb/mqbblp/mqbblp_domain.cpp @@ -14,7 +14,7 @@ // limitations under the License. // mqbblp_domain.cpp -*-C++-*- -#include +#include #include #include @@ -376,8 +376,7 @@ Domain::Domain(const bsl::string& name, Domain::~Domain() { - BSLS_ASSERT_SAFE((e_STOPPING == d_state || e_STOPPED == d_state || - e_POSTREMOVE == d_state) && + BSLS_ASSERT_SAFE((e_STOPPING == d_state || e_STOPPED == d_state) && "'teardown' must be called before the destructor"); } @@ -486,7 +485,7 @@ int Domain::configure(bsl::ostream& errorDescription, void Domain::teardown(const mqbi::Domain::TeardownCb& teardownCb) { // PRECONDITIONS - BSLS_ASSERT_SAFE(d_state != e_STOPPING && d_state != e_STOPPED); + BSLS_ASSERT_SAFE(d_state != e_STOPPING); BSLS_ASSERT_SAFE(!d_teardownCb); BSLS_ASSERT_SAFE(teardownCb); @@ -508,7 +507,7 @@ void Domain::teardown(const mqbi::Domain::TeardownCb& teardownCb) if (d_queues.empty()) { d_teardownCb(d_name); - d_teardownCb = nullptr; + d_teardownCb = bsl::nullptr_t(); d_state = e_STOPPED; return; // RETURN } @@ -521,6 +520,7 @@ void Domain::teardown(const mqbi::Domain::TeardownCb& teardownCb) void Domain::teardownRemove(const TeardownCb& teardownCb) { + // PRECONDITIONS BSLS_ASSERT_SAFE(!d_teardownRemoveCb); BSLS_ASSERT_SAFE(teardownCb); @@ -535,7 +535,8 @@ void Domain::teardownRemove(const TeardownCb& teardownCb) if (d_queues.empty()) { d_teardownRemoveCb(d_name); - d_teardownRemoveCb = nullptr; + d_teardownRemoveCb = bsl::nullptr_t(); + d_state = e_STOPPED; return; // RETURN } @@ -565,7 +566,7 @@ void Domain::openQueue( bmqp_ctrlmsg::Status status; - if (d_state == e_PREREMOVE || d_state == e_POSTREMOVE) { + if (d_state == e_PREREMOVE || d_state == e_STOPPED) { status.category() = bmqp_ctrlmsg::StatusCategory::E_REFUSED; status.code() = mqbi::ClusterErrorCode::e_UNKNOWN; status.message() = k_DOMAIN_IS_REMOVING_OR_REMOVED; @@ -730,17 +731,16 @@ void Domain::unregisterQueue(mqbi::Queue* queue) // Refer to note in 'teardown' routine to see why 'd_state' is updated // while 'd_mutex' is acquired. - if (d_teardownCb) { - if (d_queues.empty()) { + if (d_queues.empty()) { + if (d_teardownCb) { d_teardownCb(d_name); - d_teardownCb = nullptr; + d_teardownCb = bsl::nullptr_t(); d_state = e_STOPPED; } - } - if (d_teardownRemoveCb) { - if (d_queues.empty()) { + if (d_teardownRemoveCb) { d_teardownRemoveCb(d_name); - d_teardownRemoveCb = nullptr; + d_teardownRemoveCb = bsl::nullptr_t(); + d_state = e_STOPPED; } } } @@ -916,17 +916,6 @@ int Domain::processCommand(mqbcmd::DomainResult* result, return -1; } -void Domain::removeDomainReset() -{ - d_state = e_PREREMOVE; - d_teardownRemoveCb = bsl::nullptr_t(); -} - -void Domain::removeDomainComplete() -{ - d_state = e_POSTREMOVE; -} - // ACCESSORS int Domain::lookupQueue(bsl::shared_ptr* out, const bmqt::Uri& uri) const @@ -1026,19 +1015,25 @@ bool Domain::tryRemove() { bslmt::LockGuard guard(&d_mutex); // LOCK + if (d_state == e_STOPPING) { + return false; + } + if (d_pendingRequests != 0) { return false; } - // Mark DOMAIN PREREMOVE to block openQueue requests - removeDomainReset(); + // Reset d_teardownRemoveCb in case the first round of + // DOMAINS REMOVE fails and we want to call it again + d_state = e_PREREMOVE; + d_teardownRemoveCb = bsl::nullptr_t(); return true; } bool Domain::isRemoveComplete() const { - return d_state == e_POSTREMOVE; + return d_state == e_STOPPED; } } // close package namespace diff --git a/src/groups/mqb/mqbblp/mqbblp_domain.h b/src/groups/mqb/mqbblp/mqbblp_domain.h index 8549ab3607..c037c6a7e5 100644 --- a/src/groups/mqb/mqbblp/mqbblp_domain.h +++ b/src/groups/mqb/mqbblp/mqbblp_domain.h @@ -112,11 +112,9 @@ class Domain BSLS_KEYWORD_FINAL : public mqbi::Domain, e_STARTED = 0, e_STOPPING = 1, e_STOPPED = 2, - // Used as flags to indicate - // the start and finish of - // the first round for DOMAINS REMOVE - e_PREREMOVE = 3, - e_POSTREMOVE = 4, + // indicate the start of the + // first round of DOMAINS REMOVE + e_PREREMOVE = 3 }; private: @@ -334,13 +332,6 @@ class Domain BSLS_KEYWORD_FINAL : public mqbi::Domain, processCommand(mqbcmd::DomainResult* result, const mqbcmd::DomainCommand& command) BSLS_KEYWORD_OVERRIDE; - /// Mark the state of domain to be PREREMOVE - void removeDomainReset() BSLS_KEYWORD_OVERRIDE; - - /// Mark the state of domain to be POSTREMOVE, - /// indicating the first round of DOMAINS REMOVE is completed - void removeDomainComplete() BSLS_KEYWORD_OVERRIDE; - // ACCESSORS /// Load into the specified `out` the queue corresponding to the @@ -378,7 +369,7 @@ class Domain BSLS_KEYWORD_FINAL : public mqbi::Domain, const BSLS_KEYWORD_OVERRIDE; /// Check the state of the queues in this domain, return false if there's - /// queues opened or opening. + /// queues opened or opening, or if the domain is closed or closing. bool tryRemove() BSLS_KEYWORD_OVERRIDE; /// Check the state of the domain, return true if the first round diff --git a/src/groups/mqb/mqbi/mqbi_domain.h b/src/groups/mqb/mqbi/mqbi_domain.h index c85b217e2b..791bb0e918 100644 --- a/src/groups/mqb/mqbi/mqbi_domain.h +++ b/src/groups/mqb/mqbi/mqbi_domain.h @@ -185,13 +185,6 @@ class Domain { virtual int processCommand(mqbcmd::DomainResult* result, const mqbcmd::DomainCommand& command) = 0; - /// Mark the state of domain to be PREREMOVE - virtual void removeDomainReset() = 0; - - /// Mark the state of domain to be POSTREMOVE, - /// indicating the first round of DOMAINS REMOVE is completed - virtual void removeDomainComplete() = 0; - // ACCESSORS /// Load into the specified `out` the queue corresponding to the @@ -229,7 +222,7 @@ class Domain { bmqp_ctrlmsg::RoutingConfiguration* config) const = 0; /// Check the state of the queues in this domain, return false if there's - /// queues opened or opening. + /// queues opened or opening, or if the domain is closed or closing. virtual bool tryRemove() = 0; /// Check the state of the domain, return true if the first round diff --git a/src/groups/mqb/mqbmock/mqbmock_domain.cpp b/src/groups/mqb/mqbmock/mqbmock_domain.cpp index c9b845634a..57bf4209a1 100644 --- a/src/groups/mqb/mqbmock/mqbmock_domain.cpp +++ b/src/groups/mqb/mqbmock/mqbmock_domain.cpp @@ -155,16 +155,6 @@ int Domain::processCommand(mqbcmd::DomainResult* result, return -1; } -void Domain::removeDomainReset() -{ - BSLS_ASSERT_SAFE(false && "NOT IMPLEMENTED!"); -} - -void Domain::removeDomainComplete() -{ - BSLS_ASSERT_SAFE(false && "NOT IMPLEMENTED!"); -} - int Domain::lookupQueue(bsl::shared_ptr* out, const bmqt::Uri& uri) const { diff --git a/src/groups/mqb/mqbmock/mqbmock_domain.h b/src/groups/mqb/mqbmock/mqbmock_domain.h index 1624054947..900c08008b 100644 --- a/src/groups/mqb/mqbmock/mqbmock_domain.h +++ b/src/groups/mqb/mqbmock/mqbmock_domain.h @@ -211,13 +211,6 @@ class Domain : public mqbi::Domain { processCommand(mqbcmd::DomainResult* result, const mqbcmd::DomainCommand& command) BSLS_KEYWORD_OVERRIDE; - /// Mark the state of domain to be PREREMOVE - void removeDomainReset() BSLS_KEYWORD_OVERRIDE; - - /// Mark the state of domain to be POSTREMOVE, - /// indicating the first round of DOMAINS REMOVE is completed - void removeDomainComplete() BSLS_KEYWORD_OVERRIDE; - /// Load into the specified `out`, if `out` is not 0, the queue /// corresponding to the specified `uri`, if found. Return 0 on success, /// or a non-zero return code otherwise.