impala-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tarmstr...@apache.org
Subject incubator-impala git commit: IMPALA-2767: Web UI call to force expire sessions
Date Wed, 06 Jul 2016 00:40:36 GMT
Repository: incubator-impala
Updated Branches:
  refs/heads/master 0dde1c2f8 -> d60b70769


IMPALA-2767: Web UI call to force expire sessions

This change adds a "Close session" button in the sessions Web UI
which destroys the session with the client when clicked.

Change-Id: Ia2639993502a6deb5c24c3f1d055d82ade05ff67
Reviewed-on: http://gerrit.cloudera.org:8080/3555
Reviewed-by: Sailesh Mukil <sailesh@cloudera.com>
Tested-by: Sailesh Mukil <sailesh@cloudera.com>


Project: http://git-wip-us.apache.org/repos/asf/incubator-impala/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-impala/commit/d60b7076
Tree: http://git-wip-us.apache.org/repos/asf/incubator-impala/tree/d60b7076
Diff: http://git-wip-us.apache.org/repos/asf/incubator-impala/diff/d60b7076

Branch: refs/heads/master
Commit: d60b70769a7ef14a8170565253aaefdd6e80f7bf
Parents: 0dde1c2
Author: Sailesh Mukil <sailesh@cloudera.com>
Authored: Thu Jun 16 16:39:22 2016 -0700
Committer: Tim Armstrong <tarmstrong@cloudera.com>
Committed: Tue Jul 5 17:40:33 2016 -0700

----------------------------------------------------------------------
 be/src/service/impala-http-handler.cc | 46 +++++++++++++++++++++++-------
 be/src/service/impala-http-handler.h  |  4 +++
 www/sessions.tmpl                     |  2 ++
 3 files changed, 42 insertions(+), 10 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/d60b7076/be/src/service/impala-http-handler.cc
----------------------------------------------------------------------
diff --git a/be/src/service/impala-http-handler.cc b/be/src/service/impala-http-handler.cc
index 5b97890..d2ffdd8 100644
--- a/be/src/service/impala-http-handler.cc
+++ b/be/src/service/impala-http-handler.cc
@@ -50,15 +50,16 @@ Webserver::UrlCallback MakeCallback(T* caller, const F& fnc) {
   };
 }
 
