Skip to content

Commit

Permalink
mqbs::FileStore: Rename setPrimary -> setActivePrimary
Browse files Browse the repository at this point in the history
Signed-off-by: Yuan Jing Vincent Yan <yyan82@bloomberg.net>
  • Loading branch information
kaikulimu committed Sep 11, 2024
1 parent e5d59b2 commit 835ba43
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 23 deletions.
4 changes: 2 additions & 2 deletions src/groups/mqb/mqbc/mqbc_storagemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ void StorageManager::setPrimaryStatusForPartitionDispatched(

pinfo.setPrimaryStatus(value);
if (bmqp_ctrlmsg::PrimaryStatus::E_ACTIVE == value) {
d_fileStores[partitionId]->setPrimary(pinfo.primary(),
d_fileStores[partitionId]->setActivePrimary(pinfo.primary(),
pinfo.primaryLeaseId());

if (oldValue != bmqp_ctrlmsg::PrimaryStatus::E_ACTIVE &&
Expand Down Expand Up @@ -2471,7 +2471,7 @@ void StorageManager::do_processBufferedPrimaryStatusAdvisories(
}
pinfo.setPrimaryStatus(cit->first.status());
if (bmqp_ctrlmsg::PrimaryStatus::E_ACTIVE == cit->first.status()) {
d_fileStores[partitionId]->setPrimary(pinfo.primary(),
d_fileStores[partitionId]->setActivePrimary(pinfo.primary(),
pinfo.primaryLeaseId());
}
}
Expand Down
8 changes: 4 additions & 4 deletions src/groups/mqb/mqbc/mqbc_storagemanager.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -886,12 +886,12 @@ struct TestHelper {
._setDisableBroadcast(true);
fs.open();
// TODO: clean this up since its a hack to set replica node as primary!
// had to explicitly setPrimary for fileStore because of the assert in
// writeRecords which allows writes only if current node is primary for
// the fileStore.
// had to explicitly setActivePrimary for fileStore because of the
// assert in writeRecords which allows writes only if current node is
// primary for the fileStore.
// TODO: set primary to self but also correct it to the right node
// after writing 'numRecords' records.
fs.setPrimary(selfNode, 1U);
fs.setActivePrimary(selfNode, 1U);

const mqbu::StorageKey& queueKey =
writeQueueCreationRecord(handle, &fs, k_PARTITION_ID);
Expand Down
6 changes: 3 additions & 3 deletions src/groups/mqb/mqbc/mqbc_storageutil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1443,15 +1443,15 @@ void StorageUtil::onPartitionPrimarySync(
}

// Broadcast self as active primary of this partition. This must be done
// before invoking 'FileStore::setPrimary'.
// before invoking 'FileStore::setActivePrimary'.
transitionToActivePrimary(pinfo, clusterData, partitionId);

partitionPrimaryStatusCb(partitionId, status, pinfo->primaryLeaseId());

// Safe to inform partition now. Note that partition will issue a sync
// point with old leaseId (if applicable) and another with new leaseId
// immediately.
fs->setPrimary(pinfo->primary(), pinfo->primaryLeaseId());
fs->setActivePrimary(pinfo->primary(), pinfo->primaryLeaseId());
}

void StorageUtil::recoveredQueuesCb(
Expand Down Expand Up @@ -3413,7 +3413,7 @@ void StorageUtil::processPrimaryStatusAdvisoryDispatched(
pinfo->setPrimaryStatus(advisory.status());

if (bmqp_ctrlmsg::PrimaryStatus::E_ACTIVE == advisory.status()) {
fs->setPrimary(source, advisory.primaryLeaseId());
fs->setActivePrimary(source, advisory.primaryLeaseId());
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/groups/mqb/mqbs/mqbs_datastore.h
Original file line number Diff line number Diff line change
Expand Up @@ -675,10 +675,10 @@ class DataStore : public mqbi::DispatcherClient {
virtual int issueSyncPoint() = 0;

/// Set the specified `primaryNode` with the specified `primaryLeaseId`
/// as the primary for this data store partition. Note that
/// as the active primary for this data store partition. Note that
/// `primaryNode` could refer to the node which owns this data store.
virtual void setPrimary(mqbnet::ClusterNode* primaryNode,
unsigned int primaryLeaseId) = 0;
virtual void setActivePrimary(mqbnet::ClusterNode* primaryNode,
unsigned int primaryLeaseId) = 0;

/// Clear the current primary associated with this partition.
virtual void clearPrimary() = 0;
Expand Down
12 changes: 6 additions & 6 deletions src/groups/mqb/mqbs/mqbs_filestore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ const unsigned int k_REQUESTED_JOURNAL_SPACE =
// Above, 3 == 1 journal record being written +
// 1 journal sync point if rolling over +
// 1 journal sync point if self needs to issue another sync point
// in 'setPrimary' with old values
// in 'setActivePrimary' with old values

/// Return a rounded (down) percentage value (range [0-100]) representing
/// the space in use on a file with the specified `capacity`, currently
Expand Down Expand Up @@ -3758,8 +3758,8 @@ int FileStore::issueSyncPointInternal(SyncPointType::Enum type,
// New primary and no force issue requested. Currently,
// this check is redundant because we always force issue a
// sync point when a primary is chosen (see
// 'setPrimary()'), which always bumps up 'd_sequenceNum'
// to 1.
// 'setActivePrimary()'), which always bumps up
// 'd_sequenceNum' to 1.

return rc_SUCCESS; // RETURN
}
Expand Down Expand Up @@ -6261,7 +6261,7 @@ void FileStore::processStorageEvent(const bsl::shared_ptr<bdlbb::Blob>& blob,
// If we are processing a partition-sync event, we have to
// bump up the leaseId to that of the message, because we don't
// get a separate notification about leaseId (unlike in steady
// state when StorageMgr invokes fs.setPrimary()).
// state when StorageMgr invokes fs.setActivePrimary()).

d_primaryLeaseId = recHeader->primaryLeaseId();

Expand Down Expand Up @@ -6605,8 +6605,8 @@ int FileStore::issueSyncPoint()
return rc_SUCCESS;
}

void FileStore::setPrimary(mqbnet::ClusterNode* primaryNode,
unsigned int primaryLeaseId)
void FileStore::setActivePrimary(mqbnet::ClusterNode* primaryNode,
unsigned int primaryLeaseId)
{
// executed by the *DISPATCHER* thread

Expand Down
6 changes: 3 additions & 3 deletions src/groups/mqb/mqbs/mqbs_filestore.h
Original file line number Diff line number Diff line change
Expand Up @@ -859,10 +859,10 @@ class FileStore : public DataStore {
int issueSyncPoint() BSLS_KEYWORD_OVERRIDE;

/// Set the specified `primaryNode` with the specified `primaryLeaseId`
/// as the primary for this data store partition. Note that
/// as the active primary for this data store partition. Note that
/// `primaryNode` could refer to the node which owns this data store.
void setPrimary(mqbnet::ClusterNode* primaryNode,
unsigned int primaryLeaseId) BSLS_KEYWORD_OVERRIDE;
void setActivePrimary(mqbnet::ClusterNode* primaryNode,
unsigned int primaryLeaseId) BSLS_KEYWORD_OVERRIDE;

/// Clear the current primary associated with this partition.
void clearPrimary() BSLS_KEYWORD_OVERRIDE;
Expand Down
4 changes: 2 additions & 2 deletions src/groups/mqb/mqbs/mqbs_filestore.t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ static void test1_breathingTest()
unsigned int primaryLeaseId = 1;
bsls::Types::Uint64 seqNum = 1;

fs.setPrimary(tester.node(), primaryLeaseId);
fs.setActivePrimary(tester.node(), primaryLeaseId);

ASSERT_EQ(primaryLeaseId, fs.primaryLeaseId());
ASSERT_EQ(seqNum, fs.sequenceNumber());
Expand Down Expand Up @@ -902,7 +902,7 @@ static void test2_printTest()
// Set primary.
unsigned int primaryLeaseId = 1;
bsls::Types::Uint64 seqNum = 1;
fs.setPrimary(tester.node(), primaryLeaseId);
fs.setActivePrimary(tester.node(), primaryLeaseId);

// Write various records to the partition.
SyncPointOffsetPairs spOffsetPairs(s_allocator_p);
Expand Down

0 comments on commit 835ba43

Please sign in to comment.