Merge pull request #3 from ankurdave/clear-port-properties-after-tests
After unit tests, clear port properties unconditionally Also submitted to Spark upstream (mesos/spark#940)
This commit is contained in:
commit
6a5e665cdc
|
@ -40,17 +40,17 @@ trait LocalSparkContext extends BeforeAndAfterEach with BeforeAndAfterAll { self
|
||||||
}
|
}
|
||||||
|
|
||||||
def resetSparkContext() = {
|
def resetSparkContext() = {
|
||||||
if (sc != null) {
|
LocalSparkContext.stop(sc)
|
||||||
LocalSparkContext.stop(sc)
|
sc = null
|
||||||
sc = null
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
object LocalSparkContext {
|
object LocalSparkContext {
|
||||||
def stop(sc: SparkContext) {
|
def stop(sc: SparkContext) {
|
||||||
sc.stop()
|
if (sc != null) {
|
||||||
|
sc.stop()
|
||||||
|
}
|
||||||
// To avoid Akka rebinding to the same port, since it doesn't unbind immediately on shutdown
|
// To avoid Akka rebinding to the same port, since it doesn't unbind immediately on shutdown
|
||||||
System.clearProperty("spark.driver.port")
|
System.clearProperty("spark.driver.port")
|
||||||
System.clearProperty("spark.hostPort")
|
System.clearProperty("spark.hostPort")
|
||||||
|
|
|
@ -33,10 +33,8 @@ trait SharedSparkContext extends BeforeAndAfterAll { self: Suite =>
|
||||||
}
|
}
|
||||||
|
|
||||||
override def afterAll() {
|
override def afterAll() {
|
||||||
if (_sc != null) {
|
LocalSparkContext.stop(_sc)
|
||||||
LocalSparkContext.stop(_sc)
|
_sc = null
|
||||||
_sc = null
|
|
||||||
}
|
|
||||||
super.afterAll()
|
super.afterAll()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue