Author: kwright
Date: Wed Jan 29 16:15:27 2014
New Revision: 1562494

URL: http://svn.apache.org/r1562494
Log:
Fix for CONNECTORS-873.

Modified:
    manifoldcf/trunk/build.xml
    manifoldcf/trunk/connectors/solr/build.xml
    manifoldcf/trunk/connectors/solr/pom.xml
    
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/Throttler.java
    manifoldcf/trunk/pom.xml

Modified: manifoldcf/trunk/build.xml
URL: 
http://svn.apache.org/viewvc/manifoldcf/trunk/build.xml?rev=1562494&r1=1562493&r2=1562494&view=diff
==============================================================================
--- manifoldcf/trunk/build.xml (original)
+++ manifoldcf/trunk/build.xml Wed Jan 29 16:15:27 2014
@@ -4286,8 +4286,15 @@ Use Apache Forrest version forrest-0.9-d
             <param name="artifact-name" value="solr-solrj"/>
             <param name="artifact-type" value="jar"/>
         </antcall>
+        <antcall target="download-via-maven">
+            <param name="target" value="lib"/>
+            <param name="project-path" value="org/noggit"/>
+            <param name="artifact-version" value="0.5"/>
+            <param name="artifact-name" value="noggit"/>
+            <param name="artifact-type" value="jar"/>
+        </antcall>
     </target>
-    
+
     <target name="download-zookeeper">
         <mkdir dir="lib"/>
         <antcall target="download-via-maven">

Modified: manifoldcf/trunk/connectors/solr/build.xml
URL: 
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/solr/build.xml?rev=1562494&r1=1562493&r2=1562494&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/solr/build.xml (original)
+++ manifoldcf/trunk/connectors/solr/build.xml Wed Jan 29 16:15:27 2014
@@ -23,6 +23,7 @@
         <path refid="mcf-connector-build.connector-classpath"/>
         <fileset dir="../../lib">
             <include name="solr-solrj*.jar"/>
+            <include name="noggit*.jar"/>
             <include name="httpmime*.jar"/>
             <include name="wstx-asl*.jar"/>
             <include name="jcl-over-slf4j*.jar"/>
@@ -34,6 +35,7 @@
         <copy todir="dist/lib">
             <fileset dir="../../lib">
                 <include name="solr-solrj*.jar"/>
+                <include name="noggit*.jar"/>
                 <include name="httpmime*.jar"/>
                 <include name="wstx-asl*.jar"/>
                 <include name="jcl-over-slf4j*.jar"/>

Modified: manifoldcf/trunk/connectors/solr/pom.xml
URL: 
http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/solr/pom.xml?rev=1562494&r1=1562493&r2=1562494&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/solr/pom.xml (original)
+++ manifoldcf/trunk/connectors/solr/pom.xml Wed Jan 29 16:15:27 2014
@@ -92,6 +92,11 @@
       <version>${solr.version}</version>
     </dependency>
     <dependency>
+      <groupId>org.noggit</groupId>
+      <artifactId>noggit</artifactId>
+      <version>${noggit.version}</version>
+    </dependency>
+    <dependency>
       <groupId>org.apache.zookeeper</groupId>
       <artifactId>zookeeper</artifactId>
       <version>${zookeeper.version}</version>

Modified: 
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/Throttler.java
URL: 
http://svn.apache.org/viewvc/manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/Throttler.java?rev=1562494&r1=1562493&r2=1562494&view=diff
==============================================================================
--- 
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/Throttler.java
 (original)
+++ 
manifoldcf/trunk/framework/core/src/main/java/org/apache/manifoldcf/core/throttler/Throttler.java
 Wed Jan 29 16:15:27 2014
@@ -453,9 +453,33 @@ public class Throttler
           if (bin != null)
           {
             // Reserve a slot
-            int result = bin.waitConnectionAvailable(poolCount);
-            if (result == IConnectionThrottler.CONNECTION_FROM_NOWHERE ||
-              (currentRecommendation != 
IConnectionThrottler.CONNECTION_FROM_NOWHERE && currentRecommendation != 
result))
+            int result;
+            try
+            {
+              result = bin.waitConnectionAvailable(poolCount);
+            }
+            catch (Throwable e)
+            {
+              while (i > 0)
+              {
+                i--;
+                binName = binNames[i];
+                synchronized (connectionBins)
+                {
+                  bin = connectionBins.get(binName);
+                }
+                if (bin != null)
+                  bin.undoReservation(currentRecommendation, poolCount);
+              }
+              if (e instanceof InterruptedException)
+                throw (InterruptedException)e;
+              if (e instanceof Error)
+                throw (Error)e;
+              if (e instanceof RuntimeException)
+                throw (RuntimeException)e;
+              throw new RuntimeException("Unexpected exception of type 
'"+e.getClass().getName()+"': "+e.getMessage(),e);
+            }
+            if (result == IConnectionThrottler.CONNECTION_FROM_NOWHERE)
             {
               // Release previous reservations, and either return, or retry
               while (i > 0)
@@ -469,12 +493,30 @@ public class Throttler
                 if (bin != null)
                   bin.undoReservation(currentRecommendation, poolCount);
               }
-              if (result == IConnectionThrottler.CONNECTION_FROM_NOWHERE)
-                return result;
+              return result;
+            }
+
+            if (currentRecommendation != 
IConnectionThrottler.CONNECTION_FROM_NOWHERE && currentRecommendation != result)
+            {
+              // Release all previous reservations, including this one, and 
either return, or retry
+              bin.undoReservation(result, poolCount);
+              while (i > 0)
+              {
+                i--;
+                binName = binNames[i];
+                synchronized (connectionBins)
+                {
+                  bin = connectionBins.get(binName);
+                }
+                if (bin != null)
+                  bin.undoReservation(currentRecommendation, poolCount);
+              }
+
               // Break out of the outer loop so we can retry
               retry = true;
               break;
             }
+
             if (currentRecommendation == 
IConnectionThrottler.CONNECTION_FROM_NOWHERE)
               currentRecommendation = result;
           }

Modified: manifoldcf/trunk/pom.xml
URL: 
http://svn.apache.org/viewvc/manifoldcf/trunk/pom.xml?rev=1562494&r1=1562493&r2=1562494&view=diff
==============================================================================
--- manifoldcf/trunk/pom.xml (original)
+++ manifoldcf/trunk/pom.xml Wed Jan 29 16:15:27 2014
@@ -52,6 +52,7 @@
     <httpcomponent.httpcore.version>4.2.5</httpcomponent.httpcore.version>
     <httpcomponent.httpmime.version>4.2.6</httpcomponent.httpmime.version>
     <solr.version>4.6.0</solr.version>
+    <noggit.version>0.5</noggit.version>
     <commons-el.version>1.0</commons-el.version>
     <commons-lang.version>2.6</commons-lang.version>
     <xalan.version>2.7.1</xalan.version>


Reply via email to