Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ private[spark] class AppClient(
var master: ActorSelection = null
var alreadyDisconnected = false // To avoid calling listener.disconnected() multiple times
var alreadyDead = false // To avoid calling listener.dead() multiple times
var registrationRetryTimer: Option[Cancellable] = None

override def preStart() {
context.system.eventStream.subscribe(self, classOf[RemotingLifecycleEvent])
Expand All @@ -83,22 +84,21 @@ private[spark] class AppClient(

def registerWithMaster() {
tryRegisterAllMasters()

import context.dispatcher
var retries = 0
lazy val retryTimer: Cancellable =
registrationRetryTimer = Some {
context.system.scheduler.schedule(REGISTRATION_TIMEOUT, REGISTRATION_TIMEOUT) {
retries += 1
if (registered) {
retryTimer.cancel()
registrationRetryTimer.foreach(_.cancel())
} else if (retries >= REGISTRATION_RETRIES) {
logError("All masters are unresponsive! Giving up.")
markDead()
} else {
tryRegisterAllMasters()
}
}
retryTimer // start timer
}
}

def changeMaster(url: String) {
Expand Down Expand Up @@ -179,6 +179,11 @@ private[spark] class AppClient(
alreadyDead = true
}
}

override def postStop() {
registrationRetryTimer.foreach(_.cancel())
}

}

def start() {
Expand Down
10 changes: 6 additions & 4 deletions core/src/main/scala/org/apache/spark/deploy/worker/Worker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,8 @@ private[spark] class Worker(
val metricsSystem = MetricsSystem.createMetricsSystem("worker", conf, securityMgr)
val workerSource = new WorkerSource(this)

var registrationRetryTimer: Option[Cancellable] = None

def coresFree: Int = cores - coresUsed
def memoryFree: Int = memory - memoryUsed

Expand Down Expand Up @@ -163,21 +165,20 @@ private[spark] class Worker(

def registerWithMaster() {
tryRegisterAllMasters()

var retries = 0
lazy val retryTimer: Cancellable =
registrationRetryTimer = Some {
context.system.scheduler.schedule(REGISTRATION_TIMEOUT, REGISTRATION_TIMEOUT) {
retries += 1
if (registered) {
retryTimer.cancel()
registrationRetryTimer.foreach(_.cancel())
} else if (retries >= REGISTRATION_RETRIES) {
logError("All masters are unresponsive! Giving up.")
System.exit(1)
} else {
tryRegisterAllMasters()
}
}
retryTimer // start timer
}
}

override def receive = {
Expand Down Expand Up @@ -346,6 +347,7 @@ private[spark] class Worker(
}

override def postStop() {
registrationRetryTimer.foreach(_.cancel())
executors.values.foreach(_.kill())
drivers.values.foreach(_.kill())
webUi.stop()
Expand Down