Skip to content

Commit 66df1a5

Browse files
committed
Merge remote-tracking branch 'apache/master' into streaming-ui-fix
2 parents ad98bc9 + 4660991 commit 66df1a5

File tree

149 files changed

+1487
-636
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

149 files changed

+1487
-636
lines changed

assembly/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
<properties>
3535
<spark.jar.dir>scala-${scala.binary.version}</spark.jar.dir>
36-
<spark.jar.basename>${project.artifactId}-${project.version}-hadoop${hadoop.version}.jar</spark.jar.basename>
36+
<spark.jar.basename>spark-assembly-${project.version}-hadoop${hadoop.version}.jar</spark.jar.basename>
3737
<spark.jar>${project.build.directory}/${spark.jar.dir}/${spark.jar.basename}</spark.jar>
3838
<deb.pkg.name>spark</deb.pkg.name>
3939
<deb.install.path>/usr/share/spark</deb.install.path>

bin/compute-classpath.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ if [ -f "$ASSEMBLY_DIR"/spark-assembly*hadoop*-deps.jar ]; then
5050
else
5151
# Else use spark-assembly jar from either RELEASE or assembly directory
5252
if [ -f "$FWDIR/RELEASE" ]; then
53-
ASSEMBLY_JAR=`ls "$FWDIR"/jars/spark*-assembly*.jar`
53+
ASSEMBLY_JAR=`ls "$FWDIR"/lib/spark-assembly*hadoop*.jar`
5454
else
55-
ASSEMBLY_JAR=`ls "$ASSEMBLY_DIR"/spark*-assembly*hadoop*.jar`
55+
ASSEMBLY_JAR=`ls "$ASSEMBLY_DIR"/spark-assembly*hadoop*.jar`
5656
fi
5757
CLASSPATH="$CLASSPATH:$ASSEMBLY_JAR"
5858
fi

