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

[pulsar-broker] namespace resources use metadata-store api #9351

Merged
merged 2 commits into from
Feb 8, 2021

Conversation

rdhabalia
Copy link
Contributor

Motivation

This PR is on top of #9338, with this change, namespace-resources will start using metadata-api and remove zk-dependency.

@rdhabalia rdhabalia added this to the 2.8.0 milestone Jan 28, 2021
@rdhabalia rdhabalia self-assigned this Jan 28, 2021
@rdhabalia rdhabalia closed this Jan 28, 2021
@rdhabalia rdhabalia reopened this Jan 28, 2021
@rdhabalia rdhabalia force-pushed the zk_rest_ns branch 2 times, most recently from 1afcb3d to 3c4bb85 Compare January 30, 2021 09:17
@rdhabalia
Copy link
Contributor Author

/pulsarbot run-failure-checks

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.

Great work.
Code really looks cleaner

I left a couple of questions

if (maxPartitions > 0 && autoTopicCreationOverride.defaultNumPartitions > maxPartitions) {
throw new RestException(Status.NOT_ACCEPTABLE,
"Number of partitions should be less than or equal to " + maxPartitions);
if (autoTopicCreationOverride != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

this if statement was not present before, can it be null here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, I merged two methods which had duplicate code:
internalRemoveAutoTopicCreation and internalSetAutoSubscriptionCreation

@@ -2041,4 +2044,9 @@ public void testCompactionStatus() throws Exception {
assertTrue(admin.topics().compactionStatus(topicName)
.lastError.contains("Failed at something"));
}

private void clearCache() {
// (MetadataCacheImpl<ClusterData>) pulsar.getPulsarResources().
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: remove comment

if (ex.getCause() instanceof BadVersionException) {
// if resource is updated by other than metadata-cache then metadata-cache will get bad-version
// exception. so, try to invalidate the cache and try one more time.
objCache.synchronous().invalidate(key);
Copy link
Contributor

Choose a reason for hiding this comment

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

can we call here this synchronous operation ?
do we risk a deadlock ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no, it just cleans up the cache synchronously.

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.

Lgtm

@rdhabalia rdhabalia force-pushed the zk_rest_ns branch 2 times, most recently from 61001b2 to 38481a9 Compare February 5, 2021 23:50
@@ -118,7 +120,7 @@ private MetadataCacheImpl(MetadataStore store, MetadataSerde<T> serde) {

@Override
public CompletableFuture<Void> readModifyUpdateOrCreate(String path, Function<Optional<T>, T> modifyFunction) {
return objCache.get(path)
return executeWithRetry(() -> objCache.get(path)
Copy link
Contributor

Choose a reason for hiding this comment

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

This part is already in master, can you merge or rebase?

@@ -418,7 +382,7 @@ protected Policies getNamespacePolicies(NamespaceName namespaceName) {
try {
final String namespace = namespaceName.toString();
final String policyPath = AdminResource.path(POLICIES, namespace);
Policies policies = policiesCache().get(policyPath)
Policies policies = namespaceResources().get(policyPath)
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: ideally namespace resources should take a namespace name and internally resolve the path on metadata store.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes, make sense. I will try to handle in another PR so, I can handle unit-test failures related to this change separately.

} catch (KeeperException.NodeExistsException e) {
log.warn("[{}] Failed to create namespace {} - already exists", clientAppId(), namespaceName);
} catch (NotFoundException e) {
log.error("[{}] namespace already exists {}", clientAppId(), namespaceName, e);
Copy link
Contributor

Choose a reason for hiding this comment

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

The exception and the log message seem to have diverged now

* @param property the property name
* @return the list of namespaces
*/
protected List<String> getListOfNamespaces(String property) throws Exception {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
protected List<String> getListOfNamespaces(String property) throws Exception {
protected List<String> getListOfNamespaces(String tenant) throws Exception {

@Renkai
Copy link
Contributor

Renkai commented Feb 7, 2021

/pulsarbot run-failure-checks

@rdhabalia rdhabalia merged commit 7fd3218 into apache:master Feb 8, 2021
@rdhabalia rdhabalia deleted the zk_rest_ns branch February 8, 2021 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

Project-10: Replace Zookeeper API access in REST resources with Pluggable metadata resources
6 participants