shahidki31 commented on a change in pull request #26253: [SPARK-29599][WEBUI] 
Support pagination for session table in JDBC/ODBC Tab
URL: https://github.com/apache/spark/pull/26253#discussion_r339163045
 
 

 ##########
 File path: 
sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/ui/ThriftServerPage.scala
 ##########
 @@ -139,33 +138,60 @@ private[ui] class ThriftServerPage(parent: 
ThriftServerTab) extends WebUIPage(""
 
   /** Generate stats of batch sessions of the thrift server program */
   private def generateSessionStatsTable(request: HttpServletRequest): 
Seq[Node] = {
-    val sessionList = listener.getSessionList
-    val numBatches = sessionList.size
-    val table = if (numBatches > 0) {
-      val dataRows = sessionList.sortBy(_.startTimestamp).reverse
-      val headerRow = Seq("User", "IP", "Session ID", "Start Time", "Finish 
Time", "Duration",
-        "Total Execute")
-      def generateDataRow(session: SessionInfo): Seq[Node] = {
-        val sessionLink = "%s/%s/session/?id=%s".format(
-          UIUtils.prependBaseUri(request, parent.basePath), parent.prefix, 
session.sessionId)
-        <tr>
-          <td> {session.userName} </td>
-          <td> {session.ip} </td>
-          <td> <a href={sessionLink}> {session.sessionId} </a> </td>
-          <td> {formatDate(session.startTimestamp)} </td>
-          <td> {if (session.finishTimestamp > 0) 
formatDate(session.finishTimestamp)} </td>
-          <td sorttable_customkey={session.totalTime.toString}>
-            {formatDurationOption(Some(session.totalTime))} </td>
-          <td> {session.totalExecution.toString} </td>
-        </tr>
+    val numSessions = listener.getSessionList.size
+    val table = if (numSessions > 0) {
+
+      val sessionTableTag = "sessionstat"
+
+      val parameterOtherTable = request.getParameterMap().asScala
+        .filterNot(_._1.startsWith(sessionTableTag))
+        .map { case (name, vals) =>
+          name + "=" + vals(0)
+        }
+
+      val parameterSessionTablePage = 
request.getParameter(s"$sessionTableTag.page")
+      val parameterSessionTableSortColumn = 
request.getParameter(s"$sessionTableTag.sort")
+      val parameterSessionTableSortDesc = 
request.getParameter(s"$sessionTableTag.desc")
+      val parameterSessionPageSize = 
request.getParameter(s"$sessionTableTag.pageSize")
+
+      val sessionTablePage = 
Option(parameterSessionTablePage).map(_.toInt).getOrElse(1)
+      val sessionTableSortColumn = Option(parameterSessionTableSortColumn).map 
{ sortColumn =>
+        UIUtils.decodeURLParameter(sortColumn)
+      }.getOrElse("Start Time")
+      val sessionTableSortDesc = 
Option(parameterSessionTableSortDesc).map(_.toBoolean).getOrElse(
+        // Old session should be shown above new session by default.
+        !(sessionTableSortColumn == "Start Time")
 
 Review comment:
   @AngersZhuuuu By default new session should come above right? (Screenshot 
from master branch)
   ![Screenshot 2019-10-25 at 11 04 15 
PM](https://user-images.githubusercontent.com/23054875/67591803-dcdcb280-f77b-11e9-8b3e-c3828e5edbe0.png)
   
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to