Skip to content

Commit

Permalink
making rest calls sequential
Browse files Browse the repository at this point in the history
  • Loading branch information
swasti committed Apr 10, 2018
1 parent 4ebd4b9 commit 7c1e88b
Showing 1 changed file with 18 additions and 31 deletions.
49 changes: 18 additions & 31 deletions app/com/linkedin/drelephant/spark/fetchers/SparkRestClient.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,45 +81,32 @@ class SparkRestClient(sparkConf: SparkConf) {
val (applicationInfo, attemptTarget) = getApplicationMetaData(appId)

Future {
val futureJobDatas = Future {
getJobDatas(attemptTarget)
}
val futureStageDatas = Future {
getStageDatas(attemptTarget)
}
val futureExecutorSummaries = Future {
getExecutorSummaries(attemptTarget)
}

val futureFailedTaskData = Future {
getStagesWithFailedTasks(attemptTarget)
}
val futureLogData = if (fetchLogs) {
Future {
getLogData(attemptTarget)
}
} else Future.successful(None)
val jobDatas = getJobDatas(attemptTarget)
val stageDatas = getStageDatas(attemptTarget)
val executorSummaries = getExecutorSummaries(attemptTarget)
val failedTaskData = getStagesWithFailedTasks(attemptTarget)
val logData = if (fetchLogs) {
getLogData(attemptTarget)
} else None

if (fetchFailedTasks) {
val futureFailedTasksDatas = Future {
getStagesWithFailedTasks(attemptTarget)
}
val failedTasksDatas = getStagesWithFailedTasks(attemptTarget)

SparkRestDerivedData(
applicationInfo,
Await.result(futureJobDatas, DEFAULT_TIMEOUT),
Await.result(futureStageDatas, DEFAULT_TIMEOUT),
Await.result(futureExecutorSummaries, DEFAULT_TIMEOUT),
Await.result(futureFailedTasksDatas, DEFAULT_TIMEOUT),
Await.result(futureLogData, DEFAULT_TIMEOUT))
jobDatas,
stageDatas,
executorSummaries,
failedTasksDatas,
logData)
} else {
SparkRestDerivedData(
applicationInfo,
Await.result(futureJobDatas, DEFAULT_TIMEOUT),
Await.result(futureStageDatas, DEFAULT_TIMEOUT),
Await.result(futureExecutorSummaries, DEFAULT_TIMEOUT),
jobDatas,
stageDatas,
executorSummaries,
Seq.empty,
Await.result(futureLogData, DEFAULT_TIMEOUT)
)
logData)
}
}
}
Expand Down

1 comment on commit 7c1e88b

@jasonkoo
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do you want to do this ?

Please sign in to comment.