Skip to content

Commit d308815

Browse files
committed
Rename method names
1 parent 04e5324 commit d308815

File tree

7 files changed

+20
-20
lines changed

7 files changed

+20
-20
lines changed

lib/ClientImpl.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ void ClientImpl::handleProducerCreated(Result result, ProducerImplBaseWeakPtr pr
223223
CreateProducerCallback callback, ProducerImplBasePtr producer) {
224224
if (result == ResultOk) {
225225
auto address = producer.get();
226-
auto existingProducer = producers_.create(address, producer);
226+
auto existingProducer = producers_.putIfAbsent(address, producer);
227227
if (existingProducer) {
228228
auto producer = existingProducer.value().lock();
229229
LOG_ERROR("Unexpected existing producer at the same address: "
@@ -312,7 +312,7 @@ void ClientImpl::handleReaderMetadataLookup(const Result result, const LookupDat
312312
auto consumer = weakConsumerPtr.lock();
313313
if (consumer) {
314314
auto address = consumer.get();
315-
auto existingConsumer = consumers_.create(address, consumer);
315+
auto existingConsumer = consumers_.putIfAbsent(address, consumer);
316316
if (existingConsumer) {
317317
consumer = existingConsumer.value().lock();
318318
LOG_ERROR("Unexpected existing consumer at the same address: "
@@ -513,7 +513,7 @@ void ClientImpl::handleConsumerCreated(Result result, ConsumerImplBaseWeakPtr co
513513
SubscribeCallback callback, ConsumerImplBasePtr consumer) {
514514
if (result == ResultOk) {
515515
auto address = consumer.get();
516-
auto existingConsumer = consumers_.create(address, consumer);
516+
auto existingConsumer = consumers_.putIfAbsent(address, consumer);
517517
if (existingConsumer) {
518518
auto consumer = existingConsumer.value().lock();
519519
LOG_ERROR("Unexpected existing consumer at the same address: "

lib/ConsumerImpl.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -619,7 +619,7 @@ void ConsumerImpl::messageReceived(const ClientConnectionPtr& cnx, const proto::
619619
return;
620620
}
621621
if (redeliveryCount >= deadLetterPolicy_.getMaxRedeliverCount()) {
622-
possibleSendToDeadLetterTopicMessages_.update(m.getMessageId(), std::vector<Message>{m});
622+
possibleSendToDeadLetterTopicMessages_.put(m.getMessageId(), std::vector<Message>{m});
623623
if (redeliveryCount > deadLetterPolicy_.getMaxRedeliverCount()) {
624624
redeliverUnacknowledgedMessages({m.getMessageId()});
625625
increaseAvailablePermits(cnx);
@@ -786,7 +786,7 @@ uint32_t ConsumerImpl::receiveIndividualMessagesFromBatch(const ClientConnection
786786
}
787787

788788
if (!possibleToDeadLetter.empty()) {
789-
possibleSendToDeadLetterTopicMessages_.update(batchedMessage.getMessageId(), possibleToDeadLetter);
789+
possibleSendToDeadLetterTopicMessages_.put(batchedMessage.getMessageId(), possibleToDeadLetter);
790790
if (redeliveryCount > deadLetterPolicy_.getMaxRedeliverCount()) {
791791
redeliverUnacknowledgedMessages({batchedMessage.getMessageId()});
792792
}

lib/MultiTopicsConsumerImpl.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ void MultiTopicsConsumerImpl::subscribeTopicPartitions(int numPartitions, TopicN
260260
consumer->getConsumerCreatedFuture().addListener(std::bind(
261261
&MultiTopicsConsumerImpl::handleSingleConsumerCreated, get_shared_this_ptr(),
262262
std::placeholders::_1, std::placeholders::_2, partitionsNeedCreate, topicSubResultPromise));
263-
consumers_.update(topicName->toString(), consumer);
263+
consumers_.put(topicName->toString(), consumer);
264264
LOG_DEBUG("Creating Consumer for - " << topicName << " - " << consumerStr_);
265265
consumer->start();
266266

@@ -287,7 +287,7 @@ void MultiTopicsConsumerImpl::subscribeTopicPartitions(int numPartitions, TopicN
287287
&MultiTopicsConsumerImpl::handleSingleConsumerCreated, get_shared_this_ptr(),
288288
std::placeholders::_1, std::placeholders::_2, partitionsNeedCreate, topicSubResultPromise));
289289
consumer->setPartitionIndex(i);
290-
consumers_.update(topicPartitionName, consumer);
290+
consumers_.put(topicPartitionName, consumer);
291291
LOG_DEBUG("Creating Consumer for - " << topicPartitionName << " - " << consumerStr_);
292292
consumer->start();
293293
}
@@ -1063,7 +1063,7 @@ void MultiTopicsConsumerImpl::subscribeSingleNewConsumer(
10631063
});
10641064
consumer->setPartitionIndex(partitionIndex);
10651065
consumer->start();
1066-
consumers_.update(topicPartitionName, consumer);
1066+
consumers_.put(topicPartitionName, consumer);
10671067
LOG_INFO("Add Creating Consumer for - " << topicPartitionName << " - " << consumerStr_
10681068
<< " consumerSize: " << consumers_.size());
10691069
}

lib/SynchronizedHashMap.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ class SynchronizedHashMap {
5959
}
6060
}
6161

62-
// Create a new key-value pair if the key does not exist.
62+
// Put a new key-value pair if the key does not exist.
6363
// Return boost::none if the key already exists or the existing value.
64-
OptValue create(const K& key, const V& value) {
64+
OptValue putIfAbsent(const K& key, const V& value) {
6565
Lock lock(mutex_);
6666
auto pair = data_.emplace(key, value);
6767
if (pair.second) {
@@ -71,8 +71,8 @@ class SynchronizedHashMap {
7171
}
7272
}
7373

74-
// Update the key with a new value no matter if the key exists.
75-
void update(const K& key, const V& value) {
74+
// Put a key-value pair no matter if the key exists.
75+
void put(const K& key, const V& value) {
7676
Lock lock(mutex_);
7777
data_[key] = value;
7878
}

lib/TableViewImpl.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ void TableViewImpl::handleMessage(const Message& msg) {
104104
if (msg.getLength() == 0) {
105105
data_.remove(msg.getPartitionKey());
106106
} else {
107-
data_.update(msg.getPartitionKey(), value);
107+
data_.put(msg.getPartitionKey(), value);
108108
}
109109

110110
Lock lock(listenersMutex_);

tests/SynchronizedHashMapTest.cc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,23 +101,23 @@ TEST(SynchronizedHashMapTest, testForEach) {
101101
ASSERT_TRUE(values.empty());
102102
ASSERT_EQ(result, 1);
103103

104-
ASSERT_EQ(m.create(1, 100), boost::none);
105-
ASSERT_EQ(m.create(1, 101), boost::optional<int>(100));
104+
ASSERT_EQ(m.putIfAbsent(1, 100), boost::none);
105+
ASSERT_EQ(m.putIfAbsent(1, 101), boost::optional<int>(100));
106106
m.forEachValue([&values](int value, SharedFuture) { values.emplace_back(value); },
107107
[&result] { result = 2; });
108108
ASSERT_EQ(values, (std::vector<int>({100})));
109109
ASSERT_EQ(result, 1);
110110

111-
m.update(1, 102);
111+
m.put(1, 102);
112112
values.clear();
113113
m.forEachValue([&values](int value, SharedFuture) { values.emplace_back(value); },
114114
[&result] { result = 2; });
115115
ASSERT_EQ(values, (std::vector<int>({102})));
116116
ASSERT_EQ(result, 1);
117117

118118
values.clear();
119-
ASSERT_EQ(m.create(2, 200), boost::none);
120-
ASSERT_EQ(m.create(2, 201), boost::optional<int>(200));
119+
ASSERT_EQ(m.putIfAbsent(2, 200), boost::none);
120+
ASSERT_EQ(m.putIfAbsent(2, 201), boost::optional<int>(200));
121121
m.forEachValue([&values](int value, SharedFuture) { values.emplace_back(value); },
122122
[&result] { result = 2; });
123123
std::sort(values.begin(), values.end());

tests/extensibleLM/ExtensibleLoadManagerTest.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ TEST(ExtensibleLoadManagerTest, testPubSubWhileUnloading) {
116116
ASSERT_EQ(sendResult, ResultOk);
117117
ASSERT_TRUE(elapsed < maxWaitTimeMs);
118118

119-
producedMsgs.update(i, i);
119+
producedMsgs.put(i, i);
120120
i++;
121121
}
122122
LOG_INFO("producer finished");
@@ -143,7 +143,7 @@ TEST(ExtensibleLoadManagerTest, testPubSubWhileUnloading) {
143143
LOG_INFO("acked i:" << i << " " << elapsed << " ms");
144144
ASSERT_TRUE(elapsed < maxWaitTimeMs);
145145
ASSERT_EQ(ackResult, ResultOk);
146-
consumedMsgs.update(i, i);
146+
consumedMsgs.put(i, i);
147147
}
148148
LOG_INFO("consumer finished");
149149
};

0 commit comments

Comments
 (0)