Skip to content

Commit

Permalink
Apply clang format
Browse files Browse the repository at this point in the history
Signed-off-by: Yuan Jing Vincent Yan <[email protected]>
  • Loading branch information
kaikulimu committed Nov 11, 2024
1 parent 1d50340 commit b4484a3
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 29 deletions.
5 changes: 3 additions & 2 deletions src/groups/mqb/mqbc/mqbc_clusterutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,8 +200,9 @@ void applyQueueUpdate(mqbc::ClusterState* clusterState,
<< clusterData.identity().description()
<< ": Received QueueUpdateAdvisory for known queue [uri: "
<< uri << "] with a mismatched queueKey "
<< "[expected: " << cit->second->key() << ", received: " << queueKey
<< "]: " << queueUpdate << BMQTSK_ALARMLOG_END;
<< "[expected: " << cit->second->key()
<< ", received: " << queueKey << "]: " << queueUpdate
<< BMQTSK_ALARMLOG_END;
return; // RETURN
}
}
Expand Down
3 changes: 1 addition & 2 deletions src/groups/mqb/mqbc/mqbc_incoreclusterstateledger.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,8 +262,7 @@ class IncoreClusterStateLedger BSLS_KEYWORD_FINAL : public ClusterStateLedger {
///
/// THREAD: This method can be invoked only in the associated cluster's
/// dispatcher thread.
int applyImpl(const bdlbb::Blob& event,
mqbnet::ClusterNode* source);
int applyImpl(const bdlbb::Blob& event, mqbnet::ClusterNode* source);

// PRIVATE ACCESSORS

Expand Down
61 changes: 36 additions & 25 deletions src/groups/mqb/mqbc/mqbc_incoreclusterstateledger.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,10 +348,12 @@ struct Tester {
bdlbb::BlobUtil::append(event, record);
}

/// Let the specified `ledger` receive the specified `numAcks` acks for the record having the specific `sequenceNumber`. Behavior is undefined unless the caller is the leader node.
void receiveAck(mqbc::IncoreClusterStateLedger *ledger,
/// Let the specified `ledger` receive the specified `numAcks` acks for the
/// record having the specific `sequenceNumber`. Behavior is undefined
/// unless the caller is the leader node.
void receiveAck(mqbc::IncoreClusterStateLedger* ledger,
const bmqp_ctrlmsg::LeaderMessageSequence& sequenceNumber,
int numAcks)
int numAcks)
{
// PRECONDITIONS
BSLS_ASSERT_OPT(d_isLeader);
Expand All @@ -364,16 +366,17 @@ struct Tester {

bdlbb::Blob ackEvent(d_cluster_mp->_bufferFactory(), s_allocator_p);
constructEventBlob(&ackEvent,
message,
ack.sequenceNumberAcked(),
123456,
mqbc::ClusterStateRecordType::e_ACK);
message,
ack.sequenceNumberAcked(),
123456,
mqbc::ClusterStateRecordType::e_ACK);

for (int i = 1; i <= numAcks; ++i) {
ASSERT_EQ(ledger->apply(ackEvent,
d_cluster_mp->netCluster().lookupNode(
mqbmock::Cluster::k_LEADER_NODE_ID + i)),
0);
ASSERT_EQ(
ledger->apply(ackEvent,
d_cluster_mp->netCluster().lookupNode(
mqbmock::Cluster::k_LEADER_NODE_ID + i)),
0);
}
}

Expand All @@ -394,7 +397,9 @@ struct Tester {
return true;
}

/// Return true if we the follower has sent `number` messages to the leader, false otherwise. Behavior is undefined unless the caller is a follower node.
/// Return true if we the follower has sent `number` messages to the
/// leader, false otherwise. Behavior is undefined unless the caller is a
/// follower node.
bool hasSentMessagesToLeader(int number) const
{
// PRECONDITIONS
Expand All @@ -409,7 +414,8 @@ struct Tester {
return false; // RETURN
}
BSLS_ASSERT_OPT(citer->second->writeCalls().size() >= number);
} else {
}
else {
BSLS_ASSERT_OPT((!citer->second->waitFor(1)));
BSLS_ASSERT_OPT(citer->second->writeCalls().empty());
}
Expand All @@ -418,7 +424,8 @@ struct Tester {
return true;
}

/// Return true if we the leader has broadcast `number` messages, false otherwise. Behavior is undefined unless the caller is the leader node.
/// Return true if we the leader has broadcast `number` messages, false
/// otherwise. Behavior is undefined unless the caller is the leader node.
bool hasBroadcastedMessages(int number) const
{
// PRECONDITIONS
Expand Down Expand Up @@ -601,7 +608,8 @@ static void test3_apply_QueueAssignmentAdvisory()
// QUEUE ASSIGNMENT ADVISORY
//
// Concerns:
// Applying 'QueueAssignmentAdvisory' (only at leader), receive a quorum of acks, then commit the advisory.
// Applying 'QueueAssignmentAdvisory' (only at leader), receive a quorum of
// acks, then commit the advisory.
//
// Testing:
// int apply(const bmqp_ctrlmsg::QueueAssignmentAdvisory& advisory);
Expand Down Expand Up @@ -657,7 +665,8 @@ static void test4_apply_QueueUnassignedAdvisory()
// QUEUE UNASSIGNED ADVISORY
//
// Concerns:
// Applying 'QueueUnassignedAdvisory' (only at leader), receive a quorum of acks, then commit the advisory.
// Applying 'QueueUnassignedAdvisory' (only at leader), receive a quorum of
// acks, then commit the advisory.
//
// Testing:
// int apply(const bmqp_ctrlmsg::QueueUnassignedAdvisory& advisory);
Expand Down Expand Up @@ -709,7 +718,8 @@ static void test5_apply_QueueUpdateAdvisory()
// QUEUE UPDATE ADVISORY
//
// Concerns:
// Applying 'QueueUpdateAdvisory' (only at leader), receive a quorum of acks, then commit the advisory.
// Applying 'QueueUpdateAdvisory' (only at leader), receive a quorum of acks,
// then commit the advisory.
//
// Testing:
// int apply(const bmqp_ctrlmsg::QueueUpdateAdvisory& advisory);
Expand Down Expand Up @@ -778,7 +788,8 @@ static void test6_apply_LeaderAdvisory()
// LEADER ADVISORY
//
// Concerns:
// Applying 'LeaderAdvisory' (only at leader), receive a quorum of acks, then commit the advisory.
// Applying 'LeaderAdvisory' (only at leader), receive a quorum of acks, then
// commit the advisory.
//
// Testing:
// int apply(const bmqp_ctrlmsg::LeaderAdvisory& advisory);
Expand Down Expand Up @@ -1033,16 +1044,16 @@ static void test8_apply_ClusterStateRecordCommit()

// 3. Should fail for an invalid sequence number
bmqp_ctrlmsg::LeaderAdvisoryCommit invalidCommit;
invalidCommit.sequenceNumberCommitted().electorTerm() = 999U;
invalidCommit.sequenceNumberCommitted().sequenceNumber() = 999U;
invalidCommit.sequenceNumber().electorTerm() = 1U;
invalidCommit.sequenceNumber().sequenceNumber() = 4U;
invalidCommit.sequenceNumberCommitted().electorTerm() = 999U;
invalidCommit.sequenceNumberCommitted().sequenceNumber() = 999U;
invalidCommit.sequenceNumber().electorTerm() = 1U;
invalidCommit.sequenceNumber().sequenceNumber() = 4U;

bmqp_ctrlmsg::ClusterMessage invalidCommitMessage;
invalidCommitMessage.choice().makeLeaderAdvisoryCommit(invalidCommit);

bdlbb::Blob invalidCommitEvent(tester.d_cluster_mp->_bufferFactory(),
s_allocator_p);
s_allocator_p);
tester.constructEventBlob(&invalidCommitEvent,
invalidCommitMessage,
invalidCommit.sequenceNumber(),
Expand Down Expand Up @@ -1129,7 +1140,7 @@ static void test9_persistanceLeader()
qupdate.partitionId() = 1U;
key.loadBinary(&qupdate.key());
qupdate.addedAppIds().resize(1);
qupdate.domain() = "bmq.test.mmap.fanout";
qupdate.domain() = "bmq.test.mmap.fanout";
bmqp_ctrlmsg::AppIdInfo& addedAppId = qupdate.addedAppIds().back();
addedAppId.appId() = "qux";
mqbu::StorageKey appKey1(mqbu::StorageKey::BinaryRepresentation(),
Expand Down Expand Up @@ -2063,7 +2074,7 @@ static void test12_rolloverUncommittedAdvisories()
.makeQueueAssignmentAdvisory(qAssignAdvisory);
BSLS_ASSERT_OPT(tester.numCommittedMessages() == i + 1);
BSLS_ASSERT_OPT(tester.committedMessage(i) == expected);
BSLS_ASSERT_OPT(tester.hasSentMessagesToLeader(i+ 4));
BSLS_ASSERT_OPT(tester.hasSentMessagesToLeader(i + 4));

++i;
}
Expand Down

0 comments on commit b4484a3

Please sign in to comment.