[master]resolve lock contention in log rolling and cache flushing

Author: fan

Summary:
Resolve lock contention in log rolling and cache flushing.
Make HLog closing wait for unfinished rolling/flushing and vice versa.

FYI: diff on apache repository http://svn.apache.org/viewvc?view=revision&revision=1436632

Test Plan: Unit tests in TestHLog pass by chance.

Reviewers: liyintang, aaiyer

Reviewed By: liyintang

CC: hbase-eng@, pieter, manukranthk

Differential Revision: https://phabricator.fb.com/D918335

Task ID: 2553988

git-svn-id: https://svn.apache.org/repos/asf/hbase/branches/0.89-fb@1515025 13f79535-47bb-0310-9956-ffa450edef68