Skip to content

Commit

Permalink
nit
Browse files Browse the repository at this point in the history
  • Loading branch information
turboFei committed Nov 12, 2024
1 parent 5b3c7d0 commit 6e3f43e
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ trait MasterClusterFeature extends Logging {
}
}

private val usedPorts = new java.util.HashSet[Integer]()
private def selectRandomPort(): Int = {
val usedPorts = new java.util.HashSet[Integer]()
def selectRandomPort(): Int = {
val port = Utils.selectRandomInt(1024, 65535)
if (usedPorts.contains(port)) {
selectRandomPort()
Expand Down Expand Up @@ -65,6 +65,7 @@ trait MasterClusterFeature extends Logging {
}
}
}

def setupMasterWithRandomPort(masterConf: Map[String, String] = Map()): Master = {
var master: Master = null
withRetryOnPortBindException { () =>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import org.scalatest.funsuite.AnyFunSuite

import org.apache.celeborn.common.CelebornConf
import org.apache.celeborn.common.protocol.{PbCheckForWorkerTimeout, PbRegisterWorker}
import org.apache.celeborn.common.util.{CelebornExitKind, ThreadUtils, Utils}
import org.apache.celeborn.common.util.{CelebornExitKind, ThreadUtils}

class MasterSuite extends AnyFunSuite
with BeforeAndAfterAll
Expand All @@ -41,8 +41,8 @@ class MasterSuite extends AnyFunSuite
test("test single node startup functionality") {
withRetryOnPortBindException { () =>
val conf = new CelebornConf()
val randomMasterPort = Utils.selectRandomInt(1024, 65535)
val randomHttpPort = Utils.selectRandomInt(1024, 65535)
val randomMasterPort = selectRandomPort()
val randomHttpPort = selectRandomPort()
conf.set(CelebornConf.HA_ENABLED.key, "false")
conf.set(CelebornConf.HA_MASTER_RATIS_STORAGE_DIR.key, getTmpDir())
conf.set(CelebornConf.WORKER_STORAGE_DIRS.key, getTmpDir())
Expand Down Expand Up @@ -70,9 +70,9 @@ class MasterSuite extends AnyFunSuite
test("test dedicated internal port receives") {
withRetryOnPortBindException { () =>
val conf = new CelebornConf()
val randomMasterPort = Utils.selectRandomInt(1024, 65535)
val randomHttpPort = Utils.selectRandomInt(1024, 65535)
val randomInternalPort = Utils.selectRandomInt(1024, 65535)
val randomMasterPort = selectRandomPort()
val randomHttpPort = selectRandomPort()
val randomInternalPort = selectRandomPort()
conf.set(CelebornConf.HA_ENABLED.key, "false")
conf.set(CelebornConf.HA_MASTER_RATIS_STORAGE_DIR.key, getTmpDir())
conf.set(CelebornConf.WORKER_STORAGE_DIRS.key, getTmpDir())
Expand Down Expand Up @@ -117,8 +117,8 @@ class MasterSuite extends AnyFunSuite

test("test master worker host allow and deny pattern") {
val conf = new CelebornConf()
val randomMasterPort = Utils.selectRandomInt(1024, 65535)
val randomHttpPort = randomMasterPort + 1
val randomMasterPort = selectRandomPort()
val randomHttpPort = selectRandomPort()
conf.set(CelebornConf.HA_ENABLED.key, "false")
conf.set(CelebornConf.HA_MASTER_RATIS_STORAGE_DIR.key, getTmpDir())
conf.set(CelebornConf.WORKER_STORAGE_DIRS.key, getTmpDir())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ trait MiniClusterFeature extends Logging {
}
}

private val usedPorts = new java.util.HashSet[Integer]()
private def selectRandomPort(): Int = {
val usedPorts = new java.util.HashSet[Integer]()
def selectRandomPort(): Int = {
val port = Utils.selectRandomInt(1024, 65535)
if (usedPorts.contains(port)) {
selectRandomPort()
Expand Down

0 comments on commit 6e3f43e

Please sign in to comment.