Skip to content
Snippets Groups Projects
Unverified Commit e5c307c5 authored by Weiqing Yang's avatar Weiqing Yang Committed by Sean Owen
Browse files

[MINOR] Add missing sc.stop() to end of examples

## What changes were proposed in this pull request?

Add `finally` clause for `sc.stop()` in the `test("register and deregister Spark listener from SparkContext")`.

## How was this patch tested?
Pass the build and unit tests.

Author: Weiqing Yang <yangweiqing001@gmail.com>

Closes #16426 from weiqingy/testIssue.
parent ae83c211
No related branches found
No related tags found
No related merge requests found
Showing
with 45 additions and 11 deletions
......@@ -455,16 +455,14 @@ class SparkContextSuite extends SparkFunSuite with LocalSparkContext {
test("register and deregister Spark listener from SparkContext") {
sc = new SparkContext(new SparkConf().setAppName("test").setMaster("local"))
try {
val sparkListener1 = new SparkListener { }
val sparkListener2 = new SparkListener { }
sc.addSparkListener(sparkListener1)
sc.addSparkListener(sparkListener2)
assert(sc.listenerBus.listeners.contains(sparkListener1))
assert(sc.listenerBus.listeners.contains(sparkListener2))
sc.removeSparkListener(sparkListener1)
assert(!sc.listenerBus.listeners.contains(sparkListener1))
assert(sc.listenerBus.listeners.contains(sparkListener2))
}
val sparkListener1 = new SparkListener { }
val sparkListener2 = new SparkListener { }
sc.addSparkListener(sparkListener1)
sc.addSparkListener(sparkListener2)
assert(sc.listenerBus.listeners.contains(sparkListener1))
assert(sc.listenerBus.listeners.contains(sparkListener2))
sc.removeSparkListener(sparkListener1)
assert(!sc.listenerBus.listeners.contains(sparkListener1))
assert(sc.listenerBus.listeners.contains(sparkListener2))
}
}
......@@ -111,5 +111,7 @@ public class JavaBinaryClassificationMetricsExample {
model.save(sc, "target/tmp/LogisticRegressionModel");
LogisticRegressionModel.load(sc, "target/tmp/LogisticRegressionModel");
// $example off$
sc.stop();
}
}
......@@ -103,6 +103,8 @@ public class JavaLBFGSExample {
System.out.println(l);
System.out.println("Area under ROC = " + auROC);
// $example off$
sc.stop();
}
}
......@@ -91,5 +91,7 @@ public class JavaMulticlassClassificationMetricsExample {
LogisticRegressionModel sameModel = LogisticRegressionModel.load(sc,
"target/tmp/LogisticRegressionModel");
// $example off$
sc.stop();
}
}
......@@ -61,5 +61,6 @@ public class JavaPCAExample {
for (Vector vector : collectPartitions) {
System.out.println("\t" + vector);
}
sc.stop();
}
}
......@@ -47,6 +47,8 @@ object AssociationRulesExample {
+ rule.consequent.mkString(",") + "]," + rule.confidence)
}
// $example off$
sc.stop()
}
}
......
......@@ -98,6 +98,7 @@ object BinaryClassificationMetricsExample {
val auROC = metrics.areaUnderROC
println("Area under ROC = " + auROC)
// $example off$
sc.stop()
}
}
// scalastyle:on println
......@@ -62,6 +62,8 @@ object DecisionTreeClassificationExample {
model.save(sc, "target/tmp/myDecisionTreeClassificationModel")
val sameModel = DecisionTreeModel.load(sc, "target/tmp/myDecisionTreeClassificationModel")
// $example off$
sc.stop()
}
}
// scalastyle:on println
......@@ -61,6 +61,8 @@ object DecisionTreeRegressionExample {
model.save(sc, "target/tmp/myDecisionTreeRegressionModel")
val sameModel = DecisionTreeModel.load(sc, "target/tmp/myDecisionTreeRegressionModel")
// $example off$
sc.stop()
}
}
// scalastyle:on println
......@@ -62,6 +62,8 @@ object GradientBoostingClassificationExample {
val sameModel = GradientBoostedTreesModel.load(sc,
"target/tmp/myGradientBoostingClassificationModel")
// $example off$
sc.stop()
}
}
// scalastyle:on println
......
......@@ -61,6 +61,8 @@ object GradientBoostingRegressionExample {
val sameModel = GradientBoostedTreesModel.load(sc,
"target/tmp/myGradientBoostingRegressionModel")
// $example off$
sc.stop()
}
}
// scalastyle:on println
......@@ -62,6 +62,8 @@ object IsotonicRegressionExample {
model.save(sc, "target/tmp/myIsotonicRegressionModel")
val sameModel = IsotonicRegressionModel.load(sc, "target/tmp/myIsotonicRegressionModel")
// $example off$
sc.stop()
}
}
// scalastyle:on println
......@@ -84,6 +84,8 @@ object LBFGSExample {
loss.foreach(println)
println("Area under ROC = " + auROC)
// $example off$
sc.stop()
}
}
// scalastyle:on println
......@@ -64,6 +64,8 @@ object MultiLabelMetricsExample {
// Subset accuracy
println(s"Subset accuracy = ${metrics.subsetAccuracy}")
// $example off$
sc.stop()
}
}
// scalastyle:on println
......@@ -90,6 +90,8 @@ object MulticlassMetricsExample {
println(s"Weighted F1 score: ${metrics.weightedFMeasure}")
println(s"Weighted false positive rate: ${metrics.weightedFalsePositiveRate}")
// $example off$
sc.stop()
}
}
// scalastyle:on println
......@@ -45,6 +45,8 @@ object NaiveBayesExample {
model.save(sc, "target/tmp/myNaiveBayesModel")
val sameModel = NaiveBayesModel.load(sc, "target/tmp/myNaiveBayesModel")
// $example off$
sc.stop()
}
}
......
......@@ -53,6 +53,8 @@ object PCAOnRowMatrixExample {
val collect = projected.rows.collect()
println("Projected Row Matrix of principal component:")
collect.foreach { vector => println(vector) }
sc.stop()
}
}
// scalastyle:on println
......@@ -52,6 +52,8 @@ object PCAOnSourceVectorExample {
val collect = projected.collect()
println("Projected vector of principal component:")
collect.foreach { vector => println(vector) }
sc.stop()
}
}
// scalastyle:on println
......@@ -46,6 +46,8 @@ object PrefixSpanExample {
", " + freqSequence.freq)
}
// $example off$
sc.stop()
}
}
// scalastyle:off println
......@@ -62,6 +62,8 @@ object RandomForestClassificationExample {
model.save(sc, "target/tmp/myRandomForestClassificationModel")
val sameModel = RandomForestModel.load(sc, "target/tmp/myRandomForestClassificationModel")
// $example off$
sc.stop()
}
}
// scalastyle:on println
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment