title: Track requests per Minute in Spark Streaming
body: <p>I am currently trying to track requests per minute in a Spark Application to use them in another transformation. However the code below will never result in another value than the originally set value of 0 when using the variable in the transformation</p>
  
  <pre><code>var rpm: Long = 0
  
  
  val requestsPerMinute = stream.countByWindow(Seconds(60), Seconds(5)).foreachRDD(rdd =&gt; {    
     rdd.foreach(x =&gt; {
       rpm = x       
     })    
  })
  
  stream.foreachRDD { rdd =&gt;
    rdd.foreach(x =&gt; {
      //do something including parameter rpm
    })
  
  }
  </code></pre>
  
  <p>I assume it has to do something with parellization -  what I also tries was to use an RDD or a Broadcast instead of the plain variable. However that resulted in the code not being executed.</p>
  
  <p>What is the recommended way to achieve this in SparkStreaming?</p>
  
  <p>EDIT:
  The incoming objects are timestamped, if that helps with anything.</p>