Merge r1523376 from trunk to branch-2 for YARN-540. Race condition causing RM to potentially relaunch already unregistered AMs on RM restart (Jian He via bikas)