Revision: 14738
          http://gate.svn.sourceforge.net/gate/?rev=14738&view=rev
Author:   valyt
Date:     2011-12-12 14:26:59 +0000 (Mon, 12 Dec 2011)
Log Message:
-----------
The background thread now tries remote connections 10 times before reporting an 
error; and gives up after that.

Modified Paths:
--------------
    mimir/trunk/mimir-client/src/gate/mimir/search/RemoteQueryRunner.java

Modified: mimir/trunk/mimir-client/src/gate/mimir/search/RemoteQueryRunner.java
===================================================================
--- mimir/trunk/mimir-client/src/gate/mimir/search/RemoteQueryRunner.java       
2011-12-12 12:41:18 UTC (rev 14737)
+++ mimir/trunk/mimir-client/src/gate/mimir/search/RemoteQueryRunner.java       
2011-12-12 14:26:59 UTC (rev 14738)
@@ -71,6 +71,7 @@
   protected class DocumentDataUpdater implements Runnable {
     @Override
     public void run() {
+      int failuresAllowed = 10;
       // wait for the first pass to complete
       while(documentsCount < 0) {
         if(closed) return;
@@ -110,11 +111,33 @@
             documentsCount = newDocumentsCount;
           }
         } catch(IOException e) {
-          exceptionInBackgroundThread = e;
-          logger.error("Exception while obtaining remote document data", e);
+          if(failuresAllowed > 0) {
+            failuresAllowed --;
+            logger.error("Exception while obtaining remote document data (will 
retry)", e);
+            try {
+              Thread.sleep(100);
+            } catch(InterruptedException e1) {
+              Thread.currentThread().interrupt();
+            }
+          } else {
+            logger.error("Exception while obtaining remote document data.", e);
+            exceptionInBackgroundThread = e;
+            return;
+          }
         } catch(ClassNotFoundException e) {
-          exceptionInBackgroundThread = e;
-          logger.error("Exception while obtaining remote document data", e);
+          if(failuresAllowed > 0) {
+            failuresAllowed --;
+            logger.error("Exception while obtaining remote document data (will 
retry)", e);
+            try {
+              Thread.sleep(100);
+            } catch(InterruptedException e1) {
+              Thread.currentThread().interrupt();
+            }
+          } else {
+            logger.error("Exception while obtaining remote document data.", e);
+            exceptionInBackgroundThread = e;
+            return;
+          }
         } catch(InterruptedException e) {
           Thread.currentThread().interrupt();
           logger.warn("Interrupted while waiting", e);
@@ -220,7 +243,7 @@
       Exception e = exceptionInBackgroundThread;
       exceptionInBackgroundThread = null;
       throw (IOException)new IOException(
-          "Problem communicating with the remote index").initCause(e);
+          "Problem communicating with the remote index", e);
     }
     
     //an example URL looks like this:

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Learn Windows Azure Live!  Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for 
developers. It will provide a great way to learn Windows Azure and what it 
provides. You can attend the event by watching it streamed LIVE online.  
Learn more at http://p.sf.net/sfu/ms-windowsazure
_______________________________________________
GATE-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gate-cvs

Reply via email to