-
Notifications
You must be signed in to change notification settings - Fork 3.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[testclient] Improve parameter checking in pulsar-perf #11973
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall it looks good to me
I left one comment
if (Integer.parseInt(value) <= 0) { | ||
throw new ParameterException("Parameter " + name + " should be > 0 (found " + value + ")"); | ||
} | ||
return; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: this is not needed
import com.beust.jcommander.ParameterException; | ||
|
||
public class ParameterValidator implements IParameterValidator { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about naming this like PositiveNumberParameterValidator ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with it. Have renamed, PTAL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Just one minor edge case that needs to be addressed.
@@ -164,6 +167,7 @@ public ClientBuilder listenerThreads(int numListenerThreads) { | |||
|
|||
@Override | |||
public ClientBuilder connectionsPerBroker(int connectionsPerBroker) { | |||
checkArgument(connectionsPerBroker >= 0, "connectionsPerBroker needs to be >= 0"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Per the java doc on the ClientBuilder
interface, the value must be greater than 0.
checkArgument(connectionsPerBroker >= 0, "connectionsPerBroker needs to be >= 0"); | |
checkArgument(connectionsPerBroker > 0, "connectionsPerBroker needs to be > 0"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. PTAL again, THX!
I have reverted,see review
@@ -69,7 +69,7 @@ protected void cleanup() throws Exception { | |||
@Override | |||
protected void customizeNewPulsarClientBuilder(ClientBuilder clientBuilder) { | |||
// disable connection pooling | |||
clientBuilder.connectionsPerBroker(0); | |||
// clientBuilder.connectionsPerBroker(0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please revert
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The value of connectionsPerBroker
must be greater than 0 (doc in ClientBuilder L266), and this test will fail after the check is added, so a comment is made.
Related review:#11973 (comment)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so what do you suggest ?
modifying a test means that we modify the behaviour and this is not good (most of the times)
This test tells me that 0 is an allowed number, so you have to update your preconditions (and docs?) and let this test pass
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with you that 0 is a feasible value for this test. So I update the document and revert the test.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I took a look at how this setting is used, and 0 is a valid setting.
pulsar/pulsar-client/src/main/java/org/apache/pulsar/client/impl/ConnectionPool.java
Lines 148 to 151 in 4147db8
if (maxConnectionsPerHosts == 0) { | |
// Disable pooling | |
return createConnection(logicalAddress, physicalAddress, -1); | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@michaeljmarshall PTAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should improve the javadoc to better explain what 0 connections per broker means. Otherwise, looks good to me.
@@ -263,7 +263,7 @@ ClientBuilder authentication(String authPluginClassName, Map<String, String> aut | |||
* Increasing this parameter may improve throughput when using many producers over a high latency connection. | |||
* | |||
* @param connectionsPerBroker | |||
* max number of connections per broker (needs to be greater than 0) | |||
* max number of connections per broker (needs to be not less than 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given the name of this setting (connectionsPerBroker
), it isn't immediately clear to me why 0 is a valid setting. I think we should add a note specifying that a value of 0
will disable connection pooling. I think it could also be valuable to update the client configuration file with the same note:
pulsar/pulsar-client/src/main/java/org/apache/pulsar/client/impl/conf/ClientConfigurationData.java
Lines 122 to 126 in b557e24
@ApiModelProperty( | |
name = "connectionsPerBroker", | |
value = "Number of connections established between the client and each Broker." | |
) | |
private int connectionsPerBroker = 1; |
Nit: my preference for this line is to write this as needs to be greater than or equal to 0
. Your change is certainly correct, so I'm not sure how much my preference matters, but based on a quick search through the project, we often use greater than or equal to
in this situation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good suggestion, done. PTAL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Anonymitaet Please help review the docs
site2/docs/reference-cli-tools.md
Outdated
@@ -448,6 +448,7 @@ Options | |||
|`-ss`, `--subscriptions`|A list of subscriptions to consume on (e.g. sub1,sub2)|sub| | |||
|`-st`, `--subscription-type`|Subscriber type. Possible values are Exclusive, Shared, Failover, Key_Shared.|Exclusive| | |||
|`-sp`, `--subscription-position`|Subscriber position. Possible values are Latest, Earliest.|Latest| | |||
|`-time`, `--test-duration`|Test duration in secs. If <= 0, it will keep consuming|0| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|`-time`, `--test-duration`|Test duration in secs. If <= 0, it will keep consuming|0| | |
|`-time`, `--test-duration`|Test duration (in seconds). If this value is less than or equal to 0, it keeps consuming messages.|0| |
Please check all occurrences and keep consistent.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for your contribution. Does this affect only master or other versioned docs?
If latter, could you please help update all affected versions? Thanks
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The document has been checked and updated, PTAL again @Anonymitaet , thx!
- This affects only master docs.
Fixes #11983
Motivation
When I execute
pulsar-perf
to simulate pub/sub test, I found that the task can be started normally after some options are set to unreasonable values, but there is no instance running, which leads to a waste of resources. In fact, when these unreasonable values appear, we should check to prevent the task from starting.for example:
./bin/pulsar-perf consume --num-consumers -1 test
Modifications
Documentation