diff --git a/src/applications/bmqstoragetool/m_bmqstoragetool_commandprocessor.h b/src/applications/bmqstoragetool/m_bmqstoragetool_commandprocessor.h index 04ef2c2424..286e73a7d0 100644 --- a/src/applications/bmqstoragetool/m_bmqstoragetool_commandprocessor.h +++ b/src/applications/bmqstoragetool/m_bmqstoragetool_commandprocessor.h @@ -13,6 +13,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +// m_bmqstoragetool_commandprocessor.h -*-C++-*- +#ifndef INCLUDED_M_BMQSTORAGETOOL_COMMANDPROCESSOR +#define INCLUDED_M_BMQSTORAGETOOL_COMMANDPROCESSOR + // bmqstoragetool #include @@ -48,3 +52,5 @@ inline CommandProcessor::CommandProcessor( } // close package namespace } // close enterprise namespace + +#endif diff --git a/src/applications/bmqstoragetool/m_bmqstoragetool_commandprocessorfactory.h b/src/applications/bmqstoragetool/m_bmqstoragetool_commandprocessorfactory.h index 2509bdd53a..cd6f42651a 100644 --- a/src/applications/bmqstoragetool/m_bmqstoragetool_commandprocessorfactory.h +++ b/src/applications/bmqstoragetool/m_bmqstoragetool_commandprocessorfactory.h @@ -13,6 +13,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +// m_bmqstoragetool_commandprocessorfactory.h -*-C++-*- +#ifndef INCLUDED_M_BMQSTORAGETOOL_COMMANDPROCESSORFACTORY +#define INCLUDED_M_BMQSTORAGETOOL_COMMANDPROCESSORFACTORY + // bmqstoragetool #include #include @@ -36,3 +40,5 @@ class CommandProcessorFactory { } // close package namespace } // close enterprise namespace + +#endif diff --git a/src/applications/bmqstoragetool/m_bmqstoragetool_filters.cpp b/src/applications/bmqstoragetool/m_bmqstoragetool_filters.cpp new file mode 100644 index 0000000000..c12ffa9d5a --- /dev/null +++ b/src/applications/bmqstoragetool/m_bmqstoragetool_filters.cpp @@ -0,0 +1,56 @@ +// Copyright 2014-2023 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. + +// m_bmqstoragetool_filters.cpp -*-C++-*- + +#include + +namespace BloombergLP { +namespace m_bmqstoragetool { + +// ===================== +// class Filters +// ===================== + +Filters::Filters(const bsl::vector& queueHexKeys, + const bsl::vector& queueURIS, + bslma::Allocator* allocator) +: d_queueKeys(allocator) +{ + if (!queueHexKeys.empty()) { + for (auto& key : queueHexKeys) { + d_queueKeys.push_back( + mqbu::StorageKey(mqbu::StorageKey::HexRepresentation(), + key.c_str())); + } + } +} + +bool Filters::apply(const mqbs::MessageRecord& record) +{ + if (!d_queueKeys.empty()) + // Match by queueKey + if (auto it = bsl::find(d_queueKeys.begin(), + d_queueKeys.end(), + record.queueKey()); + it == d_queueKeys.end()) { + // Not matched + return false; // RETURN + } + return true; +} + +} // close package namespace +} // close enterprise namespace diff --git a/src/applications/bmqstoragetool/m_bmqstoragetool_filters.h b/src/applications/bmqstoragetool/m_bmqstoragetool_filters.h new file mode 100644 index 0000000000..d06b813f4b --- /dev/null +++ b/src/applications/bmqstoragetool/m_bmqstoragetool_filters.h @@ -0,0 +1,51 @@ +// Copyright 2014-2023 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. + +// m_bmqstoragetool_filters.h -*-C++-*- +#ifndef INCLUDED_M_BMQSTORAGETOOL_FILTERS +#define INCLUDED_M_BMQSTORAGETOOL_FILTERS + +#include + +// MQB +#include + +namespace BloombergLP { +namespace m_bmqstoragetool { + +// ===================== +// class Filters +// ===================== + +class Filters { + private: + // DATA + bsl::vector d_queueKeys; + + public: + // CREATORS + explicit Filters(const bsl::vector& queueHexKeys, + const bsl::vector& queueURIS, + bslma::Allocator* allocator); + + // MANIPULATORS + bool apply(const mqbs::MessageRecord& record); + // Apply filters and return true if filter matched, false otherwise. +}; + +} // close package namespace +} // close enterprise namespace + +#endif diff --git a/src/applications/bmqstoragetool/m_bmqstoragetool_searchprocessor.cpp b/src/applications/bmqstoragetool/m_bmqstoragetool_searchprocessor.cpp index 980aaa5d03..d9973a359b 100644 --- a/src/applications/bmqstoragetool/m_bmqstoragetool_searchprocessor.cpp +++ b/src/applications/bmqstoragetool/m_bmqstoragetool_searchprocessor.cpp @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// m_bmqstoragetool_searchprocessor.cpp -*-C++-*- + // bmqstoragetool #include #include @@ -37,58 +39,6 @@ namespace BloombergLP { namespace m_bmqstoragetool { -namespace { - -// TODO: remove -template -bool resetIterator(mqbs::MappedFileDescriptor* mfd, - ITER* iter, - const char* filename, - bsl::ostream& errorDescription) -{ - if (!bdls::FilesystemUtil::isRegularFile(filename)) { - errorDescription << "File [" << filename << "] is not a regular file."; - return false; // RETURN - } - - // 1) Open - mwcu::MemOutStream errorDesc; - int rc = mqbs::FileSystemUtil::open( - mfd, - filename, - bdls::FilesystemUtil::getFileSize(filename), - true, // read only - errorDesc); - if (0 != rc) { - errorDescription << "Failed to open file [" << filename - << "] rc: " << rc << ", error: " << errorDesc.str(); - return false; // RETURN - } - - // 2) Basic sanity check - rc = mqbs::FileStoreProtocolUtil::hasBmqHeader(*mfd); - if (0 != rc) { - errorDescription << "Missing BlazingMQ header from file [" << filename - << "] rc: " << rc; - mqbs::FileSystemUtil::close(mfd); - return false; // RETURN - } - - // 3) Load iterator and check - rc = iter->reset(mfd, mqbs::FileStoreProtocolUtil::bmqHeader(*mfd)); - if (0 != rc) { - errorDescription << "Failed to create iterator for file [" << filename - << "] rc: " << rc; - mqbs::FileSystemUtil::close(mfd); - return false; // RETURN - } - - BSLS_ASSERT_OPT(iter->isValid()); - return true; // RETURN -} - -} // close unnamed namespace - // ===================== // class SearchProcessor // ===================== @@ -105,6 +55,10 @@ SearchProcessor::SearchProcessor(const bsl::shared_ptr& params, void SearchProcessor::process(bsl::ostream& ostream) { + Filters filters(d_parameters->queueKey(), + d_parameters->queueName(), + d_allocator_p); + // TODO: why unique_ptr doesn't support deleter in reset() // bsl::unique_ptr searchResult_p; bsl::shared_ptr searchResult_p; @@ -113,6 +67,7 @@ void SearchProcessor::process(bsl::ostream& ostream) SearchGuidResult(ostream, d_parameters->details(), d_parameters->guid(), + filters, d_allocator_p), d_allocator_p); } @@ -120,6 +75,7 @@ void SearchProcessor::process(bsl::ostream& ostream) searchResult_p.reset(new (*d_allocator_p) SearchOutstandingResult( ostream, d_parameters->details(), + filters, d_allocator_p), d_allocator_p); } @@ -127,6 +83,7 @@ void SearchProcessor::process(bsl::ostream& ostream) searchResult_p.reset(new (*d_allocator_p) SearchConfirmedResult(ostream, d_parameters->details(), + filters, d_allocator_p), d_allocator_p); } @@ -135,6 +92,7 @@ void SearchProcessor::process(bsl::ostream& ostream) new (*d_allocator_p) SearchPartiallyConfirmedResult(ostream, d_parameters->details(), + filters, d_allocator_p), d_allocator_p); } @@ -142,6 +100,7 @@ void SearchProcessor::process(bsl::ostream& ostream) searchResult_p.reset(new (*d_allocator_p) SearchAllResult(ostream, d_parameters->details(), + filters, d_allocator_p), d_allocator_p); } @@ -164,8 +123,8 @@ void SearchProcessor::process(bsl::ostream& ostream) } // MessageRecord else if (iter->recordType() == mqbs::RecordType::e_MESSAGE) { - const mqbs::MessageRecord& message = iter->asMessageRecord(); - stopSearch = searchResult_p->processMessageRecord(message); + const mqbs::MessageRecord& record = iter->asMessageRecord(); + stopSearch = searchResult_p->processMessageRecord(record); } // ConfirmRecord else if (iter->recordType() == mqbs::RecordType::e_CONFIRM) { diff --git a/src/applications/bmqstoragetool/m_bmqstoragetool_searchprocessor.h b/src/applications/bmqstoragetool/m_bmqstoragetool_searchprocessor.h index 359ff5507e..e5afa38537 100644 --- a/src/applications/bmqstoragetool/m_bmqstoragetool_searchprocessor.h +++ b/src/applications/bmqstoragetool/m_bmqstoragetool_searchprocessor.h @@ -13,6 +13,10 @@ // See the License for the specific language governing permissions and // limitations under the License. +// m_bmqstoragetool_searchprocessor.h -*-C++-*- +#ifndef INCLUDED_M_BMQSTORAGETOOL_SEARCHPROCESSOR +#define INCLUDED_M_BMQSTORAGETOOL_SEARCHPROCESSOR + // bmqstoragetool #include @@ -21,7 +25,6 @@ #include #include #include -// #include // BDE #include @@ -51,3 +54,5 @@ class SearchProcessor : public CommandProcessor { } // close package namespace } // close enterprise namespace + +#endif diff --git a/src/applications/bmqstoragetool/m_bmqstoragetool_searchprocessor.t.cpp b/src/applications/bmqstoragetool/m_bmqstoragetool_searchprocessor.t.cpp index 5e12cd4a86..0c7368688e 100644 --- a/src/applications/bmqstoragetool/m_bmqstoragetool_searchprocessor.t.cpp +++ b/src/applications/bmqstoragetool/m_bmqstoragetool_searchprocessor.t.cpp @@ -420,6 +420,117 @@ bsl::vector addJournalRecordsWithPartiallyConfirmedMessages( return expectedGUIDs; } +// Generate sequence of MessageRecord, ConfirmRecord and DeleteRecord records. +// MessageRecord ConfirmRecord and DeletionRecord records have the same GUID. +// queueKey1 is used for even records, queueKey1 for odd ones. +// Returns GUIDs with queueKey1. +bsl::vector +addJournalRecordsWithTwoQueueKeys(MemoryBlock* block, + FileHeader* fileHeader, + bsls::Types::Uint64* lastRecordPos, + bsls::Types::Uint64* lastSyncPtPos, + RecordsListType* records, + unsigned int numRecords, + const char* queueKey1, + const char* queueKey2) +{ + bsls::Types::Uint64 currPos = 0; + + OffsetPtr fh(*block, currPos); + new (fh.get()) FileHeader(); + *fileHeader = *fh; + currPos += sizeof(FileHeader); + + OffsetPtr jfh(*block, currPos); + new (jfh.get()) JournalFileHeader(); // Default values are ok + currPos += sizeof(JournalFileHeader); + + bool partialyConfirmedFlag = false; + bmqt::MessageGUID lastMessageGUID; + bsl::vector expectedGUIDs; + + for (unsigned int i = 1; i <= numRecords; ++i) { + *lastRecordPos = currPos; + + const char* queueKey = (i % 2 != 0) ? queueKey1 : queueKey2; + + unsigned int remainder = i % 3; + if (1 == remainder) { + mqbu::MessageGUIDUtil::generateGUID(&lastMessageGUID); + if (queueKey == queueKey1) { + expectedGUIDs.push_back(lastMessageGUID); + } + OffsetPtr rec(*block, currPos); + new (rec.get()) MessageRecord(); + rec->header().setPrimaryLeaseId(100).setSequenceNumber(i); + rec->setRefCount(i % FileStoreProtocol::k_MAX_MSG_REF_COUNT_HARD) + .setQueueKey( + mqbu::StorageKey(mqbu::StorageKey::HexRepresentation(), + queueKey)) + .setFileKey( + mqbu::StorageKey(mqbu::StorageKey::BinaryRepresentation(), + "12345")) + .setMessageOffsetDwords(i) + .setMessageGUID(lastMessageGUID) + .setCrc32c(i) + .setCompressionAlgorithmType( + bmqt::CompressionAlgorithmType::e_NONE) + .setMagic(RecordHeader::k_MAGIC); + + RecordBufferType buf; + bsl::memcpy(buf.buffer(), + rec.get(), + FileStoreProtocol::k_JOURNAL_RECORD_SIZE); + records->push_back(bsl::make_pair(RecordType::e_MESSAGE, buf)); + } + else if (2 == remainder) { + // ConfRec + bmqt::MessageGUID g = lastMessageGUID; + OffsetPtr rec(*block, currPos); + new (rec.get()) ConfirmRecord(); + rec->header().setPrimaryLeaseId(100).setSequenceNumber(i); + rec->setReason(ConfirmReason::e_REJECTED) + .setQueueKey( + mqbu::StorageKey(mqbu::StorageKey::HexRepresentation(), + queueKey)) + .setAppKey( + mqbu::StorageKey(mqbu::StorageKey::BinaryRepresentation(), + "appid")) + .setMessageGUID(g) + .setMagic(RecordHeader::k_MAGIC); + + RecordBufferType buf; + bsl::memcpy(buf.buffer(), + rec.get(), + FileStoreProtocol::k_JOURNAL_RECORD_SIZE); + records->push_back(bsl::make_pair(RecordType::e_CONFIRM, buf)); + } + else { + // DelRec + bmqt::MessageGUID g = lastMessageGUID; + OffsetPtr rec(*block, currPos); + new (rec.get()) DeletionRecord(); + rec->header().setPrimaryLeaseId(100).setSequenceNumber(i); + rec->setDeletionRecordFlag(DeletionRecordFlag::e_IMPLICIT_CONFIRM) + .setQueueKey( + mqbu::StorageKey(mqbu::StorageKey::HexRepresentation(), + queueKey)) + .setMessageGUID(g) + .setMagic(RecordHeader::k_MAGIC); + + RecordBufferType buf; + bsl::memcpy(buf.buffer(), + rec.get(), + FileStoreProtocol::k_JOURNAL_RECORD_SIZE); + records->push_back(bsl::make_pair(RecordType::e_DELETION, buf)); + } + + currPos += FileStoreProtocol::k_JOURNAL_RECORD_SIZE; + } + + return expectedGUIDs; +} + bsls::Types::Uint64 memoryBufferSize(size_t numRecords) { return sizeof(FileHeader) + sizeof(JournalFileHeader) + @@ -872,7 +983,7 @@ static void test6_searchPartiallyConfirmedMessagesTest() // SEARCH PARTIALLY CONFIRMED MESSAGES TEST // // Concerns: -// Search partially confirmed (at least one confirm) messages in journal +// Search partially confirmed (at least one confirm) messages in journal // file and output GUIDs. // // Testing: @@ -943,6 +1054,81 @@ static void test6_searchPartiallyConfirmedMessagesTest() s_allocator_p->deallocate(p); } +static void test7_searchMessagesByQueueKeyTest() +// ------------------------------------------------------------------------ +// SEARCH MESSAGES BY QUEUE KEY TEST +// +// Concerns: +// Search messages by queueKwy in journal +// file and output GUIDs. +// +// Testing: +// SearchProcessor::process() +// ------------------------------------------------------------------------ +{ + mwctst::TestHelper::printTestName("SEARCH MESSAGES BY QUEUE KEY TEST"); + + // Simulate journal file + unsigned int numRecords = 15; + + bsls::Types::Uint64 totalSize = + sizeof(FileHeader) + sizeof(JournalFileHeader) + + numRecords * FileStoreProtocol::k_JOURNAL_RECORD_SIZE; + + char* p = static_cast(s_allocator_p->allocate(totalSize)); + MemoryBlock block(p, totalSize); + FileHeader fileHeader; + bsls::Types::Uint64 lastRecordPos = 0; + bsls::Types::Uint64 lastSyncPtPos = 0; + + RecordsListType records(s_allocator_p); + + const char* queueKey1 = "ABCDE12345"; + const char* queueKey2 = "12345ABCDE"; + + bsl::vector queueKey1GUIDS = + addJournalRecordsWithTwoQueueKeys(&block, + &fileHeader, + &lastRecordPos, + &lastSyncPtPos, + &records, + numRecords, + queueKey1, + queueKey2); + + // Create JournalFileIterator + MappedFileDescriptor mfd; + mfd.setFd(-1); // invalid fd will suffice. + mfd.setBlock(block); + mfd.setFileSize(totalSize); + JournalFileIterator it(&mfd, fileHeader, false); + + // Configure parameters to search messages by queueKey1 + CommandLineArguments arguments; + arguments.d_queueKey.push_back(queueKey1); + bsl::unique_ptr params = + bsl::make_unique(arguments, s_allocator_p); + params->journalFile()->setIterator(&it); + + auto searchProcessor = SearchProcessor(bsl::move(params), s_allocator_p); + + bsl::ostringstream resultStream(s_allocator_p); + searchProcessor.process(resultStream); + + // Prepare expected output + bsl::ostringstream expectedStream(s_allocator_p); + for (const auto& guid : queueKey1GUIDS) { + outputGuidString(expectedStream, guid); + } + expectedStream << queueKey1GUIDS.size() << " message GUID(s) found." + << bsl::endl; + + // TODO: fix ordering issue (sporadic fail) + ASSERT_EQ(resultStream.str(), expectedStream.str()); + + s_allocator_p->deallocate(p); +} + // ============================================================================ // MAIN PROGRAM // ---------------------------------------------------------------------------- @@ -959,6 +1145,7 @@ int main(int argc, char* argv[]) case 4: test4_searchOutstandingMessagesTest(); break; case 5: test5_searchConfirmedMessagesTest(); break; case 6: test6_searchPartiallyConfirmedMessagesTest(); break; + case 7: test7_searchMessagesByQueueKeyTest(); break; default: { cerr << "WARNING: CASE '" << _testCase << "' NOT FOUND." << endl; s_testStatus = -1; diff --git a/src/applications/bmqstoragetool/m_bmqstoragetool_searchresult.cpp b/src/applications/bmqstoragetool/m_bmqstoragetool_searchresult.cpp index db7683c2a8..8908d4f123 100644 --- a/src/applications/bmqstoragetool/m_bmqstoragetool_searchresult.cpp +++ b/src/applications/bmqstoragetool/m_bmqstoragetool_searchresult.cpp @@ -13,6 +13,8 @@ // See the License for the specific language governing permissions and // limitations under the License. +// m_bmqstoragetool_searchresult.cpp -*-C++-*- + // bmqstoragetool #include @@ -25,9 +27,11 @@ namespace m_bmqstoragetool { SearchResult::SearchResult(bsl::ostream& ostream, bool withDetails, + Filters& filters, bslma::Allocator* allocator) : d_ostream(ostream) , d_withDetails(withDetails) +, d_filters(filters) , d_foundMessagesCount() , d_totalMessagesCount() , d_allocator_p(bslma::Default::allocator(allocator)) @@ -38,9 +42,9 @@ SearchResult::SearchResult(bsl::ostream& ostream, bool SearchResult::processMessageRecord(const mqbs::MessageRecord& record) { d_totalMessagesCount++; - d_foundMessagesCount++; + // d_foundMessagesCount++; - return false; + return d_filters.apply(record); } bool SearchResult::processConfirmRecord(const mqbs::ConfirmRecord& record) @@ -93,19 +97,24 @@ void SearchResult::outputOutstandingRatio() SearchAllResult::SearchAllResult(bsl::ostream& ostream, bool withDetails, + Filters& filters, bslma::Allocator* allocator) -: SearchResult(ostream, withDetails, allocator) +: SearchResult(ostream, withDetails, filters, allocator) { // NOTHING } bool SearchAllResult::processMessageRecord(const mqbs::MessageRecord& record) { - if (!d_withDetails) { - outputGuidString(record.messageGUID()); + bool filterPassed = SearchResult::processMessageRecord(record); + if (filterPassed) { + if (!d_withDetails) { + outputGuidString(record.messageGUID()); + } + d_foundMessagesCount++; } - return SearchResult::processMessageRecord(record); + return false; } // ===================== @@ -115,8 +124,9 @@ bool SearchAllResult::processMessageRecord(const mqbs::MessageRecord& record) SearchGuidResult::SearchGuidResult(bsl::ostream& ostream, bool withDetails, const bsl::vector& guids, + Filters& filters, bslma::Allocator* allocator) -: SearchResult(ostream, withDetails, allocator) +: SearchResult(ostream, withDetails, filters, allocator) , d_guidsMap(allocator) { // Build MessageGUID->StrGUID Map @@ -148,8 +158,9 @@ bool SearchGuidResult::processMessageRecord(const mqbs::MessageRecord& record) SearchOutstandingResult::SearchOutstandingResult(bsl::ostream& ostream, bool withDetails, + Filters& filters, bslma::Allocator* allocator) -: SearchResult(ostream, withDetails, allocator) +: SearchResult(ostream, withDetails, filters, allocator) , d_outstandingGUIDS(allocator) { // NOTHING @@ -158,11 +169,15 @@ SearchOutstandingResult::SearchOutstandingResult(bsl::ostream& ostream, bool SearchOutstandingResult::processMessageRecord( const mqbs::MessageRecord& record) { - if (!d_withDetails) { - d_outstandingGUIDS.push_back(record.messageGUID()); + bool filterPassed = SearchResult::processMessageRecord(record); + if (filterPassed) { + if (!d_withDetails) { + d_outstandingGUIDS.push_back(record.messageGUID()); + } + d_foundMessagesCount++; } - return SearchResult::processMessageRecord(record); + return false; } bool SearchOutstandingResult::processDeletionRecord( @@ -198,8 +213,9 @@ void SearchOutstandingResult::outputResult() SearchConfirmedResult::SearchConfirmedResult(bsl::ostream& ostream, bool withDetails, + Filters& filters, bslma::Allocator* allocator) -: SearchResult(ostream, withDetails, allocator) +: SearchResult(ostream, withDetails, filters, allocator) , d_messageGUIDS(allocator) { // NOTHING @@ -208,10 +224,12 @@ SearchConfirmedResult::SearchConfirmedResult(bsl::ostream& ostream, bool SearchConfirmedResult::processMessageRecord( const mqbs::MessageRecord& record) { - if (!d_withDetails) { - d_messageGUIDS.push_back(record.messageGUID()); + bool filterPassed = SearchResult::processMessageRecord(record); + if (filterPassed) { + if (!d_withDetails) { + d_messageGUIDS.push_back(record.messageGUID()); + } } - d_totalMessagesCount++; return false; } @@ -249,8 +267,9 @@ void SearchConfirmedResult::outputResult() SearchPartiallyConfirmedResult::SearchPartiallyConfirmedResult( bsl::ostream& ostream, bool withDetails, + Filters& filters, bslma::Allocator* allocator) -: SearchResult(ostream, withDetails, allocator) +: SearchResult(ostream, withDetails, filters, allocator) , d_partiallyConfirmedGUIDS(allocator) { // NOTHING @@ -259,10 +278,12 @@ SearchPartiallyConfirmedResult::SearchPartiallyConfirmedResult( bool SearchPartiallyConfirmedResult::processMessageRecord( const mqbs::MessageRecord& record) { - if (!d_withDetails) { - d_partiallyConfirmedGUIDS[record.messageGUID()] = 0; + bool filterPassed = SearchResult::processMessageRecord(record); + if (filterPassed) { + if (!d_withDetails) { + d_partiallyConfirmedGUIDS[record.messageGUID()] = 0; + } } - d_totalMessagesCount++; return false; } diff --git a/src/applications/bmqstoragetool/m_bmqstoragetool_searchresult.h b/src/applications/bmqstoragetool/m_bmqstoragetool_searchresult.h index 6db33adb6d..16e44557a2 100644 --- a/src/applications/bmqstoragetool/m_bmqstoragetool_searchresult.h +++ b/src/applications/bmqstoragetool/m_bmqstoragetool_searchresult.h @@ -13,9 +13,15 @@ // See the License for the specific language governing permissions and // limitations under the License. +// m_bmqstoragetool_searchresult.h -*-C++-*- +#ifndef INCLUDED_M_BMQSTORAGETOOL_SEARCHRESULT +#define INCLUDED_M_BMQSTORAGETOOL_SEARCHRESULT + // bmqstoragetool // #include +#include + // BDE #include #include @@ -40,6 +46,7 @@ class SearchResult { // DATA bsl::ostream& d_ostream; bool d_withDetails; + Filters& d_filters; bsl::size_t d_totalMessagesCount; bsl::size_t d_foundMessagesCount; bslma::Allocator* d_allocator_p; @@ -48,6 +55,7 @@ class SearchResult { // CREATORS explicit SearchResult(bsl::ostream& ostream, bool withDetails, + Filters& filters, bslma::Allocator* allocator); virtual ~SearchResult() = default; @@ -70,6 +78,7 @@ class SearchAllResult : public SearchResult { // CREATORS explicit SearchAllResult(bsl::ostream& ostream, bool withDetails, + Filters& filters, bslma::Allocator* allocator); // MANIPULATORS @@ -89,6 +98,7 @@ class SearchGuidResult : public SearchResult { explicit SearchGuidResult(bsl::ostream& ostream, bool withDetails, const bsl::vector& guids, + Filters& filters, bslma::Allocator* allocator); // MANIPULATORS @@ -108,6 +118,7 @@ class SearchOutstandingResult : public SearchResult { // CREATORS explicit SearchOutstandingResult(bsl::ostream& ostream, bool withDetails, + Filters& filters, bslma::Allocator* allocator); // MANIPULATORS @@ -130,6 +141,7 @@ class SearchConfirmedResult : public SearchResult { // CREATORS explicit SearchConfirmedResult(bsl::ostream& ostream, bool withDetails, + Filters& filters, bslma::Allocator* allocator); // MANIPULATORS @@ -152,6 +164,7 @@ class SearchPartiallyConfirmedResult : public SearchResult { // CREATORS explicit SearchPartiallyConfirmedResult(bsl::ostream& ostream, bool withDetails, + Filters& filters, bslma::Allocator* allocator); // MANIPULATORS @@ -166,3 +179,5 @@ class SearchPartiallyConfirmedResult : public SearchResult { } // close package namespace } // close enterprise namespace + +#endif diff --git a/src/applications/bmqstoragetool/package/bmqstoragetool.mem b/src/applications/bmqstoragetool/package/bmqstoragetool.mem index 6ad5636651..a45f802be1 100644 --- a/src/applications/bmqstoragetool/package/bmqstoragetool.mem +++ b/src/applications/bmqstoragetool/package/bmqstoragetool.mem @@ -4,3 +4,4 @@ m_bmqstoragetool_messages m_bmqstoragetool_parameters m_bmqstoragetool_searchprocessor m_bmqstoragetool_searchresult +m_bmqstoragetool_filters