Github user srowen commented on a diff in the pull request:

    https://github.com/apache/spark/pull/3314#discussion_r20442301
  
    --- Diff: core/src/main/scala/org/apache/spark/util/Utils.scala ---
    @@ -1652,25 +1652,28 @@ private[spark] object Utils extends Logging {
        * Attempt to start a service on the given port, or fail after a number 
of attempts.
        * Each subsequent attempt uses 1 + the port used in the previous 
attempt (unless the port is 0).
        *
    -   * @param startPort The initial port to start the service on.
    +   * @param port The initial port to start the service on.
        * @param maxRetries Maximum number of retries to attempt.
        *                   A value of 3 means attempting ports n, n+1, n+2, 
and n+3, for example.
        * @param startService Function to start service on a given port.
        *                     This is expected to throw java.net.BindException 
on port collision.
        */
       def startServiceOnPort[T](
    -      startPort: Int,
    +      port: Int,
           startService: Int => (T, Int),
    +      conf: SparkConf = new SparkConf(),
           serviceName: String = "",
           maxRetries: Int = portMaxRetries): (T, Int) = {
         val serviceString = if (serviceName.isEmpty) "" else s" '$serviceName'"
    +    val startPort = conf.getInt("spark.port.min", 0)
    +    val endPort = conf.getInt("spark.port.max", 65536)
         for (offset <- 0 to maxRetries) {
    -      // Do not increment port if startPort is 0, which is treated as a 
special port
    -      val tryPort = if (startPort == 0) {
    -        startPort
    +      // Do not increment port if port is 0, which is treated as a special 
port
    +      val tryPort = if (port == 0) {
    +        (startPort + Math.random() * (endPort - startPort)).toInt
    --- End diff --
    
    @scwf I think you need to pass through 0 here. It has special meaning. 
Refer to the scaladoc. Aren't you just changing the 'else' branch here to start 
and end within a certain range, instead of 1024-65536 always?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to