lucene-solr-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From markrmil...@apache.org
Subject svn commit: r903400 - in /lucene/solr/branches/cloud/src/java/org/apache/solr/cloud: ConnectionManager.java SolrZkClient.java
Date Tue, 26 Jan 2010 20:21:54 GMT
Author: markrmiller
Date: Tue Jan 26 20:21:47 2010
New Revision: 903400

URL: http://svn.apache.org/viewvc?rev=903400&view=rev
Log:
add configurable client connect timeout, throw and log exception when interrupted during close

Modified:
    lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ConnectionManager.java
    lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/SolrZkClient.java

Modified: lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ConnectionManager.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ConnectionManager.java?rev=903400&r1=903399&r2=903400&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ConnectionManager.java (original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/ConnectionManager.java Tue Jan
26 20:21:47 2010
@@ -86,7 +86,7 @@
         connectionStrategy.reconnect(zkServerAddress, zkClientTimeout, this, new ZkClientConnectionStrategy.ZkUpdate()
{
           @Override
           public void update(ZooKeeper keeper) throws InterruptedException, TimeoutException,
IOException {
-           waitForConnected(SolrZkClient.CONNECT_TIMEOUT);
+           waitForConnected(SolrZkClient.DEFAULT_CLIENT_CONNECT_TIMEOUT);
            client.updateKeeper(keeper);
            if(onReconnect != null) {
              onReconnect.command();

Modified: lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/SolrZkClient.java
URL: http://svn.apache.org/viewvc/lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/SolrZkClient.java?rev=903400&r1=903399&r2=903400&view=diff
==============================================================================
--- lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/SolrZkClient.java (original)
+++ lucene/solr/branches/cloud/src/java/org/apache/solr/cloud/SolrZkClient.java Tue Jan 26
20:21:47 2010
@@ -25,6 +25,7 @@
 
 import org.apache.commons.io.FileUtils;
 import org.apache.solr.cloud.ZkClientConnectionStrategy.ZkUpdate;
+import org.apache.solr.common.SolrException;
 import org.apache.zookeeper.CreateMode;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.Watcher;
@@ -50,7 +51,7 @@
     public void command();
   }
 
-  static final int CONNECT_TIMEOUT = 5000;
+  static final int DEFAULT_CLIENT_CONNECT_TIMEOUT = 5000;
 
   private static final Logger log = LoggerFactory
       .getLogger(SolrZkClient.class);
@@ -80,6 +81,8 @@
    * @param zkServerAddress
    * @param zkClientTimeout
    * @param strat
+   * @param onReconnect
+   * @param clientConnectTimeout
    * @throws InterruptedException
    * @throws TimeoutException
    * @throws IOException
@@ -87,6 +90,22 @@
   public SolrZkClient(String zkServerAddress, int zkClientTimeout,
       ZkClientConnectionStrategy strat, final OnReconnect onReconnect) throws InterruptedException,
       TimeoutException, IOException {
+    this(zkServerAddress, zkClientTimeout, strat, onReconnect, DEFAULT_CLIENT_CONNECT_TIMEOUT);
+  }
+
+  /**
+   * @param zkServerAddress
+   * @param zkClientTimeout
+   * @param strat
+   * @param onReconnect
+   * @param clientConnectTimeout
+   * @throws InterruptedException
+   * @throws TimeoutException
+   * @throws IOException
+   */
+  public SolrZkClient(String zkServerAddress, int zkClientTimeout,
+      ZkClientConnectionStrategy strat, final OnReconnect onReconnect, int clientConnectTimeout)
throws InterruptedException,
+      TimeoutException, IOException {
     connManager = new ConnectionManager("ZooKeeperConnection Watcher:"
         + zkServerAddress, this, zkServerAddress, zkClientTimeout, strat, onReconnect);
     strat.connect(zkServerAddress, zkClientTimeout, connManager,
@@ -97,13 +116,17 @@
               try {
                 keeper.close();
               } catch (InterruptedException e) {
-                // nocommit
+                // Restore the interrupted status
+                Thread.currentThread().interrupt();
+                log.error("", e);
+                throw new ZooKeeperException(SolrException.ErrorCode.SERVER_ERROR,
+                    "", e);
               }
             }
             keeper = zooKeeper;
           }
         });
-    connManager.waitForConnected(CONNECT_TIMEOUT);
+    connManager.waitForConnected(clientConnectTimeout);
   }
 
   /**
@@ -402,6 +425,7 @@
           string.append(dent + "DATA: ...supressed..." + NEWL);
         }
       } catch (UnsupportedEncodingException e) {
+        // can't happen - UTF-8
         throw new RuntimeException(e);
       }
     }



Mime
View raw message