Updates to the earlier fix to resove issue with the history server data not being displayed on UI

Test cases
==========
1) Executed when both the directories are present
2) Executed as a user who doesn't have permissions on hdfs. In this case "root"
3) Executed when both the directories are not available
4) Executed when one of the directories is available and other is not and vice versa
5) Executed when the name nodeis stopped

Verified the data on the history server UI by running a map reduce job