You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucene.apache.org by ma...@apache.org on 2020/09/09 01:27:05 UTC

[lucene-solr] 02/02: @813 Tweaking for tests.

This is an automated email from the ASF dual-hosted git repository.

markrmiller pushed a commit to branch reference_impl_dev
in repository https://gitbox.apache.org/repos/asf/lucene-solr.git

commit 1dcb87f55fcb6f15b63817601ca4f219fd46b13e
Author: markrmiller@gmail.com <ma...@gmail.com>
AuthorDate: Tue Sep 8 20:25:13 2020 -0500

    @813 Tweaking for tests.
---
 .../client/solrj/embedded/JettySolrRunner.java     | 38 +++++++++++++++++-----
 .../solr/common/util/SolrQueuedThreadPool.java     |  2 +-
 .../client/solrj/impl/CloudSolrClientTest.java     |  8 +++++
 3 files changed, 39 insertions(+), 9 deletions(-)

diff --git a/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java b/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
index 124bcfa..df0cff9 100644
--- a/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
+++ b/solr/core/src/java/org/apache/solr/client/solrj/embedded/JettySolrRunner.java
@@ -29,11 +29,13 @@ import org.apache.solr.common.cloud.ZkStateReader;
 import org.apache.solr.common.util.ObjectReleaseTracker;
 import org.apache.solr.common.util.SolrQueuedThreadPool;
 import org.apache.solr.common.util.SolrScheduledExecutorScheduler;
+import org.apache.solr.common.util.TimeSource;
 import org.apache.solr.core.CloudConfig;
 import org.apache.solr.core.CoreContainer;
 import org.apache.solr.core.NodeConfig;
 import org.apache.solr.servlet.SolrDispatchFilter;
 import org.apache.solr.servlet.SolrQoSFilter;
+import org.apache.solr.util.TimeOut;
 import org.apache.zookeeper.KeeperException;
 import org.apache.zookeeper.WatchedEvent;
 import org.apache.zookeeper.Watcher;
@@ -550,15 +552,14 @@ public class JettySolrRunner implements Closeable {
       } else {
         startedBefore = true;
       }
-
+      boolean success = false;
       if (!server.isRunning()) {
-      //  if (config.portRetryTime > 0) {
-     //     retryOnPortBindFailure(config.portRetryTime, port);
-     //   } else {
+        if (config.portRetryTime > 0) {
+          retryOnPortBindFailure(port);
+        } else {
           server.start();
-          boolean success = startLatch.await(15, TimeUnit.SECONDS);
-     //   }
-
+        }
+        success = startLatch.await(15, TimeUnit.SECONDS);
         if (!success) {
           throw new RuntimeException("Timeout waiting for Jetty to start");
         }
@@ -600,7 +601,7 @@ public class JettySolrRunner implements Closeable {
           if (stat == null) {
             log.info("Collections znode not found, waiting on latch");
             try {
-              boolean success = latch.await(10000, TimeUnit.MILLISECONDS);
+              success = latch.await(10000, TimeUnit.MILLISECONDS);
               if (!success) {
                 log.warn("Timedout waiting to see {} node in zk", ZkStateReader.COLLECTIONS_ZKNODE);
               }
@@ -637,6 +638,27 @@ public class JettySolrRunner implements Closeable {
     }
   }
 
+  private void retryOnPortBindFailure(int port) throws Exception {
+    int tryCnt = 1;
+    while (tryCnt < 3) {
+      try {
+        log.info("Trying to start Jetty on port {} try number {} ...", port, tryCnt);
+        server.start();
+        break;
+      } catch (IOException ioe) {
+        Exception e = lookForBindException(ioe);
+        if (e instanceof BindException) {
+          log.info("Port is in use, will try again");
+          server.stop();
+
+          tryCnt++;
+          continue;
+        }
+
+        throw e;
+      }
+    }
+  }
 
   private void setProtocolAndHost() {
     String protocol = null;
diff --git a/solr/solrj/src/java/org/apache/solr/common/util/SolrQueuedThreadPool.java b/solr/solrj/src/java/org/apache/solr/common/util/SolrQueuedThreadPool.java
index 492227c..113196f 100644
--- a/solr/solrj/src/java/org/apache/solr/common/util/SolrQueuedThreadPool.java
+++ b/solr/solrj/src/java/org/apache/solr/common/util/SolrQueuedThreadPool.java
@@ -89,7 +89,7 @@ public class SolrQueuedThreadPool extends ContainerLifeCycle implements ThreadFa
 
     public SolrQueuedThreadPool(String name) {
         this(Integer.MAX_VALUE, 12,
-                60000, 0, // no reserved executor threads - we can process requests after shutdown or some race - we try to limit without threadpool limits no anyway
+                60000, -1, // no reserved executor threads - we can process requests after shutdown or some race - we try to limit without threadpool limits no anyway
                 null, null,
                 new  SolrNamedThreadFactory(name));
         this.name = name;
diff --git a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
index 23b7591..4186d4c 100644
--- a/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
+++ b/solr/solrj/src/test/org/apache/solr/client/solrj/impl/CloudSolrClientTest.java
@@ -106,6 +106,14 @@ public class CloudSolrClientTest extends SolrCloudTestCase {
 
   @BeforeClass
   public static void setupCluster() throws Exception {
+    System.setProperty("distribUpdateSoTimeout", "3000");
+    System.setProperty("socketTimeout", "3000");
+    System.setProperty("connTimeout", "3000");
+    System.setProperty("solr.test.socketTimeout.default", "3000");
+    System.setProperty("solr.connect_timeout.default", "3000");
+    System.setProperty("solr.httpclient.defaultConnectTimeout", "3000");
+    System.setProperty("solr.httpclient.defaultSoTimeout", "3000");
+
     configureCluster(NODE_COUNT)
         .addConfig(TEST_CONFIGSET_NAME, getFile("solrj").toPath().resolve("solr").resolve("configsets").resolve("streaming").resolve("conf"))
         .configure();