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

后端 未结 1 379
有刺的猬
有刺的猬 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)
提交回复
热议问题