[SPARK-4168][WebUI] web statges number should show correctly when stages are more than 1000

The number of completed stages and failed stages showed on webUI will always be less than 1000. This is really misleading when there are already thousands of stages completed or failed. The number should be correct even when only partial stages listed on the webUI (stage info will be removed if the number is too large).
Hi @andrewor14 , if stages are too large, may consume too much memory. So there is a mechanism to limit the buffer maintaining the `completedStages` and `failedStages`. And if the stage size is large than `retainedStages`, the starting part of the completed stages will be removed. See the code here ([trimIfNecessary](https://github.com/apache/spark/blob/master/core/src/main/scala/org/apache/spark/ui/jobs/JobProgressListener.scala#L121)). So if the stage number is too large, `completedStages.size` is not the actually the real completedStages. Currently, the threshold is 1000. So the completed stages or failed stages showed on the WebUI will never higher than 1000, it will chages between 900~1000 if the stage number is more than 1000.