-
Notifications
You must be signed in to change notification settings - Fork 139
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
Feat[Storagetool]: Add searching by record sequence numbers and offsets #508
Changes from 26 commits
ca179b8
f36e2f6
2ed441f
23ca939
33d990e
1bcf853
25a805a
9898b5d
d00d17c
1435ed4
f1d28fa
f69ee41
6897db6
08e4983
27194b8
c8758ad
7c234b9
768b164
6ecd167
10b24b5
eab1197
3c7d12f
561f4da
a290ba0
e9cf8dd
d17230a
73cb8d0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -18,10 +18,16 @@ Usage: bmqstoragetool [--journal-path <journal path>] | |||||||||||||||||
[--data-file <data file>] | ||||||||||||||||||
[--csl-file <csl file>] | ||||||||||||||||||
[--guid <guid>]* | ||||||||||||||||||
[--seqnum <seqnum>]* | ||||||||||||||||||
[--offset <offset>]* | ||||||||||||||||||
[--queue-name <queue name>]* | ||||||||||||||||||
[--queue-key <queue key>]* | ||||||||||||||||||
[--timestamp-gt <timestamp greater than>] | ||||||||||||||||||
[--timestamp-lt <timestamp less than>] | ||||||||||||||||||
[--seqnum-gt <composit sequence number greater than>] | ||||||||||||||||||
[--seqnum-lt <composit sequence number less than>] | ||||||||||||||||||
[--offset-gt <offset greater than>] | ||||||||||||||||||
[--offset-lt <offset less than>] | ||||||||||||||||||
[--outstanding] | ||||||||||||||||||
[--confirmed] | ||||||||||||||||||
[--partially-confirmed] | ||||||||||||||||||
|
@@ -42,6 +48,10 @@ Where: | |||||||||||||||||
path to a .bmq_csl file | ||||||||||||||||||
--guid <guid> | ||||||||||||||||||
message guid | ||||||||||||||||||
--seqnum <seqnum> | ||||||||||||||||||
message composite sequence number | ||||||||||||||||||
--offset <offset> | ||||||||||||||||||
message offset | ||||||||||||||||||
--queue-name <queue name> | ||||||||||||||||||
message queue name | ||||||||||||||||||
--queue-key <queue key> | ||||||||||||||||||
|
@@ -50,6 +60,14 @@ Where: | |||||||||||||||||
lower timestamp bound | ||||||||||||||||||
--timestamp-lt <timestamp less than> | ||||||||||||||||||
higher timestamp bound | ||||||||||||||||||
--seqnum-gt <composit sequence number greater than> | ||||||||||||||||||
lower composit sequence number bound, defined in form <leaseId-sequenceNumber>, e.g. 123-456 | ||||||||||||||||||
--seqnum-lt <composit sequence number less than> | ||||||||||||||||||
higher composit sequence number bound, defined in form <leaseId-sequenceNumber>, e.g. 123-456 | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Fixed. |
||||||||||||||||||
--offset-gt <offset greater than> | ||||||||||||||||||
lower offset bound | ||||||||||||||||||
--offset-lt <offset less than> | ||||||||||||||||||
higher offset bound | ||||||||||||||||||
--outstanding | ||||||||||||||||||
show only outstanding (not deleted) messages | ||||||||||||||||||
--confirmed | ||||||||||||||||||
|
@@ -122,6 +140,22 @@ bmqstoragetool --journal-file=<path> --guid=<guid_1> --guid=<guid_N> | |||||||||||||||||
``` | ||||||||||||||||||
NOTE: no other filters are allowed with this one | ||||||||||||||||||
|
||||||||||||||||||
Filter messages with corresponding composite sequence numbers (defined in form <primaryLeaseId-sequenceNumber>) | ||||||||||||||||||
--------------------------------------------------------------------------------------------------------------- | ||||||||||||||||||
Example: | ||||||||||||||||||
```bash | ||||||||||||||||||
bmqstoragetool --journal-file=<path> --seqnum=<leaseId-sequenceNumber_1> --seqnum=<leaseId-sequenceNumber_N> | ||||||||||||||||||
``` | ||||||||||||||||||
NOTE: no other filters are allowed with this one | ||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems reasonable to want to look at journal records with a particular primary lease ID that happened after a particular timestamp, no? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See earlier comment, let's make this change later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. At the first step we agreed to make these filters mutual exclusive, and then change behaviour depending on user feedback. Agree to make this change later. |
||||||||||||||||||
|
||||||||||||||||||
Filter messages with corresponding record offsets | ||||||||||||||||||
------------------------------------------------- | ||||||||||||||||||
Example: | ||||||||||||||||||
```bash | ||||||||||||||||||
bmqstoragetool --journal-file=<path> --offset=<offset_1> --offset=<offset_N> | ||||||||||||||||||
``` | ||||||||||||||||||
NOTE: no other filters are allowed with this one | ||||||||||||||||||
|
||||||||||||||||||
Filter messages within time range | ||||||||||||||||||
--------------------------------- | ||||||||||||||||||
Example: | ||||||||||||||||||
|
@@ -131,6 +165,24 @@ bmqstoragetool --journal-file=<path> --timestamp-gt=<stamp> | |||||||||||||||||
bmqstoragetool --journal-file=<path> --timestamp-lt=<stamp1> --timestamp-gt=<stamp2> | ||||||||||||||||||
``` | ||||||||||||||||||
|
||||||||||||||||||
Filter messages within composite sequence numbers (primaryLeaseId, sequenceNumber) range | ||||||||||||||||||
---------------------------------------------------------------------------------------- | ||||||||||||||||||
Example: | ||||||||||||||||||
```bash | ||||||||||||||||||
bmqstoragetool --journal-file=<path> --seqnum-lt=<leaseId-sequenceNumber> | ||||||||||||||||||
bmqstoragetool --journal-file=<path> --seqnum-gt=<leaseId-sequenceNumber> | ||||||||||||||||||
bmqstoragetool --journal-file=<path> --seqnum-lt=<leaseId1-sequenceNumber1> --seqnum-gt=<leaseId2-sequenceNumber2> | ||||||||||||||||||
``` | ||||||||||||||||||
|
||||||||||||||||||
Filter messages within record offsets range | ||||||||||||||||||
------------------------------------------- | ||||||||||||||||||
Example: | ||||||||||||||||||
```bash | ||||||||||||||||||
bmqstoragetool --journal-file=<path> --offset-lt=<offset> | ||||||||||||||||||
bmqstoragetool --journal-file=<path> --offset-gt=<offset> | ||||||||||||||||||
bmqstoragetool --journal-file=<path> --offset-lt=<offset1> --offset-gt=<offset2> | ||||||||||||||||||
``` | ||||||||||||||||||
|
||||||||||||||||||
Filter messages by queue key | ||||||||||||||||||
---------------------------- | ||||||||||||||||||
Example: | ||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
// 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. | ||
|
||
// bmqstoragetool | ||
#include <m_bmqstoragetool_compositesequencenumber.h> | ||
|
||
// BDE | ||
#include <bdlb_print.h> | ||
#include <bsl_stdexcept.h> | ||
|
||
namespace BloombergLP { | ||
namespace m_bmqstoragetool { | ||
|
||
// ============================= | ||
// class CompositeSequenceNumber | ||
// ============================= | ||
|
||
CompositeSequenceNumber::CompositeSequenceNumber() | ||
: d_leaseId(0) | ||
, d_seqNumber(0) | ||
, d_isSet(false) | ||
{ | ||
// NOTHING | ||
} | ||
|
||
CompositeSequenceNumber::CompositeSequenceNumber( | ||
const unsigned int leaseId, | ||
const bsls::Types::Uint64 sequenceNumber) | ||
: d_leaseId(leaseId) | ||
, d_seqNumber(sequenceNumber) | ||
{ | ||
BSLS_ASSERT(d_leaseId > 0 && d_seqNumber > 0); | ||
d_isSet = d_leaseId > 0 && d_seqNumber > 0; | ||
} | ||
|
||
CompositeSequenceNumber& | ||
CompositeSequenceNumber::fromString(bsl::ostream& errorDescription, | ||
const bsl::string& seqNumString) | ||
{ | ||
d_isSet = false; | ||
|
||
if (seqNumString.empty()) { | ||
errorDescription << "Invalid input: empty string."; | ||
return *this; // RETURN | ||
} | ||
|
||
// Find the position of the separator | ||
const size_t separatorPos = seqNumString.find('-'); | ||
if (separatorPos == bsl::string::npos) { | ||
errorDescription << "Invalid format: no '-' separator found."; | ||
return *this; // RETURN | ||
} | ||
|
||
// Extract parts | ||
const bsl::string firstPart = seqNumString.substr(0, separatorPos); | ||
const bsl::string secondPart = seqNumString.substr(separatorPos + 1); | ||
|
||
// Convert parts to numbers | ||
try { | ||
size_t posFirst, posSecond; | ||
|
||
unsigned long uLong = bsl::stoul(firstPart, &posFirst); | ||
d_seqNumber = bsl::stoul(secondPart, &posSecond); | ||
|
||
if (posFirst != firstPart.size() || posSecond != secondPart.size()) { | ||
throw bsl::invalid_argument(""); // THROW | ||
} | ||
|
||
d_leaseId = static_cast<unsigned int>(uLong); | ||
if (uLong != d_leaseId) { | ||
throw bsl::out_of_range(""); // THROW | ||
} | ||
|
||
if (d_leaseId == 0 || d_seqNumber == 0) { | ||
errorDescription << "Invalid input: zero values encountered."; | ||
return *this; // RETURN | ||
} | ||
|
||
d_isSet = true; | ||
} | ||
catch (const bsl::invalid_argument& e) { | ||
errorDescription << "Invalid input: non-numeric values encountered."; | ||
} | ||
catch (const bsl::out_of_range& e) { | ||
errorDescription << "Invalid input: number out of range."; | ||
} | ||
|
||
return *this; | ||
} | ||
|
||
bsl::ostream& CompositeSequenceNumber::print(bsl::ostream& stream, | ||
int level, | ||
int spacesPerLevel) const | ||
{ | ||
if (stream.bad()) { | ||
return stream; // RETURN | ||
} | ||
|
||
bdlb::Print::indent(stream, level, spacesPerLevel); | ||
|
||
if (isSet()) { | ||
stream << "leaseId: " << leaseId() | ||
<< ", sequenceNumber: " << sequenceNumber(); | ||
} | ||
else { | ||
stream << "** UNSET **"; | ||
} | ||
|
||
if (spacesPerLevel >= 0) { | ||
stream << '\n'; | ||
} | ||
|
||
return stream; | ||
} | ||
|
||
} // close package namespace | ||
} // close enterprise namespace |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.