You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "shibd (via GitHub)" <gi...@apache.org> on 2023/02/20 08:57:31 UTC
[GitHub] [pulsar-client-cpp] shibd opened a new pull request, #201: [feat] Support ExclusiveWithFencing producer access mode.
shibd opened a new pull request, #201:
URL: https://github.com/apache/pulsar-client-cpp/pull/201
### Motivation
#95
### Modifications
- Support ExclusiveWithFencing producer access mode.
### Verifying this change
- Add `testExclusiveWithFencingProducer ` to cover it.
### Documentation
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
- [ ] `doc-required`
(Your PR needs to update docs and you will update later)
- [x] `doc-not-needed`
(Please explain why)
- [ ] `doc`
(Your PR contains doc changes)
- [ ] `doc-complete`
(Docs have been already added)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar-client-cpp] Anonymitaet commented on pull request #201: [feat] Support ExclusiveWithFencing producer access mode.
Posted by "Anonymitaet (via GitHub)" <gi...@apache.org>.
Anonymitaet commented on PR #201:
URL: https://github.com/apache/pulsar-client-cpp/pull/201#issuecomment-1512408171
Hi @shibd, thanks for introducing this great feature!
========================================
As we discussed just now, for the doc side:
### ✅ Pulsar feature matrix
I've ticked the 4 boxes of ["Access Mode" for C++](https://docs.google.com/spreadsheets/d/1YHYTkIXR8-Ql103u-IMI18TXLlGStK8uJjDsOOA0T20/edit#gid=1784579914&range=52:55).
### ✅ Pulsar client docs
#### 🌈 Collobration way
To add docs for it, feel free to choose your preferred method (either way works for me):
- You provide tech inputs to me. I'll write docs based on them and request your review. Or
- You submit a PR to the pulsar-site repo directly and request my review.
#### 🌈 TO-DO tasks
1. Create a topic named "Enable access mode" in [work with producers](https://pulsar.apache.org/docs/next/client-libraries-producers/). It should explain:
- What is it? (we already have this [conceptual content](https://pulsar.apache.org/docs/next/concepts-clients/#access-mode), just add the link to this topic)
- How to use it? (e.g., any considerations? Sample code, etc.)
<img width="1919" alt="image" src="https://user-images.githubusercontent.com/50226895/232667773-6c015619-fd3f-4192-8b7c-e7a447f578cf.png">
2. This doc is added to 5 doc versions (NEXT, 2.11.x, 2.10.x, 2.9.x, 2.8.x) since this feature is available from Pulsar 2.8.x.
- Original doc file of NEXT is [here](https://github.com/apache/pulsar-site/edit/main/docs/client-libraries-producers.md).
- Original doc files of all versioned docs are [here](https://github.com/apache/pulsar-site/tree/main/versioned_docs).
We can update one version first and apply the same doc changes to the rest once it gets approved.
========================================
Feel free to reach out to me if you have questions. TIA!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar-client-cpp] shibd closed pull request #201: [feat] Support ExclusiveWithFencing producer access mode.
Posted by "shibd (via GitHub)" <gi...@apache.org>.
shibd closed pull request #201: [feat] Support ExclusiveWithFencing producer access mode.
URL: https://github.com/apache/pulsar-client-cpp/pull/201
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar-client-cpp] shibd commented on a diff in pull request #201: [feat] Support ExclusiveWithFencing producer access mode.
Posted by "shibd (via GitHub)" <gi...@apache.org>.
shibd commented on code in PR #201:
URL: https://github.com/apache/pulsar-client-cpp/pull/201#discussion_r1141596759
##########
tests/ProducerTest.cc:
##########
Review Comment:
Done, PTAL.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar-client-cpp] shibd merged pull request #201: [feat] Support ExclusiveWithFencing producer access mode.
Posted by "shibd (via GitHub)" <gi...@apache.org>.
shibd merged PR #201:
URL: https://github.com/apache/pulsar-client-cpp/pull/201
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar-client-cpp] RobertIndie commented on a diff in pull request #201: [feat] Support ExclusiveWithFencing producer access mode.
Posted by "RobertIndie (via GitHub)" <gi...@apache.org>.
RobertIndie commented on code in PR #201:
URL: https://github.com/apache/pulsar-client-cpp/pull/201#discussion_r1139929056
##########
tests/ProducerTest.cc:
##########
Review Comment:
Need to add another case to test the effect of WaitForExclusive and ExclusiveWithFencing on each other:
* Create a producer4 with `WaitForExclusive`
* The producer4 will wait until there is no other producers connecting
* producer2 sends messages successfully
* Close the producer2. And finally, the producer4 sends messages successfully
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar-client-cpp] RobertIndie commented on a diff in pull request #201: [feat] Support ExclusiveWithFencing producer access mode.
Posted by "RobertIndie (via GitHub)" <gi...@apache.org>.
RobertIndie commented on code in PR #201:
URL: https://github.com/apache/pulsar-client-cpp/pull/201#discussion_r1142148457
##########
tests/ProducerTest.cc:
##########
@@ -334,6 +334,68 @@ TEST(ProducerTest, testWaitForExclusiveProducer) {
producer2.close();
}
+TEST(ProducerTest, testExclusiveWithFencingProducer) {
+ Client client(serviceUrl);
+
+ std::string topicName =
+ "persistent://public/default/testExclusiveWithFencingProducer" + std::to_string(time(nullptr));
+
+ Producer producer1;
+ ProducerConfiguration producerConfiguration1;
+ producerConfiguration1.setProducerName("p-name-1");
+ producerConfiguration1.setAccessMode(ProducerConfiguration::Exclusive);
+
+ ASSERT_EQ(ResultOk, client.createProducer(topicName, producerConfiguration1, producer1));
+ producer1.send(MessageBuilder().setContent("content").build());
+
+ Producer producer2;
+ ProducerConfiguration producerConfiguration2;
+ producerConfiguration2.setProducerName("p-name-2");
+ producerConfiguration2.setAccessMode(ProducerConfiguration::WaitForExclusive);
+
+ Latch latch(1);
+ client.createProducerAsync(topicName, producerConfiguration2,
+ [&latch, &producer2](Result res, Producer producer) {
+ // producer2 will be fenced
+ ASSERT_EQ(ResultProducerFenced, res);
+ latch.countdown();
+ producer2 = producer;
+ });
+
+ // producer3 will create success.
+ Producer producer3;
+ ProducerConfiguration producerConfiguration3;
+ producerConfiguration3.setProducerName("p-name-3");
+ producerConfiguration3.setAccessMode(ProducerConfiguration::ExclusiveWithFencing);
+ ASSERT_EQ(ResultOk, client.createProducer(topicName, producerConfiguration3, producer3));
+ ASSERT_EQ(ResultOk, producer3.send(MessageBuilder().setContent("content").build()));
+
+ latch.wait();
+ // producer1 will be fenced
+ ASSERT_EQ(ResultProducerFenced, producer1.send(MessageBuilder().setContent("content").build()));
+
+ // Again create producer4 with WaitForExclusive
+ Producer producer4;
+ ProducerConfiguration producerConfiguration4;
+ producerConfiguration2.setProducerName("p-name-4");
+ producerConfiguration2.setAccessMode(ProducerConfiguration::WaitForExclusive);
+ Latch latch2(1);
+ client.createProducerAsync(topicName, producerConfiguration2,
+ [&latch2, &producer4](Result res, Producer producer) {
+ // producer4 will be success
+ ASSERT_EQ(ResultOk, res);
+ producer4 = producer;
+ latch2.countdown();
+ });
+
+ // When producer3 is close, producer4 will be create success
+ producer3.close();
+ latch2.wait();
+ ASSERT_EQ(ResultOk, producer4.send(MessageBuilder().setContent("content").build()));
+
+ client.close();
Review Comment:
We need to assert that the producer4 fails to send before `producer3.close()`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org