Skip to content
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

Refactored PulsarResources to avoid building metadata paths everywhere #11693

Merged
merged 32 commits into from
Sep 16, 2021

Conversation

merlimat
Copy link
Contributor

Motivation

The PulsarResources and its companion classes are all taking Strings with paths for resources in the metadata store. This has lead to a proliferation of string composition to construct these paths from all over the code base.

Instead, we should be taking the resource namings (eg: TopicName, NamespaceName, etc.) and hide the path in the metadata.

Modifications

  • Changes all methods in BaseResources to be protected
  • Each subclass exposes resource specific public methods

@merlimat merlimat added the type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages label Aug 17, 2021
@merlimat merlimat added this to the 2.9.0 milestone Aug 17, 2021
@merlimat merlimat self-assigned this Aug 17, 2021
@Anonymitaet
Copy link
Member

Thanks for your contribution. For this PR, do we need to update docs?

(The PR template contains info about doc, which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)

@merlimat merlimat added the doc-not-needed Your PR changes do not impact docs label Aug 18, 2021
@merlimat
Copy link
Contributor Author

Thanks for your contribution. For this PR, do we need to update docs?
@Anonymitaet no need for docs changes here. Just labeled.

Copy link
Contributor

@eolivelli eolivelli left a comment

Choose a reason for hiding this comment

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

Well done.
thIs is is very useful clean up.
Thanks for doing it

@merlimat merlimat merged commit 89841aa into apache:master Sep 16, 2021
codelipenghui pushed a commit that referenced this pull request Dec 28, 2021
### Motivation

This PR is used to keep same behavior with Pulsar 2.8 and 2.7 version.

In Pulsar 2.7 and 2.8, when delete a non-existent failure domain resource, it will return 404 status code.
In Pulsar 2.9, when delete a non-existent failure domain resource, it will return 200 status code.

Reproduce in Pulsar 2.8:
```
$ docker run -itd \
  -p 6650:6650 \
  -p 8080:8080 \
  apachepulsar/pulsar:2.8.1 \
  bin/pulsar standalone
$ pulsarctl clusters delete-failure-domain standalone non-existent-failure-domain
[✖]  code: 404 reason: Domain-name non-existent-failure-domain or cluster standalone does not exist
```

Reproduce in Pulsar 2.9:
```
$ docker run -itd \
  -p 6650:6650 \
  -p 8080:8080 \
  apachepulsar/pulsar:2.9.0 \
  bin/pulsar standalone
$ pulsarctl clusters delete-failure-domain standalone non-existent-failure-domain
Delete failure domain [non-existent-failure-domain] for cluster [standalone] succeed
```
                   
Affected version: 2.9.x

This issue was caused by #11693.

### Modifications

- Remove check resource exists when call the `ClusterResources#deleteFailureDomain()`
- Add check resource exists when call the  `ClusterResources#deleteFailureDomains()`
codelipenghui pushed a commit that referenced this pull request Dec 30, 2021
### Motivation

This PR is used to keep same behavior with Pulsar 2.8 and 2.7 version.

In Pulsar 2.7 and 2.8, when delete a non-existent failure domain resource, it will return 404 status code.
In Pulsar 2.9, when delete a non-existent failure domain resource, it will return 200 status code.

Reproduce in Pulsar 2.8:
```
$ docker run -itd \
  -p 6650:6650 \
  -p 8080:8080 \
  apachepulsar/pulsar:2.8.1 \
  bin/pulsar standalone
$ pulsarctl clusters delete-failure-domain standalone non-existent-failure-domain
[✖]  code: 404 reason: Domain-name non-existent-failure-domain or cluster standalone does not exist
```

Reproduce in Pulsar 2.9:
```
$ docker run -itd \
  -p 6650:6650 \
  -p 8080:8080 \
  apachepulsar/pulsar:2.9.0 \
  bin/pulsar standalone
$ pulsarctl clusters delete-failure-domain standalone non-existent-failure-domain
Delete failure domain [non-existent-failure-domain] for cluster [standalone] succeed
```

Affected version: 2.9.x

This issue was caused by #11693.

### Modifications

- Remove check resource exists when call the `ClusterResources#deleteFailureDomain()`
- Add check resource exists when call the  `ClusterResources#deleteFailureDomains()`

(cherry picked from commit 7f4aac5)
wuzhanpeng pushed a commit to wuzhanpeng/pulsar that referenced this pull request Jan 5, 2022
### Motivation

This PR is used to keep same behavior with Pulsar 2.8 and 2.7 version.

