Skip to content

Commit 1d1169b

Browse files
bsikandernoorul
authored andcommitted
refactor(jobserver): removed deprecated getJobConfigs (spark-jobserver#943)
Remove unused getJobConfigs from all over. Due to performance reasons it was deprecated and doing new changes to some parts of *DAO require changes to this part, which is not cool.
1 parent d9f8b66 commit 1d1169b

File tree

9 files changed

+2
-72
lines changed

9 files changed

+2
-72
lines changed

job-server/src/main/scala/spark/jobserver/io/JobCassandraDAO.scala

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -298,16 +298,6 @@ class JobCassandraDAO(config: Config) extends JobDAO with FileCacher {
298298
}
299299
}
300300

301-
override def getJobConfigs: Future[Map[String, Config]] = {
302-
val query = QB.select(Metadata.JobId, Metadata.JobConfig).from(Metadata.JobsTable)
303-
session.executeAsync(query).map { rs =>
304-
JListWrapper(rs.all()).map { row =>
305-
val config = Option(row.getString(Metadata.JobConfig)).getOrElse("")
306-
(row.getUUID(Metadata.JobId).toString, ConfigFactory.parseString(config))
307-
}.toMap
308-
}
309-
}
310-
311301
override def getJobConfig(jobId: String): Future[Option[Config]] = {
312302
val query = QB.select(Metadata.JobConfig).from(Metadata.JobsTable)
313303
.where(QB.eq(Metadata.JobId, UUID.fromString(jobId)))

job-server/src/main/scala/spark/jobserver/io/JobDAO.scala

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,14 +172,6 @@ trait JobDAO {
172172
*/
173173
def saveJobConfig(jobId: String, jobConfig: Config)
174174

175-
/**
176-
* Return all job ids to their job configuration.
177-
* @todo remove. used only in test
178-
* @return
179-
*/
180-
@deprecated("Leads to performance problems and OutOfMemory error ultimately", "0.7.1")
181-
def getJobConfigs: Future[Map[String, Config]]
182-
183175
/**
184176
* Returns a config for a given jobId
185177
* @return

job-server/src/main/scala/spark/jobserver/io/JobDAOActor.scala

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,6 @@ object JobDAOActor {
3636
case class GetJobInfos(limit: Int) extends JobDAORequest
3737

3838
case class SaveJobConfig(jobId: String, jobConfig: Config) extends JobDAORequest
39-
@deprecated("Leads to performance problems and OutOfMemory error ultimately", "0.7.1")
40-
case object GetJobConfigs extends JobDAORequest
4139
case class GetJobConfig(jobId: String) extends JobDAORequest
4240
case class CleanContextJobInfos(contextName: String, endTime: DateTime)
4341

@@ -49,7 +47,6 @@ object JobDAOActor {
4947
case class BinaryPath(binPath: String) extends JobDAOResponse
5048
case class BinaryContent(content: Array[Byte]) extends JobDAOResponse
5149
case class JobInfos(jobInfos: Seq[JobInfo]) extends JobDAOResponse
52-
case class JobConfigs(jobConfigs: Map[String, Config]) extends JobDAOResponse
5350
case class JobConfig(jobConfig: Option[Config]) extends JobDAOResponse
5451
case class LastUploadTimeAndType(uploadTimeAndType: Option[(DateTime, BinaryType)]) extends JobDAOResponse
5552

@@ -89,9 +86,6 @@ class JobDAOActor(dao: JobDAO) extends InstrumentedActor {
8986
case SaveJobConfig(jobId, jobConfig) =>
9087
dao.saveJobConfig(jobId, jobConfig)
9188

92-
case GetJobConfigs =>
93-
dao.getJobConfigs.map(JobConfigs).pipeTo(sender)
94-
9589
case GetJobConfig(jobId) =>
9690
dao.getJobConfig(jobId).map(JobConfig).pipeTo(sender)
9791

job-server/src/main/scala/spark/jobserver/io/JobFileDAO.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,6 @@ class JobFileDAO(config: Config) extends JobDAO {
220220
configs(jobId) = jobConfig
221221
}
222222

223-
override def getJobConfigs: Future[Map[String, Config]] = Future { configs.toMap }
224-
225223
override def getJobConfig(jobId: String): Future[Option[Config]] = Future {
226224
configs.get(jobId)
227225
}

job-server/src/main/scala/spark/jobserver/io/JobSqlDAO.scala

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -231,14 +231,6 @@ class JobSqlDAO(config: Config) extends JobDAO with FileCacher {
231231
// Convert from java.sql.Timestamp to joda DateTime
232232
private def convertDateSqlToJoda(timestamp: Timestamp): DateTime = new DateTime(timestamp.getTime)
233233

234-
override def getJobConfigs: Future[Map[String, Config]] = {
235-
for (r <- db.run(configs.result)) yield {
236-
r.map {
237-
case (jobId, jobConfig) => jobId -> ConfigFactory.parseString(jobConfig)
238-
}.toMap
239-
}
240-
}
241-
242234
override def getJobConfig(jobId: String): Future[Option[Config]] = {
243235
val query = configs
244236
.filter(_.jobId === jobId).map(_.jobConfig).result

job-server/src/test/scala/spark/jobserver/InMemoryDAO.scala

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,6 @@ class InMemoryDAO extends JobDAO {
7777

7878
override def saveJobConfig(jobId: String, jobConfig: Config) { jobConfigs(jobId) = jobConfig }
7979

80-
override def getJobConfigs: Future[Map[String, Config]] = Future {
81-
jobConfigs.toMap
82-
}
83-
8480
override def getJobConfig(jobId: String): Future[Option[Config]] = Future {
8581
jobConfigs.get(jobId)
8682
}

job-server/src/test/scala/spark/jobserver/io/JobCassandraDAOSpec.scala

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,7 @@ class JobCassandraDAOSpec extends TestJarFinder with FunSpecLike with Matchers w
152152
}
153153
}
154154

155-
describe("saveJobConfig() and getJobConfigs() tests") {
156-
it("should provide an empty map on getJobConfigs() for an empty CONFIGS table") {
157-
val configs = Await.result(dao.getJobConfigs, timeout)
158-
(Map.empty[String, Config]) should equal (configs)
159-
}
160-
155+
describe("saveJobConfig() tests") {
161156
it("should provide None on getJobConfig(jobId) where there is no config for a given jobId") {
162157
val config = Await.result(dao.getJobConfig("44c32fe1-38a4-11e1-a06a-485d60c81a3e"), timeout)
163158
config shouldBe None
@@ -167,26 +162,19 @@ class JobCassandraDAOSpec extends TestJarFinder with FunSpecLike with Matchers w
167162
// save job config
168163
dao.saveJobConfig(jobId, jobConfig)
169164

170-
// get all configs
171-
val configs = Await.result(dao.getJobConfigs, timeout)
172165
val config = Await.result(dao.getJobConfig(jobId), timeout).get
173166

174167
// test
175-
configs.keySet should equal (Set(jobId))
176-
configs(jobId) should equal (expectedConfig)
177168
config should equal (expectedConfig)
178169
}
179170

180171
it("should be able to get previously saved config") {
181172
// config saved in prior test
182173

183174
// get job configs
184-
val configs = Await.result(dao.getJobConfigs, timeout)
185175
val config = Await.result(dao.getJobConfig(jobId), timeout).get
186176

187177
// test
188-
configs.keySet should equal (Set(jobId))
189-
configs(jobId) should equal (expectedConfig)
190178
config should equal (expectedConfig)
191179
}
192180

@@ -204,14 +192,10 @@ class JobCassandraDAOSpec extends TestJarFinder with FunSpecLike with Matchers w
204192
dao = new JobCassandraDAO(config)
205193

206194
// Get all configs
207-
val configs = Await.result(dao.getJobConfigs, timeout)
208195
val jobIdConfig = Await.result(dao.getJobConfig(jobId), timeout).get
209196
val jobId2Config = Await.result(dao.getJobConfig(jobId2), timeout).get
210197

211198
// test
212-
configs.keySet should equal (Set(jobId, jobId2))
213-
configs.values.toSeq should contain (expectedConfig)
214-
configs.values.toSeq should contain (expectedConfig2)
215199
jobIdConfig should equal (expectedConfig)
216200
jobId2Config should equal (expectedConfig2)
217201
}

job-server/src/test/scala/spark/jobserver/io/JobDAOActorSpec.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,6 @@ object JobDAOActorSpec {
5959

6060
override def saveJobInfo(jobInfo: JobInfo): Unit = ???
6161

62-
override def getJobConfigs: Future[Map[String, Config]] = ???
63-
6462
override def getJobConfig(jobId: String): Future[Option[Config]] = ???
6563

6664
override def deleteBinary(appName: String): Unit = {

job-server/src/test/scala/spark/jobserver/io/JobSqlDAOSpec.scala

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -178,11 +178,7 @@ class JobSqlDAOSpec extends JobSqlDAOSpecBase with TestJarFinder with FunSpecLik
178178
}
179179
}
180180

181-
describe("saveJobConfig() and getJobConfigs() tests") {
182-
it("should provide an empty map on getJobConfigs() for an empty CONFIGS table") {
183-
Map.empty[String, Config] should equal (Await.result(dao.getJobConfigs, timeout))
184-
}
185-
181+
describe("saveJobConfig() tests") {
186182
it("should provide None on getJobConfig(jobId) where there is no config for a given jobId") {
187183
val config = Await.result(dao.getJobConfig("44c32fe1-38a4-11e1-a06a-485d60c81a3e"), timeout)
188184
config shouldBe None
@@ -193,25 +189,18 @@ class JobSqlDAOSpec extends JobSqlDAOSpecBase with TestJarFinder with FunSpecLik
193189
dao.saveJobConfig(jobId, jobConfig)
194190

195191
// get all configs
196-
val configs = Await.result(dao.getJobConfigs, timeout)
197192
val config = Await.result(dao.getJobConfig(jobId), timeout).get
198193

199194
// test
200-
configs.keySet should equal (Set(jobId))
201-
configs(jobId) should equal (expectedConfig)
202195
config should equal (expectedConfig)
203196
}
204197

205198
it("should be able to get previously saved config") {
206199
// config saved in prior test
207200

208-
// get job configs
209-
val configs = Await.result(dao.getJobConfigs, timeout)
210201
val config = Await.result(dao.getJobConfig(jobId), timeout).get
211202

212203
// test
213-
configs.keySet should equal (Set(jobId))
214-
configs(jobId) should equal (expectedConfig)
215204
config should equal (expectedConfig)
216205
}
217206

@@ -229,13 +218,10 @@ class JobSqlDAOSpec extends JobSqlDAOSpecBase with TestJarFinder with FunSpecLik
229218
dao = new JobSqlDAO(config)
230219

231220
// Get all configs
232-
val configs = Await.result(dao.getJobConfigs, timeout)
233221
val jobIdConfig = Await.result(dao.getJobConfig(jobId), timeout).get
234222
val jobId2Config = Await.result(dao.getJobConfig(jobId2), timeout).get
235223

236224
// test
237-
configs.keySet should equal (Set(jobId, jobId2))
238-
configs.values.toSeq should equal (Seq(expectedConfig, expectedConfig2))
239225
jobIdConfig should equal (expectedConfig)
240226
jobId2Config should equal (expectedConfig2)
241227
}

0 commit comments

Comments
 (0)