[GitHub] [spark] shahidki31 commented on a change in pull request #26253: [SPARK-29599][WEBUI] Support pagination for session table in JDBC/ODBC Tab
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_r339061591 ## File path: sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/ui/ThriftServerPage.scala ## @@ -442,3 +627,45 @@ private[ui] class SqlStatsPagedTable( } } + + private[ui] class SessionStatsTableDataSource( +info: Seq[SessionInfo], +pageSize: Int, +sortColumn: String, +desc: Boolean) extends PagedDataSource[SessionInfo](pageSize) { + +// Sorting SessionInfo data +private val data = info.sorted(ordering(sortColumn, desc)) + +private var _slicedStartTime: Set[Long] = null + +override def dataSize: Int = data.size + +override def sliceData(from: Int, to: Int): Seq[SessionInfo] = { + val r = data.slice(from, to) + r.map(x => x) Review comment: Yes, we can remove the line. 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: us...@infra.apache.org With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] [spark] shahidki31 commented on a change in pull request #26253: [SPARK-29599][WEBUI] Support pagination for session table in JDBC/ODBC Tab
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_r339060123 ## File path: sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/ui/ThriftServerPage.scala ## @@ -377,6 +404,164 @@ private[ui] class SqlStatsPagedTable( "%s/jobs/job/?id=%s".format(UIUtils.prependBaseUri(request, parent.basePath), jobId) } +private[ui] class SessionStatsPagedTable( +request: HttpServletRequest, +parent: ThriftServerTab, +data: Seq[SessionInfo], +subPath: String, +basePath: String, +parameterOtherTable: Iterable[String], +sessionStatsTableTag: String, +pageSize: Int, +sortColumn: String, +desc: Boolean) extends PagedTable[SessionInfo] { + + override val dataSource = new SessionStatsTableDataSource(data, pageSize, sortColumn, desc) + + private val parameterPath = s"$basePath/$subPath/?${parameterOtherTable.mkString("&")}" + + override def tableId: String = sessionStatsTableTag + + override def tableCssClass: String = +"table table-bordered table-condensed table-striped " + + "table-head-clickable table-cell-width-limited" + + override def pageLink(page: Int): String = { +val encodedSortColumn = URLEncoder.encode(sortColumn, UTF_8.name()) +parameterPath + + s"&$pageNumberFormField=$page" + + s"&$sessionStatsTableTag.sort=$encodedSortColumn" + + s"&$sessionStatsTableTag.desc=$desc" + + s"&$pageSizeFormField=$pageSize" + } + + override def pageSizeFormField: String = s"$sessionStatsTableTag.pageSize" + + override def pageNumberFormField: String = s"$sessionStatsTableTag.page" + + override def goButtonFormPath: String = { +val encodedSortColumn = URLEncoder.encode(sortColumn, UTF_8.name()) + s"$parameterPath&$sessionStatsTableTag.sort=$encodedSortColumn&$sessionStatsTableTag.desc=$desc" + } + + override def headers: Seq[Node] = { +val sessionTableHeaders = + Seq("User", "IP", "Session ID", "Start Time", "Finish Time", "Duration", "Total Execute") + +val tooltips = Seq[Option[String]](None, None, None, None, None, None, None) + +assert(sessionTableHeaders.length == tooltips.length) + +val headerRow: Seq[Node] = { + sessionTableHeaders.zip(tooltips).map { case (header, tooltip) => +if (header == sortColumn) { + val headerLink = Unparsed( +parameterPath + + s"&$sessionStatsTableTag.sort=${URLEncoder.encode(header, UTF_8.name())}" + + s"&$sessionStatsTableTag.desc=${!desc}" + + s"&$sessionStatsTableTag.pageSize=$pageSize" + + s"#$sessionStatsTableTag") + val arrow = if (desc) "▾" else "▴" // UP or DOWN + + if (tooltip.nonEmpty) { + + + + {header} {Unparsed(arrow)} + + + + } else { + + +{header} {Unparsed(arrow)} + + + } +} else { + val headerLink = Unparsed( +parameterPath + + s"&$sessionStatsTableTag.sort=${URLEncoder.encode(header, UTF_8.name())}" + + s"&$sessionStatsTableTag.pageSize=$pageSize" + + s"#$sessionStatsTableTag") + + if(tooltip.nonEmpty) { + + + + {header} + + + + } else { + + +{header} + + + } +} + } +} + + {headerRow} + + } + + override def row(session: SessionInfo): Seq[Node] = { +val sessionLink = "%s/%s/session/?id=%s".format( + UIUtils.prependBaseUri(request, parent.basePath), parent.prefix, session.sessionId) + + {session.userName} + {session.ip} +{session.sessionId} + {formatDate(session.startTimestamp)} + {if (session.finishTimestamp > 0) formatDate(session.finishTimestamp)} + +{formatDurationOption(Some(session.totalTime))} + {session.totalExecution.toString} + + } + + /** + * Returns a human-readable string representing a duration such as "5 second 35 ms" + */ + private def formatDurationOption(msOption: Option[Long]): String = { +msOption.map(formatDurationVerbose).getOrElse("-") + } + + private def errorMessageCell(errorMessage: String): Seq[Node] = { +val isMultiline = errorMessage.indexOf('\n') >= 0 Review comment: Is this method used anywhere? 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 conta
[GitHub] [spark] shahidki31 commented on a change in pull request #26253: [SPARK-29599][WEBUI] Support pagination for session table in JDBC/ODBC Tab
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_r339060339 ## File path: sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/ui/ThriftServerPage.scala ## @@ -377,6 +404,164 @@ private[ui] class SqlStatsPagedTable( "%s/jobs/job/?id=%s".format(UIUtils.prependBaseUri(request, parent.basePath), jobId) } +private[ui] class SessionStatsPagedTable( +request: HttpServletRequest, +parent: ThriftServerTab, +data: Seq[SessionInfo], +subPath: String, +basePath: String, +parameterOtherTable: Iterable[String], +sessionStatsTableTag: String, +pageSize: Int, +sortColumn: String, +desc: Boolean) extends PagedTable[SessionInfo] { + + override val dataSource = new SessionStatsTableDataSource(data, pageSize, sortColumn, desc) + + private val parameterPath = s"$basePath/$subPath/?${parameterOtherTable.mkString("&")}" + + override def tableId: String = sessionStatsTableTag + + override def tableCssClass: String = +"table table-bordered table-condensed table-striped " + + "table-head-clickable table-cell-width-limited" + + override def pageLink(page: Int): String = { +val encodedSortColumn = URLEncoder.encode(sortColumn, UTF_8.name()) +parameterPath + + s"&$pageNumberFormField=$page" + + s"&$sessionStatsTableTag.sort=$encodedSortColumn" + + s"&$sessionStatsTableTag.desc=$desc" + + s"&$pageSizeFormField=$pageSize" + } + + override def pageSizeFormField: String = s"$sessionStatsTableTag.pageSize" + + override def pageNumberFormField: String = s"$sessionStatsTableTag.page" + + override def goButtonFormPath: String = { +val encodedSortColumn = URLEncoder.encode(sortColumn, UTF_8.name()) + s"$parameterPath&$sessionStatsTableTag.sort=$encodedSortColumn&$sessionStatsTableTag.desc=$desc" + } + + override def headers: Seq[Node] = { +val sessionTableHeaders = + Seq("User", "IP", "Session ID", "Start Time", "Finish Time", "Duration", "Total Execute") + +val tooltips = Seq[Option[String]](None, None, None, None, None, None, None) + +assert(sessionTableHeaders.length == tooltips.length) + +val headerRow: Seq[Node] = { + sessionTableHeaders.zip(tooltips).map { case (header, tooltip) => +if (header == sortColumn) { + val headerLink = Unparsed( +parameterPath + + s"&$sessionStatsTableTag.sort=${URLEncoder.encode(header, UTF_8.name())}" + + s"&$sessionStatsTableTag.desc=${!desc}" + + s"&$sessionStatsTableTag.pageSize=$pageSize" + + s"#$sessionStatsTableTag") + val arrow = if (desc) "▾" else "▴" // UP or DOWN + + if (tooltip.nonEmpty) { + + + + {header} {Unparsed(arrow)} + + + + } else { + + +{header} {Unparsed(arrow)} + + + } +} else { + val headerLink = Unparsed( +parameterPath + + s"&$sessionStatsTableTag.sort=${URLEncoder.encode(header, UTF_8.name())}" + + s"&$sessionStatsTableTag.pageSize=$pageSize" + + s"#$sessionStatsTableTag") + + if(tooltip.nonEmpty) { + + + + {header} + + + + } else { + + +{header} + + + } +} + } +} + + {headerRow} + + } + + override def row(session: SessionInfo): Seq[Node] = { +val sessionLink = "%s/%s/session/?id=%s".format( + UIUtils.prependBaseUri(request, parent.basePath), parent.prefix, session.sessionId) + + {session.userName} + {session.ip} +{session.sessionId} + {formatDate(session.startTimestamp)} + {if (session.finishTimestamp > 0) formatDate(session.finishTimestamp)} + +{formatDurationOption(Some(session.totalTime))} + {session.totalExecution.toString} + + } + + /** + * Returns a human-readable string representing a duration such as "5 second 35 ms" + */ + private def formatDurationOption(msOption: Option[Long]): String = { +msOption.map(formatDurationVerbose).getOrElse("-") + } + + private def errorMessageCell(errorMessage: String): Seq[Node] = { +val isMultiline = errorMessage.indexOf('\n') >= 0 +val errorSummary = StringEscapeUtils.escapeHtml4( + if (isMultiline) { +errorMessage.substring(0, errorMessage.indexOf('\n')) + } else { +errorMessage + }) +val details = if (isMultiline) { + // scalastyle:off + ++ details + ++ + + +
[GitHub] [spark] shahidki31 commented on a change in pull request #26253: [SPARK-29599][WEBUI] Support pagination for session table in JDBC/ODBC Tab
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_r339068783 ## File path: sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/ui/ThriftServerPage.scala ## @@ -377,6 +404,133 @@ private[ui] class SqlStatsPagedTable( "%s/jobs/job/?id=%s".format(UIUtils.prependBaseUri(request, parent.basePath), jobId) } +private[ui] class SessionStatsPagedTable( +request: HttpServletRequest, +parent: ThriftServerTab, +data: Seq[SessionInfo], +subPath: String, +basePath: String, +parameterOtherTable: Iterable[String], +sessionStatsTableTag: String, +pageSize: Int, +sortColumn: String, +desc: Boolean) extends PagedTable[SessionInfo] { + + override val dataSource = new SessionStatsTableDataSource(data, pageSize, sortColumn, desc) + + private val parameterPath = s"$basePath/$subPath/?${parameterOtherTable.mkString("&")}" + + override def tableId: String = sessionStatsTableTag + + override def tableCssClass: String = +"table table-bordered table-condensed table-striped " + + "table-head-clickable table-cell-width-limited" + + override def pageLink(page: Int): String = { +val encodedSortColumn = URLEncoder.encode(sortColumn, UTF_8.name()) +parameterPath + + s"&$pageNumberFormField=$page" + + s"&$sessionStatsTableTag.sort=$encodedSortColumn" + + s"&$sessionStatsTableTag.desc=$desc" + + s"&$pageSizeFormField=$pageSize" + } + + override def pageSizeFormField: String = s"$sessionStatsTableTag.pageSize" + + override def pageNumberFormField: String = s"$sessionStatsTableTag.page" + + override def goButtonFormPath: String = { +val encodedSortColumn = URLEncoder.encode(sortColumn, UTF_8.name()) + s"$parameterPath&$sessionStatsTableTag.sort=$encodedSortColumn&$sessionStatsTableTag.desc=$desc" + } + + override def headers: Seq[Node] = { +val sessionTableHeaders = + Seq("User", "IP", "Session ID", "Start Time", "Finish Time", "Duration", "Total Execute") + +val tooltips = Seq[Option[String]](None, None, None, None, None, None, None) Review comment: Do we need `tooltips` for the table? 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: us...@infra.apache.org With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] [spark] shahidki31 commented on a change in pull request #26253: [SPARK-29599][WEBUI] Support pagination for session table in JDBC/ODBC Tab
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_r339079554 ## File path: sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/ui/ThriftServerPage.scala ## @@ -377,6 +404,133 @@ private[ui] class SqlStatsPagedTable( "%s/jobs/job/?id=%s".format(UIUtils.prependBaseUri(request, parent.basePath), jobId) } +private[ui] class SessionStatsPagedTable( +request: HttpServletRequest, +parent: ThriftServerTab, +data: Seq[SessionInfo], +subPath: String, +basePath: String, +parameterOtherTable: Iterable[String], +sessionStatsTableTag: String, +pageSize: Int, +sortColumn: String, +desc: Boolean) extends PagedTable[SessionInfo] { + + override val dataSource = new SessionStatsTableDataSource(data, pageSize, sortColumn, desc) + + private val parameterPath = s"$basePath/$subPath/?${parameterOtherTable.mkString("&")}" + + override def tableId: String = sessionStatsTableTag + + override def tableCssClass: String = +"table table-bordered table-condensed table-striped " + + "table-head-clickable table-cell-width-limited" + + override def pageLink(page: Int): String = { +val encodedSortColumn = URLEncoder.encode(sortColumn, UTF_8.name()) +parameterPath + + s"&$pageNumberFormField=$page" + + s"&$sessionStatsTableTag.sort=$encodedSortColumn" + + s"&$sessionStatsTableTag.desc=$desc" + + s"&$pageSizeFormField=$pageSize" + } + + override def pageSizeFormField: String = s"$sessionStatsTableTag.pageSize" + + override def pageNumberFormField: String = s"$sessionStatsTableTag.page" + + override def goButtonFormPath: String = { +val encodedSortColumn = URLEncoder.encode(sortColumn, UTF_8.name()) + s"$parameterPath&$sessionStatsTableTag.sort=$encodedSortColumn&$sessionStatsTableTag.desc=$desc" + } + + override def headers: Seq[Node] = { +val sessionTableHeaders = + Seq("User", "IP", "Session ID", "Start Time", "Finish Time", "Duration", "Total Execute") + +val tooltips = Seq[Option[String]](None, None, None, None, None, None, None) Review comment: I think there is already a PR working on it, related to tool tips here, https://github.com/apache/spark/pull/26138 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: us...@infra.apache.org With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] [spark] shahidki31 commented on a change in pull request #26253: [SPARK-29599][WEBUI] Support pagination for session table in JDBC/ODBC Tab
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_r339079990 ## File path: sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/ui/ThriftServerPage.scala ## @@ -377,6 +404,133 @@ private[ui] class SqlStatsPagedTable( "%s/jobs/job/?id=%s".format(UIUtils.prependBaseUri(request, parent.basePath), jobId) } +private[ui] class SessionStatsPagedTable( +request: HttpServletRequest, +parent: ThriftServerTab, +data: Seq[SessionInfo], +subPath: String, +basePath: String, +parameterOtherTable: Iterable[String], +sessionStatsTableTag: String, +pageSize: Int, +sortColumn: String, +desc: Boolean) extends PagedTable[SessionInfo] { + + override val dataSource = new SessionStatsTableDataSource(data, pageSize, sortColumn, desc) + + private val parameterPath = s"$basePath/$subPath/?${parameterOtherTable.mkString("&")}" + + override def tableId: String = sessionStatsTableTag + + override def tableCssClass: String = +"table table-bordered table-condensed table-striped " + + "table-head-clickable table-cell-width-limited" + + override def pageLink(page: Int): String = { +val encodedSortColumn = URLEncoder.encode(sortColumn, UTF_8.name()) +parameterPath + + s"&$pageNumberFormField=$page" + + s"&$sessionStatsTableTag.sort=$encodedSortColumn" + + s"&$sessionStatsTableTag.desc=$desc" + + s"&$pageSizeFormField=$pageSize" + } + + override def pageSizeFormField: String = s"$sessionStatsTableTag.pageSize" + + override def pageNumberFormField: String = s"$sessionStatsTableTag.page" + + override def goButtonFormPath: String = { +val encodedSortColumn = URLEncoder.encode(sortColumn, UTF_8.name()) + s"$parameterPath&$sessionStatsTableTag.sort=$encodedSortColumn&$sessionStatsTableTag.desc=$desc" + } + + override def headers: Seq[Node] = { +val sessionTableHeaders = + Seq("User", "IP", "Session ID", "Start Time", "Finish Time", "Duration", "Total Execute") + +val tooltips = Seq[Option[String]](None, None, None, None, None, None, None) + +assert(sessionTableHeaders.length == tooltips.length) + +val headerRow: Seq[Node] = { + sessionTableHeaders.zip(tooltips).map { case (header, tooltip) => +if (header == sortColumn) { + val headerLink = Unparsed( +parameterPath + + s"&$sessionStatsTableTag.sort=${URLEncoder.encode(header, UTF_8.name())}" + + s"&$sessionStatsTableTag.desc=${!desc}" + + s"&$sessionStatsTableTag.pageSize=$pageSize" + + s"#$sessionStatsTableTag") + val arrow = if (desc) "▾" else "▴" // UP or DOWN + + if (tooltip.nonEmpty) { + + + + {header} {Unparsed(arrow)} + + + + } else { + + +{header} {Unparsed(arrow)} + + + } +} else { + val headerLink = Unparsed( +parameterPath + + s"&$sessionStatsTableTag.sort=${URLEncoder.encode(header, UTF_8.name())}" + + s"&$sessionStatsTableTag.pageSize=$pageSize" + + s"#$sessionStatsTableTag") + + if(tooltip.nonEmpty) { + + + + {header} + + + + } else { + + +{header} + + + } +} + } +} + + {headerRow} + + } + + override def row(session: SessionInfo): Seq[Node] = { +val sessionLink = "%s/%s/session/?id=%s".format( + UIUtils.prependBaseUri(request, parent.basePath), parent.prefix, session.sessionId) + + {session.userName} + {session.ip} +{session.sessionId} + {formatDate(session.startTimestamp)} + {if (session.finishTimestamp > 0) formatDate(session.finishTimestamp)} + +{formatDurationOption(Some(session.totalTime))} Review comment: I think, we can directly call `UIUtils.formatDurationOption` , because `totalTime` is always defined. Also can remove the method `formatDurationOption` 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: us...@infra.apache.org With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] [spark] shahidki31 commented on a change in pull request #26253: [SPARK-29599][WEBUI] Support pagination for session table in JDBC/ODBC Tab
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_r339079990 ## File path: sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/ui/ThriftServerPage.scala ## @@ -377,6 +404,133 @@ private[ui] class SqlStatsPagedTable( "%s/jobs/job/?id=%s".format(UIUtils.prependBaseUri(request, parent.basePath), jobId) } +private[ui] class SessionStatsPagedTable( +request: HttpServletRequest, +parent: ThriftServerTab, +data: Seq[SessionInfo], +subPath: String, +basePath: String, +parameterOtherTable: Iterable[String], +sessionStatsTableTag: String, +pageSize: Int, +sortColumn: String, +desc: Boolean) extends PagedTable[SessionInfo] { + + override val dataSource = new SessionStatsTableDataSource(data, pageSize, sortColumn, desc) + + private val parameterPath = s"$basePath/$subPath/?${parameterOtherTable.mkString("&")}" + + override def tableId: String = sessionStatsTableTag + + override def tableCssClass: String = +"table table-bordered table-condensed table-striped " + + "table-head-clickable table-cell-width-limited" + + override def pageLink(page: Int): String = { +val encodedSortColumn = URLEncoder.encode(sortColumn, UTF_8.name()) +parameterPath + + s"&$pageNumberFormField=$page" + + s"&$sessionStatsTableTag.sort=$encodedSortColumn" + + s"&$sessionStatsTableTag.desc=$desc" + + s"&$pageSizeFormField=$pageSize" + } + + override def pageSizeFormField: String = s"$sessionStatsTableTag.pageSize" + + override def pageNumberFormField: String = s"$sessionStatsTableTag.page" + + override def goButtonFormPath: String = { +val encodedSortColumn = URLEncoder.encode(sortColumn, UTF_8.name()) + s"$parameterPath&$sessionStatsTableTag.sort=$encodedSortColumn&$sessionStatsTableTag.desc=$desc" + } + + override def headers: Seq[Node] = { +val sessionTableHeaders = + Seq("User", "IP", "Session ID", "Start Time", "Finish Time", "Duration", "Total Execute") + +val tooltips = Seq[Option[String]](None, None, None, None, None, None, None) + +assert(sessionTableHeaders.length == tooltips.length) + +val headerRow: Seq[Node] = { + sessionTableHeaders.zip(tooltips).map { case (header, tooltip) => +if (header == sortColumn) { + val headerLink = Unparsed( +parameterPath + + s"&$sessionStatsTableTag.sort=${URLEncoder.encode(header, UTF_8.name())}" + + s"&$sessionStatsTableTag.desc=${!desc}" + + s"&$sessionStatsTableTag.pageSize=$pageSize" + + s"#$sessionStatsTableTag") + val arrow = if (desc) "▾" else "▴" // UP or DOWN + + if (tooltip.nonEmpty) { + + + + {header} {Unparsed(arrow)} + + + + } else { + + +{header} {Unparsed(arrow)} + + + } +} else { + val headerLink = Unparsed( +parameterPath + + s"&$sessionStatsTableTag.sort=${URLEncoder.encode(header, UTF_8.name())}" + + s"&$sessionStatsTableTag.pageSize=$pageSize" + + s"#$sessionStatsTableTag") + + if(tooltip.nonEmpty) { + + + + {header} + + + + } else { + + +{header} + + + } +} + } +} + + {headerRow} + + } + + override def row(session: SessionInfo): Seq[Node] = { +val sessionLink = "%s/%s/session/?id=%s".format( + UIUtils.prependBaseUri(request, parent.basePath), parent.prefix, session.sessionId) + + {session.userName} + {session.ip} +{session.sessionId} + {formatDate(session.startTimestamp)} + {if (session.finishTimestamp > 0) formatDate(session.finishTimestamp)} + +{formatDurationOption(Some(session.totalTime))} Review comment: I think, we can directly call `UIUtils.formatDurationVerbose` , because `totalTime` is always defined. Also can remove the method `formatDurationOption` 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: us...@infra.apache.org With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] [spark] shahidki31 commented on a change in pull request #26253: [SPARK-29599][WEBUI] Support pagination for session table in JDBC/ODBC Tab
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) - - {session.userName} - {session.ip} -{session.sessionId} - {formatDate(session.startTimestamp)} - {if (session.finishTimestamp > 0) formatDate(session.finishTimestamp)} - -{formatDurationOption(Some(session.totalTime))} - {session.totalExecution.toString} - +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: @AngersZh 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: us...@infra.apache.org With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] [spark] shahidki31 commented on a change in pull request #26253: [SPARK-29599][WEBUI] Support pagination for session table in JDBC/ODBC Tab
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_r339345359 ## 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) - - {session.userName} - {session.ip} -{session.sessionId} - {formatDate(session.startTimestamp)} - {if (session.finishTimestamp > 0) formatDate(session.finishTimestamp)} - -{formatDurationOption(Some(session.totalTime))} - {session.totalExecution.toString} - +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( +// New session should be shown above old session by default. +(sessionTableSortColumn == "Start Time") + ) + val sessionTablePageSize = Option(parameterSessionPageSize).map(_.toInt).getOrElse(100) + + try { +Some(new SessionStatsPagedTable( + request, + parent, + listener.getSessionList, + "sqlserver", + UIUtils.prependBaseUri(request, parent.basePath), + parameterOtherTable, + sessionTableTag, + pageSize = sessionTablePageSize, + sortColumn = sessionTableSortColumn, + desc = sessionTableSortDesc +).table(sessionTablePage)) + } catch { +case e@(_: IllegalArgumentException | _: IndexOutOfBoundsException) => + Some( +Error while rendering job table: + + {Utils.exceptionString(e)} + + ) } - Some(UIUtils.listingTable(headerRow, generateDataRow, dataRows, true, None, Seq(null), false)) Review comment: nit: Here for the sessions table `fixedWidth` is true. right? Are we making the paged table also fixed width? 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: us...@infra.apache.org With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] [spark] shahidki31 commented on a change in pull request #26253: [SPARK-29599][WEBUI] Support pagination for session table in JDBC/ODBC Tab
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_r339345258 ## File path: sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/ui/ThriftServerPage.scala ## @@ -370,6 +389,102 @@ private[ui] class SqlStatsPagedTable( "%s/jobs/job/?id=%s".format(UIUtils.prependBaseUri(request, parent.basePath), jobId) } +private[ui] class SessionStatsPagedTable( +request: HttpServletRequest, +parent: ThriftServerTab, +data: Seq[SessionInfo], +subPath: String, +basePath: String, +parameterOtherTable: Iterable[String], +sessionStatsTableTag: String, +pageSize: Int, +sortColumn: String, +desc: Boolean) extends PagedTable[SessionInfo] { + + override val dataSource = new SessionStatsTableDataSource(data, pageSize, sortColumn, desc) + + private val parameterPath = s"$basePath/$subPath/?${parameterOtherTable.mkString("&")}" + + override def tableId: String = sessionStatsTableTag + + override def tableCssClass: String = +"table table-bordered table-condensed table-striped " + + "table-head-clickable table-cell-width-limited" + + override def pageLink(page: Int): String = { +val encodedSortColumn = URLEncoder.encode(sortColumn, UTF_8.name()) +parameterPath + + s"&$pageNumberFormField=$page" + + s"&$sessionStatsTableTag.sort=$encodedSortColumn" + + s"&$sessionStatsTableTag.desc=$desc" + + s"&$pageSizeFormField=$pageSize" + } + + override def pageSizeFormField: String = s"$sessionStatsTableTag.pageSize" + + override def pageNumberFormField: String = s"$sessionStatsTableTag.page" + + override def goButtonFormPath: String = { +val encodedSortColumn = URLEncoder.encode(sortColumn, UTF_8.name()) + s"$parameterPath&$sessionStatsTableTag.sort=$encodedSortColumn&$sessionStatsTableTag.desc=$desc" + } + + override def headers: Seq[Node] = { +val sessionTableHeaders = + Seq("User", "IP", "Session ID", "Start Time", "Finish Time", "Duration", "Total Execute") + +val headerRow: Seq[Node] = { + sessionTableHeaders.map { case header => +if (header == sortColumn) { + val headerLink = Unparsed( +parameterPath + + s"&$sessionStatsTableTag.sort=${URLEncoder.encode(header, UTF_8.name())}" + + s"&$sessionStatsTableTag.desc=${!desc}" + + s"&$sessionStatsTableTag.pageSize=$pageSize" + + s"#$sessionStatsTableTag") + val arrow = if (desc) "▾" else "▴" // UP or DOWN + + + + {header} {Unparsed(arrow)} + + +} else { + val headerLink = Unparsed( +parameterPath + + s"&$sessionStatsTableTag.sort=${URLEncoder.encode(header, UTF_8.name())}" + + s"&$sessionStatsTableTag.pageSize=$pageSize" + + s"#$sessionStatsTableTag") + + + + {header} + + +} + } +} + + {headerRow} + + } + + override def row(session: SessionInfo): Seq[Node] = { +val sessionLink = "%s/%s/session/?id=%s".format( + UIUtils.prependBaseUri(request, parent.basePath), parent.prefix, session.sessionId) + + {session.userName} + {session.ip} +{session.sessionId} + {formatDate(session.startTimestamp)} + {if (session.finishTimestamp > 0) formatDate(session.finishTimestamp)} + Review comment: nit: Is it necessary to add `sorttable_customkey` as we are already sorting using raw data inn `ordering` method? 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: us...@infra.apache.org With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] [spark] shahidki31 commented on a change in pull request #26253: [SPARK-29599][WEBUI] Support pagination for session table in JDBC/ODBC Tab
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_r339345258 ## File path: sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/ui/ThriftServerPage.scala ## @@ -370,6 +389,102 @@ private[ui] class SqlStatsPagedTable( "%s/jobs/job/?id=%s".format(UIUtils.prependBaseUri(request, parent.basePath), jobId) } +private[ui] class SessionStatsPagedTable( +request: HttpServletRequest, +parent: ThriftServerTab, +data: Seq[SessionInfo], +subPath: String, +basePath: String, +parameterOtherTable: Iterable[String], +sessionStatsTableTag: String, +pageSize: Int, +sortColumn: String, +desc: Boolean) extends PagedTable[SessionInfo] { + + override val dataSource = new SessionStatsTableDataSource(data, pageSize, sortColumn, desc) + + private val parameterPath = s"$basePath/$subPath/?${parameterOtherTable.mkString("&")}" + + override def tableId: String = sessionStatsTableTag + + override def tableCssClass: String = +"table table-bordered table-condensed table-striped " + + "table-head-clickable table-cell-width-limited" + + override def pageLink(page: Int): String = { +val encodedSortColumn = URLEncoder.encode(sortColumn, UTF_8.name()) +parameterPath + + s"&$pageNumberFormField=$page" + + s"&$sessionStatsTableTag.sort=$encodedSortColumn" + + s"&$sessionStatsTableTag.desc=$desc" + + s"&$pageSizeFormField=$pageSize" + } + + override def pageSizeFormField: String = s"$sessionStatsTableTag.pageSize" + + override def pageNumberFormField: String = s"$sessionStatsTableTag.page" + + override def goButtonFormPath: String = { +val encodedSortColumn = URLEncoder.encode(sortColumn, UTF_8.name()) + s"$parameterPath&$sessionStatsTableTag.sort=$encodedSortColumn&$sessionStatsTableTag.desc=$desc" + } + + override def headers: Seq[Node] = { +val sessionTableHeaders = + Seq("User", "IP", "Session ID", "Start Time", "Finish Time", "Duration", "Total Execute") + +val headerRow: Seq[Node] = { + sessionTableHeaders.map { case header => +if (header == sortColumn) { + val headerLink = Unparsed( +parameterPath + + s"&$sessionStatsTableTag.sort=${URLEncoder.encode(header, UTF_8.name())}" + + s"&$sessionStatsTableTag.desc=${!desc}" + + s"&$sessionStatsTableTag.pageSize=$pageSize" + + s"#$sessionStatsTableTag") + val arrow = if (desc) "▾" else "▴" // UP or DOWN + + + + {header} {Unparsed(arrow)} + + +} else { + val headerLink = Unparsed( +parameterPath + + s"&$sessionStatsTableTag.sort=${URLEncoder.encode(header, UTF_8.name())}" + + s"&$sessionStatsTableTag.pageSize=$pageSize" + + s"#$sessionStatsTableTag") + + + + {header} + + +} + } +} + + {headerRow} + + } + + override def row(session: SessionInfo): Seq[Node] = { +val sessionLink = "%s/%s/session/?id=%s".format( + UIUtils.prependBaseUri(request, parent.basePath), parent.prefix, session.sessionId) + + {session.userName} + {session.ip} +{session.sessionId} + {formatDate(session.startTimestamp)} + {if (session.finishTimestamp > 0) formatDate(session.finishTimestamp)} + Review comment: nit: Is it necessary to add `sorttable_customkey` as we are already sorting using raw data in `ordering` method? 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: us...@infra.apache.org With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org
[GitHub] [spark] shahidki31 commented on a change in pull request #26253: [SPARK-29599][WEBUI] Support pagination for session table in JDBC/ODBC Tab
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_r339346361 ## File path: sql/hive-thriftserver/src/main/scala/org/apache/spark/sql/hive/thriftserver/ui/ThriftServerPage.scala ## @@ -370,6 +389,102 @@ private[ui] class SqlStatsPagedTable( "%s/jobs/job/?id=%s".format(UIUtils.prependBaseUri(request, parent.basePath), jobId) } +private[ui] class SessionStatsPagedTable( +request: HttpServletRequest, +parent: ThriftServerTab, +data: Seq[SessionInfo], +subPath: String, +basePath: String, +parameterOtherTable: Iterable[String], +sessionStatsTableTag: String, +pageSize: Int, +sortColumn: String, +desc: Boolean) extends PagedTable[SessionInfo] { + + override val dataSource = new SessionStatsTableDataSource(data, pageSize, sortColumn, desc) + + private val parameterPath = s"$basePath/$subPath/?${parameterOtherTable.mkString("&")}" + + override def tableId: String = sessionStatsTableTag + + override def tableCssClass: String = +"table table-bordered table-condensed table-striped " + + "table-head-clickable table-cell-width-limited" + + override def pageLink(page: Int): String = { +val encodedSortColumn = URLEncoder.encode(sortColumn, UTF_8.name()) +parameterPath + + s"&$pageNumberFormField=$page" + + s"&$sessionStatsTableTag.sort=$encodedSortColumn" + + s"&$sessionStatsTableTag.desc=$desc" + + s"&$pageSizeFormField=$pageSize" + } + + override def pageSizeFormField: String = s"$sessionStatsTableTag.pageSize" + + override def pageNumberFormField: String = s"$sessionStatsTableTag.page" + + override def goButtonFormPath: String = { +val encodedSortColumn = URLEncoder.encode(sortColumn, UTF_8.name()) + s"$parameterPath&$sessionStatsTableTag.sort=$encodedSortColumn&$sessionStatsTableTag.desc=$desc" + } + + override def headers: Seq[Node] = { +val sessionTableHeaders = + Seq("User", "IP", "Session ID", "Start Time", "Finish Time", "Duration", "Total Execute") + +val headerRow: Seq[Node] = { + sessionTableHeaders.map { case header => +if (header == sortColumn) { + val headerLink = Unparsed( +parameterPath + + s"&$sessionStatsTableTag.sort=${URLEncoder.encode(header, UTF_8.name())}" + + s"&$sessionStatsTableTag.desc=${!desc}" + + s"&$sessionStatsTableTag.pageSize=$pageSize" + + s"#$sessionStatsTableTag") + val arrow = if (desc) "▾" else "▴" // UP or DOWN + + + + {header} {Unparsed(arrow)} + + +} else { + val headerLink = Unparsed( +parameterPath + + s"&$sessionStatsTableTag.sort=${URLEncoder.encode(header, UTF_8.name())}" + + s"&$sessionStatsTableTag.pageSize=$pageSize" + + s"#$sessionStatsTableTag") + + + + {header} + + +} + } +} + + {headerRow} + + } + + override def row(session: SessionInfo): Seq[Node] = { +val sessionLink = "%s/%s/session/?id=%s".format( + UIUtils.prependBaseUri(request, parent.basePath), parent.prefix, session.sessionId) + + {session.userName} + {session.ip} +{session.sessionId} + {formatDate(session.startTimestamp)} + {if (session.finishTimestamp > 0) formatDate(session.finishTimestamp)} + Review comment: Also, please confirm if the sorting is working properly after changing this. Thanks 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: us...@infra.apache.org With regards, Apache Git Services - To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org