-
Notifications
You must be signed in to change notification settings - Fork 79
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 close() method to connectionPool so connections are closed when origins are reloaded #551
Add close() method to connectionPool so connections are closed when origins are reloaded #551
Conversation
…rigins are reloaded.
Hi @dvlato this PR doesn't have any effect unless the pool consumer calls the We need to check the following pool consumers:
Going forward, the |
I suggest: Add a
Of course we may have to take extra care to ensure metrics are correctly maintained. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks for this @dvlato. Very helpful :-D
Left a quick comment regarding borrowed connections. Please have a look.
Approved this regardless.
components/client/src/main/java/com/hotels/styx/client/connectionpool/SimpleConnectionPool.java
Show resolved
Hide resolved
components/client/src/main/java/com/hotels/styx/client/connectionpool/SimpleConnectionPool.java
Outdated
Show resolved
Hide resolved
components/client/src/main/java/com/hotels/styx/client/connectionpool/SimpleConnectionPool.java
Show resolved
Hide resolved
components/client/src/main/java/com/hotels/styx/client/connectionpool/SimpleConnectionPool.java
Outdated
Show resolved
Hide resolved
...lient/src/test/unit/java/com/hotels/styx/client/connectionpool/SimpleConnectionPoolTest.java
Outdated
Show resolved
Hide resolved
...lient/src/test/unit/java/com/hotels/styx/client/connectionpool/SimpleConnectionPoolTest.java
Outdated
Show resolved
Hide resolved
...lient/src/test/unit/java/com/hotels/styx/client/connectionpool/SimpleConnectionPoolTest.java
Show resolved
Hide resolved
Travis fails due to check style error:
|
We were missing a ConnectionPool.close() method that will close open connections when an origins file is reloaded.
We are just invoking Connection::close() without modifying the metrics as, in most cases (except when the origin is removed), they would be overridden by the new SimpleConnectionPool for that origin server. We can discuss this to see what's the best way to implement it.
We can also discuss what's the best meaningful test we can implement. I guess we could add a global counter for the tota number of connections opened / closed (not per origin but global!). We might also have to locate all the code paths that should trigger a pool closure and add assertions for those in unit tests.
Of course, this PR does not prevent us from leaving connections pool that hadn't been returned to the pool (they are not in "availableConnections") at the moment the pool was closed.