Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
support websocket producer for v2 topic (apache#8535)
Browse files Browse the repository at this point in the history
### Motivation
- Not support v2 topics.
- Not working because `/` is missing between `"ws/producer" and topicName`
https://github.com/apache/pulsar/blob/1c7b12d379cf36183d60919dcaff75e4d6cf63f2/pulsar-testclient/src/main/java/org/apache/pulsar/proxy/socket/client/PerformanceClient.java#L169

### Modifications
- Fix that if use V2 topics, use "ws/v2/producer/".

(cherry picked from commit 67f544c)
  • Loading branch information
k2la authored and codelipenghui committed Nov 21, 2020
1 parent 8793963 commit 81d5caa
Showing 1 changed file with 5 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,11 @@
import java.util.concurrent.atomic.LongAdder;

import org.apache.commons.lang3.StringUtils;
import org.apache.pulsar.broker.service.Topic;
import org.apache.pulsar.client.api.Authentication;
import org.apache.pulsar.client.api.AuthenticationDataProvider;
import org.apache.pulsar.client.api.AuthenticationFactory;
import org.apache.pulsar.common.naming.TopicName;
import org.apache.pulsar.testclient.utils.PaddingDecimalFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -166,7 +168,9 @@ public void runPerformanceTest(long messages, long limit, int numOfTopic, int si
String topicName, String authPluginClassName, String authParams) throws InterruptedException, FileNotFoundException {
ExecutorService executor = Executors.newCachedThreadPool(new DefaultThreadFactory("pulsar-perf-producer-exec"));
HashMap<String, Tuple> producersMap = new HashMap<>();
String produceBaseEndPoint = baseUrl + "ws/producer" + topicName;
String restPath = TopicName.get(topicName).getRestPath();
String produceBaseEndPoint = TopicName.get(topicName).isV2() ?
baseUrl + "ws/v2/producer/" + restPath : baseUrl + "ws/producer/" + restPath;
for (int i = 0; i < numOfTopic; i++) {
String topic = numOfTopic > 1 ? produceBaseEndPoint + String.valueOf(i) : produceBaseEndPoint;
URI produceUri = URI.create(topic);
Expand Down

0 comments on commit 81d5caa

Please sign in to comment.