-// We expect the query id to be passed as one parameter, 'query_id'.
-// Returns true if the query id was present and valid; false otherwise.
-static Status ParseQueryId(const Webserver::ArgumentMap& args, TUniqueId* id) {
-  Webserver::ArgumentMap::const_iterator it = args.find("query_id");
+// We expect the id to be passed as one parameter. Eg: 'query_id' or 'session_id'.
+// Returns true if the id was present and valid; false otherwise.
+static Status ParseIdFromArguments(const Webserver::ArgumentMap& args, TUniqueId* id,
+    const std::string &to_find) {
+  Webserver::ArgumentMap::const_iterator it = args.find(to_find);
   if (it == args.end()) {
-    return Status("No 'query_id' argument found");
+    return Status(Substitute("No '$0' argument found.", to_find));
   } else {
     if (ParseId(it->second, id)) return Status::OK();
-    return Status(Substitute("Could not parse 'query_id' argument: $0", it->second));
+    return Status(Substitute("Could not parse '$0' argument: $1", to_find, it->second));
   }
 }
 
@@ -88,6 +89,9 @@ void ImpalaHttpHandler::RegisterHandlers(Webserver* webserver) {
   webserver->RegisterUrlCallback("/cancel_query", "common-pre.tmpl",
       MakeCallback(this, &ImpalaHttpHandler::CancelQueryHandler), false);
 
+  webserver->RegisterUrlCallback("/close_session", "common-pre.tmpl",
+      MakeCallback(this, &ImpalaHttpHandler::CloseSessionHandler), false);
+
   webserver->RegisterUrlCallback("/query_profile_encoded", "raw_text.tmpl",
       MakeCallback(this, &ImpalaHttpHandler::QueryProfileEncodedHandler), false);
 
@@ -133,7 +137,7 @@ void ImpalaHttpHandler::HadoopVarzHandler(const Webserver::ArgumentMap&
args,
 void ImpalaHttpHandler::CancelQueryHandler(const Webserver::ArgumentMap& args,
     Document* document) {
   TUniqueId unique_id;
-  Status status = ParseQueryId(args, &unique_id);
+  Status status = ParseIdFromArguments(args, &unique_id, "query_id");
   if (!status.ok()) {
     Value error(status.GetDetail().c_str(), document->GetAllocator());
     document->AddMember("error", error, document->GetAllocator());
@@ -150,10 +154,32 @@ void ImpalaHttpHandler::CancelQueryHandler(const Webserver::ArgumentMap&
args,
   document->AddMember("contents", message, document->GetAllocator());
 }
 
+void ImpalaHttpHandler::CloseSessionHandler(const Webserver::ArgumentMap& args,
+    Document* document) {
+  TUniqueId unique_id;
+  Status status = ParseIdFromArguments(args, &unique_id, "session_id");
+  if (!status.ok()) {
+    Value error(status.GetDetail().c_str(), document->GetAllocator());
+    document->AddMember("error", error, document->GetAllocator());
+    return;
+  }
+  Status cause("Session closed from Impala's debug web interface");
+  status = server_->CloseSessionInternal(unique_id, true);
+  if (!status.ok()) {
+    Value error(status.GetDetail().c_str(), document->GetAllocator());
+    document->AddMember("error", error, document->GetAllocator());
+    return;
+  }
+  stringstream ss;
+  ss << "Session " << unique_id << " closed successfully";
+  Value message(ss.str().c_str(), document->GetAllocator());
+  document->AddMember("contents", message, document->GetAllocator());
+}
+
 void ImpalaHttpHandler::QueryProfileHandler(const Webserver::ArgumentMap& args,
     Document* document) {
   TUniqueId unique_id;
-  Status parse_status = ParseQueryId(args, &unique_id);
+  Status parse_status = ParseIdFromArguments(args, &unique_id, "query_id");
   if (!parse_status.ok()) {
     Value error(parse_status.GetDetail().c_str(), document->GetAllocator());
     document->AddMember("error", error, document->GetAllocator());
@@ -178,7 +204,7 @@ void ImpalaHttpHandler::QueryProfileEncodedHandler(const Webserver::ArgumentMap&
     Document* document) {
   TUniqueId unique_id;
   stringstream ss;
-  Status status = ParseQueryId(args, &unique_id);
+  Status status = ParseIdFromArguments(args, &unique_id, "query_id");
   if (!status.ok()) {
     ss << status.GetDetail();
   } else {
@@ -609,7 +635,7 @@ void PlanToJson(const vector<TPlanFragment>& fragments, const
TExecSummary& summ
 void ImpalaHttpHandler::QuerySummaryHandler(bool include_json_plan, bool include_summary,
     const Webserver::ArgumentMap& args, Document* document) {
   TUniqueId query_id;
-  Status status = ParseQueryId(args, &query_id);
+  Status status = ParseIdFromArguments(args, &query_id, "query_id");
   if (!status.ok()) {
     // Redact the error message, it may contain part or all of the query.
     Value json_error(RedactCopy(status.GetDetail()).c_str(), document->GetAllocator());

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/d60b7076/be/src/service/impala-http-handler.h
----------------------------------------------------------------------
diff --git a/be/src/service/impala-http-handler.h b/be/src/service/impala-http-handler.h
index e5c41f9..443ab65 100644
--- a/be/src/service/impala-http-handler.h
+++ b/be/src/service/impala-http-handler.h
@@ -92,6 +92,10 @@ class ImpalaHttpHandler {
   void CancelQueryHandler(const Webserver::ArgumentMap& args,
       rapidjson::Document* document);
 
+  /// Closes an active session with a client.
+  void CloseSessionHandler(const Webserver::ArgumentMap& args,
+      rapidjson::Document* document);
+
   /// Upon return, 'document' will contain the query profile as a base64 encoded object in
   /// 'contents'.
   void QueryProfileEncodedHandler(const Webserver::ArgumentMap& args,

http://git-wip-us.apache.org/repos/asf/incubator-impala/blob/d60b7076/www/sessions.tmpl
----------------------------------------------------------------------
diff --git a/www/sessions.tmpl b/www/sessions.tmpl
index e8f541d..9d2de5d 100644
--- a/www/sessions.tmpl
+++ b/www/sessions.tmpl
@@ -34,6 +34,7 @@ There are {{num_sessions}} active sessions.
     <th>Expired</th>
     <th>Closed</th>
     <th>Ref count</th>
+    <th>Action</th>
   </tr>
 {{#sessions}}
   <tr>
@@ -51,6 +52,7 @@ There are {{num_sessions}} active sessions.
     <td>{{expired}}</td>
     <td>{{closed}}</td>
     <td>{{ref_count}}</td>
+    <td><a href='/close_session?session_id={{session_id}}'>Close Session</a></td>
   </tr>
 {{/sessions}}
 </table>


Mime
View raw message