aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/scala/org
diff options
context:
space:
mode:
authorLiang-Chi Hsieh <viirya@gmail.com>2017-02-20 21:25:21 -0800
committerSean Owen <sowen@cloudera.com>2017-02-20 21:25:21 -0800
commit33941914548cc5a65e8467821745d65728176368 (patch)
treea6dca58c72889e0e44b7c8fa5410a23978eb3759 /core/src/main/scala/org
parent73f065569d352081b7d64c254af70ce996860c53 (diff)
downloadspark-33941914548cc5a65e8467821745d65728176368.tar.gz
spark-33941914548cc5a65e8467821745d65728176368.tar.bz2
spark-33941914548cc5a65e8467821745d65728176368.zip
[SPARK-19508][CORE] Improve error message when binding service fails
## What changes were proposed in this pull request? Utils provides a helper function to bind service on port. This function can bind the service to a random free port. However, if the binding fails on a random free port, the retrying and final exception messages look confusing. 17/02/06 16:25:43 WARN Utils: Service 'sparkDriver' could not bind on port 0. Attempting port 1. 17/02/06 16:25:43 WARN Utils: Service 'sparkDriver' could not bind on port 0. Attempting port 1. 17/02/06 16:25:43 WARN Utils: Service 'sparkDriver' could not bind on port 0. Attempting port 1. 17/02/06 16:25:43 WARN Utils: Service 'sparkDriver' could not bind on port 0. Attempting port 1. 17/02/06 16:25:43 WARN Utils: Service 'sparkDriver' could not bind on port 0. Attempting port 1. ... 17/02/06 16:25:43 ERROR SparkContext: Error initializing SparkContext. java.net.BindException: Can't assign requested address: Service 'sparkDriver' failed after 16 retries (starting from 0)! Consider explicitly setting the appropriate port for the service 'sparkDriver' (for example spark.ui.port for SparkUI) to an available port or increasing spark.port.maxRetries. ## How was this patch tested? Jenkins tests. Please review http://spark.apache.org/contributing.html before opening a pull request. Author: Liang-Chi Hsieh <viirya@gmail.com> Closes #16851 from viirya/better-log-message.
Diffstat (limited to 'core/src/main/scala/org')
-rw-r--r--core/src/main/scala/org/apache/spark/util/Utils.scala27
1 files changed, 21 insertions, 6 deletions
diff --git a/core/src/main/scala/org/apache/spark/util/Utils.scala b/core/src/main/scala/org/apache/spark/util/Utils.scala
index 1e6e9a223e..55382899a3 100644
--- a/core/src/main/scala/org/apache/spark/util/Utils.scala
+++ b/core/src/main/scala/org/apache/spark/util/Utils.scala
@@ -2210,17 +2210,32 @@ private[spark] object Utils extends Logging {
} catch {
case e: Exception if isBindCollision(e) =>
if (offset >= maxRetries) {
- val exceptionMessage = s"${e.getMessage}: Service$serviceString failed after " +
- s"$maxRetries retries (starting from $startPort)! Consider explicitly setting " +
- s"the appropriate port for the service$serviceString (for example spark.ui.port " +
- s"for SparkUI) to an available port or increasing spark.port.maxRetries."
+ val exceptionMessage = if (startPort == 0) {
+ s"${e.getMessage}: Service$serviceString failed after " +
+ s"$maxRetries retries (on a random free port)! " +
+ s"Consider explicitly setting the appropriate binding address for " +
+ s"the service$serviceString (for example spark.driver.bindAddress " +
+ s"for SparkDriver) to the correct binding address."
+ } else {
+ s"${e.getMessage}: Service$serviceString failed after " +
+ s"$maxRetries retries (starting from $startPort)! Consider explicitly setting " +
+ s"the appropriate port for the service$serviceString (for example spark.ui.port " +
+ s"for SparkUI) to an available port or increasing spark.port.maxRetries."
+ }
val exception = new BindException(exceptionMessage)
// restore original stack trace
exception.setStackTrace(e.getStackTrace)
throw exception
}
- logWarning(s"Service$serviceString could not bind on port $tryPort. " +
- s"Attempting port ${tryPort + 1}.")
+ if (startPort == 0) {
+ // As startPort 0 is for a random free port, it is most possibly binding address is
+ // not correct.
+ logWarning(s"Service$serviceString could not bind on a random free port. " +
+ "You may check whether configuring an appropriate binding address.")
+ } else {
+ logWarning(s"Service$serviceString could not bind on port $tryPort. " +
+ s"Attempting port ${tryPort + 1}.")
+ }
}
}
// Should never happen