You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@manifoldcf.apache.org by kw...@apache.org on 2012/01/11 16:00:11 UTC
svn commit: r1230078 -
/incubator/lcf/integration/solr-3.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java
Author: kwright
Date: Wed Jan 11 15:00:11 2012
New Revision: 1230078
URL: http://svn.apache.org/viewvc?rev=1230078&view=rev
Log:
Fix for CONNECTORS-333. Use the CloseHook API to free connections. We still get a warning message, but that's going to happen since the connection manager creates a static thread.
Modified:
incubator/lcf/integration/solr-3.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java
Modified: incubator/lcf/integration/solr-3.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java
URL: http://svn.apache.org/viewvc/incubator/lcf/integration/solr-3.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java?rev=1230078&r1=1230077&r2=1230078&view=diff
==============================================================================
--- incubator/lcf/integration/solr-3.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java (original)
+++ incubator/lcf/integration/solr-3.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java Wed Jan 11 15:00:11 2012
@@ -76,6 +76,7 @@ public class ManifoldCFQParserPlugin ext
String fieldAllowShare = null;
String fieldDenyShare = null;
int socketTimeOut;
+ Integer connectionManagerSynchronizer = new Integer(0);
MultiThreadedHttpConnectionManager httpConnectionManager = null;
HttpClient client = null;
int poolSize;
@@ -104,29 +105,35 @@ public class ManifoldCFQParserPlugin ext
fieldDenyShare = denyAttributePrefix+"share";
Integer connectionPoolSize = (Integer)args.get("ConnectionPoolSize");
poolSize = (connectionPoolSize==null)?50:connectionPoolSize.intValue();
-
- // Initialize the connection pool
- HttpConnectionManagerParams params = new HttpConnectionManagerParams();
- params.setTcpNoDelay(true);
- params.setStaleCheckingEnabled(false);
- params.setDefaultMaxConnectionsPerHost(poolSize);
- params.setMaxTotalConnections(poolSize);
- httpConnectionManager = new MultiThreadedHttpConnectionManager();
- httpConnectionManager.setParams(params);
- client = new HttpClient(httpConnectionManager);
+ }
+
+ protected void initializeClient(SolrCore core)
+ {
+ synchronized (connectionManagerSynchronizer)
+ {
+ if (client == null)
+ {
+ // Initialize the connection pool
+ HttpConnectionManagerParams params = new HttpConnectionManagerParams();
+ params.setTcpNoDelay(true);
+ params.setStaleCheckingEnabled(false);
+ params.setDefaultMaxConnectionsPerHost(poolSize);
+ params.setMaxTotalConnections(poolSize);
+ httpConnectionManager = new MultiThreadedHttpConnectionManager();
+ httpConnectionManager.setParams(params);
+ client = new HttpClient(httpConnectionManager);
+ core.addCloseHook(new CloseHandler());
+ }
+ }
}
@Override
public QParser createParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req)
{
+ initializeClient(req.getCore());
return new ManifoldCFQueryParser(qstr,localParams,params,req);
}
- public void inform(SolrCore core)
- {
- core.addCloseHook(new CloseHandler());
- }
-
protected class ManifoldCFQueryParser extends QParser
{
public ManifoldCFQueryParser(String qstr, SolrParams localParams, SolrParams params, SolrQueryRequest req)