bin/run-example

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,15 @@ fi
4040
# Figure out the JAR file that our examples were packaged into. This includes a bit of a hack
4141
# to avoid the -sources and -doc packages that are built by publish-local.
4242
EXAMPLES_DIR="$FWDIR"/examples
43-
SPARK_EXAMPLES_JAR=""
44-
if [ -e "$EXAMPLES_DIR"/target/scala-$SCALA_VERSION/*assembly*[0-9Tg].jar ]; then
45-
export SPARK_EXAMPLES_JAR=`ls "$EXAMPLES_DIR"/target/scala-$SCALA_VERSION/*assembly*[0-9Tg].jar`
43+
44+
if [ -f "$FWDIR/RELEASE" ]; then
45+
export SPARK_EXAMPLES_JAR=`ls "$FWDIR"/lib/spark-examples-*hadoop*.jar`
46+
elif [ -e "$EXAMPLES_DIR"/target/scala-$SCALA_VERSION/spark-examples-*hadoop*.jar ]; then
47+
export SPARK_EXAMPLES_JAR=`ls "$EXAMPLES_DIR"/target/scala-$SCALA_VERSION/spark-examples-*hadoop*.jar`
4648
fi
49+
4750
if [[ -z $SPARK_EXAMPLES_JAR ]]; then
48-
echo "Failed to find Spark examples assembly in $FWDIR/examples/target" >&2
51+
echo "Failed to find Spark examples assembly in $FWDIR/lib or $FWDIR/examples/target" >&2
4952
echo "You need to build Spark with sbt/sbt assembly before running this program" >&2
5053
exit 1
5154
fi

conf/spark-env.sh.template

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
# Options read when launching programs locally with
77
# ./bin/run-example or ./bin/spark-submit
8+
# - HADOOP_CONF_DIR, to point Spark towards Hadoop configuration files
89
# - SPARK_LOCAL_IP, to set the IP address Spark binds to on this node
910
# - SPARK_PUBLIC_DNS, to set the public dns name of the driver program
1011
# - SPARK_CLASSPATH, default classpath entries to append
@@ -17,6 +18,7 @@
1718
# - MESOS_NATIVE_LIBRARY, to point to your libmesos.so if you use Mesos
1819

1920
# Options read in YARN client mode
21+
# - HADOOP_CONF_DIR, to point Spark towards Hadoop configuration files
2022
# - SPARK_EXECUTOR_INSTANCES, Number of workers to start (Default: 2)
2123
# - SPARK_EXECUTOR_CORES, Number of cores for the workers (Default: 1).
2224
# - SPARK_EXECUTOR_MEMORY, Memory per Worker (e.g. 1000M, 2G) (Default: 1G)

core/src/main/scala/org/apache/spark/Accumulators.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,8 +104,11 @@ class Accumulable[R, T] (
104104
* Set the accumulator's value; only allowed on master.
105105
*/
106106
def value_= (newValue: R) {
107-
if (!deserialized) value_ = newValue
108-
else throw new UnsupportedOperationException("Can't assign accumulator value in task")
107+
if (!deserialized) {
108+
value_ = newValue
109+
} else {
110+
throw new UnsupportedOperationException("Can't assign accumulator value in task")
111+
}
109112
}
110113

111114
/**

core/src/main/scala/org/apache/spark/CacheManager.scala

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ private[spark] class CacheManager(blockManager: BlockManager) extends Logging {
4747
if (loading.contains(key)) {
4848
logInfo("Another thread is loading %s, waiting for it to finish...".format(key))
4949
while (loading.contains(key)) {
50-
try {loading.wait()} catch {case _ : Throwable =>}
50+
try {
51+
loading.wait()
52+
} catch {
53+
case e: Exception =>
54+
logWarning(s"Got an exception while waiting for another thread to load $key", e)
55+
}
5156
}
5257
logInfo("Finished waiting for %s".format(key))
5358
/* See whether someone else has successfully loaded it. The main way this would fail
@@ -72,7 +77,9 @@ private[spark] class CacheManager(blockManager: BlockManager) extends Logging {
7277
val computedValues = rdd.computeOrReadCheckpoint(split, context)
7378

7479
// Persist the result, so long as the task is not running locally
75-
if (context.runningLocally) { return computedValues }
80+
if (context.runningLocally) {
81+
return computedValues
82+
}
7683

7784
// Keep track of blocks with updated statuses
7885
var updatedBlocks = Seq[(BlockId, BlockStatus)]()
@@ -88,7 +95,7 @@ private[spark] class CacheManager(blockManager: BlockManager) extends Logging {
8895
updatedBlocks = blockManager.put(key, computedValues, storageLevel, tellMaster = true)
8996
blockManager.get(key) match {
9097
case Some(values) =>
91-
new InterruptibleIterator(context, values.asInstanceOf[Iterator[T]])
98+
values.asInstanceOf[Iterator[T]]
9299
case None =>
93100
logInfo("Failure to store %s".format(key))
94101
throw new Exception("Block manager failed to return persisted valued")
@@ -107,7 +114,7 @@ private[spark] class CacheManager(blockManager: BlockManager) extends Logging {
107114
val metrics = context.taskMetrics
108115
metrics.updatedBlocks = Some(updatedBlocks)
109116

110-
returnValue
117+
new InterruptibleIterator(context, returnValue)
111118

112119
} finally {
113120
loading.synchronized {

core/src/main/scala/org/apache/spark/InterruptibleIterator.scala

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,17 @@ package org.apache.spark
2424
private[spark] class InterruptibleIterator[+T](val context: TaskContext, val delegate: Iterator[T])
2525
extends Iterator[T] {
2626

27-
def hasNext: Boolean = !context.interrupted && delegate.hasNext
27+
def hasNext: Boolean = {
28+
// TODO(aarondav/rxin): Check Thread.interrupted instead of context.interrupted if interrupt
29+
// is allowed. The assumption is that Thread.interrupted does not have a memory fence in read
30+
// (just a volatile field in C), while context.interrupted is a volatile in the JVM, which
31+
// introduces an expensive read fence.
32+
if (context.interrupted) {
33+
throw new TaskKilledException
34+
} else {
35+
delegate.hasNext
36+
}
37+
}
2838

2939
def next(): T = delegate.next()
3040
}

core/src/main/scala/org/apache/spark/SparkContext.scala

Lines changed: 41 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -216,10 +216,33 @@ class SparkContext(config: SparkConf) extends Logging {
216216
private[spark] val ui = new SparkUI(this)
217217
ui.bind()
218218

219+
/** A default Hadoop Configuration for the Hadoop code (e.g. file systems) that we reuse. */
220+
val hadoopConfiguration: Configuration = {
221+
val env = SparkEnv.get
222+
val hadoopConf = SparkHadoopUtil.get.newConfiguration()
223+
// Explicitly check for S3 environment variables
224+
if (System.getenv("AWS_ACCESS_KEY_ID") != null &&
225+
System.getenv("AWS_SECRET_ACCESS_KEY") != null) {
226+
hadoopConf.set("fs.s3.awsAccessKeyId", System.getenv("AWS_ACCESS_KEY_ID"))
227+
hadoopConf.set("fs.s3n.awsAccessKeyId", System.getenv("AWS_ACCESS_KEY_ID"))
228+
hadoopConf.set("fs.s3.awsSecretAccessKey", System.getenv("AWS_SECRET_ACCESS_KEY"))
229+
hadoopConf.set("fs.s3n.awsSecretAccessKey", System.getenv("AWS_SECRET_ACCESS_KEY"))
230+
}
231+
// Copy any "spark.hadoop.foo=bar" system properties into conf as "foo=bar"
232+
conf.getAll.foreach { case (key, value) =>
233+
if (key.startsWith("spark.hadoop.")) {
234+
hadoopConf.set(key.substring("spark.hadoop.".length), value)
235+
}
236+
}
237+
val bufferSize = conf.get("spark.buffer.size", "65536")
238+
hadoopConf.set("io.file.buffer.size", bufferSize)
239+
hadoopConf
240+
}
241+
219242
// Optionally log Spark events
220243
private[spark] val eventLogger: Option[EventLoggingListener] = {
221244
if (conf.getBoolean("spark.eventLog.enabled", false)) {
222-
val logger = new EventLoggingListener(appName, conf)
245+
val logger = new EventLoggingListener(appName, conf, hadoopConfiguration)
223246
logger.start()
224247
listenerBus.addListener(logger)
225248
Some(logger)
@@ -294,29 +317,6 @@ class SparkContext(config: SparkConf) extends Logging {
294317
postEnvironmentUpdate()
295318
postApplicationStart()
296319

297-
/** A default Hadoop Configuration for the Hadoop code (e.g. file systems) that we reuse. */
298-
val hadoopConfiguration: Configuration = {
299-
val env = SparkEnv.get
300-
val hadoopConf = SparkHadoopUtil.get.newConfiguration()
301-
// Explicitly check for S3 environment variables
302-
if (System.getenv("AWS_ACCESS_KEY_ID") != null &&
303-
System.getenv("AWS_SECRET_ACCESS_KEY") != null) {
304-
hadoopConf.set("fs.s3.awsAccessKeyId", System.getenv("AWS_ACCESS_KEY_ID"))
305-
hadoopConf.set("fs.s3n.awsAccessKeyId", System.getenv("AWS_ACCESS_KEY_ID"))
306-
hadoopConf.set("fs.s3.awsSecretAccessKey", System.getenv("AWS_SECRET_ACCESS_KEY"))
307-
hadoopConf.set("fs.s3n.awsSecretAccessKey", System.getenv("AWS_SECRET_ACCESS_KEY"))
308-
}
309-
// Copy any "spark.hadoop.foo=bar" system properties into conf as "foo=bar"
310-
conf.getAll.foreach { case (key, value) =>
311-
if (key.startsWith("spark.hadoop.")) {
312-
hadoopConf.set(key.substring("spark.hadoop.".length), value)
313-
}
314-
}
315-
val bufferSize = conf.get("spark.buffer.size", "65536")
316-
hadoopConf.set("io.file.buffer.size", bufferSize)
317-
hadoopConf
318-
}
319-
320320
private[spark] var checkpointDir: Option[String] = None
321321

322322
// Thread Local variable that can be used by users to pass information down the stack
@@ -381,16 +381,27 @@ class SparkContext(config: SparkConf) extends Logging {
381381
* // In a separate thread:
382382
* sc.cancelJobGroup("some_job_to_cancel")
383383
* }}}
384+
*
385+
* If interruptOnCancel is set to true for the job group, then job cancellation will result
386+
* in Thread.interrupt() being called on the job's executor threads. This is useful to help ensure
387+
* that the tasks are actually stopped in a timely manner, but is off by default due to HDFS-1208,
388+
* where HDFS may respond to Thread.interrupt() by marking nodes as dead.
384389
*/
385-
def setJobGroup(groupId: String, description: String) {
390+
def setJobGroup(groupId: String, description: String, interruptOnCancel: Boolean = false) {
386391
setLocalProperty(SparkContext.SPARK_JOB_DESCRIPTION, description)
387392
setLocalProperty(SparkContext.SPARK_JOB_GROUP_ID, groupId)
393+
// Note: Specifying interruptOnCancel in setJobGroup (rather than cancelJobGroup) avoids
394+
// changing several public APIs and allows Spark cancellations outside of the cancelJobGroup
395+
// APIs to also take advantage of this property (e.g., internal job failures or canceling from
396+
// JobProgressTab UI) on a per-job basis.
397+
setLocalProperty(SparkContext.SPARK_JOB_INTERRUPT_ON_CANCEL, interruptOnCancel.toString)
388398
}
389399

390400
/** Clear the current thread's job group ID and its description. */
391401
def clearJobGroup() {
392402
setLocalProperty(SparkContext.SPARK_JOB_DESCRIPTION, null)
393403
setLocalProperty(SparkContext.SPARK_JOB_GROUP_ID, null)
404+
setLocalProperty(SparkContext.SPARK_JOB_INTERRUPT_ON_CANCEL, null)
394405
}
395406

396407
// Post init
@@ -1244,6 +1255,8 @@ object SparkContext extends Logging {
12441255

12451256
private[spark] val SPARK_JOB_GROUP_ID = "spark.jobGroup.id"
12461257

1258+
private[spark] val SPARK_JOB_INTERRUPT_ON_CANCEL = "spark.job.interruptOnCancel"
1259+
12471260
private[spark] val SPARK_UNKNOWN_USER = "<unknown>"
12481261

12491262
implicit object DoubleAccumulatorParam extends AccumulatorParam[Double] {
@@ -1268,8 +1281,10 @@ object SparkContext extends Logging {
12681281

12691282
// TODO: Add AccumulatorParams for other types, e.g. lists and strings
12701283

1271-
implicit def rddToPairRDDFunctions[K: ClassTag, V: ClassTag](rdd: RDD[(K, V)]) =
1284+
implicit def rddToPairRDDFunctions[K, V](rdd: RDD[(K, V)])
1285+
(implicit kt: ClassTag[K], vt: ClassTag[V], ord: Ordering[K] = null) = {
12721286
new PairRDDFunctions(rdd)
1287+
}
12731288

12741289
implicit def rddToAsyncRDDActions[T: ClassTag](rdd: RDD[T]) = new AsyncRDDActions(rdd)
12751290

core/src/main/scala/org/apache/spark/TaskContext.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ class TaskContext(
3333
val attemptId: Long,
3434
val runningLocally: Boolean = false,
3535
@volatile var interrupted: Boolean = false,
36-
private[spark] val taskMetrics: TaskMetrics = TaskMetrics.empty()
36+
private[spark] val taskMetrics: TaskMetrics = TaskMetrics.empty
3737
) extends Serializable {
3838

3939
@deprecated("use partitionId", "0.8.1")
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/*
2+
* Licensed to the Apache Software Foundation (ASF) under one or more
3+
* contributor license agreements. See the NOTICE file distributed with
4+
* this work for additional information regarding copyright ownership.
5+
* The ASF licenses this file to You under the Apache License, Version 2.0
6+
* (the "License"); you may not use this file except in compliance with
7+
* the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
package org.apache.spark
19+
20+
/**
21+
* Exception for a task getting killed.
22+
*/
23+
private[spark] class TaskKilledException extends RuntimeException

0 commit comments

Comments
 (0)