Description
In KYLIN-2814 , it fixs some kinds of sync wipe fails.
After we use this patch , sync wipe fails still often happen, the log is like this.
2017-09-08 21:28:13,029 WARN [pool-10-thread-2] cachesync.Broadcaster:137 : Thread failed during wipe cache at BroadcastEvent
{entity=cube, event=update, cacheKey=olap_nh_log_all_di_cube}, error msg: java.lang.IllegalStateException: Invalid use of BasicClientConnManager: connection still allocated.
Make sure to release the connection before allocating another one.
We search the code, then we found , the DefaultHttpClient uses BasicClientConnManager as default ConnManager.
and the BasicClientConnManager is a simple connection manager that maintains only one connection at a time. Even though this class is thread-safe it ought to be used by one execution thread only.
if we have many query servers, the BasicClientConnManager will be bottleneck.
so we use PoolingClientConnectionManager instead, which can manages a pool of client connections and is able to service connection requests from multiple execution threads.
Then everything goes fine. the code is below
final PoolingClientConnectionManager cm = new PoolingClientConnectionManager();
cm.setDefaultMaxPerRoute(20);
cm.setMaxTotal(200);
client = new DefaultHttpClient(cm, httpParams);
see more about BasicClientConnManager and PoolingClientConnectionManager
http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html#d5e619