Repository navigation
[improve][cli] Pick the v4 or V5 client from the topic domain in pulsar-perf and pulsar-client - #26693
Merged
Conversation
…sar-cli-utils ClientApi picks the v4 or V5 client from the topic domain (topic:// means V5, anything else v4), honours a --client-api override and rejects mixed or unaddressable topics. ClientApiOptionGroups rejects options typed on the command line whose @Arggroup belongs to the other client. Assisted-by: Claude Code (claude-opus-5-5)
…the v4 or V5 client by topic domain The produce-v4, consume-v4, read-v4 and transaction-v4 commands are merged back into produce, consume, read and transaction. A topic:// (scalable) topic selects the V5 client, any other topic the v4 client, and --client-api overrides the choice. Each command is now a picocli class that only parses and validates; the benchmarks run in per-client runners (PerformanceXxxV5 / PerformanceXxxV4) that take the parsed command. Options that only one client supports live in an @Arggroup with its own --help section and are a usage error when the other client is used. The runners log under the command's class name, so the report lines read the same for both clients. Assisted-by: Claude Code (claude-opus-5-5)
…V5 client by topic domain The produce-v4, consume-v4 and read-v4 commands are merged back into produce, consume and read. A topic:// (scalable) topic selects the V5 client, any other topic the v4 client, and --client-api overrides the choice. pulsar-shell's client commands follow automatically. CmdProduce, CmdConsume and CmdRead now hold all options and delegate to package-private per-client runners. v4-only options (KeyValue schemas, --disable-replication, --start-timestamp, the chunking and pooling knobs, --start-message-id-inclusive, ...) are in their own @Arggroup and --help section, and are a usage error with the V5 client. generate_documentation emits the same sections. Assisted-by: Claude Code (claude-opus-5-5)
…sts, profiling harness and docs PerfToolTest covers the V5 client with --client-api V5 and the v4 client with the default routing of a persistent:// topic. The profiling harness derives the client from the topic domain and passes v4-only options (-o, --isolated-clients) only to the v4 client. Assisted-by: Claude Code (claude-opus-5-5)
lhotari
requested review from
Technoboy-,
dao-jun,
david-streamlio,
merlimat and
nodece
September 22, 2026 23:36
merlimat
approved these changes
Sep 22, 2026
…e-v4-cmds Resolve conflicts with apache#26679, which made -rs/--replicated v4-only: in the merged commands it moves into the v4 client option group of pulsar-perf consume and transaction and of pulsar-client consume, and the V5 runners no longer set replicateSubscriptionState. Assisted-by: Claude Code (claude-opus-5-5)
Radiancebobo
pushed a commit
to Radiancebobo/pulsar
that referenced
this pull request
Oct 8, 2026
…ar-perf and pulsar-client (apache#26693)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
#26480 restored the v4 client in
pulsar-perfandpulsar-client, but as separate commands:produce-v4,consume-v4,read-v4andtransaction-v4. So anyone upgrading from 4.x has to renameevery script and benchmark invocation to get the behaviour they already had. The
-v4commands haveonly shipped in the 5.0.0-M2 milestone, so it is still possible to fix this before 5.0.
The topic name already carries the information needed. Scalable topics always use the
topic://domain. Everything else — a name without a domain,
persistent://ornon-persistent://— is a v4topic that the v4 client can address.
Modifications
The externally visible commands are merged back into
produce,consume,read(both tools) andtransaction(pulsar-perf). The-v4commands are removed.Client selection. The topic domain picks the client:
topic://uses the V5 client, and anyother topic uses the v4 client. A new
--client-api V4|V5option overrides the choice, for exampleto drive a
persistent://topic with the V5 client as the V5 commands could before. The followingare rejected as usage errors:
topic://and other topics in one invocation;--client-api V4with atopic://topic;--client-api V5with anon-persistent://topic;segment://topic names.Each run logs one line saying which client was chosen.
Option groups in
--help. Options that only one client supports are declared in picocli@ArgGroups with headings, so--helpshows a Common options section, a v4 client optionssection and, where there are any, a V5 client options section.
gen-docandgenerate_documentationproduce the same sections.Wrong-client options are rejected. An option from the other client's section, typed on the
command line, is a picocli usage error. Previously the V5 commands warned about or silently
ignored many v4-only options. The check follows the resolved client, so
consume --client-api V5 -aq persistent://…is rejected, whileconsume --client-api V5 -sct Stream persistent://…is accepted. Values that come from theconfiguration file never trigger the check.
-rs/--replicatedis in the v4 group ofconsume(both tools) andpulsar-perf transaction, because[fix][broker] Do not enable replicated subscriptions on scalable topic segments #26679 removed replicated subscriptions from the V5 consumers.
Shared helpers. The routing and the group check live in
ClientApiandClientApiOptionGroupsin
pulsar-cli-utils, which both tools use.EnumNameConverteraccepts both enum spellings, sofor example
-am ExclusiveWithFencing(4.x) and-am EXCLUSIVE_WITH_FENCING(5.0-M2) both work.Parsing is decoupled from the implementations. Each command is a picocli class that only parses
and validates. The benchmark or client work runs in per-client runners that take the parsed
command:
pulsar-perf:PerformanceProducerV5/PerformanceProducerV4, and the same pairs for theconsumer, reader and transaction.
pulsar-client:ProduceV5/ProduceV4, and so on.The
pulsar-perfrunners log under the command's class name, so the report lines(
PerformanceProducer - Aggregated throughput stats, …) are the same for both clients and match4.x.
pulsar-clientspecifics:topic://is rejected with aws://service URL, because the WebSocket proxy only servespersistent and non-persistent topics.
file:--encryption-key-valueis rejected with the V5 client, which only reads key files.pulsar-shell'sclientcommands pick all of this up unchanged.Harness and docs.
PerfToolTest, the profiling harness and the docs now use the mergedcommands. The harness derives the client from the topic domain and passes the v4-only
-oand--isolated-clientsoptions only to the v4 client.Verifying this change
This change added tests and can be verified as follows:
ClientApiTest(pulsar-cli-utils): routing for every topic kind and override, the rejectedcombinations, the wrong-group check, conf-file defaults, the help section layout and
EnumNameConverter.PulsarPerfTestToolTest(pulsar-perf, parsed throughPulsarPerfTestToolwith a conf file):--helpsection order and membership;read -m lid:eid, and--scalabletogether with--partitions.CmdClientApiRoutingTest(pulsar-client) replacesCmdV4CommandsTestwith the same kind ofcoverage.
--client-api V5:PerformanceV4CommandsTest,PerformanceProducerTest,PerformanceTransactionV4TestandPerformanceTransactionTest;PulsarClientToolTestandPulsarClientToolWsTest.Does this pull request potentially affect one of the following parts:
If the box was checked, please highlight the changes
pulsar-perfandpulsar-client: the-v4commands are removed and--client-apiis added.persistent://or unprefixed topic now uses the v4 client by default.