[jvm-packages] throw ControlThrowable instead of InterruptedException (#3632)

* add back train method but mark as deprecated

* add back train method but mark as deprecated

* fix scalastyle error

* fix scalastyle error

* interrupted exception is not rethrown
This commit is contained in:
Nan Zhu 2018-08-25 20:30:21 -07:00 committed by GitHub
parent cb4de521c1
commit 3261002099
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -19,13 +19,14 @@ package org.apache.spark
import java.net.URL
import org.apache.commons.logging.LogFactory
import org.apache.spark.scheduler.{SparkListener, SparkListenerTaskEnd}
import org.codehaus.jackson.map.ObjectMapper
import scala.collection.JavaConverters._
import scala.concurrent.ExecutionContext.Implicits.global
import scala.concurrent.duration._
import scala.concurrent.{Await, Future, TimeoutException}
import scala.util.control.ControlThrowable
/**
* A tracker that ensures enough number of executor cores are alive.
@ -111,11 +112,15 @@ class SparkParallelismTracker(
}
}
private class ErrorInXGBoostTraining(msg: String) extends ControlThrowable {
override def toString: String = s"ErrorInXGBoostTraining: $msg"
}
private[spark] class TaskFailedListener extends SparkListener {
override def onTaskEnd(taskEnd: SparkListenerTaskEnd): Unit = {
taskEnd.reason match {
case reason: TaskFailedReason =>
throw new InterruptedException(s"ExecutorLost during XGBoost Training: " +
throw new ErrorInXGBoostTraining(s"ExecutorLost during XGBoost Training: " +
s"${reason.toErrorString}")
case _ =>
}