Skip to content

Commit

Permalink
codegen admin command to remove a domain
Browse files Browse the repository at this point in the history
Signed-off-by: Emelia Lei <[email protected]>
  • Loading branch information
emelialei88 committed Dec 10, 2024
1 parent 1739af0 commit d760dbb
Show file tree
Hide file tree
Showing 5 changed files with 155 additions and 38 deletions.
3 changes: 2 additions & 1 deletion src/groups/mqb/mqbcmd/mqbcmd.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<element name='encoding' type='tns:EncodingFormat' default='TEXT'/>
</sequence>
</complexType>

<simpleType name='EncodingFormat'>
<annotation>
<documentation>
Expand Down Expand Up @@ -306,6 +306,7 @@
<complexType name="DomainCommand">
<choice>
<element name="purge" type="tns:Void"/>
<element name="remove" type="tns:Void"/>
<element name="info" type="tns:Void"/>
<element name="queue" type="tns:DomainQueue"/>
</choice>
Expand Down
3 changes: 3 additions & 0 deletions src/groups/mqb/mqbcmd/mqbcmd_commandlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ struct CommandDefinition {
{"DOMAINS DOMAIN <name> PURGE",
"Purge all queues in domain 'name'",
"Purge all queues in domain 'name'"},
{"DOMAINS DOMAIN <name> REMOVE",
"Reject all incoming connections to all queues in domain 'name'",
"and purge them from the domain"},
{"DOMAINS DOMAIN <name> INFOS",
"Show information about domain 'name' and its queues",
"Show information about domain 'name' and its queues"},
Expand Down
95 changes: 79 additions & 16 deletions src/groups/mqb/mqbcmd/mqbcmd_messages.cpp
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
// Copyright 2019-2024 Bloomberg Finance L.P.
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

// mqbcmd_messages.cpp *DO NOT EDIT* @generated -*-C++-*-

#include <mqbcmd_messages.h>
Expand Down Expand Up @@ -13626,6 +13611,11 @@ const bdlat_SelectionInfo DomainCommand::SELECTION_INFO_ARRAY[] = {
sizeof("purge") - 1,
"",
bdlat_FormattingMode::e_DEFAULT},
{SELECTION_ID_REMOVE,
"remove",
sizeof("remove") - 1,
"",
bdlat_FormattingMode::e_DEFAULT},
{SELECTION_ID_INFO,
"info",
sizeof("info") - 1,
Expand All @@ -13642,7 +13632,7 @@ const bdlat_SelectionInfo DomainCommand::SELECTION_INFO_ARRAY[] = {
const bdlat_SelectionInfo* DomainCommand::lookupSelectionInfo(const char* name,
int nameLength)
{
for (int i = 0; i < 3; ++i) {
for (int i = 0; i < 4; ++i) {
const bdlat_SelectionInfo& selectionInfo =
DomainCommand::SELECTION_INFO_ARRAY[i];

Expand All @@ -13660,6 +13650,8 @@ const bdlat_SelectionInfo* DomainCommand::lookupSelectionInfo(int id)
switch (id) {
case SELECTION_ID_PURGE:
return &SELECTION_INFO_ARRAY[SELECTION_INDEX_PURGE];
case SELECTION_ID_REMOVE:
return &SELECTION_INFO_ARRAY[SELECTION_INDEX_REMOVE];
case SELECTION_ID_INFO: return &SELECTION_INFO_ARRAY[SELECTION_INDEX_INFO];
case SELECTION_ID_QUEUE:
return &SELECTION_INFO_ARRAY[SELECTION_INDEX_QUEUE];
Expand All @@ -13678,6 +13670,9 @@ DomainCommand::DomainCommand(const DomainCommand& original,
case SELECTION_ID_PURGE: {
new (d_purge.buffer()) Void(original.d_purge.object());
} break;
case SELECTION_ID_REMOVE: {
new (d_remove.buffer()) Void(original.d_remove.object());
} break;
case SELECTION_ID_INFO: {
new (d_info.buffer()) Void(original.d_info.object());
} break;
Expand All @@ -13699,6 +13694,9 @@ DomainCommand::DomainCommand(DomainCommand&& original) noexcept
case SELECTION_ID_PURGE: {
new (d_purge.buffer()) Void(bsl::move(original.d_purge.object()));
} break;
case SELECTION_ID_REMOVE: {
new (d_remove.buffer()) Void(bsl::move(original.d_remove.object()));
} break;
case SELECTION_ID_INFO: {
new (d_info.buffer()) Void(bsl::move(original.d_info.object()));
} break;
Expand All @@ -13719,6 +13717,9 @@ DomainCommand::DomainCommand(DomainCommand&& original,
case SELECTION_ID_PURGE: {
new (d_purge.buffer()) Void(bsl::move(original.d_purge.object()));
} break;
case SELECTION_ID_REMOVE: {
new (d_remove.buffer()) Void(bsl::move(original.d_remove.object()));
} break;
case SELECTION_ID_INFO: {
new (d_info.buffer()) Void(bsl::move(original.d_info.object()));
} break;
Expand All @@ -13740,6 +13741,9 @@ DomainCommand& DomainCommand::operator=(const DomainCommand& rhs)
case SELECTION_ID_PURGE: {
makePurge(rhs.d_purge.object());
} break;
case SELECTION_ID_REMOVE: {
makeRemove(rhs.d_remove.object());
} break;
case SELECTION_ID_INFO: {
makeInfo(rhs.d_info.object());
} break;
Expand All @@ -13764,6 +13768,9 @@ DomainCommand& DomainCommand::operator=(DomainCommand&& rhs)
case SELECTION_ID_PURGE: {
makePurge(bsl::move(rhs.d_purge.object()));
} break;
case SELECTION_ID_REMOVE: {
makeRemove(bsl::move(rhs.d_remove.object()));
} break;
case SELECTION_ID_INFO: {
makeInfo(bsl::move(rhs.d_info.object()));
} break;
Expand All @@ -13786,6 +13793,9 @@ void DomainCommand::reset()
case SELECTION_ID_PURGE: {
d_purge.object().~Void();
} break;
case SELECTION_ID_REMOVE: {
d_remove.object().~Void();
} break;
case SELECTION_ID_INFO: {
d_info.object().~Void();
} break;
Expand All @@ -13804,6 +13814,9 @@ int DomainCommand::makeSelection(int selectionId)
case SELECTION_ID_PURGE: {
makePurge();
} break;
case SELECTION_ID_REMOVE: {
makeRemove();
} break;
case SELECTION_ID_INFO: {
makeInfo();
} break;
Expand Down Expand Up @@ -13874,6 +13887,51 @@ Void& DomainCommand::makePurge(Void&& value)
}
#endif

Void& DomainCommand::makeRemove()
{
if (SELECTION_ID_REMOVE == d_selectionId) {
bdlat_ValueTypeFunctions::reset(&d_remove.object());
}
else {
reset();
new (d_remove.buffer()) Void();
d_selectionId = SELECTION_ID_REMOVE;
}

return d_remove.object();
}

Void& DomainCommand::makeRemove(const Void& value)
{
if (SELECTION_ID_REMOVE == d_selectionId) {
d_remove.object() = value;
}
else {
reset();
new (d_remove.buffer()) Void(value);
d_selectionId = SELECTION_ID_REMOVE;
}

return d_remove.object();
}

#if defined(BSLS_COMPILERFEATURES_SUPPORT_RVALUE_REFERENCES) && \
defined(BSLS_COMPILERFEATURES_SUPPORT_NOEXCEPT)
Void& DomainCommand::makeRemove(Void&& value)
{
if (SELECTION_ID_REMOVE == d_selectionId) {
d_remove.object() = bsl::move(value);
}
else {
reset();
new (d_remove.buffer()) Void(bsl::move(value));
d_selectionId = SELECTION_ID_REMOVE;
}

return d_remove.object();
}
#endif

Void& DomainCommand::makeInfo()
{
if (SELECTION_ID_INFO == d_selectionId) {
Expand Down Expand Up @@ -13975,6 +14033,9 @@ DomainCommand::print(bsl::ostream& stream, int level, int spacesPerLevel) const
case SELECTION_ID_PURGE: {
printer.printAttribute("purge", d_purge.object());
} break;
case SELECTION_ID_REMOVE: {
printer.printAttribute("remove", d_remove.object());
} break;
case SELECTION_ID_INFO: {
printer.printAttribute("info", d_info.object());
} break;
Expand All @@ -13992,6 +14053,8 @@ const char* DomainCommand::selectionName() const
switch (d_selectionId) {
case SELECTION_ID_PURGE:
return SELECTION_INFO_ARRAY[SELECTION_INDEX_PURGE].name();
case SELECTION_ID_REMOVE:
return SELECTION_INFO_ARRAY[SELECTION_INDEX_REMOVE].name();
case SELECTION_ID_INFO:
return SELECTION_INFO_ARRAY[SELECTION_INDEX_INFO].name();
case SELECTION_ID_QUEUE:
Expand Down
Loading

0 comments on commit d760dbb

Please sign in to comment.