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 2011/12/20 13:13:32 UTC

svn commit: r1221217 - in /incubator/lcf/integration/solr-4.x/trunk: CHANGES.txt build.xml mcf/src/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java mcf/src/java/org/apache/solr/mcf/ManifoldCFSearchComponent.java

Author: kwright
Date: Tue Dec 20 12:13:32 2011
New Revision: 1221217

URL: http://svn.apache.org/viewvc?rev=1221217&view=rev
Log:
Partial fix for CONNECTORS-333.  Use MultiThreadedHttpConnectionManager to pool connections.

Modified:
    incubator/lcf/integration/solr-4.x/trunk/CHANGES.txt
    incubator/lcf/integration/solr-4.x/trunk/build.xml
    incubator/lcf/integration/solr-4.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java
    incubator/lcf/integration/solr-4.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFSearchComponent.java

Modified: incubator/lcf/integration/solr-4.x/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/lcf/integration/solr-4.x/trunk/CHANGES.txt?rev=1221217&r1=1221216&r2=1221217&view=diff
==============================================================================
--- incubator/lcf/integration/solr-4.x/trunk/CHANGES.txt (original)
+++ incubator/lcf/integration/solr-4.x/trunk/CHANGES.txt Tue Dec 20 12:13:32 2011
@@ -1,7 +1,13 @@
 Apache ManifoldCF Solr 4.x Plugin change Log
 $Id$
 
-======================= 0.1-dev =====================
+======================= 0.2-incubating-dev =====================
+
+CONNECTORS-333: Use multithreaded connection manager and tcp-no-delay
+in order to avoid sockets accumulating in CLOSE_WAIT.
+(Simon Willnauer via Karl Wright)
+
+======================= Release 0.1 =====================
 
 Initial commit.
 (Karl Wright)

Modified: incubator/lcf/integration/solr-4.x/trunk/build.xml
URL: http://svn.apache.org/viewvc/incubator/lcf/integration/solr-4.x/trunk/build.xml?rev=1221217&r1=1221216&r2=1221217&view=diff
==============================================================================
--- incubator/lcf/integration/solr-4.x/trunk/build.xml (original)
+++ incubator/lcf/integration/solr-4.x/trunk/build.xml Tue Dec 20 12:13:32 2011
@@ -63,7 +63,7 @@
   <target name="build" depends="deliver"/>
 
   <target name="set-version">
-      <property name="release-version" value="0.1-incubating"/>
+      <property name="release-version" value="0.2-incubating-dev"/>
   </target>
     
   <target name="create-source-zip" depends="set-version">

Modified: incubator/lcf/integration/solr-4.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java
URL: http://svn.apache.org/viewvc/incubator/lcf/integration/solr-4.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java?rev=1221217&r1=1221216&r2=1221217&view=diff
==============================================================================
--- incubator/lcf/integration/solr-4.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java (original)
+++ incubator/lcf/integration/solr-4.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFQParserPlugin.java Tue Dec 20 12:13:32 2011
@@ -37,6 +37,7 @@ import org.apache.solr.handler.component
 import org.apache.solr.handler.component.SearchComponent;
 import org.apache.commons.httpclient.*;
 import org.apache.commons.httpclient.methods.*;
+import org.apache.commons.httpclient.params.*;
 import org.slf4j.*;
 
 import java.io.*;
@@ -73,10 +74,26 @@ public class ManifoldCFQParserPlugin ext
   String fieldAllowShare = null;
   String fieldDenyShare = null;
   int socketTimeOut;
+  MultiThreadedHttpConnectionManager httpConnectionManager;
+  HttpClient client;
   
   public ManifoldCFQParserPlugin()
   {
     super();
+    HttpConnectionManagerParams params = new HttpConnectionManagerParams();
+    params.setTcpNoDelay(true);
+    params.setStaleCheckingEnabled(false);
+    httpConnectionManager = new MultiThreadedHttpConnectionManager();
+    httpConnectionManager.setParams(params);
+    client = new HttpClient(httpConnectionManager);
+  }
+
+  @Override
+  protected void finalize()
+    throws Throwable
+  {
+    super.finalize();
+    httpConnectionManager.shutdown();
   }
 
   @Override
@@ -228,7 +245,6 @@ public class ManifoldCFQParserPlugin ext
       throws IOException
     {
       // We can make this more complicated later, with support for https etc., but this is enough to demonstrate how it all should work.
-      HttpClient client = new HttpClient();
       String theURL = authorityBaseURL + "/UserACLs?username="+URLEncoder.encode(authenticatedUserName,"utf-8");
         
       GetMethod method = new GetMethod(theURL);
@@ -245,7 +261,7 @@ public class ManifoldCFQParserPlugin ext
         InputStream is = method.getResponseBodyAsStream();
         try
         {
-          Reader r = new InputStreamReader(is,"utf-8");
+          Reader r = new InputStreamReader(is,method.getResponseCharSet());
           try
           {
             BufferedReader br = new BufferedReader(r);

Modified: incubator/lcf/integration/solr-4.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFSearchComponent.java
URL: http://svn.apache.org/viewvc/incubator/lcf/integration/solr-4.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFSearchComponent.java?rev=1221217&r1=1221216&r2=1221217&view=diff
==============================================================================
--- incubator/lcf/integration/solr-4.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFSearchComponent.java (original)
+++ incubator/lcf/integration/solr-4.x/trunk/mcf/src/java/org/apache/solr/mcf/ManifoldCFSearchComponent.java Tue Dec 20 12:13:32 2011
@@ -28,6 +28,7 @@ import org.apache.solr.handler.component
 import org.apache.solr.handler.component.SearchComponent;
 import org.apache.commons.httpclient.*;
 import org.apache.commons.httpclient.methods.*;
+import org.apache.commons.httpclient.params.*;
 import org.slf4j.*;
 
 import java.io.*;
@@ -65,10 +66,26 @@ public class ManifoldCFSearchComponent e
   String fieldAllowShare = null;
   String fieldDenyShare = null;
   int socketTimeOut;
+  MultiThreadedHttpConnectionManager httpConnectionManager;
+  HttpClient client;
   
   public ManifoldCFSearchComponent()
   {
     super();
+    HttpConnectionManagerParams params = new HttpConnectionManagerParams();
+    params.setTcpNoDelay(true);
+    params.setStaleCheckingEnabled(false);
+    httpConnectionManager = new MultiThreadedHttpConnectionManager();
+    httpConnectionManager.setParams(params);
+    client = new HttpClient(httpConnectionManager);
+  }
+
+  @Override
+  protected void finalize()
+    throws Throwable
+  {
+    super.finalize();
+    httpConnectionManager.shutdown();
   }
 
   @Override
@@ -254,7 +271,6 @@ public class ManifoldCFSearchComponent e
     throws IOException
   {
     // We can make this more complicated later, with support for https etc., but this is enough to demonstrate how it all should work.
-    HttpClient client = new HttpClient();
     String theURL = authorityBaseURL + "/UserACLs?username="+URLEncoder.encode(authenticatedUserName,"utf-8");
       
     GetMethod method = new GetMethod(theURL);
@@ -271,7 +287,7 @@ public class ManifoldCFSearchComponent e
       InputStream is = method.getResponseBodyAsStream();
       try
       {
-        Reader r = new InputStreamReader(is,"utf-8");
+        Reader r = new InputStreamReader(is,method.getResponseCharSet());
         try
         {
           BufferedReader br = new BufferedReader(r);