2

Following offical doc, I'm trying to revovery StreamingContext:

def get_or_create_ssc():
    cfg = SparkConf().setAppName('MyApp').setMaster('local[10]')
    sc = SparkContext(conf=cfg)
    ssc = StreamingContext(sparkContext=sc, batchDuration=2)

    lines = ssc.socketTextStream('localhost', 9999).checkpoint(10)

    def update_func(x, y):
        return sum(x) + (y or 0)

    word = lines.flatMap(lambda x: x.split()).map(lambda x: (x, 1)).updateStateByKey(update_func)
    word.pprint()
    return ssc


ssc = StreamingContext.getOrCreate('checkpoint', get_or_create_ssc)

ssc.start()
ssc.awaitTermination()

When I launch code at the first time(checkpoint is empty), It works as well

To simulate system failures, I turn off Terminal

But it can not recover when launching again

Terminal only show this

16/10/17 15:04:53 WARN Utils: Your hostname, localhost resolves to a loopback address: 127.0.0.1; using 192.168.177.1 instead (on interface eth0)
16/10/17 15:04:53 WARN Utils: Set SPARK_LOCAL_IP if you need to bind to another address
16/10/17 15:04:55 WARN SparkContext: Use an existing SparkContext, some configuration may not take effect.
16/10/17 15:04:57 WARN SocketInputDStream: isTimeValid called with 1476686252000 ms whereas the last valid time is 1476686572000 ms
[Stage 3:>                                                         (0 + 0) / 20]

And there is no new information later

Zhang Tong
  • 4,569
  • 3
  • 19
  • 38

1 Answers1

0

Finally,I found the reason from Spark UI`s Environment page.

When I launch the code at first time, spark.master has been set to 'local[10]'。

But after recover from checkpoint , spark.master change to 'local[*]' automatically

I have to edit conf/spark-defaults.conf with 'park.master local[10]' due to my VMware only has one core.

In offical doc there is a comment say that:

Metadata includes:
    Configuration - The configuration that was used to create the streaming application.

It seems that Configuration does not include spark.master.

Why ?

Zhang Tong
  • 4,569
  • 3
  • 19
  • 38