Closed maumunoz closed 7 years ago
This is reasonable. I will take a look as soon as I am able.
@maumunoz I created a pull request with this change. It is on the feature branch Async. Can you please test it out and let me know if it fixes your issue.
To test: I added a new OSGi Property threadPoolSize to set your pool size. All methods in the CcuManager interface should work as you expect it.
@maumunoz Do you think 10 is a good default for the thread pool? Might be too high for low volume sites but too low for high volume sites.
@kairas, between 5 and 10 will be perfect. Maybe 5 will work better for low volume sites. Any high volume site can go ahead and modify the service configuration.
I was able to test the code and it worked great.
Thanks
Good to hear. I'll release a non-snapshot version tomorrow.
I'm facing an issue with concurrent connections to Akamai. The project I'm working has a high load of invalidations that are triggered in workflows. The following exception is thrown when there are concurrent connections:
Caused by: java.lang.IllegalStateException: Invalid use of BasicClientConnManager: connection still allocated. Make sure to release the connection before allocating another one. at org.apache.http.util.Asserts.check(Asserts.java:34) at org.apache.http.impl.conn.BasicClientConnectionManager.getConnection(BasicClientConnectionManager.java:166) at org.apache.http.impl.conn.BasicClientConnectionManager$1.getConnection(BasicClientConnectionManager.java:148) at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:424) at org.apache.http.impl.client.AbstractHttpClient.doExecute(AbstractHttpClient.java:884) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:71) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:220) at org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:164) at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:515) at groovyx.net.http.HTTPBuilder.doRequest(HTTPBuilder.java:434) at groovyx.net.http.HTTPBuilder.request(HTTPBuilder.java:383) at groovyx.net.http.HTTPBuilder$request.call(Unknown Source) at com.velir.aem.akamai.ccu.impl.CcuManagerImpl.purge(CcuManagerImpl.groovy:110) at com.velir.aem.akamai.ccu.CcuManager$purge$0.callCurrent(Unknown Source) at com.velir.aem.akamai.ccu.impl.CcuManagerImpl.purgeByUrls(CcuManagerImpl.groovy:72) at com.velir.aem.akamai.ccu.CcuManager$purgeByUrls.callCurrent(Unknown Source) at com.velir.aem.akamai.ccu.impl.CcuManagerImpl.purgeByUrl(CcuManagerImpl.groovy:64)
The recommendation is to use AsyncHTTPBuilder instead of HTTPBuilder to support concurrent connections. The pool size can be configured as part of the service properties.