YARN-2607. Fixed issues in TestDistributedShell. Contributed by Wangda Tan.

(cherry picked from commit 737d9284c109dac20ff423f30c62f6abe2db10f7)
HDFS-7382. DataNode in secure mode may throw NullPointerException if client connects before DataNode registers itself with NameNode. Contributed by Chris Nauroth.

(cherry picked from commit 9ba8d8c7eb65eeb6fe673f04e493d9eedd95a822)
Merge remote-tracking branch 'remotes/origin/branch-2' into branch-2