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

[broker] Setup pulsar cluster with MetadataStore #10600

Merged
merged 1 commit into from
May 17, 2021

Conversation

fantapsody
Copy link
Contributor

Motivation

Refactor the pulsar cluster setup command to use the new MetadataStore API.

Modifications

  • Refactored PulsarClusterMetadataSetup command to use the new MetadataStore API.
  • Added a new MetadataStoreLifecycle interface for the MetadataStore implementations to do initialization as needed.
    • For zookeeper, it creates the root node in chroot mode

Verifying this change

  • Make sure that the change passes the CI checks.
    This change is already covered by existing tests, such as ClusterMetadataSetupTest.

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

If yes was chosen, please highlight the changes

  • Dependencies (does it add or upgrade a dependency): (no)
  • The public API: (no)
  • The schema: (no)
  • The default values of configurations: (no)
  • The wire protocol: (no)
  • The rest endpoints: (no)
  • The admin cli options: (no)
  • Anything that affects deployment: (no)

Documentation

  • Does this pull request introduce a new feature? (no)

@@ -308,6 +324,32 @@ static void createTenantIfAbsent(ZooKeeper configStoreZk, String tenant, String
}
}

static void createTenantIfAbsent(MetadataStore configStore, String tenant, String cluster) throws IOException,
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As @BewareMyPower pointed out, these methods are still used in PulsarInitialNamespaceSetup and PulsarTransactionCoordinatorMetadataSetup. I plan to open more PRs to fix these commands as well and then remove these methods altogether.

Copy link
Contributor

Choose a reason for hiding this comment

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

I see, thanks.

@@ -338,6 +380,32 @@ static void createNamespaceIfAbsent(ZooKeeper configStoreZk, NamespaceName names
}
}

static void createNamespaceIfAbsent(MetadataStore configStore, NamespaceName namespaceName, String cluster)
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

It's referenced in PulsarInitialNamespaceSetup, I think it's better to open a new PR for setup namespace with MetadataStore API.

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, as I explained above.

return FutureUtil.failedFuture(e);
}
}
return CompletableFuture.completedFuture(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

IMO there's no need to return a future because it's not an asynchronous API.

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean MetadataStoreLifecycle#initializeCluster should not be an asynchronous API. Otherwise it should be renamed to initializeClusterAsync and the associated synchronous API initializeCluster needs to be added as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Understood. It seems MetadataStore APIs are following a different pattern: all IO operations are asynchronous by default. So I think MetadataStoreLifecycle#initializeCluster should be designed in the same way.

Copy link
Contributor

Choose a reason for hiding this comment

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

Apart from the creating of the ZooKeeper client you could use all ZK async API calls in order to make it fully async.
But I believe it is overkilling, as you usually are going to wait for this setup operation to complete in real world operations.

I am fine to keep using CompletableFuture, it makes sense to me, for consistency as @fantapsody said

Copy link
Contributor

Choose a reason for hiding this comment

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

I agree with @eolivelli that if you're going to design an asynchronous API, it's better keep using CompletableFuture. I suggested using a synchronous API here just because your implementation is a synchronous way @fantapsody

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's true. The synchronous implementation is because I want to keep this piece of code simple and reuse the previous code, and the asynchronous API definition is to leave room for future optimizations if needed.

return FutureUtil.failedFuture(e);
}
}
return CompletableFuture.completedFuture(null);
Copy link
Contributor

Choose a reason for hiding this comment

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

Apart from the creating of the ZooKeeper client you could use all ZK async API calls in order to make it fully async.
But I believe it is overkilling, as you usually are going to wait for this setup operation to complete in real world operations.

I am fine to keep using CompletableFuture, it makes sense to me, for consistency as @fantapsody said

@codelipenghui codelipenghui merged commit 76ae7b1 into apache:master May 17, 2021
yangl pushed a commit to yangl/pulsar that referenced this pull request Jun 23, 2021
### Motivation

Refactor the pulsar cluster setup command to use the new `MetadataStore` API.

### Modifications

- Refactored `PulsarClusterMetadataSetup` command to use the new `MetadataStore` API.
- Added a new `MetadataStoreLifecycle` interface for the `MetadataStore` implementations to do initialization as needed.
  - For zookeeper, it creates the root node in chroot mode
bharanic-dev pushed a commit to bharanic-dev/pulsar that referenced this pull request Mar 18, 2022
### Motivation

Refactor the pulsar cluster setup command to use the new `MetadataStore` API.

### Modifications

- Refactored `PulsarClusterMetadataSetup` command to use the new `MetadataStore` API.
- Added a new `MetadataStoreLifecycle` interface for the `MetadataStore` implementations to do initialization as needed.
  - For zookeeper, it creates the root node in chroot mode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants