Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions core/src/main/scala/org/apache/spark/SparkContext.scala
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,8 @@ class SparkContext(config: SparkConf) extends Logging {
.foreach(logLevel => _schedulerBackend.updateExecutorsLogLevel(logLevel))
}

_conf.get(CHECKPOINT_DIR).foreach(setCheckpointDir)

val _executorMetricsSource =
if (_conf.get(METRICS_EXECUTORMETRICS_SOURCE_ENABLED)) {
Some(new ExecutorMetricsSource)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1317,6 +1317,15 @@ package object config {
s" be less than or equal to ${ByteArrayMethods.MAX_ROUNDED_ARRAY_LENGTH}.")
.createWithDefault(64 * 1024 * 1024)

private[spark] val CHECKPOINT_DIR =
ConfigBuilder("spark.checkpoint.dir")
.doc(
"Set the default directory for checkpointing. It can be overwritten by " +
"SparkContext.setCheckpointDir.")
.version("4.0.0")
.stringConf
.createOptional

private[spark] val CHECKPOINT_COMPRESS =
ConfigBuilder("spark.checkpoint.compress")
.doc("Whether to compress RDD checkpoints. Generally a good idea. Compression will use " +
Expand Down
16 changes: 16 additions & 0 deletions core/src/test/scala/org/apache/spark/CheckpointSuite.scala
Original file line number Diff line number Diff line change
Expand Up @@ -669,4 +669,20 @@ class CheckpointStorageSuite extends SparkFunSuite with LocalSparkContext {
assert(rdd.firstParent.isInstanceOf[ReliableCheckpointRDD[_]])
}
}

test("SPARK-48268: checkpoint directory via configuration") {
withTempDir { checkpointDir =>
val conf = new SparkConf()
.set("spark.checkpoint.dir", checkpointDir.toString)
.set(UI_ENABLED.key, "false")
sc = new SparkContext("local", "test", conf)
val parCollection = sc.makeRDD(1 to 4)
val flatMappedRDD = parCollection.flatMap(x => 1 to x)
flatMappedRDD.checkpoint()
assert(flatMappedRDD.dependencies.head.rdd === parCollection)
val result = flatMappedRDD.collect()
assert(flatMappedRDD.dependencies.head.rdd != parCollection)
assert(flatMappedRDD.collect() === result)
}
}
}
9 changes: 9 additions & 0 deletions docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -1795,6 +1795,15 @@ Apart from these, the following properties are also available, and may be useful
</td>
<td>0.6.0</td>
</tr>
<tr>
<td><code>spark.checkpoint.dir</code></td>
<td>(none)</td>
<td>
Set the default directory for checkpointing. It can be overwritten by
SparkContext.setCheckpointDir.
</td>
<td>4.0.0</td>
</tr>
<tr>
<td><code>spark.checkpoint.compress</code></td>
<td>false</td>
Expand Down