spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From squito <...@git.apache.org>
Subject [GitHub] spark pull request: [SPARK-7161][History Server] Provide REST api ...
Date Wed, 13 May 2015 19:13:29 GMT
Github user squito commented on a diff in the pull request:

    https://github.com/apache/spark/pull/5792#discussion_r30265291
  
    --- Diff: core/src/main/scala/org/apache/spark/deploy/history/HistoryServer.scala ---
    @@ -104,6 +108,52 @@ class HistoryServer(
     
       initialize()
     
    +  private[spark] class HistoryServlet(val appId: String) extends HttpServlet {
    +
    +    // SPARK-5983 ensure TRACE is not supported
    +    protected override def doTrace(req: HttpServletRequest, res: HttpServletResponse):
Unit = {
    +      res.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED)
    +    }
    +
    +    protected override def doGet(req: HttpServletRequest, res: HttpServletResponse):
Unit = {
    +      try {
    +        val tempDir = Utils.createTempDir()
    +        Utils.chmod700(tempDir)
    +        provider.getApplicationEventLogs(appId, tempDir) match {
    +          case Some(file) =>
    +            val inStream = new FileInputStream(file)
    +            res.setContentType("application/zip")
    +            res.setHeader("Content-Disposition", s"attachment; filename=${file.getName}")
    +            val length = file.length()
    +            if (length <= Integer.MAX_VALUE) {
    +              res.setContentLength(length.toInt)
    +            } else {
    +              res.setHeader("Content-Length", length.toString)
    +            }
    +            val buffer = new Array[Byte](1024 * 1024)
    +            val outputStream = res.getOutputStream
    +            var remaining = true
    +            while (remaining) {
    +              val read = inStream.read(buffer)
    +              if (read != -1) {
    +                outputStream.write(buffer, 0, read)
    +              } else {
    +                remaining = false
    +              }
    +            }
    +            outputStream.flush()
    +
    +          case None =>
    +            res.sendError(HttpServletResponse.SC_NO_CONTENT)
    +        }
    +        Utils.deleteRecursively(tempDir)
    --- End diff --
    
    should this go in a `finally`?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message