| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
There was a problem hiding this comment.
Thanks a lot!
Could you please have a look at my question?
Sorry, something went wrong.
|
|
||
| //see https://github.com/netty/netty/issues/2084#issuecomment-44822314 | ||
| try { | ||
| ThreadDeathWatcher.awaitInactivity(5, TimeUnit.SECONDS); |
There was a problem hiding this comment.
Shouldn't the await activity be aligned with AsyncHttpClientConfig#getShutdownTimeout or AsyncHttpClientConfig#getShutdownQuietPeriod instead of being hard coded?
Sorry, something went wrong.
There was a problem hiding this comment.
Yes, I guess aligning it with AsyncHttpClientConfig#getShutdownTimeout makes absolutely sense. The quietPeriod seems to have different meaning and I guess it is inappropriate at this place.
Sorry, something went wrong.
There was a problem hiding this comment.
👍
Sorry, something went wrong.
|
|
||
| //see https://github.com/netty/netty/issues/2084#issuecomment-44822314 | ||
| try { | ||
| GlobalEventExecutor.INSTANCE.awaitInactivity(5, TimeUnit.SECONDS); |
There was a problem hiding this comment.
Same here
Sorry, something went wrong.
| // Ignore | ||
| } | ||
|
|
||
| closeLatch.countDown(); |
There was a problem hiding this comment.
In finally block?
Sorry, something went wrong.
There was a problem hiding this comment.
Yes could be done to cover the corner cases.
Sorry, something went wrong.
| doClose(); | ||
|
|
||
| try { | ||
| closeLatch.await(); |
There was a problem hiding this comment.
No timeout for this await?
Sorry, something went wrong.
There was a problem hiding this comment.
yes, timeout could be reused!
Sorry, something went wrong.
|
|
||
| public boolean isClosed() { | ||
| public boolean isClosedOrClosingIsTriggered() { | ||
| return closed.get(); |
There was a problem hiding this comment.
I guess it's best to rename closed into closeTriggered.
Sorry, something went wrong.
| sendNextRequest(newRequest, future); | ||
| } | ||
|
|
||
| public boolean isClosed() { |
There was a problem hiding this comment.
Rename method too.
Sorry, something went wrong.
There was a problem hiding this comment.
Done and attached another commit to the pull request!
Sorry, something went wrong.
|
I'm just wondering... Will this interfere with other parts of an application that also use Netty? So let's say I close an AHC instance but have some other Netty-based component, e.g. a server component - or just another AHC instance - that is still in use. To me, it sounds like those global helper methods would then just run into a timeout. |
Sorry, something went wrong.
|
Yeah, actually I think @twz123 is right and this would also break for people who spawn and shutdown AHC instances at runtime without stopping the application :( |
Sorry, something went wrong.
|
@twz123 thanks for the check but I can't see any interference to other instances of AHC or netty. If there is still activity on the threads the awaitInactivity calls triggered in the close method of the AHC client should run into the timeout and that's it. The close returns successfully without any exception. Maybe the close then needs a while till it returns but it should not affect other instances or did I miss something? The awaitInactivity implementations call join on a thread but this only waits for the thread to die and does not trigger an active kill or did I miss something here? Javadoc of join: "Waits at most millis milliseconds for this thread to die." If we could not clarify this today we have to discuss this another time because I'm out of office for four weeks now (starting tomorrow). Sorry for this inconvenience. |
Sorry, something went wrong.
|
Hey @MiErnst,
Okay, that's true. Maybe I should have written in passive voice "is affected by other parts of the app that use Netty" instead of "interferes with". My caveat is exactly what you wrote:
So the blocking behavior of close only works as expected when no other parts of the app are currently using Netty. This is certainly not a complete show-stopper but boils down to "just wait some amount of time and just assume that all resources have been closed concurrently by then" for those cases where Netty is still in use. From my point of view, there are several possibilities now:
|
Sorry, something went wrong.
|
|
||
| public boolean isClosed() { | ||
| return closed.get(); | ||
| public boolean isCloseTriggered() { |
There was a problem hiding this comment.
What's wrong with the old name?
Sorry, something went wrong.
| try { | ||
| ThreadDeathWatcher.awaitInactivity(config.getShutdownTimeout(), TimeUnit.MILLISECONDS); | ||
| } catch(InterruptedException t) { | ||
| // Ignore |
There was a problem hiding this comment.
Re-assert interrupted status
Sorry, something went wrong.
| try { | ||
| GlobalEventExecutor.INSTANCE.awaitInactivity(config.getShutdownTimeout(), TimeUnit.MILLISECONDS); | ||
| } catch(InterruptedException t) { | ||
| // Ignore |
There was a problem hiding this comment.
Re-assert interrupted status
Sorry, something went wrong.
| try { | ||
| closeLatch.await(config.getShutdownTimeout(), TimeUnit.MILLISECONDS); | ||
| } catch (InterruptedException e) { | ||
| // Ignore |
There was a problem hiding this comment.
Re-assert interrupted status
Sorry, something went wrong.
|
Hi guys, is there a plan to release these commits? |
Sorry, something went wrong.
|
@zhan-ge There was changes request,so won't be any soon.and AHC has its own release cycle. |
Sorry, something went wrong.
|
Frankly, I'm not fond of this implementation.
So having a mechanism based on this GlobalEventExecutor.INSTANCE singleton seems broken to me. Why not keeping track of flying requests? Like having an AsyncHttpClient that would be a decorator, that would increment an AtomicInteger when executing requests, would register a Listener to decrement on completion, and that could switch to closing state (reject new requests, await for current flying requests and then close). |
Sorry, something went wrong.
|
Hey together, sorry for the circumstances that I wasn’t able to work on this pull request. @twz123
As you can see in the implementation I changed the return type of the ChannelManager’s close method. Although this method is public, the instance of the ChannelManager seems only to managed by the DefaultAsyncHttpClient and is not returned by any public method of this client, so I think this internal API change should not be a problem. The current close method also waits for the ChannelManager to complete successfully. If the eventLoopGroup is going to shutdown gracefully, the close will wait till this method completes but I think this is OK because it’s a resource created by the AHC. To prevent the amount of TimeoutExceptions in the travis build, the system property org.asynchttpclient.shutdownTimeout in the surefire plugin configuration has to be increased to 1500 because the gracefull shutdown needs at least 1.2 seconds to complete. I don’t know if this affects the travis build time to much so it is currently not part of the push request. I don’t think the currently failed test is related to this implementation. Can’t see what the cause is. @slandelle |
Sorry, something went wrong.
|
Can you guys just change it to this and be done with it, I think by the time they are closing the pool waiting sync vs async does not matter that much: private void doClose() {
openChannels.close().awaitUninterruptibly();
channelPool.destroy();
}
|
Sorry, something went wrong.
| Back | FazBrowse Home | New Git URL |
#1412 Implemented a count down latch and called some API methods to close resources of netty.