Mehrere SparkContext erkannt, in der gleichen JVM
laut meiner Letzte Frage ich habe zu definieren, die Mehrere SparkContext für meine einzigartige JVM.
Habe ich es in der nächsten Weg (mit Java):
SparkConf conf = new SparkConf();
conf.setAppName("Spark MultipleContest Test");
conf.set("spark.driver.allowMultipleContexts", "true");
conf.setMaster("local");
Danach erstelle ich die nächste Quelle-code:
SparkContext sc = new SparkContext(conf);
SQLContext sqlContext = new org.apache.spark.sql.SQLContext(sc);
später im code:
JavaSparkContext ctx = new JavaSparkContext(conf);
JavaRDD<Row> testRDD = ctx.parallelize(AllList);
Nachdem der code ausgeführt ich bekam die nächste Fehlermeldung:
16/01/19 15:21:08 WARN SparkContext: Multiple running SparkContexts detected in the same JVM!
org.apache.spark.SparkException: Only one SparkContext may be running in this JVM (see SPARK-2243). To ignore this error, set spark.driver.allowMultipleContexts = true. The currently running SparkContext was created at:
org.apache.spark.SparkContext.<init>(SparkContext.scala:81)
test.MLlib.BinarryClassification.main(BinaryClassification.java:41)
at org.apache.spark.SparkContext$$anonfun$assertNoOtherContextIsRunning$1.apply(SparkContext.scala:2083)
at org.apache.spark.SparkContext$$anonfun$assertNoOtherContextIsRunning$1.apply(SparkContext.scala:2065)
at scala.Option.foreach(Option.scala:236)
at org.apache.spark.SparkContext$.assertNoOtherContextIsRunning(SparkContext.scala:2065)
at org.apache.spark.SparkContext$.setActiveContext(SparkContext.scala:2151)
at org.apache.spark.SparkContext.<init>(SparkContext.scala:2023)
at org.apache.spark.api.java.JavaSparkContext.<init>(JavaSparkContext.scala:61)
at test.MLlib.BinarryClassification.main(BinaryClassification.java:105)
Die zahlen 41
und 105
sind die Linien, in denen beide Objekte sind in Java-code. Meine Frage ist, ist es möglich, die Ausführung von mehreren SparkContext auf der gleichen JVM und wie es zu tun, wenn ich bereits die set
-Methode ?
- Sie können zum erstellen mehrerer Kontext, in einer JVM ?
- Es gibt eine riesige Diskussion hier, im Fall Sie haven ' T Lesen Sie es bereits : issues.apache.org/jira/browse/SPARK-2243
Du musst angemeldet sein, um einen Kommentar abzugeben.
Sind Sie sicher, dass Sie müssen die JavaSparkContext als separate Kontext? Die Vorherige Frage, dass Sie sich nicht so sagen. Wenn Sie bereits ein Funke Kontext Sie können eine neue JavaSparkContext aus, anstatt erstellen Sie einen separaten Kontext:
den SparkContext ausgeführt wird, standardmäßig aktiviert, so u haben, um dies zu stoppen Kontext:
sc.stoppen
dann können Sie weiterhin ohne pb