Skip to content

Commit

Permalink
[jvm-packages] RabitTracker for Scala: allow specifying host ip from …
Browse files Browse the repository at this point in the history
…the xgboost-tracker.properties file (#3833)
  • Loading branch information
tovbinm authored and CodingCat committed Oct 27, 2018
1 parent 5fbe230 commit d81fedb
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import java.net.{InetAddress, InetSocketAddress}

import akka.actor.ActorSystem
import akka.pattern.ask
import ml.dmlc.xgboost4j.java.IRabitTracker
import ml.dmlc.xgboost4j.java.{IRabitTracker, TrackerProperties}
import ml.dmlc.xgboost4j.scala.rabit.handler.RabitTrackerHandler

import scala.concurrent.duration._
Expand Down Expand Up @@ -93,8 +93,11 @@ private[scala] class RabitTracker(numWorkers: Int, port: Option[Int] = None,
* @return Boolean flag indicating if the Rabit tracker starts successfully.
*/
private def start(timeout: Duration): Boolean = {
val hostAddress = Option(TrackerProperties.getInstance().getHostIp)
.map(InetAddress.getByName).getOrElse(InetAddress.getLocalHost)

handler ? RabitTrackerHandler.StartTracker(
new InetSocketAddress(InetAddress.getLocalHost, port.getOrElse(0)), maxPortTrials, timeout)
new InetSocketAddress(hostAddress, port.getOrElse(0)), maxPortTrials, timeout)

// block by waiting for the actor to bind to a port
Try(Await.result(handler ? RabitTrackerHandler.RequestBoundFuture, askTimeout.duration)
Expand Down

0 comments on commit d81fedb

Please sign in to comment.