|
17 | 17 |
|
18 | 18 | package org.apache.spark.scheduler |
19 | 19 |
|
| 20 | +import java.util.Properties |
| 21 | + |
20 | 22 | import scala.collection.mutable.{ArrayBuffer, HashSet, HashMap, Map} |
21 | 23 | import scala.language.reflectiveCalls |
22 | 24 | import scala.util.control.NonFatal |
@@ -234,9 +236,10 @@ class DAGSchedulerSuite |
234 | 236 | rdd: RDD[_], |
235 | 237 | partitions: Array[Int], |
236 | 238 | func: (TaskContext, Iterator[_]) => _ = jobComputeFunc, |
237 | | - listener: JobListener = jobListener): Int = { |
| 239 | + listener: JobListener = jobListener, |
| 240 | + properties: Properties = null): Int = { |
238 | 241 | val jobId = scheduler.nextJobId.getAndIncrement() |
239 | | - runEvent(JobSubmitted(jobId, rdd, func, partitions, CallSite("", ""), listener)) |
| 242 | + runEvent(JobSubmitted(jobId, rdd, func, partitions, CallSite("", ""), listener, properties)) |
240 | 243 | jobId |
241 | 244 | } |
242 | 245 |
|
@@ -749,6 +752,43 @@ class DAGSchedulerSuite |
749 | 752 | assertDataStructuresEmpty() |
750 | 753 | } |
751 | 754 |
|
| 755 | + /** |
| 756 | + * Makes sure that tasks for a stage used by multiple jobs are submitted with the properties of a |
| 757 | + * later, active job if they were previously run under a job that is no longer active |
| 758 | + */ |
| 759 | + test("stage used by two jobs, the first no longer active") { |
| 760 | + val baseRdd = new MyRDD(sc, 1, Nil) |
| 761 | + val finalRdd1 = new MyRDD(sc, 1, List(new OneToOneDependency(baseRdd))) |
| 762 | + val finalRdd2 = new MyRDD(sc, 1, List(new OneToOneDependency(baseRdd))) |
| 763 | + val job1Properties = new Properties() |
| 764 | + val job2Properties = new Properties() |
| 765 | + job1Properties.setProperty("testProperty", "job1") |
| 766 | + job2Properties.setProperty("testProperty", "job2") |
| 767 | + |
| 768 | + // run job1 |
| 769 | + val jobId1 = submit(finalRdd1, Array(0), properties = job1Properties) |
| 770 | + assert(scheduler.activeJobs.nonEmpty) |
| 771 | + val testProperty1 = scheduler.jobIdToActiveJob(jobId1).properties.getProperty("testProperty") |
| 772 | + |
| 773 | + // remove job1 as an ActiveJob |
| 774 | + cancel(jobId1) |
| 775 | + sc.listenerBus.waitUntilEmpty(WAIT_TIMEOUT_MILLIS) |
| 776 | + assert(sparkListener.failedStages.contains(0)) |
| 777 | + assert(sparkListener.failedStages.size === 1) |
| 778 | + assert(scheduler.activeJobs.isEmpty) |
| 779 | + |
| 780 | + // run job2 |
| 781 | + val jobId2 = submit(finalRdd2, Array(0), properties = job2Properties) |
| 782 | + assert(scheduler.activeJobs.nonEmpty) |
| 783 | + val testProperty2 = scheduler.jobIdToActiveJob(jobId2).properties.getProperty("testProperty") |
| 784 | + assert(testProperty1 != testProperty2) |
| 785 | + complete(taskSets(1), Seq((Success, 42))) |
| 786 | + assert(results === Map(0 -> 42)) |
| 787 | + assert(scheduler.activeJobs.isEmpty) |
| 788 | + |
| 789 | + assertDataStructuresEmpty() |
| 790 | + } |
| 791 | + |
752 | 792 | test("run trivial shuffle with out-of-band failure and retry") { |
753 | 793 | val shuffleMapRdd = new MyRDD(sc, 2, Nil) |
754 | 794 | val shuffleDep = new ShuffleDependency(shuffleMapRdd, null) |
|
0 commit comments