Skip to content

Add ServiceUrlProvider and add method forceCloseConnection in PulsarC… - #2543

Merged
sijie merged 9 commits into
apache:masterfrom
codelipenghui:service-url-provider
Sep 19, 2018
Merged

Add ServiceUrlProvider and add method forceCloseConnection in PulsarC…#2543
sijie merged 9 commits into
apache:masterfrom
codelipenghui:service-url-provider

Conversation

@codelipenghui

Copy link
Copy Markdown
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
Copy Markdown
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?

}

@Override
public void forceCloseConnection() {

Copy link
Copy Markdown
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 ?


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

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.

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
Copy Markdown
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

sijie commented Sep 10, 2018

Copy link
Copy Markdown
Member

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

sijie commented Sep 13, 2018

Copy link
Copy Markdown
Member

@merlimat can you review this PR?

@sijie

sijie commented Sep 14, 2018

Copy link
Copy Markdown
Member

retest this please

@sijie

sijie commented Sep 15, 2018

Copy link
Copy Markdown
Member

run java8 tests

@jiazhai

jiazhai commented Sep 17, 2018

Copy link
Copy Markdown
Member

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

@sijie

sijie commented Sep 18, 2018

Copy link
Copy Markdown
Member

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
Copy Markdown
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

sijie commented Sep 19, 2018

Copy link
Copy Markdown
Member

@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.

4 participants