In Pulsar 2.7 and 2.8, when delete a non-existent failure domain resource, it will return 404 status code.
In Pulsar 2.9, when delete a non-existent failure domain resource, it will return 200 status code.

Reproduce in Pulsar 2.8:
```
$ docker run -itd \
  -p 6650:6650 \
  -p 8080:8080 \
  apachepulsar/pulsar:2.8.1 \
  bin/pulsar standalone
$ pulsarctl clusters delete-failure-domain standalone non-existent-failure-domain
[✖]  code: 404 reason: Domain-name non-existent-failure-domain or cluster standalone does not exist
```

Reproduce in Pulsar 2.9:
```
$ docker run -itd \
  -p 6650:6650 \
  -p 8080:8080 \
  apachepulsar/pulsar:2.9.0 \
  bin/pulsar standalone
$ pulsarctl clusters delete-failure-domain standalone non-existent-failure-domain
Delete failure domain [non-existent-failure-domain] for cluster [standalone] succeed
```
                   
Affected version: 2.9.x

This issue was caused by apache#11693.

### Modifications

- Remove check resource exists when call the `ClusterResources#deleteFailureDomain()`
- Add check resource exists when call the  `ClusterResources#deleteFailureDomains()`
bharanic-dev pushed a commit to bharanic-dev/pulsar that referenced this pull request Mar 18, 2022
apache#11693)

* Refactored PulsarResources to avoid building metadata paths everywhere

* Fixed usages of ZkAdminPaths

* Removed unused import

* Fixed proxy

* Fixed ResourceGroupServiceTest

* Added MetadataStore deleteRecursive operation

* Fixed merge issues

* Use constant

* Removed unused import

* Fixes for ResourceGroupConfigListenerTest

* Fixed cluster resources cleanup

* Fixed topic list rest call

* Fixed NPE in PersistentDispatcherFailoverConsumerTest setup

* Fixed flaky test ReplicatorTest.testRemoveClusterFromNamespace

* Fixed handling notification for V1 path namespaces

* Fixed LocalPoliciesResources create

* Fixed deadlock when making blocking calls from MetadataStore callback thread

* Fixed usage of NamespaceName as key

* Fixed missing mock in BacklogQuotaManagerConfigurationTest

* Fixed RGUsageMTAggrWaitForAllMesgsTest

* fixed ServerCnxTest

* Fixed mock in PersistentSubscriptionTest

* Fixed PersistentTopicTest

* Fixed getting partitions list from NamespaceService

* Fixed tenant not found expectation

* Fixed ProxyConnection to check for existence of auth_data field
BewareMyPower pushed a commit that referenced this pull request Jul 28, 2022
…l sync method for AuthoriationService (#15694)

(cherry picked from commit 6af365e)

Besides resolving the basic conflicts, this PR
- migrate `validateAdminAccessForTenantAsync` from #14149
- migrate `TenantResources#getTenantAsync` from #11693
BewareMyPower pushed a commit that referenced this pull request Jul 28, 2022
…l sync method for AuthoriationService (#15694)

(cherry picked from commit 6af365e)

Besides resolving the basic conflicts, this PR
- migrate `validateAdminAccessForTenantAsync` from #14149
- migrate `TenantResources#getTenantAsync` from #11693
BewareMyPower pushed a commit that referenced this pull request Jul 28, 2022
…l sync method for AuthoriationService (#15694)

(cherry picked from commit 6af365e)

Besides resolving the basic conflicts, this PR
- migrate `validateAdminAccessForTenantAsync` from #14149
- migrate `TenantResources#getTenantAsync` from #11693
BewareMyPower pushed a commit that referenced this pull request Jul 29, 2022
…l sync method for AuthoriationService (#15694)

(cherry picked from commit 6af365e)

Besides resolving the basic conflicts, this PR
- migrate `validateAdminAccessForTenantAsync` from #14149
- migrate `TenantResources#getTenantAsync` from #11693
BewareMyPower added a commit that referenced this pull request Aug 2, 2022
…l sync method for AuthoriationService (#15694) (#16831)

(cherry picked from commit 6af365e)

Besides resolving the basic conflicts, this PR
- migrate `validateAdminAccessForTenantAsync` from #14149
- migrate `TenantResources#getTenantAsync` from #11693

Co-authored-by: lipenghui <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
doc-not-needed Your PR changes do not impact docs type/enhancement The enhancements for the existing features or docs. e.g. reduce memory usage of the delayed messages
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants