SPARK-4214. With dynamic allocation, avoid outstanding requests for more...

... executors than pending tasks need.

WIP. Still need to add and fix tests.
Hey @sryza it's possible to estimate the size of the queue pretty well from the data in `ExecutorAllocationListener`, we would just ignore the effect of speculated and re-submitted tasks (and this I think is a small enough margin that it's not a big deal). I think you can just add a function called `getPendingTasks` to ExecutorAllocationListener and it would go through each stage and subtract the number of distinct indices started from the number of tasks in the stage. This would retain the isolation of these two components and only sacrifice a small amount of accuracy.