Skip to content

Commit

Permalink
Remove unused interface
Browse files Browse the repository at this point in the history
Signed-off-by: Emelia Lei <wlei29@bloomberg.net>
  • Loading branch information
emelialei88 committed Jan 15, 2025
1 parent 2259144 commit 99fff14
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 75 deletions.
6 changes: 2 additions & 4 deletions src/groups/mqb/mqba/mqba_domainmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down Expand Up @@ -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 {
Expand Down
16 changes: 11 additions & 5 deletions src/groups/mqb/mqbblp/mqbblp_clusterqueuehelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand All @@ -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
}
}
Expand Down
50 changes: 22 additions & 28 deletions src/groups/mqb/mqbblp/mqbblp_domain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
// limitations under the License.

// mqbblp_domain.cpp -*-C++-*-
#include <bslmt_latch.h>
#include <bsls_nullptr.h>
#include <mqbblp_domain.h>

#include <mqbscm_version.h>
Expand Down Expand Up @@ -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");
}

Expand Down Expand Up @@ -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);

Expand All @@ -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
}
Expand All @@ -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_STOPPED;
return; // RETURN
}

Expand Down Expand Up @@ -565,7 +565,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;
Expand Down Expand Up @@ -730,17 +730,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;
}
}
}
Expand Down Expand Up @@ -916,17 +915,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<mqbi::Queue>* out,
const bmqt::Uri& uri) const
Expand Down Expand Up @@ -1026,19 +1014,25 @@ bool Domain::tryRemove()
{
bslmt::LockGuard<bslmt::Mutex> 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
Expand Down
17 changes: 4 additions & 13 deletions src/groups/mqb/mqbblp/mqbblp_domain.h
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
9 changes: 1 addition & 8 deletions src/groups/mqb/mqbi/mqbi_domain.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
10 changes: 0 additions & 10 deletions src/groups/mqb/mqbmock/mqbmock_domain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<mqbi::Queue>* out,
const bmqt::Uri& uri) const
{
Expand Down
7 changes: 0 additions & 7 deletions src/groups/mqb/mqbmock/mqbmock_domain.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 99fff14

Please sign in to comment.