You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by "harshithasudhakar (via GitHub)" <gi...@apache.org> on 2023/07/17 08:46:23 UTC
[GitHub] [pulsar] harshithasudhakar opened a new pull request, #20821: Update ClusterDataImpl.java
harshithasudhakar opened a new pull request, #20821:
URL: https://github.com/apache/pulsar/pull/20821
Fixes #5638
Main/Original Issue: [apache#19866](https://github.com/apache/pulsar/issues/19866)
### Motivation
<!-- Explain here the context, and why you're making that change. What is the problem you're trying to solve. -->
### Modifications
Checking if `serviceUrl`, `serviceUrlTls`, `brokerServiceUrl`, or `brokerServiceUrlTls` are not null. Then proceeds to throw `IllegalArgumentException` if either of `serviceUrl`, `serviceUrlTls` or `brokerServiceUrl`, `brokerServiceUrlTls` has not been set.
### Verifying this change
- [ ] Make sure that the change passes the CI checks.
### Does this pull request potentially affect one of the following parts:
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
*If the box was checked, please highlight the changes*
- [ ] Dependencies (add or upgrade a dependency)
- [ ] The public API
- [ ] The schema
- [ ] The default values of configurations
- [ ] The threading model
- [ ] The binary protocol
- [ ] The REST endpoints
- [ ] The admin CLI options
- [ ] The metrics
- [ ] Anything that affects deployment
### Documentation
<!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
- [ ] `doc` <!-- Your PR contains doc changes. -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
- [ ] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `doc-complete` <!-- Docs have been already added -->
### Matching PR in forked repository
PR in forked repository: [<!-- ENTER URL HERE -->](https://github.com/apache/pulsar/pull/20820)
<!--
After opening this PR, the build in apache/pulsar will fail and instructions will
be provided for opening a PR in the PR author's forked repository.
apache/pulsar pull requests should be first tested in your own fork since the
apache/pulsar CI based on GitHub Actions has constrained resources and quota.
GitHub Actions provides separate quota for pull requests that are executed in
a forked repository.
The tests will be run in the forked repository until all PR review comments have
been handled, the tests pass and the PR is approved by a reviewer.
-->
--
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] Technoboy- commented on a diff in pull request #20821: [Enhancement] Verify at least one URL is present for cluster creation
Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- commented on code in PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#discussion_r1271901786
##########
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/ClusterDataImpl.java:
##########
@@ -412,7 +412,20 @@ public ClusterDataImpl build() {
*
* @throws IllegalArgumentException exist illegal property.
*/
- public void checkPropertiesIfPresent() throws IllegalArgumentException {
+ public void checkPropertiesIfPresent() throws IllegalArgumentException {
+ boolean hasServiceUrl = getServiceUrl() != null;
+ boolean hasServiceUrlTls = getServiceUrlTls() != null;
+ boolean hasBrokerServiceUrl = getBrokerServiceUrl() != null;
+ boolean hasBrokerServiceUrlTls = getBrokerServiceUrlTls() != null;
+
+ if (!hasServiceUrl && !hasServiceUrlTls) {
+ throw new IllegalArgumentException("Atleast one of ServiceUrl or ServiceUrlTls must be set.");
Review Comment:
@harshithasudhakar
--
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] yannick commented on pull request #20821: [improve][common] Verify at least one URL is present for cluster creation
Posted by "yannick (via GitHub)" <gi...@apache.org>.
yannick commented on PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#issuecomment-1726164276
No clue. We dont use pulsar anymore!
--
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] github-actions[bot] commented on pull request #20821: [improve][common] Verify at least one URL is present for cluster creation
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#issuecomment-1722655331
The pr had no activity for 30 days, mark with Stale label.
--
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
Re: [PR] [improve] [broker] Verify at least one URL is present for cluster creation [pulsar]
Posted by "harshithasudhakar (via GitHub)" <gi...@apache.org>.
harshithasudhakar commented on PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#issuecomment-1762890345
@Technoboy- Thank you for helping me out with this PR. Sure, I'll get started on identifying and addressing these tests and will certainly reach out for guidance when needed. If you have any specific resources or tips for getting started with this task, please do to share them.
--
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] harshithasudhakar commented on pull request #20821: [improve][common] Verify at least one URL is present for cluster creation
Posted by "harshithasudhakar (via GitHub)" <gi...@apache.org>.
harshithasudhakar commented on PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#issuecomment-1675225979
@poorbarcode I made the following changes in `AdminApi2Test`:
1. `testUpdateClusterServiceUrl()`: Tests API for updating cluster's Service URL, and checks if the retrieved serviceURL matches with it.
2. `testUpdateClusterBrokerServiceUrl()`: Tests API for updating cluster's Service Broker URL, and checks if the retrieved serviceBrokerURL matches with it.
--
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] harshithasudhakar commented on pull request #20821: [improve][common] Verify at least one URL is present for cluster creation
Posted by "harshithasudhakar (via GitHub)" <gi...@apache.org>.
harshithasudhakar commented on PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#issuecomment-1654101710
@poorbarcode I have made two testcases to make sure at least one URL is set.
--
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] poorbarcode commented on a diff in pull request #20821: [improve][common] Verify at least one URL is present for cluster creation
Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode commented on code in PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#discussion_r1276632756
##########
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/ClusterDataImpl.java:
##########
@@ -412,7 +412,16 @@ public ClusterDataImpl build() {
*
* @throws IllegalArgumentException exist illegal property.
*/
- public void checkPropertiesIfPresent() throws IllegalArgumentException {
+ public void checkPropertiesIfPresent() throws IllegalArgumentException {
Review Comment:
Could you format the code to make the code lines have the same alignment?
<img width="880" alt="截屏2023-07-28 01 55 37" src="https://github.com/apache/pulsar/assets/25195800/998cf694-79ab-4b49-a905-ae0f8824d300">
##########
pulsar-common/src/test/java/org/apache/pulsar/common/policies/data/ClusterDataImplTest.java:
##########
@@ -62,4 +66,34 @@ public void verifyClone() {
assertEquals(clone, originalData, "Clones should have object equality.");
assertNotSame(clone, originalData, "Clones should not be the same reference.");
}
+
+ @Test
+ public void testBothServiceUrlsisEmpty(){
+ ClusterDataImpl clusterData = new ClusterDataImpl();
+ clusterData.setServiceUrl("");
+ clusterData.setServiceUrlTls("");
+ clusterData.setBrokerServiceUrl("pulsar://pulsar.example.com:6650");
+ clusterData.setBrokerServiceUrlTls("pulsar+ssl://pulsar.example.com:6651");
+
+ IllegalArgumentException exception = assertThrows(
+ IllegalArgumentException.class, clusterData::checkPropertiesIfPresent
+ );
+
+ assertEquals("At least one of ServiceUrl or ServiceUrlTls must be set.", exception.getMessage());
+ }
+
+ @Test
+ public void testBothBrokerServiceUrlsisEmpty(){
+ ClusterDataImpl clusterData = new ClusterDataImpl();
+ clusterData.setServiceUrl("http://pulsar.example.com:8080");
+ clusterData.setServiceUrlTls("https://pulsar.example.com:8443");
+ clusterData.setBrokerServiceUrl("");
+ clusterData.setBrokerServiceUrlTls("");
+
+ IllegalArgumentException exception = assertThrows(
+ IllegalArgumentException.class, clusterData::checkPropertiesIfPresent
+ );
+
+ assertEquals("At least one of BrokerServiceUrl or BrokerServiceUrlTls must be set.", exception.getMessage());
Review Comment:
Since this change affects the API `Update cluster`, could you also add a test for this API? You can write this test in the class `AdminApi2Test`, and there are a lot of demos.
##########
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/ClusterDataImpl.java:
##########
@@ -412,7 +412,16 @@ public ClusterDataImpl build() {
*
* @throws IllegalArgumentException exist illegal property.
*/
- public void checkPropertiesIfPresent() throws IllegalArgumentException {
+ public void checkPropertiesIfPresent() throws IllegalArgumentException {
Review Comment:
Could you format the code to make the code lines have the same alignment?
<img width="880" alt="截屏2023-07-28 01 55 37" src="https://github.com/apache/pulsar/assets/25195800/998cf694-79ab-4b49-a905-ae0f8824d300">
--
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] harshithasudhakar commented on a diff in pull request #20821: [improve][common] Verify at least one URL is present for cluster creation
Posted by "harshithasudhakar (via GitHub)" <gi...@apache.org>.
harshithasudhakar commented on code in PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#discussion_r1291682890
##########
pulsar-common/src/test/java/org/apache/pulsar/common/policies/data/ClusterDataImplTest.java:
##########
@@ -62,4 +66,34 @@ public void verifyClone() {
assertEquals(clone, originalData, "Clones should have object equality.");
assertNotSame(clone, originalData, "Clones should not be the same reference.");
}
+
+ @Test
+ public void testBothServiceUrlsisEmpty(){
+ ClusterDataImpl clusterData = new ClusterDataImpl();
+ clusterData.setServiceUrl("");
+ clusterData.setServiceUrlTls("");
+ clusterData.setBrokerServiceUrl("pulsar://pulsar.example.com:6650");
+ clusterData.setBrokerServiceUrlTls("pulsar+ssl://pulsar.example.com:6651");
+
+ IllegalArgumentException exception = assertThrows(
+ IllegalArgumentException.class, clusterData::checkPropertiesIfPresent
+ );
+
+ assertEquals("At least one of ServiceUrl or ServiceUrlTls must be set.", exception.getMessage());
+ }
+
+ @Test
+ public void testBothBrokerServiceUrlsisEmpty(){
+ ClusterDataImpl clusterData = new ClusterDataImpl();
+ clusterData.setServiceUrl("http://pulsar.example.com:8080");
+ clusterData.setServiceUrlTls("https://pulsar.example.com:8443");
+ clusterData.setBrokerServiceUrl("");
+ clusterData.setBrokerServiceUrlTls("");
+
+ IllegalArgumentException exception = assertThrows(
+ IllegalArgumentException.class, clusterData::checkPropertiesIfPresent
+ );
+
+ assertEquals("At least one of BrokerServiceUrl or BrokerServiceUrlTls must be set.", exception.getMessage());
Review Comment:
@poorbarcode Hi, I made the test cases in `AdminApi2Test`
--
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] Technoboy- commented on a diff in pull request #20821: [Enhancement] Verify at least one URL is present for cluster creation
Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- commented on code in PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#discussion_r1271894989
##########
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/ClusterDataImpl.java:
##########
@@ -412,7 +412,20 @@ public ClusterDataImpl build() {
*
* @throws IllegalArgumentException exist illegal property.
*/
- public void checkPropertiesIfPresent() throws IllegalArgumentException {
+ public void checkPropertiesIfPresent() throws IllegalArgumentException {
+ boolean hasServiceUrl = getServiceUrl() != null;
+ boolean hasServiceUrlTls = getServiceUrlTls() != null;
+ boolean hasBrokerServiceUrl = getBrokerServiceUrl() != null;
+ boolean hasBrokerServiceUrlTls = getBrokerServiceUrlTls() != null;
+
+ if (!hasServiceUrl && !hasServiceUrlTls) {
+ throw new IllegalArgumentException("Atleast one of ServiceUrl or ServiceUrlTls must be set.");
Review Comment:
At least
##########
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/ClusterDataImpl.java:
##########
@@ -412,7 +412,20 @@ public ClusterDataImpl build() {
*
* @throws IllegalArgumentException exist illegal property.
*/
- public void checkPropertiesIfPresent() throws IllegalArgumentException {
+ public void checkPropertiesIfPresent() throws IllegalArgumentException {
+ boolean hasServiceUrl = getServiceUrl() != null;
+ boolean hasServiceUrlTls = getServiceUrlTls() != null;
+ boolean hasBrokerServiceUrl = getBrokerServiceUrl() != null;
+ boolean hasBrokerServiceUrlTls = getBrokerServiceUrlTls() != null;
+
+ if (!hasServiceUrl && !hasServiceUrlTls) {
+ throw new IllegalArgumentException("Atleast one of ServiceUrl or ServiceUrlTls must be set.");
+ }
+
+ if (!hasBrokerServiceUrl && !hasBrokerServiceUrlTls) {
+ throw new IllegalArgumentException("Atleast one of BrokerServiceUrl or BrokerServiceUrlTls must be set.");
Review Comment:
At least
--
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] Technoboy- commented on a diff in pull request #20821: [Enhancement] Verify at least one URL is present for cluster creation
Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- commented on code in PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#discussion_r1271896430
##########
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/ClusterDataImpl.java:
##########
@@ -412,7 +412,20 @@ public ClusterDataImpl build() {
*
* @throws IllegalArgumentException exist illegal property.
*/
- public void checkPropertiesIfPresent() throws IllegalArgumentException {
+ public void checkPropertiesIfPresent() throws IllegalArgumentException {
+ boolean hasServiceUrl = getServiceUrl() != null;
+ boolean hasServiceUrlTls = getServiceUrlTls() != null;
+ boolean hasBrokerServiceUrl = getBrokerServiceUrl() != null;
+ boolean hasBrokerServiceUrlTls = getBrokerServiceUrlTls() != null;
+
+ if (!hasServiceUrl && !hasServiceUrlTls) {
+ throw new IllegalArgumentException("Atleast one of ServiceUrl or ServiceUrlTls must be set.");
Review Comment:
Also I think we can use `StringUtils.isEmpty(getServiceUrl()) && StringUtils.isEmpty(getServiceUrlTls())` to reduce the codes
--
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] harshithasudhakar commented on a diff in pull request #20821: [improve][common] Verify at least one URL is present for cluster creation
Posted by "harshithasudhakar (via GitHub)" <gi...@apache.org>.
harshithasudhakar commented on code in PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#discussion_r1291682890
##########
pulsar-common/src/test/java/org/apache/pulsar/common/policies/data/ClusterDataImplTest.java:
##########
@@ -62,4 +66,34 @@ public void verifyClone() {
assertEquals(clone, originalData, "Clones should have object equality.");
assertNotSame(clone, originalData, "Clones should not be the same reference.");
}
+
+ @Test
+ public void testBothServiceUrlsisEmpty(){
+ ClusterDataImpl clusterData = new ClusterDataImpl();
+ clusterData.setServiceUrl("");
+ clusterData.setServiceUrlTls("");
+ clusterData.setBrokerServiceUrl("pulsar://pulsar.example.com:6650");
+ clusterData.setBrokerServiceUrlTls("pulsar+ssl://pulsar.example.com:6651");
+
+ IllegalArgumentException exception = assertThrows(
+ IllegalArgumentException.class, clusterData::checkPropertiesIfPresent
+ );
+
+ assertEquals("At least one of ServiceUrl or ServiceUrlTls must be set.", exception.getMessage());
+ }
+
+ @Test
+ public void testBothBrokerServiceUrlsisEmpty(){
+ ClusterDataImpl clusterData = new ClusterDataImpl();
+ clusterData.setServiceUrl("http://pulsar.example.com:8080");
+ clusterData.setServiceUrlTls("https://pulsar.example.com:8443");
+ clusterData.setBrokerServiceUrl("");
+ clusterData.setBrokerServiceUrlTls("");
+
+ IllegalArgumentException exception = assertThrows(
+ IllegalArgumentException.class, clusterData::checkPropertiesIfPresent
+ );
+
+ assertEquals("At least one of BrokerServiceUrl or BrokerServiceUrlTls must be set.", exception.getMessage());
Review Comment:
Hi, I made the test cases in `AdminApi2Test`
--
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] poorbarcode commented on a diff in pull request #20821: [improve][common] Verify at least one URL is present for cluster creation
Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode commented on code in PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#discussion_r1276630615
##########
pulsar-common/src/test/java/org/apache/pulsar/common/policies/data/ClusterDataImplTest.java:
##########
@@ -62,4 +66,34 @@ public void verifyClone() {
assertEquals(clone, originalData, "Clones should have object equality.");
assertNotSame(clone, originalData, "Clones should not be the same reference.");
}
+
+ @Test
+ public void testBothServiceUrlsisEmpty(){
+ ClusterDataImpl clusterData = new ClusterDataImpl();
+ clusterData.setServiceUrl("");
+ clusterData.setServiceUrlTls("");
+ clusterData.setBrokerServiceUrl("pulsar://pulsar.example.com:6650");
+ clusterData.setBrokerServiceUrlTls("pulsar+ssl://pulsar.example.com:6651");
+
+ IllegalArgumentException exception = assertThrows(
+ IllegalArgumentException.class, clusterData::checkPropertiesIfPresent
+ );
+
+ assertEquals("At least one of ServiceUrl or ServiceUrlTls must be set.", exception.getMessage());
+ }
+
+ @Test
+ public void testBothBrokerServiceUrlsisEmpty(){
+ ClusterDataImpl clusterData = new ClusterDataImpl();
+ clusterData.setServiceUrl("http://pulsar.example.com:8080");
+ clusterData.setServiceUrlTls("https://pulsar.example.com:8443");
+ clusterData.setBrokerServiceUrl("");
+ clusterData.setBrokerServiceUrlTls("");
+
+ IllegalArgumentException exception = assertThrows(
+ IllegalArgumentException.class, clusterData::checkPropertiesIfPresent
+ );
+
+ assertEquals("At least one of BrokerServiceUrl or BrokerServiceUrlTls must be set.", exception.getMessage());
Review Comment:
> I have made two testcases to make sure at least one URL is set.
Good work. Thanks.
Since this change affects the API `Update cluster`, could you also add a test for this API? You can write this test in the class `AdminApi2Test`, and there are a lot of demos.
--
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] harshithasudhakar commented on a diff in pull request #20821: [improve][common] Verify at least one URL is present for cluster creation
Posted by "harshithasudhakar (via GitHub)" <gi...@apache.org>.
harshithasudhakar commented on code in PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#discussion_r1276637432
##########
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/ClusterDataImpl.java:
##########
@@ -412,7 +412,16 @@ public ClusterDataImpl build() {
*
* @throws IllegalArgumentException exist illegal property.
*/
- public void checkPropertiesIfPresent() throws IllegalArgumentException {
+ public void checkPropertiesIfPresent() throws IllegalArgumentException {
Review Comment:
Thanks, I've fixed it.
--
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] harshithasudhakar commented on a diff in pull request #20821: [Enhancement] Verify at least one URL is present for cluster creation
Posted by "harshithasudhakar (via GitHub)" <gi...@apache.org>.
harshithasudhakar commented on code in PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#discussion_r1271908406
##########
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/ClusterDataImpl.java:
##########
@@ -412,7 +412,20 @@ public ClusterDataImpl build() {
*
* @throws IllegalArgumentException exist illegal property.
*/
- public void checkPropertiesIfPresent() throws IllegalArgumentException {
+ public void checkPropertiesIfPresent() throws IllegalArgumentException {
+ boolean hasServiceUrl = getServiceUrl() != null;
+ boolean hasServiceUrlTls = getServiceUrlTls() != null;
+ boolean hasBrokerServiceUrl = getBrokerServiceUrl() != null;
+ boolean hasBrokerServiceUrlTls = getBrokerServiceUrlTls() != null;
+
+ if (!hasServiceUrl && !hasServiceUrlTls) {
+ throw new IllegalArgumentException("Atleast one of ServiceUrl or ServiceUrlTls must be set.");
Review Comment:
Yes, I'll make the necessary changes.
--
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] harshithasudhakar commented on pull request #20821: [improve][common] Verify at least one URL is present for cluster creation
Posted by "harshithasudhakar (via GitHub)" <gi...@apache.org>.
harshithasudhakar commented on PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#issuecomment-1684350840
@poorbarcode @Technoboy- Hi, are there any other similar issues I can work on?
--
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] github-actions[bot] commented on pull request #20821: Update ClusterDataImpl.java
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#issuecomment-1637623141
@harshithasudhakar Please add the following content to your PR description and select a checkbox:
```
- [ ] `doc` <!-- Your PR contains doc changes -->
- [ ] `doc-required` <!-- Your PR changes impact docs and you will update later -->
- [ ] `doc-not-needed` <!-- Your PR changes do not impact docs -->
- [ ] `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] poorbarcode commented on a diff in pull request #20821: [improve][common] Verify at least one URL is present for cluster creation
Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode commented on code in PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#discussion_r1330851721
##########
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/ClusterDataImpl.java:
##########
@@ -412,7 +412,16 @@ public ClusterDataImpl build() {
*
* @throws IllegalArgumentException exist illegal property.
*/
- public void checkPropertiesIfPresent() throws IllegalArgumentException {
+ public void checkPropertiesIfPresent() throws IllegalArgumentException {
Review Comment:
We should move this line backward two Spaces.
--
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] poorbarcode commented on pull request #20821: [improve] [broker] Verify at least one URL is present for cluster creation
Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode commented on PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#issuecomment-1726749692
@harshithasudhakar
Please remove these useless imports.
https://github.com/apache/pulsar/actions/runs/6242793194/job/16947265796?pr=20821
<img width="1411" alt="截屏2023-09-20 09 27 58" src="https://github.com/apache/pulsar/assets/25195800/1811f9ee-446e-4497-a064-a34c4d0cf44c">
--
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] harshithasudhakar commented on a diff in pull request #20821: [improve][common] Verify at least one URL is present for cluster creation
Posted by "harshithasudhakar (via GitHub)" <gi...@apache.org>.
harshithasudhakar commented on code in PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#discussion_r1276647237
##########
pulsar-common/src/test/java/org/apache/pulsar/common/policies/data/ClusterDataImplTest.java:
##########
@@ -62,4 +66,34 @@ public void verifyClone() {
assertEquals(clone, originalData, "Clones should have object equality.");
assertNotSame(clone, originalData, "Clones should not be the same reference.");
}
+
+ @Test
+ public void testBothServiceUrlsisEmpty(){
+ ClusterDataImpl clusterData = new ClusterDataImpl();
+ clusterData.setServiceUrl("");
+ clusterData.setServiceUrlTls("");
+ clusterData.setBrokerServiceUrl("pulsar://pulsar.example.com:6650");
+ clusterData.setBrokerServiceUrlTls("pulsar+ssl://pulsar.example.com:6651");
+
+ IllegalArgumentException exception = assertThrows(
+ IllegalArgumentException.class, clusterData::checkPropertiesIfPresent
+ );
+
+ assertEquals("At least one of ServiceUrl or ServiceUrlTls must be set.", exception.getMessage());
+ }
+
+ @Test
+ public void testBothBrokerServiceUrlsisEmpty(){
+ ClusterDataImpl clusterData = new ClusterDataImpl();
+ clusterData.setServiceUrl("http://pulsar.example.com:8080");
+ clusterData.setServiceUrlTls("https://pulsar.example.com:8443");
+ clusterData.setBrokerServiceUrl("");
+ clusterData.setBrokerServiceUrlTls("");
+
+ IllegalArgumentException exception = assertThrows(
+ IllegalArgumentException.class, clusterData::checkPropertiesIfPresent
+ );
+
+ assertEquals("At least one of BrokerServiceUrl or BrokerServiceUrlTls must be set.", exception.getMessage());
Review Comment:
Sure, I'll look into it :)
--
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
Re: [PR] [improve] [broker] Verify at least one URL is present for cluster creation [pulsar]
Posted by "harshithasudhakar (via GitHub)" <gi...@apache.org>.
harshithasudhakar commented on PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#issuecomment-2171117352
Hi, I'd like to fix the errors in this PR but I'm unable to find the log files for this. Can you help me out? How can I run the tests again?
--
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
Re: [PR] [improve] [broker] Verify at least one URL is present for cluster creation [pulsar]
Posted by "merlimat (via GitHub)" <gi...@apache.org>.
merlimat closed pull request #20821: [improve] [broker] Verify at least one URL is present for cluster creation
URL: https://github.com/apache/pulsar/pull/20821
--
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] harshithasudhakar commented on pull request #20821: [improve][common] Verify at least one URL is present for cluster creation
Posted by "harshithasudhakar (via GitHub)" <gi...@apache.org>.
harshithasudhakar commented on PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#issuecomment-1725952268
@yannick @electrum Hi, can you guide me on what I can do further?
--
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
Re: [PR] [improve] [broker] Verify at least one URL is present for cluster creation [pulsar]
Posted by "Technoboy- (via GitHub)" <gi...@apache.org>.
Technoboy- commented on PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#issuecomment-1756691500
> @poorbarcode @Technoboy- Hi, are there any other similar issues I can work on?
Sorry for the late response. I think you can try to fix the flaky tests, it can help you understand the related function more clearly.
--
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] poorbarcode closed pull request #20821: [improve][common] Verify at least one URL is present for cluster creation
Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode closed pull request #20821: [improve][common] Verify at least one URL is present for cluster creation
URL: https://github.com/apache/pulsar/pull/20821
--
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] poorbarcode commented on a diff in pull request #20821: [Enhancement] Verify at least one URL is present for cluster creation
Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode commented on code in PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#discussion_r1271907672
##########
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/ClusterDataImpl.java:
##########
@@ -412,7 +412,20 @@ public ClusterDataImpl build() {
*
* @throws IllegalArgumentException exist illegal property.
*/
- public void checkPropertiesIfPresent() throws IllegalArgumentException {
+ public void checkPropertiesIfPresent() throws IllegalArgumentException {
+ boolean hasServiceUrl = getServiceUrl() != null;
+ boolean hasServiceUrlTls = getServiceUrlTls() != null;
+ boolean hasBrokerServiceUrl = getBrokerServiceUrl() != null;
+ boolean hasBrokerServiceUrlTls = getBrokerServiceUrlTls() != null;
+
+ if (!hasServiceUrl && !hasServiceUrlTls) {
+ throw new IllegalArgumentException("At least one of ServiceUrl or ServiceUrlTls must be set.");
+ }
+
+ if (!hasBrokerServiceUrl && !hasBrokerServiceUrlTls) {
+ throw new IllegalArgumentException("At least one of BrokerServiceUrl or BrokerServiceUrlTls must be set.");
Review Comment:
Could you format the code for this line?
##########
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/ClusterDataImpl.java:
##########
@@ -412,7 +412,20 @@ public ClusterDataImpl build() {
*
* @throws IllegalArgumentException exist illegal property.
*/
- public void checkPropertiesIfPresent() throws IllegalArgumentException {
+ public void checkPropertiesIfPresent() throws IllegalArgumentException {
+ boolean hasServiceUrl = getServiceUrl() != null;
+ boolean hasServiceUrlTls = getServiceUrlTls() != null;
+ boolean hasBrokerServiceUrl = getBrokerServiceUrl() != null;
+ boolean hasBrokerServiceUrlTls = getBrokerServiceUrlTls() != null;
+
+ if (!hasServiceUrl && !hasServiceUrlTls) {
+ throw new IllegalArgumentException("At least one of ServiceUrl or ServiceUrlTls must be set.");
Review Comment:
Could you format the code for this line?
--
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] poorbarcode commented on a diff in pull request #20821: [Enhancement] Verify at least one URL is present for cluster creation
Posted by "poorbarcode (via GitHub)" <gi...@apache.org>.
poorbarcode commented on code in PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#discussion_r1271908695
##########
pulsar-common/src/main/java/org/apache/pulsar/common/policies/data/ClusterDataImpl.java:
##########
@@ -412,7 +412,20 @@ public ClusterDataImpl build() {
*
* @throws IllegalArgumentException exist illegal property.
*/
- public void checkPropertiesIfPresent() throws IllegalArgumentException {
+ public void checkPropertiesIfPresent() throws IllegalArgumentException {
+ boolean hasServiceUrl = getServiceUrl() != null;
+ boolean hasServiceUrlTls = getServiceUrlTls() != null;
+ boolean hasBrokerServiceUrl = getBrokerServiceUrl() != null;
+ boolean hasBrokerServiceUrlTls = getBrokerServiceUrlTls() != null;
+
+ if (!hasServiceUrl && !hasServiceUrlTls) {
+ throw new IllegalArgumentException("Atleast one of ServiceUrl or ServiceUrlTls must be set.");
Review Comment:
> Also I think we can use StringUtils.isEmpty(getServiceUrl()) && StringUtils.isEmpty(getServiceUrlTls()) to reduce the codes
+1
--
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
Re: [PR] [improve] [broker] Verify at least one URL is present for cluster creation [pulsar]
Posted by "merlimat (via GitHub)" <gi...@apache.org>.
merlimat commented on PR #20821:
URL: https://github.com/apache/pulsar/pull/20821#issuecomment-6354340865
Thanks @harshithasudhakar for the work here, and sorry it sat for so long. I'm closing this as part of the open-PR backlog triage. The discussion in #19866 ended up keeping a warning instead of rejecting the request (#20541, already on master), because Pulsar works with only one of the four URLs set. Making them mandatory would break existing `clusters create` calls and setups that pass only `serviceUrl`. If you'd like to look at this again, a proposal on dev@ for a stricter, opt-in check would be the way to go.
--
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