@@ -1693,11 +1693,12 @@ private[spark] object Utils extends Logging {
16931693 * Default maximum number of retries when binding to a port before giving up.
16941694 */
16951695 def portMaxRetries (conf : SparkConf ): Int = {
1696- if (sys.props.contains(" spark.testing" )) {
1696+ val maxRetries = conf.getOption(" spark.port.maxRetries" ).map(_.toInt)
1697+ if (conf.contains(" spark.testing" )) {
16971698 // Set a higher number of retries for tests...
1698- sys.props.get( " spark.port. maxRetries" ).map(_.toInt) .getOrElse(100 )
1699+ maxRetries.getOrElse(100 )
16991700 } else {
1700- conf.getOption( " spark.port. maxRetries" ).map(_.toInt) .getOrElse(16 )
1701+ maxRetries.getOrElse(16 )
17011702 }
17021703 }
17031704
@@ -1708,18 +1709,16 @@ private[spark] object Utils extends Logging {
17081709 * @param startPort The initial port to start the service on.
17091710 * @param startService Function to start service on a given port.
17101711 * This is expected to throw java.net.BindException on port collision.
1711- * @param conf Used to get maximum number of retries.
1712+ * @param conf A SparkConf used to get the maximum number of retries when binding to a port .
17121713 * @param serviceName Name of the service.
17131714 */
17141715 def startServiceOnPort [T ](
17151716 startPort : Int ,
17161717 startService : Int => (T , Int ),
17171718 conf : SparkConf ,
1718- serviceName : String = " "
1719- ): (T , Int ) = {
1719+ serviceName : String = " " ): (T , Int ) = {
17201720 val serviceString = if (serviceName.isEmpty) " " else s " ' $serviceName' "
17211721 val maxRetries = portMaxRetries(conf)
1722- logInfo(s " Starting service $serviceString on port $startPort with maximum $maxRetries retries. " )
17231722 for (offset <- 0 to maxRetries) {
17241723 // Do not increment port if startPort is 0, which is treated as a special port
17251724 val tryPort = if (startPort == 0 ) {
0 commit comments