title: Spark Custom AccumulatorV2
body: <p>I have defined a Custom Accumulator as:</p>
  
  <pre><code>import org.apache.spark.util.LongAccumulator
  
  class CustomAccumulator extends LongAccumulator with java.io.Serializable  {
    override def add(v: Long): Unit = {
      super.add(v)
      if (v % 100 == 0) println(v)
    }
  }
  </code></pre>
  
  <p>And registered it as:</p>
  
  <pre><code>val cusAcc = new CustomAccumulator
  sc.register(cusAcc, "customAccumulator")
  </code></pre>
  
  <p>My issue is that when I try to use it as:</p>
  
  <pre><code>val count = sc.customAccumulator  
  </code></pre>
  
  <p>I get the following error:</p>
  
  <pre><code>&lt;console&gt;:51: error: value customAccumulator is not a member of org.apache.spark.SparkContext
     val count = sc.customAccumulator
  </code></pre>
  
  <p>I am new to Spark and scala, and maybe missing something very trivial. Any guidance will be greatly appreciated.</p>