SPARK-732: eliminate duplicate update of the accumulator

https://spark-project.atlassian.net/browse/SPARK-732

In current implementation, the accumulator will be updated for every successfully finished task, even the task is from a resubmitted stage, which makes the accumulator counter-intuitive

In this patch, I changed the way for the DAGScheduler to update the accumulator, 

DAGScheduler maintains a HashTable, mapping the stage id to the received \<accumulator_id , value\> pairs. Only when the stage becomes independent, (no job needs it any more), we accumulate the values of the \<accumulator_id , value\>  pairs, when a task finished, we check if the HashTable has contained such stageId, it saves the accumulator_id, value only when the task is the first finished task of a new stage or the stage is running for the first attempt...

---


However, the existence of the duplicate update is also related to the cache, especially when we make some accumulator operation in the transformation....(the original JIRA also discussed this)

e.g. 

```
val a = sc.parallelize(List(1, 2, 3, 4))
val b = a.map(i => {accum += 1; i + 1})
val c = b.filter(i => i < 4)
c.count() - accum is 4
c.count() - accum is 8
c.cache()
c.count() - accum is still 8
```

So for the user, the uncontrollable cache behaviour also affects the final result of the accumulator presented to the user when they put the accumulator operation in a transformation...

My question here is whether we should ensure the accumulator += operation is executed for only once in transformation level, or we can assume that the user should be aware of the possible duplicate update...

Glad to hear your advice