Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add autoIncremented parameter to batch-post in bmqtool #357

Merged
merged 10 commits into from
Jul 23, 2024
2 changes: 1 addition & 1 deletion src/applications/bmqtool/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ opened regularly (without specifying a mode). To run the `bmqtool`, you invoke
| `open` | `uri=string [async=true] [maxUnconfirmedMessages=N) (maxUnconfirmedByes=M)` | Open a connection with the queue at the given `uri`. |
| `close` | `uri=string [async=true]` | Close connection with the queue at the given `uri`. |
| `post` | `uri=string payload=string [, ...] [async=true]` | Post a message (the `payload`) to the queue at the given `uri`. |
| `batch-post` | `uri=string payload=string [, ...] (msgSize=S) (eventSize=N) (eventsCount=M) (postInterval=P) (postRate=R)` | Post `M` events containing `N` messages containing provided `payload` or auto-generated and containing `S` bytes each to the queue at the given `uri` at a rate of `R/P` (where `P` is expressed in ms). `M=0` means endless posting. |
| `batch-post` | `uri=string payload=string [, ...] (msgSize=S) (eventSize=N) (eventsCount=M) (postInterval=P) (postRate=R)` (autoIncremented=F)| Post `M` events containing `N` messages containing provided `payload` or auto-generated and containing `S` bytes each to the queue at the given `uri` at a rate of `R/P` (where `P` is expressed in ms). `M=0` means endless posting. Each message can have an integer property F which will be auto-incremented (0, 1, 2, ...).|
syuzvinsky marked this conversation as resolved.
Show resolved Hide resolved
| `list` | N/A | List the messages that have yet to be ACKed by the tool. |
| `confirm` | `guid=string` | Confirm (ACK) the message matching the given GUID. |
| `help` | N/A | Show the help dialog. |
Expand Down
1 change: 1 addition & 0 deletions src/applications/bmqtool/bmqtoolcmd.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@
<element name='eventsCount' type='long' default="0"/>
<element name='postInterval' type='int' default="1000"/>
<element name='postRate' type='int' default="1"/>
<element name='autoIncremented' type='string' default=""/>
</sequence>
</complexType>

Expand Down
6 changes: 4 additions & 2 deletions src/applications/bmqtool/m_bmqtool_interactive.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ void Interactive::printHelp()
"\"type\": \"\"}])"
<< bsl::endl
<< " batch-post uri=\"\" payload=[\"\",\"\"] (msgSize=u) "
"(eventSize=v) (eventsCount=w) (postInterval=x) (postRate=y)"
"(eventSize=v) (eventsCount=w) (postInterval=x) (postRate=y) "
"(autoIncremented=\"field\")"
<< bsl::endl
<< " list (uri=\"\")" << bsl::endl
<< " confirm uri=\"\" guid=\"\" "
Expand Down Expand Up @@ -152,7 +153,7 @@ void Interactive::printHelp()
<< bsl::endl
<< " batch-post uri=\"bmq://bmq.test.persistent.priority/qqq\" "
"payload=[\"sample message\"] eventsCount=300 postInterval=5000 "
"postRate=10"
"postRate=10 autoIncremented=\"x\""
<< bsl::endl
<< " - 'batch-post' command requires 'uri' argument, "
"all the rest are optional"
Expand Down Expand Up @@ -716,6 +717,7 @@ void Interactive::processCommand(const BatchPostCommand& command)
parameters.setEventSize(command.eventSize());
parameters.setPostInterval(command.postInterval());
parameters.setMsgSize(command.msgSize());
parameters.setAutoIncrementedField(command.autoIncremented());

// Lookup the Queue by URI
bmqa::QueueId queueId;
Expand Down
62 changes: 39 additions & 23 deletions src/applications/bmqtool/m_bmqtool_messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
// 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.

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

#include <m_bmqtool_messages.h>
Expand Down Expand Up @@ -58,6 +57,8 @@ const int BatchPostCommand::DEFAULT_INITIALIZER_POST_INTERVAL = 1000;

const int BatchPostCommand::DEFAULT_INITIALIZER_POST_RATE = 1;

const char BatchPostCommand::DEFAULT_INITIALIZER_AUTO_INCREMENTED[] = "";

const bdlat_AttributeInfo BatchPostCommand::ATTRIBUTE_INFO_ARRAY[] = {
{ATTRIBUTE_ID_URI,
"uri",
Expand Down Expand Up @@ -93,14 +94,19 @@ const bdlat_AttributeInfo BatchPostCommand::ATTRIBUTE_INFO_ARRAY[] = {
"postRate",
sizeof("postRate") - 1,
"",
bdlat_FormattingMode::e_DEC}};
bdlat_FormattingMode::e_DEC},
{ATTRIBUTE_ID_AUTO_INCREMENTED,
"autoIncremented",
sizeof("autoIncremented") - 1,
"",
bdlat_FormattingMode::e_TEXT}};

// CLASS METHODS

const bdlat_AttributeInfo*
BatchPostCommand::lookupAttributeInfo(const char* name, int nameLength)
{
for (int i = 0; i < 7; ++i) {
for (int i = 0; i < 8; ++i) {
const bdlat_AttributeInfo& attributeInfo =
BatchPostCommand::ATTRIBUTE_INFO_ARRAY[i];

Expand Down Expand Up @@ -129,6 +135,8 @@ const bdlat_AttributeInfo* BatchPostCommand::lookupAttributeInfo(int id)
return &ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_POST_INTERVAL];
case ATTRIBUTE_ID_POST_RATE:
return &ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_POST_RATE];
case ATTRIBUTE_ID_AUTO_INCREMENTED:
return &ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_AUTO_INCREMENTED];
default: return 0;
}
}
Expand All @@ -140,6 +148,7 @@ BatchPostCommand::BatchPostCommand(bslma::Allocator* basicAllocator)
, d_eventsCount(DEFAULT_INITIALIZER_EVENTS_COUNT)
, d_payload(basicAllocator)
, d_uri(basicAllocator)
, d_autoIncremented(DEFAULT_INITIALIZER_AUTO_INCREMENTED, basicAllocator)
, d_msgSize(DEFAULT_INITIALIZER_MSG_SIZE)
, d_postInterval(DEFAULT_INITIALIZER_POST_INTERVAL)
, d_postRate(DEFAULT_INITIALIZER_POST_RATE)
Expand All @@ -152,6 +161,7 @@ BatchPostCommand::BatchPostCommand(const BatchPostCommand& original,
, d_eventsCount(original.d_eventsCount)
, d_payload(original.d_payload, basicAllocator)
, d_uri(original.d_uri, basicAllocator)
, d_autoIncremented(original.d_autoIncremented, basicAllocator)
, d_msgSize(original.d_msgSize)
, d_postInterval(original.d_postInterval)
, d_postRate(original.d_postRate)
Expand All @@ -165,6 +175,7 @@ BatchPostCommand::BatchPostCommand(BatchPostCommand&& original) noexcept
d_eventsCount(bsl::move(original.d_eventsCount)),
d_payload(bsl::move(original.d_payload)),
d_uri(bsl::move(original.d_uri)),
d_autoIncremented(bsl::move(original.d_autoIncremented)),
d_msgSize(bsl::move(original.d_msgSize)),
d_postInterval(bsl::move(original.d_postInterval)),
d_postRate(bsl::move(original.d_postRate))
Expand All @@ -177,6 +188,7 @@ BatchPostCommand::BatchPostCommand(BatchPostCommand&& original,
, d_eventsCount(bsl::move(original.d_eventsCount))
, d_payload(bsl::move(original.d_payload), basicAllocator)
, d_uri(bsl::move(original.d_uri), basicAllocator)
, d_autoIncremented(bsl::move(original.d_autoIncremented), basicAllocator)
, d_msgSize(bsl::move(original.d_msgSize))
, d_postInterval(bsl::move(original.d_postInterval))
, d_postRate(bsl::move(original.d_postRate))
Expand All @@ -193,13 +205,14 @@ BatchPostCommand::~BatchPostCommand()
BatchPostCommand& BatchPostCommand::operator=(const BatchPostCommand& rhs)
{
if (this != &rhs) {
d_uri = rhs.d_uri;
d_payload = rhs.d_payload;
d_msgSize = rhs.d_msgSize;
d_eventSize = rhs.d_eventSize;
d_eventsCount = rhs.d_eventsCount;
d_postInterval = rhs.d_postInterval;
d_postRate = rhs.d_postRate;
d_uri = rhs.d_uri;
d_payload = rhs.d_payload;
d_msgSize = rhs.d_msgSize;
d_eventSize = rhs.d_eventSize;
d_eventsCount = rhs.d_eventsCount;
d_postInterval = rhs.d_postInterval;
d_postRate = rhs.d_postRate;
d_autoIncremented = rhs.d_autoIncremented;
}

return *this;
Expand All @@ -210,13 +223,14 @@ BatchPostCommand& BatchPostCommand::operator=(const BatchPostCommand& rhs)
BatchPostCommand& BatchPostCommand::operator=(BatchPostCommand&& rhs)
{
if (this != &rhs) {
d_uri = bsl::move(rhs.d_uri);
d_payload = bsl::move(rhs.d_payload);
d_msgSize = bsl::move(rhs.d_msgSize);
d_eventSize = bsl::move(rhs.d_eventSize);
d_eventsCount = bsl::move(rhs.d_eventsCount);
d_postInterval = bsl::move(rhs.d_postInterval);
d_postRate = bsl::move(rhs.d_postRate);
d_uri = bsl::move(rhs.d_uri);
d_payload = bsl::move(rhs.d_payload);
d_msgSize = bsl::move(rhs.d_msgSize);
d_eventSize = bsl::move(rhs.d_eventSize);
d_eventsCount = bsl::move(rhs.d_eventsCount);
d_postInterval = bsl::move(rhs.d_postInterval);
d_postRate = bsl::move(rhs.d_postRate);
d_autoIncremented = bsl::move(rhs.d_autoIncremented);
}

return *this;
Expand All @@ -227,11 +241,12 @@ void BatchPostCommand::reset()
{
bdlat_ValueTypeFunctions::reset(&d_uri);
bdlat_ValueTypeFunctions::reset(&d_payload);
d_msgSize = DEFAULT_INITIALIZER_MSG_SIZE;
d_eventSize = DEFAULT_INITIALIZER_EVENT_SIZE;
d_eventsCount = DEFAULT_INITIALIZER_EVENTS_COUNT;
d_postInterval = DEFAULT_INITIALIZER_POST_INTERVAL;
d_postRate = DEFAULT_INITIALIZER_POST_RATE;
d_msgSize = DEFAULT_INITIALIZER_MSG_SIZE;
d_eventSize = DEFAULT_INITIALIZER_EVENT_SIZE;
d_eventsCount = DEFAULT_INITIALIZER_EVENTS_COUNT;
d_postInterval = DEFAULT_INITIALIZER_POST_INTERVAL;
d_postRate = DEFAULT_INITIALIZER_POST_RATE;
d_autoIncremented = DEFAULT_INITIALIZER_AUTO_INCREMENTED;
}

// ACCESSORS
Expand All @@ -249,6 +264,7 @@ bsl::ostream& BatchPostCommand::print(bsl::ostream& stream,
printer.printAttribute("eventsCount", this->eventsCount());
printer.printAttribute("postInterval", this->postInterval());
printer.printAttribute("postRate", this->postRate());
printer.printAttribute("autoIncremented", this->autoIncremented());
printer.end();
return stream;
}
Expand Down Expand Up @@ -6799,6 +6815,6 @@ const char* Command::selectionName() const
} // close package namespace
} // close enterprise namespace

// GENERATED BY BLP_BAS_CODEGEN_2024.05.16
// GENERATED BY BLP_BAS_CODEGEN_2024.07.04.1
// USING bas_codegen.pl -m msg --noAggregateConversion --noExternalization
// --noIdent --package m_bmqtool --msgComponent messages bmqtoolcmd.xsd
81 changes: 64 additions & 17 deletions src/applications/bmqtool/m_bmqtool_messages.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ class BatchPostCommand {
bsls::Types::Int64 d_eventsCount;
bsl::vector<bsl::string> d_payload;
bsl::string d_uri;
bsl::string d_autoIncremented;
int d_msgSize;
int d_postInterval;
int d_postRate;
Expand All @@ -156,25 +157,27 @@ class BatchPostCommand {
public:
// TYPES
enum {
ATTRIBUTE_ID_URI = 0,
ATTRIBUTE_ID_PAYLOAD = 1,
ATTRIBUTE_ID_MSG_SIZE = 2,
ATTRIBUTE_ID_EVENT_SIZE = 3,
ATTRIBUTE_ID_EVENTS_COUNT = 4,
ATTRIBUTE_ID_POST_INTERVAL = 5,
ATTRIBUTE_ID_POST_RATE = 6
ATTRIBUTE_ID_URI = 0,
ATTRIBUTE_ID_PAYLOAD = 1,
ATTRIBUTE_ID_MSG_SIZE = 2,
ATTRIBUTE_ID_EVENT_SIZE = 3,
ATTRIBUTE_ID_EVENTS_COUNT = 4,
ATTRIBUTE_ID_POST_INTERVAL = 5,
ATTRIBUTE_ID_POST_RATE = 6,
ATTRIBUTE_ID_AUTO_INCREMENTED = 7
};

enum { NUM_ATTRIBUTES = 7 };
enum { NUM_ATTRIBUTES = 8 };

enum {
ATTRIBUTE_INDEX_URI = 0,
ATTRIBUTE_INDEX_PAYLOAD = 1,
ATTRIBUTE_INDEX_MSG_SIZE = 2,
ATTRIBUTE_INDEX_EVENT_SIZE = 3,
ATTRIBUTE_INDEX_EVENTS_COUNT = 4,
ATTRIBUTE_INDEX_POST_INTERVAL = 5,
ATTRIBUTE_INDEX_POST_RATE = 6
ATTRIBUTE_INDEX_URI = 0,
ATTRIBUTE_INDEX_PAYLOAD = 1,
ATTRIBUTE_INDEX_MSG_SIZE = 2,
ATTRIBUTE_INDEX_EVENT_SIZE = 3,
ATTRIBUTE_INDEX_EVENTS_COUNT = 4,
ATTRIBUTE_INDEX_POST_INTERVAL = 5,
ATTRIBUTE_INDEX_POST_RATE = 6,
ATTRIBUTE_INDEX_AUTO_INCREMENTED = 7
};

// CONSTANTS
Expand All @@ -190,6 +193,8 @@ class BatchPostCommand {

static const int DEFAULT_INITIALIZER_POST_RATE;

static const char DEFAULT_INITIALIZER_AUTO_INCREMENTED[];

static const bdlat_AttributeInfo ATTRIBUTE_INFO_ARRAY[];

public:
Expand Down Expand Up @@ -310,6 +315,10 @@ class BatchPostCommand {
// Return a reference to the modifiable "PostRate" attribute of this
// object.

bsl::string& autoIncremented();
// Return a reference to the modifiable "AutoIncremented" attribute of
// this object.

// ACCESSORS
bsl::ostream&
print(bsl::ostream& stream, int level = 0, int spacesPerLevel = 4) const;
Expand Down Expand Up @@ -376,6 +385,10 @@ class BatchPostCommand {
int postRate() const;
// Return the value of the "PostRate" attribute of this object.

const bsl::string& autoIncremented() const;
// Return a reference offering non-modifiable access to the
// "AutoIncremented" attribute of this object.

// HIDDEN FRIENDS
friend bool operator==(const BatchPostCommand& lhs,
const BatchPostCommand& rhs)
Expand Down Expand Up @@ -6875,6 +6888,7 @@ void BatchPostCommand::hashAppendImpl(t_HASH_ALGORITHM& hashAlgorithm) const
hashAppend(hashAlgorithm, this->eventsCount());
hashAppend(hashAlgorithm, this->postInterval());
hashAppend(hashAlgorithm, this->postRate());
hashAppend(hashAlgorithm, this->autoIncremented());
}

inline bool BatchPostCommand::isEqualTo(const BatchPostCommand& rhs) const
Expand All @@ -6884,7 +6898,8 @@ inline bool BatchPostCommand::isEqualTo(const BatchPostCommand& rhs) const
this->eventSize() == rhs.eventSize() &&
this->eventsCount() == rhs.eventsCount() &&
this->postInterval() == rhs.postInterval() &&
this->postRate() == rhs.postRate();
this->postRate() == rhs.postRate() &&
this->autoIncremented() == rhs.autoIncremented();
}

// CLASS METHODS
Expand Down Expand Up @@ -6935,6 +6950,12 @@ int BatchPostCommand::manipulateAttributes(t_MANIPULATOR& manipulator)
return ret;
}

ret = manipulator(&d_autoIncremented,
ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_AUTO_INCREMENTED]);
if (ret) {
return ret;
}

return 0;
}

Expand Down Expand Up @@ -6972,6 +6993,11 @@ int BatchPostCommand::manipulateAttribute(t_MANIPULATOR& manipulator, int id)
return manipulator(&d_postRate,
ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_POST_RATE]);
}
case ATTRIBUTE_ID_AUTO_INCREMENTED: {
return manipulator(
&d_autoIncremented,
ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_AUTO_INCREMENTED]);
}
default: return NOT_FOUND;
}
}
Expand Down Expand Up @@ -7027,6 +7053,11 @@ inline int& BatchPostCommand::postRate()
return d_postRate;
}

