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

Removing transport shutdown hooks from channel builder #837

Closed
wants to merge 1 commit into from

Conversation

nmittler
Copy link
Member

The current process of building a channel is a bit complicated in that transports have to provide a own shutdown hook to the channel builder in order to close shared executors. This somewhat entagled creation pattern makes it difficult to separate the process of channel building from transport building. Better separating these two should make the code more readable and maintainable moving forward.

@nmittler
Copy link
Member Author

@zhangkun83 zhangkun83 self-assigned this Aug 19, 2015
@nmittler
Copy link
Member Author

The main issue with this PR ATM is that because the channel only creates a single transport at a time, the shared executor will be repeatedly created and destroyed if using a single Channel. Need to put some thought into how to better handle that ... or if it is really going to matter much, especially once we add load balancing.

} finally {
// If we are using the shared event loop group, we need to return our reference.
if (usingSharedGroup) {
SharedResourceHolder.release(Utils.DEFAULT_WORKER_EVENT_LOOP_GROUP, group);
Copy link
Member

Choose a reason for hiding this comment

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

This must only be called once. It should observe notifyTerminated.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ack ... this has changed.

@nmittler
Copy link
Member Author

@madongfly @ejona86 @zhangkun83 @carl-mastrangelo PTAL ... I've reworked this to add reference counting of ClientTransportFactory. Also removed all termination hooks from both client and server.

@carl-mastrangelo
Copy link
Contributor

@nmittler LGTM

@@ -98,7 +100,7 @@
*/
public ServerImpl(Executor executor, HandlerRegistry registry,
Copy link
Contributor

Choose a reason for hiding this comment

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

@Nullable

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

@zhangkun83
Copy link
Contributor

@nmittler LGTM

@madongfly
Copy link
Contributor

LGTM

@nmittler
Copy link
Member Author

@ejona86 gentle ping...

@@ -380,10 +401,8 @@ public void transportTerminated() {
log.warning("transportTerminated called after already terminated");
}
terminated = true;
onChannelTerminated();
Copy link
Member

Choose a reason for hiding this comment

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

nit: keep ordering the same between this and shutdown(). notifyAll() and onChannelTerminated() are swapped.

Copy link
Member Author

Choose a reason for hiding this comment

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

done.

@ejona86
Copy link
Member

ejona86 commented Aug 24, 2015

@nmittler LGTM. My comment for AbstractReferenceCounted is the most important one.

@nmittler
Copy link
Member Author

@ejona86 PTAL

@ejona86
Copy link
Member

ejona86 commented Aug 24, 2015

@nmittler, LGTM.

@nmittler nmittler force-pushed the transport_factory branch 2 times, most recently from a4dee9f to 1d83d43 Compare August 25, 2015 15:34
The current process of building a channel is a bit complicated in that transports have to provide a own shutdown hook to the channel builder in order to close shared executors. This somewhat entagled creation pattern makes it difficult to separate the process of channel building from transport building. Better separating these two should make the code more readable and maintainable moving forward.
@nmittler
Copy link
Member Author

Cherry-picked as 777e928

FYI @zhangkun83 this should help with your load balancing work

@nmittler nmittler closed this Aug 25, 2015
@lock lock bot locked as resolved and limited conversation to collaborators Jan 22, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants