Merge -c r1470243 from trunk to branch-2 for YARN-594. Update test and add comments in YARN-534 (Jian He via bikas)