Improve spark worker hang detection logic

1. Make the spark worker hang detection logic work on spark cluster
2. fix the http connection (to spark web url) time out issue after some idle time.
3. fix some minor formatting issues.