我正在用java编写spark代码。当我使用foreachAsync
火花失败并给我java.lang.IllegalStateException: Cannot call methods on a stopped SparkContext.
在这段代码中:
JavaSparkContext sparkContext = new JavaSparkContext("local","MyAppName");
JavaPairRDD<String, String> wholeTextFiles = sparkContext.wholeTextFiles("somePath");
wholeTextFiles.foreach(new VoidFunction<Tuple2<String, String>>() {
public void call(Tuple2<String, String> stringStringTuple2) throws Exception {
//do something
}
});
它工作正常。但在这段代码中:
JavaSparkContext sparkContext = new JavaSparkContext("local","MyAppName");
JavaPairRDD<String, String> wholeTextFiles = sparkContext.wholeTextFiles("somePath");
wholeTextFiles.foreachAsync(new VoidFunction<Tuple2<String, String>>() {
public void call(Tuple2<String, String> stringStringTuple2) throws Exception {
//do something
}
});
它返回错误。我哪里错了?