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