SparkException using JavaStreamingContext.getOrCreate(): Only one SparkContext may be running in this JVM

后端 未结 1 378
有刺的猬
有刺的猬 2021-01-26 05:43

Related to this question, I got the tip that the getOrCreate idiom should be used to avoid this issues. But trying:

JavaStreamingContextFactory cont         


        
相关标签:
1条回答
  • 2021-01-26 06:12

    According to this question I think this is how I should do it:

    SparkConf conf = new SparkConf().setAppName(NAME);
    JavaSparkContext ctx = JavaSparkContext.fromSparkContext(SparkContext.getOrCreate(conf));
    JavaStreamingContext context = new JavaStreamingContext(ctx, Durations.seconds(BATCH_SPAN));
    

    Right?

    0 讨论(0)
提交回复
热议问题