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)
(cherry picked from commit 98b81c662419d5e136fddee87d18b48b4b969ef2)