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

Fix[MQB] mqbc::ClusterUtil: Validate appIds in CSL #545

Merged
merged 1 commit into from
Jan 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/groups/mqb/mqbc/mqbc_clusterstate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ bsl::ostream& ClusterStateQueueInfo::print(bsl::ostream& stream,
printer.printAttribute("queueKey", key());
printer.printAttribute("partitionId", partitionId());
printer.printAttribute("appIdInfos", appInfos());
printer.printAttribute("stateOfAssignment", state());
printer.end();

return stream;
Expand Down Expand Up @@ -94,7 +95,7 @@ void ClusterStateObserver::onQueueUpdated(
}

void ClusterStateObserver::onPartitionOrphanThreshold(
BSLS_ANNOTATION_UNUSED size_t partitiondId)
BSLS_ANNOTATION_UNUSED size_t partitionId)
{
// NOTHING
}
Expand Down
39 changes: 31 additions & 8 deletions src/groups/mqb/mqbc/mqbc_clusterstate.h
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,6 @@ class ClusterStatePartitionInfo {
/// `bmqp_ctrlmsg::QueueInfo`. Doing vice versa will not be possible
/// because we don't want to edit generated file. Perhaps we can place the
/// converter routine in `ClusterUtil`.
///
/// TBD: When should AppIds and AppKeys come from? Should the leader/primary
/// generate them, or should we hardcode them in the domain config?
class ClusterStateQueueInfo {
public:
// TYPES
Expand All @@ -171,10 +168,10 @@ class ClusterStateQueueInfo {
// Assigning following unassigning is also supported.
// On Replica, the only possible state is k_ASSIGNED.

k_NONE,
k_ASSIGNING,
k_ASSIGNED,
k_UNASSIGNING
k_NONE = 0,
k_ASSIGNING = -1,
k_ASSIGNED = -2,
k_UNASSIGNING = -3
};

private:
Expand Down Expand Up @@ -272,6 +269,18 @@ class ClusterStateQueueInfo {
bsl::ostream& operator<<(bsl::ostream& stream,
const ClusterStateQueueInfo& rhs);

/// Return `true` if the specified `rhs` object contains the value of the
/// same type as contained in the specified `lhs` object and the value
/// itself is the same in both objects, return false otherwise.
bool operator==(const ClusterStateQueueInfo& lhs,
const ClusterStateQueueInfo& rhs);

/// Return `false` if the specified `rhs` object contains the value of the
/// same type as contained in the specified `lhs` object and the value
/// itself is the same in both objects, return `true` otherwise.
bool operator!=(const ClusterStateQueueInfo& lhs,
const ClusterStateQueueInfo& rhs);

// ==========================
// class ClusterStateObserver
// ==========================
Expand Down Expand Up @@ -343,7 +352,7 @@ class ClusterStateObserver {
///
/// THREAD: This method is invoked in the associated cluster's
/// dispatcher thread.
virtual void onPartitionOrphanThreshold(size_t partitiondId);
virtual void onPartitionOrphanThreshold(size_t partitionId);

/// Callback invoked when the specified `node` has been unavailable
/// above a certain threshold amount of time.
Expand Down Expand Up @@ -1163,6 +1172,20 @@ inline bsl::ostream& mqbc::operator<<(bsl::ostream& stream,
return rhs.print(stream, 0, -1);
}

inline bool mqbc::operator==(const ClusterStateQueueInfo& lhs,
const ClusterStateQueueInfo& rhs)
{
return lhs.uri() == rhs.uri() && lhs.key() == rhs.key() &&
lhs.partitionId() == rhs.partitionId() &&
lhs.appInfos() == rhs.appInfos() && lhs.state() == rhs.state();
}

inline bool mqbc::operator!=(const ClusterStateQueueInfo& lhs,
const ClusterStateQueueInfo& rhs)
{
return !(lhs == rhs);
}

} // close enterprise namespace

#endif
Loading
Loading