I'm using spark streaming. According to the Spark Programming Guide (see http://spark.apache.org/docs/latest/programming-guide.html#accumulators), named accumulators will be displayed in the WebUI as below: Unfortunately, I cannot find this anywhere. I am registering the accumulators like this (Java):
LongAccumulator accumulator = new LongAccumulator();
ssc.sparkContext.sc().register(accumulator, "my accumulator");
I am using Spark 2.0.0.
When you create a named accumulator, you can see them on Spark web UI under the “Accumulator” tab. On this tab, you will see two tables; the first table “accumulable” – consists of all named accumulator variables and their values. And on the second table “Tasks” – value for each accumulator modified by a task.
An accumulator is created from an initial value v by calling SparkContext. accumulator(v). Tasks running on the cluster can then add to it using the add method or the += operator (in Scala and Python). However, they cannot read its value.
Apache Spark provides a suite of Web UI/User Interfaces (Jobs, Stages, Tasks, Storage, Environment, Executors, and SQL) to monitor the status of your Spark/PySpark application, resource consumption of Spark cluster, and Spark configurations.
Spark natively supports programmers for new types and accumulators of numeric types. We can also create named or unnamed accumulators, as a user. As similar in below image, In the web UI, it displays a named accumulator. For each accumulator modified by a task in the “Tasks” table Spark displays the value.
I do not have a working streaming example but in non streaming example this UI could be found at the stages tab when choosing a specific stage. Also, I generally create the accumulator like this:
val accum = sc.longAccumulator("My Accumulator")
The equivalent in for spark streaming would probably be to replace sc with ssc.SparkContext
It worked for me. Below is my sample code
Accumulator<Integer> spansWritten = jsc.sparkContext().intAccumulator(0,"Spans_Written");
JavaDStream<Span> dStream = SourceFactory.getSource().createStream(jsc)
.map( s -> {
spansWritten.add(1);
return s;
});
However, when I tried to use them inside a Decoder while creating stream for kafka, it didn't show up in the UI.
Here is how it looks in the UI (select stages tab from the top, and click on one of the stage) screen shot
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With