title: Spark : forEachPartition not working
body: <p>I want to use foreachpartition to save data in my database, but I noticed that this function not working</p>
  
  <pre><code>RDD2.foreachRDD(new VoidFunction&lt;JavaRDD&lt;Object&gt;&gt;() {
  
  
              @Override
              public void call(JavaRDD&lt;Object&gt; t) throws Exception {
  
  
                  t.foreachPartition(new VoidFunction&lt;Iterator&lt;Object&gt;&gt;() {
  
                      @Override
                      public void call(Iterator&lt;Object&gt; t) throws Exception {
                          System.out.println("test");
                      }   }
                  );
            }});
  </code></pre>
  
  <p>When I run this example, my my spark program will be blocked in these steps, without showing others RDD or even print test</p>
  
  <pre><code>6/05/30 10:18:41 INFO SparkContext: Created broadcast 0 from broadcast at DAGScheduler.scala:1006
  16/05/30 10:18:41 INFO TaskSchedulerImpl: Adding task set 0.0 with 1 tasks
  16/05/30 10:18:41 INFO TaskSetManager: Starting task 0.0 in stage 0.0 (TID 0, localhost, partition 0,PROCESS_LOCAL, 2946 bytes)
  16/05/30 10:18:41 INFO Executor: Running task 0.0 in stage 0.0 (TID 0)
  16/05/30 10:18:41 INFO SparkContext: Starting job: foreachPartition at BrokerSpout.java:265
  16/05/30 10:18:41 INFO RecurringTimer: Started timer for BlockGenerator at time 1464596321600
  -------------------------------------------
  Time: 1464596321500 ms
  -------------------------------------------
  
  16/05/30 10:18:41 INFO ReceivedBlockTracker: Deleting batches ArrayBuffer()
  16/05/30 10:18:41 INFO ReceiverTracker: Registered receiver for stream 0 from 10.25.30.41:59407
  16/05/30 10:18:41 INFO InputInfoTracker: remove old batch metadata: 
  16/05/30 10:18:41 INFO ReceiverSupervisorImpl: Starting receiver
  16/05/30 10:18:41 INFO ReceiverSupervisorImpl: Called receiver onStart
  16/05/30 10:18:41 INFO ReceiverSupervisorImpl: Waiting for receiver to be stopped
  16/05/30 10:18:42 INFO SparkContext: Starting job: foreachPartition at BrokerSpout.java:265
  16/05/30 10:18:42 INFO SparkContext: Created broadcast 1 from broadcast at DAGScheduler.scala:1006
  16/05/30 10:18:42 INFO TaskSchedulerImpl: Adding task set 1.0 with 2 tasks
  </code></pre>
  
  <p>As you see in my logging, it says that my spark is Waiting for a receiver to be stopped, but my receiver must not be stopped, if not, what is the purpose of spark streaming if we have to stop the sender.</p>