inline bsl::string& BatchPostCommand::autoIncremented()
{
return d_autoIncremented;
}

// ACCESSORS
template <typename t_ACCESSOR>
int BatchPostCommand::accessAttributes(t_ACCESSOR& accessor) const
Expand Down Expand Up @@ -7072,6 +7103,12 @@ int BatchPostCommand::accessAttributes(t_ACCESSOR& accessor) const
return ret;
}

ret = accessor(d_autoIncremented,
ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_AUTO_INCREMENTED]);
if (ret) {
return ret;
}

return 0;
}

Expand Down Expand Up @@ -7108,6 +7145,11 @@ int BatchPostCommand::accessAttribute(t_ACCESSOR& accessor, int id) const
return accessor(d_postRate,
ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_POST_RATE]);
}
case ATTRIBUTE_ID_AUTO_INCREMENTED: {
return accessor(
d_autoIncremented,
ATTRIBUTE_INFO_ARRAY[ATTRIBUTE_INDEX_AUTO_INCREMENTED]);
}
default: return NOT_FOUND;
}
}
Expand Down Expand Up @@ -7163,6 +7205,11 @@ inline int BatchPostCommand::postRate() const
return d_postRate;
}

inline const bsl::string& BatchPostCommand::autoIncremented() const
{
return d_autoIncremented;
}

// -----------------------
// class CloseQueueCommand
// -----------------------
Expand Down Expand Up @@ -12319,6 +12366,6 @@ inline bool Command::isUndefinedValue() const
} // close enterprise namespace
#endif

// GENERATED BY BLP_BAS_CODEGEN_2024.05.16
// GENERATED BY BLP_BAS_CODEGEN_2024.07.04.1
// USING bas_codegen.pl -m msg --noAggregateConversion --noExternalization
// --noIdent --package m_bmqtool --msgComponent messages bmqtoolcmd.xsd
1 change: 1 addition & 0 deletions src/applications/bmqtool/m_bmqtool_parameters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ Parameters::Parameters(bslma::Allocator* allocator)
, d_logFilePath(allocator)
, d_messageProperties(allocator)
, d_subscriptions(allocator)
, d_autoIncrementedField(allocator)
{
CommandLineParameters params(allocator);
const bool rc = from(bsl::cerr, params);
Expand Down
Loading
Loading