[SPARK-2532] WIP Consolidated shuffle fixes

Status of the PR
- [X] Cherry pick and merge changes from internal branch to spark master
- [X] Remove WIP comments and 2G branch references.
- [X] Tests for BlockObjectWriter
- [ ] Tests for ExternalAppendOnlyMap
- [x] Tests for ShuffleBlockManager



This (and related commented inShutdown references) has been left around in case someone else can suggest an improvement !
The issue is, this works fine in 'normal' use : but while running spark tests in local mode, it fails.