Source:
private void startSparkStreamingContext(Properties sparkConfigs, final SparkStreamingSupport sparkStreamingSupport) { final Receiver receiver = getComponent(Receiver.class); Environment env = this.getApplicationContext().getEnvironment(); String masterURL = env.getProperty(SparkStreamingSupport.SPARK_MASTER_URL_PROP, SparkStreamingSupport.SPARK_DEFAULT_MASTER_URL); final SparkConf sparkConf = setupSparkConf(masterURL, sparkConfigs); final String batchInterval = env.getProperty("batchInterval", env.getProperty("spark.streaming.batchInterval", SPARK_STREAMING_BATCH_INTERVAL)); final SparkStreamingListener streamingListener = new SparkStreamingListener(); final SparkMessageSender sender = (this.getType().equals(ModuleType.processor)) ? getComponent(SparkMessageSender.class) : null; streamingContext = new StreamingContext(sparkConf, new Duration(Long.valueOf(batchInterval))); streamingContext.addStreamingListener(streamingListener); Executors.newSingleThreadExecutor().execute(new Runnable() { @Override @SuppressWarnings("unchecked") public void run() { try { if (sparkStreamingSupport instanceof Processor) { javaStreamingContext = new JavaStreamingContext(streamingContext); JavaDStreamLike input = javaStreamingContext.receiverStream(receiver); new SparkStreamingModuleExecutor().execute(input, (Processor) sparkStreamingSupport, sender); } if (sparkStreamingSupport instanceof org.springframework.xd.spark.streaming.scala.Processor) { ReceiverInputDStream input = streamingContext.receiverStream(receiver, null); new org.springframework.xd.spark.streaming.scala.SparkStreamingModuleExecutor().execute(input, (org.springframework.xd.spark.streaming.scala.Processor) sparkStreamingSupport, sender); } streamingContext.start(); streamingContext.awaitTermination(); } catch (Exception e) { throw new RuntimeException("Exception when running Spark Streaming application.", e); } } }); try { boolean started = receiverStartLatch.await(30, TimeUnit.SECONDS); if (!started) { logger.warn("Deployment timed out when deploying Spark Streaming module " + sparkStreamingSupport); } if (!receiverStartSuccess.get()) { throw new IllegalStateException("Failed to start Spark Streaming Receiver"); } } catch (InterruptedException ie) { throw new RuntimeException(ie); } }

Target:
private void startSparkStreamingContext(Properties sparkConfigs, final SparkStreamingSupport sparkStreamingSupport) { final Receiver receiver = getComponent(Receiver.class); Environment env = this.getApplicationContext().getEnvironment(); String masterURL = env.getProperty(SparkStreamingSupport.SPARK_MASTER_URL_PROP, SparkStreamingSupport.SPARK_DEFAULT_MASTER_URL); final SparkConf sparkConf = setupSparkConf(masterURL, sparkConfigs); final String batchInterval = env.getProperty(SparkStreamingSupport.SPARK_STREAMING_BATCH_INTERVAL_MODULE_OPTION, env.getProperty(SparkStreamingSupport.SPARK_STREAMING_BATCH_INTERVAL_PROP, SparkStreamingSupport.SPARK_STREAMING_DEFAULT_BATCH_INTERVAL)); final SparkStreamingListener streamingListener = new SparkStreamingListener(); final SparkMessageSender sender = (this.getType().equals(ModuleType.processor)) ? getComponent(SparkMessageSender.class) : null; streamingContext = new StreamingContext(sparkConf, new Duration(Long.valueOf(batchInterval))); streamingContext.addStreamingListener(streamingListener); Executors.newSingleThreadExecutor().execute(new Runnable() { @Override @SuppressWarnings("unchecked") public void run() { try { if (sparkStreamingSupport instanceof Processor) { javaStreamingContext = new JavaStreamingContext(streamingContext); JavaDStreamLike input = javaStreamingContext.receiverStream(receiver); new ModuleExecutor().execute(input, (Processor) sparkStreamingSupport, sender); } if (sparkStreamingSupport instanceof org.springframework.xd.spark.streaming.scala.Processor) { ReceiverInputDStream input = streamingContext.receiverStream(receiver, null); new org.springframework.xd.spark.streaming.scala.ModuleExecutor().execute(input, (org.springframework.xd.spark.streaming.scala.Processor) sparkStreamingSupport, sender); } streamingContext.start(); streamingContext.awaitTermination(); } catch (Exception e) { throw new RuntimeException("Exception when running Spark Streaming application.", e); } } }); try { boolean started = receiverStartLatch.await(30, TimeUnit.SECONDS); if (!started) { logger.warn("Deployment timed out when deploying Spark Streaming module " + sparkStreamingSupport); } if (!receiverStartSuccess.get()) { throw new IllegalStateException("Failed to start Spark Streaming Receiver"); } } catch (InterruptedException ie) { throw new RuntimeException(ie); } }