From ad9642cbadee909859a3d56f2defd1552679008c 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 | 29 +++++++------------ src/groups/mqb/mqbblp/mqbblp_domain.h | 9 +----- 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, 26 insertions(+), 60 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..4c8d2a23a3 100644 --- a/src/groups/mqb/mqbblp/mqbblp_domain.cpp +++ b/src/groups/mqb/mqbblp/mqbblp_domain.cpp @@ -14,7 +14,6 @@ // limitations under the License. // mqbblp_domain.cpp -*-C++-*- -#include #include #include @@ -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 } @@ -535,7 +534,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_POSTREMOVE; return; // RETURN } @@ -733,14 +733,15 @@ void Domain::unregisterQueue(mqbi::Queue* queue) if (d_teardownCb) { if (d_queues.empty()) { d_teardownCb(d_name); - d_teardownCb = nullptr; + d_teardownCb = bsl::nullptr_t(); d_state = e_STOPPED; } } if (d_teardownRemoveCb) { if (d_queues.empty()) { d_teardownRemoveCb(d_name); - d_teardownRemoveCb = nullptr; + d_teardownRemoveCb = bsl::nullptr_t(); + d_state = e_POSTREMOVE; } } } @@ -916,17 +917,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,12 +1016,15 @@ bool Domain::tryRemove() { bslmt::LockGuard guard(&d_mutex); // LOCK + if (d_state == e_STOPPING || d_state == e_STOPPED) { + return false; + } + if (d_pendingRequests != 0) { return false; } - // Mark DOMAIN PREREMOVE to block openQueue requests - removeDomainReset(); + d_state = e_PREREMOVE; return true; } diff --git a/src/groups/mqb/mqbblp/mqbblp_domain.h b/src/groups/mqb/mqbblp/mqbblp_domain.h index 8549ab3607..72b9cf4134 100644 --- a/src/groups/mqb/mqbblp/mqbblp_domain.h +++ b/src/groups/mqb/mqbblp/mqbblp_domain.h @@ -334,13 +334,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 +371,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.