Skip to content

Commit d8ddede

Browse files
Remove unnecessary case in EventLogDownloadResource.
1 parent ffffb53 commit d8ddede

File tree

3 files changed

+31
-38
lines changed

3 files changed

+31
-38
lines changed

core/src/main/scala/org/apache/spark/deploy/history/FsHistoryProvider.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import com.google.common.util.concurrent.{MoreExecutors, ThreadFactoryBuilder}
2727
import org.apache.hadoop.fs.{FileStatus, FileSystem, Path}
2828
import org.apache.hadoop.fs.permission.AccessControlException
2929

30-
import org.apache.spark.{SparkException, Logging, SecurityManager, SparkConf}
30+
import org.apache.spark.{Logging, SecurityManager, SparkConf, SparkException}
3131
import org.apache.spark.deploy.SparkHadoopUtil
3232
import org.apache.spark.io.CompressionCodec
3333
import org.apache.spark.scheduler._

core/src/main/scala/org/apache/spark/status/api/v1/ApiRootResource.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -205,10 +205,13 @@ private[spark] object ApiRootResource {
205205
private[spark] trait UIRoot {
206206
def getSparkUI(appKey: String): Option[SparkUI]
207207
def getApplicationInfoList: Iterator[ApplicationInfo]
208-
def writeEventLogs(
209-
appId: String,
210-
attemptId: Option[String],
211-
zipStream: ZipOutputStream): Unit = { }
208+
209+
def writeEventLogs(appId: String, attemptId: Option[String], zipStream: ZipOutputStream): Unit = {
210+
Response.serverError()
211+
.entity("Event logs are only available through the history server.")
212+
.status(Response.Status.SERVICE_UNAVAILABLE)
213+
.build()
214+
}
212215

213216
/**
214217
* Get the spark UI with the given appID, and apply a function

core/src/main/scala/org/apache/spark/status/api/v1/EventLogDownloadResource.scala

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ import scala.util.control.NonFatal
2525

2626
import org.apache.spark.{Logging, SparkConf}
2727
import org.apache.spark.deploy.SparkHadoopUtil
28-
import org.apache.spark.deploy.history.HistoryServer
2928

3029
@Produces(Array(MediaType.APPLICATION_OCTET_STREAM))
3130
private[v1] class EventLogDownloadResource(
@@ -36,43 +35,34 @@ private[v1] class EventLogDownloadResource(
3635

3736
@GET
3837
def getEventLogs(): Response = {
39-
uIRoot match {
40-
case hs: HistoryServer =>
41-
try {
42-
val fileName = {
43-
attemptId match {
44-
case Some(id) => s"eventLogs-$appId-$id.zip"
45-
case None => s"eventLogs-$appId.zip"
46-
}
47-
}
48-
49-
val stream = new StreamingOutput {
50-
override def write(output: OutputStream) = {
51-
val zipStream = new ZipOutputStream(output)
52-
try {
53-
hs.writeEventLogs(appId, attemptId, zipStream)
54-
} finally {
55-
zipStream.close()
56-
}
38+
try {
39+
val fileName = {
40+
attemptId match {
41+
case Some(id) => s"eventLogs-$appId-$id.zip"
42+
case None => s"eventLogs-$appId.zip"
43+
}
44+
}
5745

58-
}
46+
val stream = new StreamingOutput {
47+
override def write(output: OutputStream) = {
48+
val zipStream = new ZipOutputStream(output)
49+
try {
50+
uIRoot.writeEventLogs(appId, attemptId, zipStream)
51+
} finally {
52+
zipStream.close()
5953
}
6054

61-
Response.ok(stream)
62-
.header("Content-Disposition", s"attachment; filename=$fileName")
63-
.header("Content-Type", MediaType.APPLICATION_OCTET_STREAM)
64-
.build()
65-
66-
} catch {
67-
case NonFatal(e) =>
68-
Response.serverError()
69-
.entity(s"Event logs are not available for app: $appId.")
70-
.status(Response.Status.SERVICE_UNAVAILABLE)
71-
.build()
7255
}
73-
case _ =>
56+
}
57+
58+
Response.ok(stream)
59+
.header("Content-Disposition", s"attachment; filename=$fileName")
60+
.header("Content-Type", MediaType.APPLICATION_OCTET_STREAM)
61+
.build()
62+
} catch {
63+
case NonFatal(e) =>
7464
Response.serverError()
75-
.entity("Event logs are only available through the history server.")
65+
.entity(s"Event logs are not available for app: $appId.")
7666
.status(Response.Status.SERVICE_UNAVAILABLE)
7767
.build()
7868
}

0 commit comments

Comments
 (0)