Properly initialise query_resource_mgr_ in RuntimeState

Change-Id: I9f1b3d606007e7fd64cb44b31401de608e2db84b
Reviewed-on: http://gerrit.ent.cloudera.com:8080/1835
Reviewed-by: Nong Li <nong@cloudera.com>
Reviewed-by: Matthew Jacobs <mj@cloudera.com>
Tested-by: jenkins
(cherry picked from commit 7fbe268078c93ac5675832c9fd7127e5a5104dda)
Reviewed-on: http://gerrit.ent.cloudera.com:8080/1929
Reviewed-by: Henry Robinson <henry@cloudera.com>
Fix race between AMNotification() and Reserve() / Expand()

If the resource broker received a notification from the AM before
Reserve() (or Expand()) had started waiting on that notification, the
notification was lost and the resource was never claimed.

This patch ensures that it doesn't matter which side of the notification
gets there first. The new logic is mostly in WaitForNotification(). One
possible concern is that notifications for resources that are genuinely
not known by Impala will always live in the pending_requests_ map. This
would represent a bug in Llama, so it's ok to fix this in the future.

Change-Id: I31d90c1d55bfd9327d5fa063945411fc9820c040
Reviewed-on: http://gerrit.ent.cloudera.com:8080/1891
Reviewed-by: Alex Behm <alex.behm@cloudera.com>
Tested-by: jenkins
(cherry picked from commit 1eeb4dc31e388c2b7e4e80384e1e1136032387df)
Reviewed-on: http://gerrit.ent.cloudera.com:8080/1930
Reviewed-by: Henry Robinson <henry@cloudera.com>
IMPALA-838: Fix premature timeout of sessions

A crucial comparison was between time values with different units.

Tests didn't catch this because they only confirmed that sessions were
timed out within the correct time, not that they were *not* timed out
early.

Change-Id: Ia8c57d3d70e4702996d0225b167142b7bf88d236
Reviewed-on: http://gerrit.ent.cloudera.com:8080/1677
Reviewed-by: Alan Choi <alan@cloudera.com>
Reviewed-by: Henry Robinson <henry@cloudera.com>
Tested-by: jenkins