forked from apache/spark
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request apache#392 from palantir/rk/upstream
- Loading branch information
Showing
150 changed files
with
4,128 additions
and
724 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
core/src/main/scala/org/apache/spark/BarrierTaskContext.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.spark | ||
|
||
import org.apache.spark.annotation.{Experimental, Since} | ||
|
||
/** A [[TaskContext]] with extra info and tooling for a barrier stage. */ | ||
trait BarrierTaskContext extends TaskContext { | ||
|
||
/** | ||
* :: Experimental :: | ||
* Sets a global barrier and waits until all tasks in this stage hit this barrier. Similar to | ||
* MPI_Barrier function in MPI, the barrier() function call blocks until all tasks in the same | ||
* stage have reached this routine. | ||
*/ | ||
@Experimental | ||
@Since("2.4.0") | ||
def barrier(): Unit | ||
|
||
/** | ||
* :: Experimental :: | ||
* Returns the all task infos in this barrier stage, the task infos are ordered by partitionId. | ||
*/ | ||
@Experimental | ||
@Since("2.4.0") | ||
def getTaskInfos(): Array[BarrierTaskInfo] | ||
} |
49 changes: 49 additions & 0 deletions
49
core/src/main/scala/org/apache/spark/BarrierTaskContextImpl.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.spark | ||
|
||
import java.util.Properties | ||
|
||
import org.apache.spark.executor.TaskMetrics | ||
import org.apache.spark.memory.TaskMemoryManager | ||
import org.apache.spark.metrics.MetricsSystem | ||
|
||
/** A [[BarrierTaskContext]] implementation. */ | ||
private[spark] class BarrierTaskContextImpl( | ||
override val stageId: Int, | ||
override val stageAttemptNumber: Int, | ||
override val partitionId: Int, | ||
override val taskAttemptId: Long, | ||
override val attemptNumber: Int, | ||
override val taskMemoryManager: TaskMemoryManager, | ||
localProperties: Properties, | ||
@transient private val metricsSystem: MetricsSystem, | ||
// The default value is only used in tests. | ||
override val taskMetrics: TaskMetrics = TaskMetrics.empty) | ||
extends TaskContextImpl(stageId, stageAttemptNumber, partitionId, taskAttemptId, attemptNumber, | ||
taskMemoryManager, localProperties, metricsSystem, taskMetrics) | ||
with BarrierTaskContext { | ||
|
||
// TODO SPARK-24817 implement global barrier. | ||
override def barrier(): Unit = {} | ||
|
||
override def getTaskInfos(): Array[BarrierTaskInfo] = { | ||
val addressesStr = localProperties.getProperty("addresses", "") | ||
addressesStr.split(",").map(_.trim()).map(new BarrierTaskInfo(_)) | ||
} | ||
} |
31 changes: 31 additions & 0 deletions
31
core/src/main/scala/org/apache/spark/BarrierTaskInfo.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.spark | ||
|
||
import org.apache.spark.annotation.{Experimental, Since} | ||
|
||
|
||
/** | ||
* :: Experimental :: | ||
* Carries all task infos of a barrier task. | ||
* | ||
* @param address the IPv4 address(host:port) of the executor that a barrier task is running on | ||
*/ | ||
@Experimental | ||
@Since("2.4.0") | ||
class BarrierTaskInfo(val address: String) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
/* | ||
* Licensed to the Apache Software Foundation (ASF) under one or more | ||
* contributor license agreements. See the NOTICE file distributed with | ||
* this work for additional information regarding copyright ownership. | ||
* The ASF licenses this file to You under the Apache License, Version 2.0 | ||
* (the "License"); you may not use this file except in compliance with | ||
* the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.apache.spark.rdd | ||
|
||
import scala.reflect.ClassTag | ||
|
||
import org.apache.spark.BarrierTaskContext | ||
import org.apache.spark.TaskContext | ||
import org.apache.spark.annotation.{Experimental, Since} | ||
|
||
/** Represents an RDD barrier, which forces Spark to launch tasks of this stage together. */ | ||
class RDDBarrier[T: ClassTag](rdd: RDD[T]) { | ||
|
||
/** | ||
* :: Experimental :: | ||
* Maps partitions together with a provided BarrierTaskContext. | ||
* | ||
* `preservesPartitioning` indicates whether the input function preserves the partitioner, which | ||
* should be `false` unless `rdd` is a pair RDD and the input function doesn't modify the keys. | ||
*/ | ||
@Experimental | ||
@Since("2.4.0") | ||
def mapPartitions[S: ClassTag]( | ||
f: (Iterator[T], BarrierTaskContext) => Iterator[S], | ||
preservesPartitioning: Boolean = false): RDD[S] = rdd.withScope { | ||
val cleanedF = rdd.sparkContext.clean(f) | ||
new MapPartitionsRDD( | ||
rdd, | ||
(context: TaskContext, index: Int, iter: Iterator[T]) => | ||
cleanedF(iter, context.asInstanceOf[BarrierTaskContext]), | ||
preservesPartitioning, | ||
isFromBarrier = true | ||
) | ||
} | ||
|
||
/** TODO extra conf(e.g. timeout) */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.