BewareMyPower commented on code in PR #389:
URL: https://github.com/apache/pulsar-client-cpp/pull/389#discussion_r1462619276
##########
lib/ClientImpl.h:
##########
@@ -124,6 +128,8 @@ class ClientImpl : public
std::enable_shared_from_this<ClientImpl> {
std::shared_ptr<std::atomic<uint64_t>> getRequestIdGenerator() const {
return requestIdGenerator_; }
ConnectionPool& getConnectionPool() noexcept { return pool_; }
+ bool useProxy() { return useProxy_; }
Review Comment:
This method is never used.
##########
lib/ClientImpl.h:
##########
@@ -97,6 +97,10 @@ class ClientImpl : public
std::enable_shared_from_this<ClientImpl> {
Future<Result, ClientConnectionPtr> getConnection(const std::string&
topic, size_t key);
+ Future<Result, ClientConnectionPtr> connect(const std::string&
logicalAddress, size_t key);
+
+ const std::string& getPhysicalAddress(const std::string& logicalAddress);
Review Comment:
It should be private.
##########
tests/extensibleLM/ExtensibleLoadManagerTest.cc:
##########
@@ -0,0 +1,210 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+// Run `docker-compose up -d` to set up the test environment for this test.
+#include <gtest/gtest.h>
+
+#include <thread>
+
+#include "include/pulsar/Client.h"
+#include "lib/Semaphore.h"
+#include "tests/HttpHelper.h"
+#include "tests/PulsarFriend.h"
+
+using namespace pulsar;
+
+bool checkTime() {
+ const static auto start = std::chrono::high_resolution_clock::now();
+ auto end = std::chrono::high_resolution_clock::now();
+ auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end
- start).count();
+ return duration < 180 * 1000;
+}
+
+TEST(ExtensibleLoadManagerTest, testConsumeSuccess) {
+ const static std::string adminUrl = "http://localhost:8080/";
+ const static std::string topicName =
+ "persistent://public/unload-test/topic-1" + std::to_string(time(NULL));
+ while (checkTime()) {
+ std::string url = adminUrl +
"admin/v2/namespaces/public/unload-test?bundles=1";
+ int res = makePutRequest(url, "");
+ if (res != 204 && res != 409) {
+ continue;
+ }
+ break;
+ }
+
+ Client client{"pulsar://localhost:6650"};
+ Producer producer;
+ ProducerConfiguration producerConfiguration;
+ Result producerResult = client.createProducer(topicName,
producerConfiguration, producer);
+ ASSERT_EQ(producerResult, ResultOk);
+ Consumer consumer;
+ Result consumerResult = client.subscribe(topicName, "sub", consumer);
+ ASSERT_EQ(consumerResult, ResultOk);
+
+ Semaphore firstUnloadSemaphore(0);
+ Semaphore secondUnloadSemaphore(0);
+ Semaphore halfPubWaitSemaphore(0);
+ const int msgCount = 10;
+ int produced = 0;
+ auto produce = [&producer, &produced, &firstUnloadSemaphore,
&secondUnloadSemaphore,
+ &halfPubWaitSemaphore]() {
+ int i = 0;
+ while (i < msgCount && checkTime()) {
+ if (i == 3) {
+ firstUnloadSemaphore.acquire();
+ }
+
+ if (i == 5) {
+ halfPubWaitSemaphore.release();
+ }
+
+ if (i == 8) {
+ secondUnloadSemaphore.acquire();
+ }
+
+ std::string content = std::to_string(i);
+ const auto msg = MessageBuilder().setContent(content).build();
+ while (checkTime()) {
+ Result sendResult = producer.send(msg);
+ if (sendResult != ResultOk) {
+ continue;
+ }
+ break;
+ }
+ std::cout << "produced index:" << i << std::endl;
Review Comment:
Use `LOG_INFO` to print messages in tests.
```c++
#include "lib/LogUtils.h"
DECLARE_LOG_OBJECT()
```
##########
lib/ClientImpl.cc:
##########
@@ -531,6 +533,10 @@ Future<Result, ClientConnectionPtr>
ClientImpl::getConnection(const std::string&
promise.setFailed(result);
return;
}
+ if (useProxy_ != data.proxyThroughServiceUrl) {
+ useProxy_ = data.proxyThroughServiceUrl;
+ }
Review Comment:
```suggestion
useProxy_ = data.proxyThroughServiceUrl;
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]