aboutsummaryrefslogtreecommitdiff
path: root/launcher/src/main
diff options
context:
space:
mode:
authorMarcelo Vanzin <vanzin@cloudera.com>2015-10-15 14:46:40 -0700
committerAndrew Or <andrew@databricks.com>2015-10-15 14:46:40 -0700
commita5719804c5ed99ce36bd0dd230ab8b3b7a3b92e3 (patch)
tree8119ec12ffda38284ebd4ed384fc2fc46c4c2fa9 /launcher/src/main
parentb591de7c07ba8e71092f71e34001520bec995a8a (diff)
downloadspark-a5719804c5ed99ce36bd0dd230ab8b3b7a3b92e3.tar.gz
spark-a5719804c5ed99ce36bd0dd230ab8b3b7a3b92e3.tar.bz2
spark-a5719804c5ed99ce36bd0dd230ab8b3b7a3b92e3.zip
[SPARK-11071] [LAUNCHER] Fix flakiness in LauncherServerSuite::timeout.
The test could fail depending on scheduling of the various threads involved; the change removes some sources of races, while making the test a little more resilient by trying a few times before giving up. Author: Marcelo Vanzin <vanzin@cloudera.com> Closes #9079 from vanzin/SPARK-11071.
Diffstat (limited to 'launcher/src/main')
-rw-r--r--launcher/src/main/java/org/apache/spark/launcher/LauncherServer.java9
1 files changed, 8 insertions, 1 deletions
diff --git a/launcher/src/main/java/org/apache/spark/launcher/LauncherServer.java b/launcher/src/main/java/org/apache/spark/launcher/LauncherServer.java
index c5fd40816d..d099ee9aa9 100644
--- a/launcher/src/main/java/org/apache/spark/launcher/LauncherServer.java
+++ b/launcher/src/main/java/org/apache/spark/launcher/LauncherServer.java
@@ -242,7 +242,14 @@ class LauncherServer implements Closeable {
synchronized (clients) {
clients.add(clientConnection);
}
- timeoutTimer.schedule(timeout, getConnectionTimeout());
+ long timeoutMs = getConnectionTimeout();
+ // 0 is used for testing to avoid issues with clock resolution / thread scheduling,
+ // and force an immediate timeout.
+ if (timeoutMs > 0) {
+ timeoutTimer.schedule(timeout, getConnectionTimeout());
+ } else {
+ timeout.run();
+ }
}
}
} catch (IOException ioe) {