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 2014/01/30 12:01:01 UTC

svn commit: r1562775 - in /manifoldcf/trunk: CHANGES.txt connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/HttpPoster.java

Author: kwright
Date: Thu Jan 30 11:01:00 2014
New Revision: 1562775

URL: http://svn.apache.org/r1562775
Log:
Fix for CONNECTORS-874.

Modified:
    manifoldcf/trunk/CHANGES.txt
    manifoldcf/trunk/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/HttpPoster.java

Modified: manifoldcf/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/CHANGES.txt?rev=1562775&r1=1562774&r2=1562775&view=diff
==============================================================================
--- manifoldcf/trunk/CHANGES.txt (original)
+++ manifoldcf/trunk/CHANGES.txt Thu Jan 30 11:01:00 2014
@@ -18,6 +18,10 @@ a pair of partial fixes.)
 
 ======================= Release 1.5 =====================
 
+CONNECTORS-874: Uncaught runtime exception when SolrJ can't talk
+to zookeeper.
+(Karl Wright)
+
 CONNECTORS-872: Throttling hang for web connector, as well as web
 connector not obeying rate throttling.
 (Erlend Garåsen, Karl Wright)

Modified: manifoldcf/trunk/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/HttpPoster.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/HttpPoster.java?rev=1562775&r1=1562774&r2=1562775&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/HttpPoster.java (original)
+++ manifoldcf/trunk/connectors/solr/connector/src/main/java/org/apache/manifoldcf/agents/output/solr/HttpPoster.java Thu Jan 30 11:01:00 2014
@@ -290,20 +290,7 @@ public class HttpPoster
       try
       {
         t.start();
-        t.join();
-
-        Throwable thr = t.getException();
-        if (thr != null)
-        {
-          if (thr instanceof SolrServerException)
-            throw (SolrServerException)thr;
-          if (thr instanceof IOException)
-            throw (IOException)thr;
-          if (thr instanceof RuntimeException)
-            throw (RuntimeException)thr;
-          else
-            throw (Error)thr;
-        }
+        t.finishUp();
         return;
       }
       catch (InterruptedException e)
@@ -322,6 +309,11 @@ public class HttpPoster
       handleSolrException(e, "commit");
       return;
     }
+    catch (RuntimeException e)
+    {
+      handleRuntimeException(e, "commit");
+      return;
+    }
     catch (IOException ioe)
     {
       handleIOException(ioe, "commit");
@@ -329,6 +321,27 @@ public class HttpPoster
     }
   }
   
+  /** Handle a RuntimeException.
+  * Unfortunately, SolrCloud 4.6.x throws RuntimeExceptions whenever ZooKeeper is not happy.
+  * We have to catch these too.  I've logged a ticket: SOLR-5678.
+  */
+  protected static void handleRuntimeException(RuntimeException e, String context)
+    throws ManifoldCFException, ServiceInterruption
+  {
+    Throwable childException = e.getCause();
+    if (childException != null && childException instanceof java.util.concurrent.TimeoutException)
+    {
+      Logging.ingest.warn("SolrJ runtime exception during "+context+": "+childException.getMessage(),childException);
+      long currentTime = System.currentTimeMillis();
+      throw new ServiceInterruption(childException.getMessage(),childException,
+        currentTime + interruptionRetryTime,
+        currentTime + 2L * 60L * 60000L,
+        -1,
+        true);
+    }
+    throw e;
+  }
+  
   /** Handle a SolrServerException.
   * These exceptions seem to be catch-all exceptions having to do either with misconfiguration or
   * with underlying IO exceptions.
@@ -508,24 +521,8 @@ public class HttpPoster
       try
       {
         t.start();
-        t.join();
+        t.finishUp();
 
-        // Log the activity, if any, regardless of any exception
-        if (t.getActivityCode() != null)
-          activities.recordActivity(t.getActivityStart(),SolrConnector.INGEST_ACTIVITY,t.getActivityBytes(),documentURI,t.getActivityCode(),t.getActivityDetails());
-
-        Throwable thr = t.getException();
-        if (thr != null)
-        {
-          if (thr instanceof SolrServerException)
-            throw (SolrServerException)thr;
-          if (thr instanceof IOException)
-            throw (IOException)thr;
-          if (thr instanceof RuntimeException)
-            throw (RuntimeException)thr;
-          else
-            throw (Error)thr;
-        }
         return t.getRval();
       }
       catch (InterruptedException e)
@@ -533,6 +530,30 @@ public class HttpPoster
         t.interrupt();
         throw new ManifoldCFException("Interrupted: "+e.getMessage(),ManifoldCFException.INTERRUPTED);
       }
+      catch (SolrServerException e)
+      {
+        if (t.getActivityCode() != null)
+          activities.recordActivity(t.getActivityStart(),SolrConnector.INGEST_ACTIVITY,t.getActivityBytes(),documentURI,t.getActivityCode(),t.getActivityDetails());
+        throw e;
+      }
+      catch (SolrException e)
+      {
+        if (t.getActivityCode() != null)
+          activities.recordActivity(t.getActivityStart(),SolrConnector.INGEST_ACTIVITY,t.getActivityBytes(),documentURI,t.getActivityCode(),t.getActivityDetails());
+        throw e;
+      }
+      catch (RuntimeException e)
+      {
+        if (t.getActivityCode() != null)
+          activities.recordActivity(t.getActivityStart(),SolrConnector.INGEST_ACTIVITY,t.getActivityBytes(),documentURI,t.getActivityCode(),t.getActivityDetails());
+        throw e;
+      }
+      catch (IOException e)
+      {
+        if (t.getActivityCode() != null)
+          activities.recordActivity(t.getActivityStart(),SolrConnector.INGEST_ACTIVITY,t.getActivityBytes(),documentURI,t.getActivityCode(),t.getActivityDetails());
+        throw e;
+      }
     }
     catch (SolrServerException e)
     {
@@ -544,6 +565,11 @@ public class HttpPoster
       handleSolrException(e, "indexing");
       return false;
     }
+    catch (RuntimeException e)
+    {
+      handleRuntimeException(e, "indexing");
+      return false;
+    }
     catch (IOException ioe)
     {
       handleIOException(ioe, "indexing");
@@ -567,20 +593,7 @@ public class HttpPoster
       try
       {
         t.start();
-        t.join();
-
-        Throwable thr = t.getException();
-        if (thr != null)
-        {
-          if (thr instanceof SolrServerException)
-            throw (SolrServerException)thr;
-          if (thr instanceof IOException)
-            throw (IOException)thr;
-          if (thr instanceof RuntimeException)
-            throw (RuntimeException)thr;
-          else
-            throw (Error)thr;
-        }
+        t.finishUp();
         return;
       }
       catch (InterruptedException e)
@@ -599,6 +612,11 @@ public class HttpPoster
       handleSolrException(e, "check");
       return;
     }
+    catch (RuntimeException e)
+    {
+      handleRuntimeException(e, "check");
+      return;
+    }
     catch (IOException ioe)
     {
       handleIOException(ioe, "check");
@@ -622,24 +640,7 @@ public class HttpPoster
       try
       {
         t.start();
-        t.join();
-
-        // Log the activity, if any, regardless of any exception
-        if (t.getActivityCode() != null)
-          activities.recordActivity(t.getActivityStart(),SolrConnector.REMOVE_ACTIVITY,null,documentURI,t.getActivityCode(),t.getActivityDetails());
-
-        Throwable thr = t.getException();
-        if (thr != null)
-        {
-          if (thr instanceof SolrServerException)
-            throw (SolrServerException)thr;
-          if (thr instanceof IOException)
-            throw (IOException)thr;
-          if (thr instanceof RuntimeException)
-            throw (RuntimeException)thr;
-          else
-            throw (Error)thr;
-        }
+        t.finishUp();
         return;
       }
       catch (InterruptedException e)
@@ -647,6 +648,30 @@ public class HttpPoster
         t.interrupt();
         throw new ManifoldCFException("Interrupted: "+e.getMessage(),ManifoldCFException.INTERRUPTED);
       }
+      catch (SolrServerException e)
+      {
+        if (t.getActivityCode() != null)
+          activities.recordActivity(t.getActivityStart(),SolrConnector.REMOVE_ACTIVITY,null,documentURI,t.getActivityCode(),t.getActivityDetails());
+        throw e;
+      }
+      catch (SolrException e)
+      {
+        if (t.getActivityCode() != null)
+          activities.recordActivity(t.getActivityStart(),SolrConnector.REMOVE_ACTIVITY,null,documentURI,t.getActivityCode(),t.getActivityDetails());
+        throw e;
+      }
+      catch (RuntimeException e)
+      {
+        if (t.getActivityCode() != null)
+          activities.recordActivity(t.getActivityStart(),SolrConnector.REMOVE_ACTIVITY,null,documentURI,t.getActivityCode(),t.getActivityDetails());
+        throw e;
+      }
+      catch (IOException e)
+      {
+        if (t.getActivityCode() != null)
+          activities.recordActivity(t.getActivityStart(),SolrConnector.REMOVE_ACTIVITY,null,documentURI,t.getActivityCode(),t.getActivityDetails());
+        throw e;
+      }
     }
     catch (SolrServerException e)
     {
@@ -658,6 +683,11 @@ public class HttpPoster
       handleSolrException(e, "delete");
       return;
     }
+    catch (RuntimeException e)
+    {
+      handleRuntimeException(e, "delete");
+      return;
+    }
     catch (IOException ioe)
     {
       handleIOException(ioe, "delete");
@@ -995,9 +1025,25 @@ public class HttpPoster
       }
     }
 
-    public Throwable getException()
+    public void finishUp()
+      throws InterruptedException, SolrServerException, IOException
     {
-      return exception;
+      join();
+
+      Throwable thr = exception;
+      if (thr != null)
+      {
+        if (thr instanceof SolrServerException)
+          throw (SolrServerException)thr;
+        if (thr instanceof IOException)
+          throw (IOException)thr;
+        if (thr instanceof RuntimeException)
+          throw (RuntimeException)thr;
+        if (thr instanceof Error)
+          throw (Error)thr;
+        else
+          throw new RuntimeException("Unexpected exception type: "+thr.getClass().getName()+": "+thr.getMessage(),thr);
+      }
     }
 
     public Long getActivityStart()
@@ -1110,11 +1156,26 @@ public class HttpPoster
       }
     }
 
-    public Throwable getException()
+    public void finishUp()
+      throws InterruptedException, SolrServerException, IOException
     {
-      return exception;
-    }
+      join();
 
+      Throwable thr = exception;
+      if (thr != null)
+      {
+        if (thr instanceof SolrServerException)
+          throw (SolrServerException)thr;
+        if (thr instanceof IOException)
+          throw (IOException)thr;
+        if (thr instanceof RuntimeException)
+          throw (RuntimeException)thr;
+        if (thr instanceof Error)
+          throw (Error)thr;
+        else
+          throw new RuntimeException("Unexpected exception type: "+thr.getClass().getName()+": "+thr.getMessage(),thr);
+      }
+    }
     public Long getActivityStart()
     {
       return activityStart;
@@ -1175,10 +1236,27 @@ public class HttpPoster
       }
     }
 
-    public Throwable getException()
+    public void finishUp()
+      throws InterruptedException, SolrServerException, IOException
     {
-      return exception;
+      join();
+
+      Throwable thr = exception;
+      if (thr != null)
+      {
+        if (thr instanceof SolrServerException)
+          throw (SolrServerException)thr;
+        if (thr instanceof IOException)
+          throw (IOException)thr;
+        if (thr instanceof RuntimeException)
+          throw (RuntimeException)thr;
+        if (thr instanceof Error)
+          throw (Error)thr;
+        else
+          throw new RuntimeException("Unexpected exception type: "+thr.getClass().getName()+": "+thr.getMessage(),thr);
+      }
     }
+
   }
 
 
@@ -1225,10 +1303,27 @@ public class HttpPoster
       }
     }
 
-    public Throwable getException()
+    public void finishUp()
+      throws InterruptedException, SolrServerException, IOException
     {
-      return exception;
+      join();
+
+      Throwable thr = exception;
+      if (thr != null)
+      {
+        if (thr instanceof SolrServerException)
+          throw (SolrServerException)thr;
+        if (thr instanceof IOException)
+          throw (IOException)thr;
+        if (thr instanceof RuntimeException)
+          throw (RuntimeException)thr;
+        if (thr instanceof Error)
+          throw (Error)thr;
+        else
+          throw new RuntimeException("Unexpected exception type: "+thr.getClass().getName()+": "+thr.getMessage(),thr);
+      }
     }
+
   }
 
   /** Class for importing documents into Solr via SolrJ