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

Add ServiceUrlProvider and add method forceCloseConnection in PulsarC… #2543

Merged
merged 9 commits into from
Sep 19, 2018

Conversation

codelipenghui
Copy link
Contributor

Support build Pulsar client with serviceUrlProvider method.

Motivation

With serviceUrlProvider we can store the pulsar service url in zookeeper or any other config service.
And we can watch the service url change event then control the pulsar client, such as change pulsar client serviceUrl, force close client connection or re-connect with new service url.

Modifications

Add ServiceUrlProvider interface.
Add forceCloseConnection method in PulsarClient.

*
* @param client created pulsar client.
*/
void setClient(PulsarClient client);
Copy link
Member

Choose a reason for hiding this comment

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

@codelipenghui do you mind providing an example how this would be used?

@@ -706,6 +706,58 @@ public void shutdown() throws PulsarClientException {
}
}

@Override
public void forceCloseConnection() {
Copy link
Member

Choose a reason for hiding this comment

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

can you describe more on how forceCloseConnection will be used in ServiceUrlProvider ?

@@ -706,6 +706,58 @@ public void shutdown() throws PulsarClientException {
}
}

@Override
public void forceCloseConnection() {
if (this.producers != null) {
Copy link
Contributor

Choose a reason for hiding this comment

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

There are few problems with this way of closing the connections.

channelInactive() is supposed to be called by Netty when the connection gets closed. With the current approache the original TCP connection will stay open and the broker will still have registered the producer/consumer as connected.

The right approach here should be to close all the connections in the ConnectionPool. That will be triggering the reconnections for all producers/consumers.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@merlimat I'm already fix it.

@sijie
Copy link
Member

sijie commented Sep 10, 2018

run java8 tests

@sijie sijie added area/client type/feature The PR added a new feature or issue requested a new feature labels Sep 10, 2018
@sijie
Copy link
Member

sijie commented Sep 13, 2018

@merlimat can you review this PR?

@sijie
Copy link
Member

sijie commented Sep 14, 2018

retest this please

@sijie
Copy link
Member

sijie commented Sep 15, 2018

run java8 tests

@jiazhai
Copy link
Member

jiazhai commented Sep 17, 2018

over all lgtm, it would be better provide more comments and examples as @sijie suggested.

@sijie
Copy link
Member

sijie commented Sep 18, 2018

run java8 tests

@sijie sijie added this to the 2.2.0-incubating milestone Sep 19, 2018
@sijie sijie merged commit ee5afa5 into apache:master Sep 19, 2018
@codelipenghui
Copy link
Contributor Author

Thanks @sijie.

We will implement a service url provider base on Zookeeper. If this url provider have a good practice in zhaopin.com. we pleasure to contribute a Pulsar Client extend.

@sijie
Copy link
Member

sijie commented Sep 19, 2018

@codelipenghui yeah, thank you so much for your contribution! look forward to your contribution about zookeeper based service url provider :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/client type/feature The PR added a new feature or issue requested a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants