Skip to content

[improve][broker] Refactor update topic partitions endpoint.#19166

Merged
eolivelli merged 16 commits into
apache:masterfrom
mattisonchao:refactor_update_partitions_endpoint
Jan 18, 2023
Merged

[improve][broker] Refactor update topic partitions endpoint.#19166
eolivelli merged 16 commits into
apache:masterfrom
mattisonchao:refactor_update_partitions_endpoint

Conversation

@mattisonchao

@mattisonchao mattisonchao commented Jan 10, 2023

Copy link
Copy Markdown
Member

Motivation

This PR follow-up #19086 to clean up complex logic and remove duplicate method invoke.

Modifications

  • Remove unnecessary topic owner redirect.
  • Refactor unreadable code.
  • Change unreasonable status code 406 to 422.

Verifying this change

  • Make sure that the change passes the CI checks.

Does this pull request potentially affect one of the following parts:

  • The REST endpoints

Documentation

  • doc-not-needed

@github-actions github-actions Bot added the doc-not-needed Your PR changes do not impact docs label Jan 10, 2023
@mattisonchao mattisonchao self-assigned this Jan 10, 2023
@mattisonchao mattisonchao added this to the 2.12.0 milestone Jan 10, 2023
@mattisonchao mattisonchao reopened this Jan 10, 2023
@codecov-commenter

codecov-commenter commented Jan 10, 2023

Copy link
Copy Markdown

Codecov Report

Merging #19166 (47c5015) into master (246c270) will increase coverage by 5.10%.
The diff coverage is 59.50%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #19166      +/-   ##
============================================
+ Coverage     43.01%   48.12%   +5.10%     
+ Complexity    10167     9640     -527     
============================================
  Files           747      636     -111     
  Lines         72255    60083   -12172     
  Branches       7786     6271    -1515     
============================================
- Hits          31080    28913    -2167     
+ Misses        37577    28048    -9529     
+ Partials       3598     3122     -476     
Flag Coverage Δ
unittests 48.12% <59.50%> (+5.10%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
.../org/apache/pulsar/broker/admin/AdminResource.java 64.96% <ø> (+0.04%) ⬆️
...pulsar/broker/admin/impl/PersistentTopicsBase.java 58.84% <55.23%> (-0.34%) ⬇️
...pache/pulsar/broker/admin/v1/PersistentTopics.java 48.42% <75.00%> (+0.45%) ⬆️
...pache/pulsar/broker/admin/v2/PersistentTopics.java 72.27% <100.00%> (-2.14%) ⬇️
.../org/apache/pulsar/broker/lookup/LookupResult.java 56.66% <0.00%> (-20.00%) ⬇️
...ulsar/broker/namespace/NamespaceEphemeralData.java 68.18% <0.00%> (-18.19%) ⬇️
.../apache/pulsar/broker/admin/impl/PackagesBase.java 54.12% <0.00%> (-13.77%) ⬇️
...balance/impl/SimpleResourceAllocationPolicies.java 48.57% <0.00%> (-5.72%) ⬇️
...g/apache/pulsar/client/impl/ConnectionHandler.java 50.00% <0.00%> (-5.32%) ⬇️
.../org/apache/pulsar/broker/admin/v2/Namespaces.java 56.16% <0.00%> (-3.62%) ⬇️
... and 259 more

@mattisonchao mattisonchao requested a review from lhotari January 10, 2023 11:56
@mattisonchao mattisonchao marked this pull request as draft January 12, 2023 05:15
@mattisonchao mattisonchao marked this pull request as ready for review January 17, 2023 09:47
final PulsarAdmin adminClient;
int brokerMaximumPartitionsPerTopic = pulsarService.getConfiguration()
.getMaxNumPartitionsPerPartitionedTopic();
if (brokerMaximumPartitionsPerTopic != 0 && expectPartitions > brokerMaximumPartitionsPerTopic) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

brokerMaximumPartitionsPerTopic != 0 -> brokerMaximumPartitionsPerTopic > 0
Seems better

@eolivelli eolivelli merged commit 4d7c7d0 into apache:master Jan 18, 2023
@mattisonchao mattisonchao deleted the refactor_update_partitions_endpoint branch January 18, 2023 08:37
gaozhangmin pushed a commit to gaozhangmin/pulsar that referenced this pull request Apr 6, 2023
RobertIndie added a commit to streamnative/pulsarctl that referenced this pull request May 16, 2023
…1067)

### Motivation

There is two failed tests when using Pulsar 3.0.0:
```
=== RUN   TestUpdateTopicNotExist
    update_test.go:85: 
        	Error Trace:	/pulsarctl/pkg/ctl/topic/update_test.go:85
        	Error:      	Not equal: 
        	            	expected: "code: 409 reason: Topic is not partitioned topic"
        	            	actual  : "code: 409 reason: Topic persistent://public/default/non-exist-topic is not the partitioned topic."
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1 +1 @@
        	            	-code: 409 reason: Topic is not partitioned topic
        	            	+code: 409 reason: Topic persistent://public/default/non-exist-topic is not the partitioned topic.
        	Test:       	TestUpdateTopicNotExist
--- FAIL: TestUpdateTopicNotExist (0.01s)
=== RUN   TestUpdateNonPartitionedTopic
    update_test.go:96: 
        	Error Trace:	/pulsarctl/pkg/ctl/topic/update_test.go:96
        	Error:      	Not equal: 
        	            	expected: "code: 409 reason: Topic is not partitioned topic"
        	            	actual  : "code: 409 reason: Topic persistent://public/default/test-update-non-partitioned-topic is not the partitioned topic."
        	            	
        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1 +1 @@
        	            	-code: 409 reason: Topic is not partitioned topic
        	            	+code: 409 reason: Topic persistent://public/default/test-update-non-partitioned-topic is not the partitioned topic.
        	Test:       	TestUpdateNonPartitionedTopic
--- FAIL: TestUpdateNonPartitionedTopic (0.02s)
```

More details in https://github.com/streamnative/pulsarctl/actions/runs/4976702208/jobs/8905382299?pr=1064#step:3:1349

This is because we change the log message in Pulsar 3.0.0 by this PR: apache/pulsar#19166

### Modifications

* Fix the assert of the test
RobertIndie added a commit to streamnative/pulsarctl that referenced this pull request May 16, 2023
…1067)

### Motivation

There is two failed tests when using Pulsar 3.0.0:
```
=== RUN   TestUpdateTopicNotExist
    update_test.go:85:
        	Error Trace:	/pulsarctl/pkg/ctl/topic/update_test.go:85
        	Error:      	Not equal:
        	            	expected: "code: 409 reason: Topic is not partitioned topic"
        	            	actual  : "code: 409 reason: Topic persistent://public/default/non-exist-topic is not the partitioned topic."

        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1 +1 @@
        	            	-code: 409 reason: Topic is not partitioned topic
        	            	+code: 409 reason: Topic persistent://public/default/non-exist-topic is not the partitioned topic.
        	Test:       	TestUpdateTopicNotExist
--- FAIL: TestUpdateTopicNotExist (0.01s)
=== RUN   TestUpdateNonPartitionedTopic
    update_test.go:96:
        	Error Trace:	/pulsarctl/pkg/ctl/topic/update_test.go:96
        	Error:      	Not equal:
        	            	expected: "code: 409 reason: Topic is not partitioned topic"
        	            	actual  : "code: 409 reason: Topic persistent://public/default/test-update-non-partitioned-topic is not the partitioned topic."

        	            	Diff:
        	            	--- Expected
        	            	+++ Actual
        	            	@@ -1 +1 @@
        	            	-code: 409 reason: Topic is not partitioned topic
        	            	+code: 409 reason: Topic persistent://public/default/test-update-non-partitioned-topic is not the partitioned topic.
        	Test:       	TestUpdateNonPartitionedTopic
--- FAIL: TestUpdateNonPartitionedTopic (0.02s)
```

More details in https://github.com/streamnative/pulsarctl/actions/runs/4976702208/jobs/8905382299?pr=1064#step:3:1349

This is because we change the log message in Pulsar 3.0.0 by this PR: apache/pulsar#19166

### Modifications

* Fix the assert of the test

(cherry picked from commit 11a3e8f)
nodece pushed a commit to nodece/pulsar that referenced this pull request Sep 6, 2024
…19166)

(cherry picked from commit 4d7c7d0)
Signed-off-by: Zixuan Liu <nodeces@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/broker doc-not-needed Your PR changes do not impact docs ready-to-test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants