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 2018/11/15 08:45:27 UTC

svn commit: r1846627 - in /manifoldcf/trunk: CHANGES.txt connectors/tikaservice/connector/src/main/java/org/apache/manifoldcf/agents/transformation/tikaservice/TikaExtractor.java

Author: kwright
Date: Thu Nov 15 08:45:27 2018
New Revision: 1846627

URL: http://svn.apache.org/viewvc?rev=1846627&view=rev
Log:
Fix for CONNECTORS-1556.

Modified:
    manifoldcf/trunk/CHANGES.txt
    manifoldcf/trunk/connectors/tikaservice/connector/src/main/java/org/apache/manifoldcf/agents/transformation/tikaservice/TikaExtractor.java

Modified: manifoldcf/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/CHANGES.txt?rev=1846627&r1=1846626&r2=1846627&view=diff
==============================================================================
--- manifoldcf/trunk/CHANGES.txt (original)
+++ manifoldcf/trunk/CHANGES.txt Thu Nov 15 08:45:27 2018
@@ -3,6 +3,9 @@ $Id$
 
 ======================= 2.12-dev =====================
 
+CONNECTORS-1556: Modify retry strategy for Tika Service connector.
+(Karl Wright)
+
 CONNECTORS-1542:  Add switch to let user select the Version Policy to be applied to ingested documents
 (Piergiorgio Lucidi)
 

Modified: manifoldcf/trunk/connectors/tikaservice/connector/src/main/java/org/apache/manifoldcf/agents/transformation/tikaservice/TikaExtractor.java
URL: http://svn.apache.org/viewvc/manifoldcf/trunk/connectors/tikaservice/connector/src/main/java/org/apache/manifoldcf/agents/transformation/tikaservice/TikaExtractor.java?rev=1846627&r1=1846626&r2=1846627&view=diff
==============================================================================
--- manifoldcf/trunk/connectors/tikaservice/connector/src/main/java/org/apache/manifoldcf/agents/transformation/tikaservice/TikaExtractor.java (original)
+++ manifoldcf/trunk/connectors/tikaservice/connector/src/main/java/org/apache/manifoldcf/agents/transformation/tikaservice/TikaExtractor.java Thu Nov 15 08:45:27 2018
@@ -608,13 +608,13 @@ public class TikaExtractor extends org.a
               response = this.httpClient.execute(tikaHost, httpPut);
               //System.out.println("PUT successful");
             } catch (IOException e) {
-              // Retry 3 times, 10000 ms between retries, and abort if doesn't work
+              // Retry for 10 minutes, 10000 ms between retries, and abort if doesn't work
               final long currentTime = System.currentTimeMillis();
               throw new ServiceInterruption("Tika down, retrying: "+e.getMessage(),e,currentTime + 10000L,
-                -1L,3,true);
+                currentTime + 60000L * 10L,-1,true);
             }
             int responseCode = response.getStatusLine().getStatusCode();
-            if (response.getStatusLine().getStatusCode() == 200 || response.getStatusLine().getStatusCode() == 204) {
+            if (responseCode == 200 || responseCode == 204) {
               tikaServerIs = response.getEntity().getContent();
               try {
                 final BufferedReader br = new BufferedReader(new InputStreamReader(tikaServerIs, java.nio.charset.StandardCharsets.UTF_8));
@@ -640,6 +640,12 @@ public class TikaExtractor extends org.a
               } finally {
                 tikaServerIs.close();
               }
+            } else if (responseCode == 503) {
+              // Service interruption; Tika trying to come up.
+              // Retry for 10 minutes, 10000 ms between retries, and abort if doesn't work
+              final long currentTime = System.currentTimeMillis();
+              throw new ServiceInterruption("Tika restarting, retrying",null,currentTime + 10000L,
+                currentTime + 60000L * 10L,-1,true);
             } else {
               activities.noDocument();
               if (responseCode == 422) {
@@ -669,14 +675,14 @@ public class TikaExtractor extends org.a
               response = this.httpClient.execute(tikaHost, httpPut);
               //System.out.println("... content PUT succeeded");
             } catch (IOException e) {
-              // Retry 3 times, 10000 ms between retries, and abort if doesn't work
+              // Retry for 10 minutes, 10000 ms between retries, and abort if doesn't work
               final long currentTime = System.currentTimeMillis();
               throw new ServiceInterruption("Tika down, retrying: "+e.getMessage(),e,currentTime + 10000L,
-                -1L,3,true);
+                currentTime + 60000L * 10L,-1,true);
             }
 
             responseCode = response.getStatusLine().getStatusCode();
-            if (response.getStatusLine().getStatusCode() == 200 || response.getStatusLine().getStatusCode() == 204) {
+            if (responseCode == 200 || responseCode == 204) {
               tikaServerIs = response.getEntity().getContent();
               try {
                 responseDs = new FileDestinationStorage();
@@ -690,6 +696,12 @@ public class TikaExtractor extends org.a
               } finally {
                 tikaServerIs.close();
               }
+            } else if (responseCode == 503) {
+              // Service interruption; Tika trying to come up.
+              // Retry for 10 minutes, 10000 ms between retries, and abort if doesn't work
+              final long currentTime = System.currentTimeMillis();
+              throw new ServiceInterruption("Tika restarting, retrying",null,currentTime + 10000L,
+                currentTime + 60000L * 10L,-1,true);
             } else {
               activities.noDocument();
               if (responseCode == 422) {