All Downloads are FREE. Search and download functionalities are using the official Maven repository.

tech.ytsaurus.spark.launcher.rest.MasterWrapperLauncher.scala Maven / Gradle / Ivy

There is a newer version: 2.3.0
Show newest version
package tech.ytsaurus.spark.launcher.rest

import org.slf4j.LoggerFactory
import tech.ytsaurus.spark.launcher.ByopLauncher.ByopConfig
import tech.ytsaurus.spark.launcher.Service.{BasicService, MasterService}
import tech.ytsaurus.spark.launcher.VanillaLauncher
import tech.ytsaurus.spyt.HostAndPort

trait MasterWrapperLauncher {
  self: VanillaLauncher =>

  private val log = LoggerFactory.getLogger(getClass)

  private def startMasterWrapper(masterEndpoint: HostAndPort, byopPort: Option[Int])
                                (port: Int): (Thread, Int) = {
    val thread = MasterWrapperServer.start(port, masterEndpoint, byopPort).joinThread()
    (thread, port)
  }

  def startMasterWrapper(args: Array[String], master: MasterService): BasicService = {
    log.info("Start master wrapper")

    val startPort = sys.env.get("SPARK_MASTER_PORT").map(_.toInt).getOrElse(27001)
    val maxRetries = sparkSystemProperties.get("spark.port.maxRetries").map(_.toInt).getOrElse(200)

    val byopPort = ByopConfig.byopPort(sparkSystemProperties, args)

    val (thread, port) = Utils.startServiceOnPort(
      startPort, startMasterWrapper(master.masterAddress.restHostAndPort, byopPort), maxRetries
    )

    BasicService("MasterWrapper", port, thread)
  }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy