title: How to save and use Variables in Spark Streaming?
body: <p>I have <strong>three businesses</strong> called <strong>a,b,c</strong>, they are will be processed in one spark streaming Application.</p>
  
  <p>All businesses depend on <code>b1</code> and <code>b2</code>, and I need change value of <code>b1</code> and <code>b2</code> once when finished all businesses in one batch. that is to say, I must change value of <code>b1</code> and <code>b2</code> before last one bussiness being finished. Maybe last one finished bessiness  is <strong>a</strong> or <strong>b</strong> or <strong>c</strong>. How to do it?</p>
  
  <pre><code>object Variables extends Serializable{
      var b1 = true
      var b2 = false
  }
  
  
  object test{
      def main(args: Array[String]){
  
          val sc = new SparkContext
          val sec = 3
  
          val ssc = new StreamingContext(sc, Seconds(sec))
          val input = ssc.socketTextStream("192.168.41.55", 12345)
  
          // a business
          input.transform(/*I need use b1,b2 in here*/).saveAsTextFiles("")
  
          // b business
          input.transform(/*I need use b1,b2 in here*/).saveAsTextFiles("")
  
          // c business
          input.transform(/*I need use b1,b2 in here*/).saveAsTextFiles("")
  
          ssc.start()
          ssc.awaitTermination()
      }
  }
  </code></pre>