-
Notifications
You must be signed in to change notification settings - Fork 605
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## What changes were proposed in this pull request? The PR adds a new table in the Session tab dedicated to thrift-server sessions. The table contains the active sessions with a link to the corresponding Livy session. Moreover, the same information is also exposed through a REST endpoint (`"thriftserver/sessions"`). ## How was this patch tested? Manual tests. A screenshot of the UI is: ![screen shot 2018-10-09 at 11 32 18 am](https://user-images.githubusercontent.com/8821783/46660327-11082400-cbb7-11e8-9779-e8d85483dc97.png) Author: Marco Gaido <[email protected]> Closes #114 from mgaido91/LIVY-495.
- Loading branch information
Showing
8 changed files
with
222 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...erver/src/main/resources/org/apache/livy/server/ui/static/html/thrift-sessions-table.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<!-- | ||
Licensed to the Apache Software Foundation (ASF) under one or more | ||
contributor license agreements. See the NOTICE file distributed with | ||
this work for additional information regarding copyright ownership. | ||
The ASF licenses this file to You under the Apache License, Version 2.0 | ||
(the "License"); you may not use this file except in compliance with | ||
the License. You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
--> | ||
|
||
<h4 class="sessions-template">JDBC/ODBC Open Sessions</h4> | ||
|
||
<table id="thrift-sessions-table" | ||
class="table table-striped sessions-table sessions-template"> | ||
<thead class="sessions-table-head"> | ||
<tr> | ||
<th> | ||
<span data-toggle="tooltip" | ||
title="JDBC/ODBC session Id for the session"> | ||
Session Id | ||
</span> | ||
</th> | ||
<th> | ||
<span data-toggle="tooltip" | ||
title="Livy Interactive Session Id for this session. Links to the Session Summary Page"> | ||
Livy Session Id | ||
</span> | ||
</th> | ||
<th> | ||
<span data-toggle="tooltip" title="Remote user who submitted this session"> | ||
Owner | ||
</span> | ||
</th> | ||
<th> | ||
<span data-toggle="tooltip" | ||
title="Creation time of the session"> | ||
Created At | ||
</span> | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody class="sessions-table-body"> | ||
</tbody> | ||
</table> |
50 changes: 50 additions & 0 deletions
50
...ftserver/server/src/main/resources/org/apache/livy/server/ui/static/js/thrift-sessions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
function loadThriftSessionsTable(sessions) { | ||
$.each(sessions, function(index, session) { | ||
$("#thrift-sessions-table .sessions-table-body").append( | ||
"<tr>" + | ||
tdWrap(session.sessionId) + | ||
tdWrap(uiLink("session/" + session.livySessionId, session.livySessionId)) + | ||
tdWrap(session.owner) + | ||
tdWrap(session.createdAt) + | ||
"</tr>" | ||
); | ||
}); | ||
} | ||
|
||
var numSessions = 0; | ||
|
||
$(document).ready(function () { | ||
var sessionsReq = $.getJSON(location.origin + prependBasePath("/thriftserver/sessions"), function(response) { | ||
if (response && response.total > 0) { | ||
$("#thrift-sessions").load(prependBasePath("/static/html/thrift-sessions-table.html .sessions-template"), function() { | ||
loadThriftSessionsTable(response.sessions); | ||
$("#thrift-sessions-table").DataTable(); | ||
$('#thrift-sessions [data-toggle="tooltip"]').tooltip(); | ||
}); | ||
} | ||
numSessions = response.total; | ||
}); | ||
|
||
$.when(sessionsReq).done(function () { | ||
if (numSessions == 0) { | ||
$("#thrift-sessions").append('<h4>No open JDBC/ODBC sessions.</h4>'); | ||
} | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
thriftserver/server/src/main/scala/org/apache/livy/thriftserver/ui/ThriftJsonServlet.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.livy.thriftserver.ui | ||
|
||
import java.text.SimpleDateFormat | ||
|
||
import org.apache.livy.server.JsonServlet | ||
import org.apache.livy.thriftserver.LivyThriftServer | ||
|
||
|
||
class ThriftJsonServlet(val basePath: String) extends JsonServlet { | ||
|
||
private val df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z") | ||
|
||
case class SessionInfo( | ||
sessionId: String, | ||
livySessionId: String, | ||
owner: String, | ||
createdAt: String) | ||
|
||
get("/sessions") { | ||
val thriftSessions = LivyThriftServer.getInstance.map { server => | ||
val sessionManager = server.getSessionManager() | ||
sessionManager.getSessions.map { sessionHandle => | ||
val info = sessionManager.getSessionInfo(sessionHandle) | ||
SessionInfo(sessionHandle.getSessionId.toString, | ||
sessionManager.livySessionId(sessionHandle).map(_.toString).getOrElse(""), | ||
info.username, | ||
df.format(info.creationTime)) | ||
}.toSeq | ||
}.getOrElse(Seq.empty) | ||
val from = params.get("from").map(_.toInt).getOrElse(0) | ||
val size = params.get("size").map(_.toInt).getOrElse(100) | ||
|
||
Map( | ||
"from" -> from, | ||
"total" -> thriftSessions.length, | ||
"sessions" -> thriftSessions.view(from, from + size)) | ||
} | ||
} |