本期内容:函数
1,Spark Streaming中的空RDD处理oop
2,Spark Streaming程序的中止spa
StreamingContext的stop方法,是当即中止,不会等待处理完已接收到的数据的。是否再调用stop方式时中止SparkContext能够经过spark.streaming.stopSparkContextByDefault这个参数来设置。it
在stop方法中,调用scheduler的stop方法,判断是否中止SparkContext。spark
在JobScheduler的stop方法中,先调用receiverTracker的stop方法,再调用jobGenerator的stop方法,而后根据是否须要等待数据处理完,分别调用jobExecutor的awaitTermination方法,等待时间为2s或1h,最后调用listenerBus和eventLoop的stop方法。io
在调用StreamingContext的start方法时,其实已经注册了构造函数stopOnShutdown。event
在stopOnShutdown方法中,还会调用stop方法,其中能够配置spark.streaming.stopGracefullyOnShutdown来使得是否须要在中止Spark Streaming时处理完已接收到的数据。stream