Skip to content

Commit 75eac55

Browse files
Merge remote-tracking branch 'upstream/master' into SPARK-3278
2 parents 88eb4e2 + 0a95085 commit 75eac55

File tree

239 files changed

+8427
-2906
lines changed

Some content is hidden

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

239 files changed

+8427
-2906
lines changed

assembly/pom.xml

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,6 @@
4343
</properties>
4444

4545
<dependencies>
46-
<!-- Promote Guava to compile scope in this module so it's included while shading. -->
47-
<dependency>
48-
<groupId>com.google.guava</groupId>
49-
<artifactId>guava</artifactId>
50-
<scope>compile</scope>
51-
</dependency>
5246
<dependency>
5347
<groupId>org.apache.spark</groupId>
5448
<artifactId>spark-core_${scala.binary.version}</artifactId>
@@ -133,20 +127,6 @@
133127
<goal>shade</goal>
134128
</goals>
135129
<configuration>
136-
<relocations>
137-
<relocation>
138-
<pattern>com.google</pattern>
139-
<shadedPattern>org.spark-project.guava</shadedPattern>
140-
<includes>
141-
<include>com.google.common.**</include>
142-
</includes>
143-
<excludes>
144-
<exclude>com/google/common/base/Absent*</exclude>
145-
<exclude>com/google/common/base/Optional*</exclude>
146-
<exclude>com/google/common/base/Present*</exclude>
147-
</excludes>
148-
</relocation>
149-
</relocations>
150130
<transformers>
151131
<transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
152132
<transformer implementation="org.apache.maven.plugins.shade.resource.AppendingTransformer">

bin/spark-class

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ FWDIR="$(cd "`dirname "$0"`"/..; pwd)"
2929

3030
# Export this as SPARK_HOME
3131
export SPARK_HOME="$FWDIR"
32+
export SPARK_CONF_DIR="${SPARK_CONF_DIR:-"$SPARK_HOME/conf"}"
3233

3334
. "$FWDIR"/bin/load-spark-env.sh
3435

@@ -120,8 +121,8 @@ fi
120121
JAVA_OPTS="$JAVA_OPTS -Xms$OUR_JAVA_MEM -Xmx$OUR_JAVA_MEM"
121122

122123
# Load extra JAVA_OPTS from conf/java-opts, if it exists
123-
if [ -e "$FWDIR/conf/java-opts" ] ; then
124-
JAVA_OPTS="$JAVA_OPTS `cat "$FWDIR"/conf/java-opts`"
124+
if [ -e "$SPARK_CONF_DIR/java-opts" ] ; then
125+
JAVA_OPTS="$JAVA_OPTS `cat "$SPARK_CONF_DIR"/java-opts`"
125126
fi
126127

127128
# Attention: when changing the way the JAVA_OPTS are assembled, the change must be reflected in CommandUtils.scala!

build/mvn

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ install_app() {
4848
# check if we already have the tarball
4949
# check if we have curl installed
5050
# download application
51-
[ ! -f "${local_tarball}" ] && [ -n "`which curl 2>/dev/null`" ] && \
51+
[ ! -f "${local_tarball}" ] && [ $(command -v curl) ] && \
5252
echo "exec: curl ${curl_opts} ${remote_tarball}" && \
5353
curl ${curl_opts} "${remote_tarball}" > "${local_tarball}"
5454
# if the file still doesn't exist, lets try `wget` and cross our fingers
55-
[ ! -f "${local_tarball}" ] && [ -n "`which wget 2>/dev/null`" ] && \
55+
[ ! -f "${local_tarball}" ] && [ $(command -v wget) ] && \
5656
echo "exec: wget ${wget_opts} ${remote_tarball}" && \
5757
wget ${wget_opts} -O "${local_tarball}" "${remote_tarball}"
5858
# if both were unsuccessful, exit
@@ -68,10 +68,10 @@ install_app() {
6868
# Install maven under the build/ folder
6969
install_mvn() {
7070
install_app \
71-
"http://apache.claz.org/maven/maven-3/3.2.3/binaries" \
72-
"apache-maven-3.2.3-bin.tar.gz" \
73-
"apache-maven-3.2.3/bin/mvn"
74-
MVN_BIN="${_DIR}/apache-maven-3.2.3/bin/mvn"
71+
"http://archive.apache.org/dist/maven/maven-3/3.2.5/binaries" \
72+
"apache-maven-3.2.5-bin.tar.gz" \
73+
"apache-maven-3.2.5/bin/mvn"
74+
MVN_BIN="${_DIR}/apache-maven-3.2.5/bin/mvn"
7575
}
7676

7777
# Install zinc under the build/ folder

build/sbt-launch-lib.bash

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,9 @@ acquire_sbt_jar () {
5050
# Download
5151
printf "Attempting to fetch sbt\n"
5252
JAR_DL="${JAR}.part"
53-
if hash curl 2>/dev/null; then
53+
if [ $(command -v curl) ]; then
5454
(curl --silent ${URL1} > "${JAR_DL}" || curl --silent ${URL2} > "${JAR_DL}") && mv "${JAR_DL}" "${JAR}"
55-
elif hash wget 2>/dev/null; then
55+
elif [ $(command -v wget) ]; then
5656
(wget --quiet ${URL1} -O "${JAR_DL}" || wget --quiet ${URL2} -O "${JAR_DL}") && mv "${JAR_DL}" "${JAR}"
5757
else
5858
printf "You do not have curl or wget installed, please install sbt manually from http://www.scala-sbt.org/\n"

core/pom.xml

Lines changed: 4 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@
3434
<name>Spark Project Core</name>
3535
<url>http://spark.apache.org/</url>
3636
<dependencies>
37+
<dependency>
38+
<groupId>com.google.guava</groupId>
39+
<artifactId>guava</artifactId>
40+
</dependency>
3741
<dependency>
3842
<groupId>com.twitter</groupId>
3943
<artifactId>chill_${scala.binary.version}</artifactId>
@@ -106,16 +110,6 @@
106110
<groupId>org.eclipse.jetty</groupId>
107111
<artifactId>jetty-server</artifactId>
108112
</dependency>
109-
<!--
110-
Promote Guava to "compile" so that maven-shade-plugin picks it up (for packaging the Optional
111-
class exposed in the Java API). The plugin will then remove this dependency from the published
112-
pom, so that Guava does not pollute the client's compilation classpath.
113-
-->
114-
<dependency>
115-
<groupId>com.google.guava</groupId>
116-
<artifactId>guava</artifactId>
117-
<scope>compile</scope>
118-
</dependency>
119113
<dependency>
120114
<groupId>org.apache.commons</groupId>
121115
<artifactId>commons-lang3</artifactId>
@@ -350,42 +344,6 @@
350344
<verbose>true</verbose>
351345
</configuration>
352346
</plugin>
353-
<plugin>
354-
<groupId>org.apache.maven.plugins</groupId>
355-
<artifactId>maven-shade-plugin</artifactId>
356-
<executions>
357-
<execution>
358-
<phase>package</phase>
359-
<goals>
360-
<goal>shade</goal>
361-
</goals>
362-
<configuration>
363-
<shadedArtifactAttached>false</shadedArtifactAttached>
364-
<artifactSet>
365-
<includes>
366-
<include>com.google.guava:guava</include>
367-
</includes>
368-
</artifactSet>
369-
<filters>
370-
<!-- See comment in the guava dependency declaration above. -->
371-
<filter>
372-
<artifact>com.google.guava:guava</artifact>
373-
<includes>
374-
<include>com/google/common/base/Absent*</include>
375-
<include>com/google/common/base/Optional*</include>
376-
<include>com/google/common/base/Present*</include>
377-
</includes>
378-
</filter>
379-
</filters>
380-
</configuration>
381-
</execution>
382-
</executions>
383-
</plugin>
384-
<!--
385-
Copy guava to the build directory. This is needed to make the SPARK_PREPEND_CLASSES
386-
option work in compute-classpath.sh, since it would put the non-shaded Spark classes in
387-
the runtime classpath.
388-
-->
389347
<plugin>
390348
<groupId>org.apache.maven.plugins</groupId>
391349
<artifactId>maven-dependency-plugin</artifactId>

core/src/main/resources/org/apache/spark/log4j-defaults.properties

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,3 @@ log4j.logger.org.eclipse.jetty=WARN
1010
log4j.logger.org.eclipse.jetty.util.component.AbstractLifeCycle=ERROR
1111
log4j.logger.org.apache.spark.repl.SparkIMain$exprTyper=INFO
1212
log4j.logger.org.apache.spark.repl.SparkILoop$SparkILoopInterpreter=INFO
13-
log4j.logger.org.apache.hadoop.yarn.util.RackResolver=WARN

core/src/main/resources/org/apache/spark/ui/static/webui.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,7 @@ span.additional-metric-title {
190190

191191
/* Hide all additional metrics by default. This is done here rather than using JavaScript to
192192
* avoid slow page loads for stage pages with large numbers (e.g., thousands) of tasks. */
193-
.scheduler_delay, .deserialization_time, .serialization_time, .getting_result_time {
193+
.scheduler_delay, .deserialization_time, .fetch_wait_time, .serialization_time,
194+
.getting_result_time {
194195
display: none;
195196
}

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,17 @@ trait Logging {
118118
// org.slf4j.impl.Log4jLoggerFactory, from the log4j 2.0 binding, currently
119119
// org.apache.logging.slf4j.Log4jLoggerFactory
120120
val usingLog4j12 = "org.slf4j.impl.Log4jLoggerFactory".equals(binderClass)
121-
val log4j12Initialized = LogManager.getRootLogger.getAllAppenders.hasMoreElements
122-
if (!log4j12Initialized && usingLog4j12) {
123-
val defaultLogProps = "org/apache/spark/log4j-defaults.properties"
124-
Option(Utils.getSparkClassLoader.getResource(defaultLogProps)) match {
125-
case Some(url) =>
126-
PropertyConfigurator.configure(url)
127-
System.err.println(s"Using Spark's default log4j profile: $defaultLogProps")
128-
case None =>
129-
System.err.println(s"Spark was unable to load $defaultLogProps")
121+
if (usingLog4j12) {
122+
val log4j12Initialized = LogManager.getRootLogger.getAllAppenders.hasMoreElements
123+
if (!log4j12Initialized) {
124+
val defaultLogProps = "org/apache/spark/log4j-defaults.properties"
125+
Option(Utils.getSparkClassLoader.getResource(defaultLogProps)) match {
126+
case Some(url) =>
127+
PropertyConfigurator.configure(url)
128+
System.err.println(s"Using Spark's default log4j profile: $defaultLogProps")
129+
case None =>
130+
System.err.println(s"Spark was unable to load $defaultLogProps")
131+
}
130132
}
131133
}
132134
Logging.initialized = true

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

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@
1717

1818
package org.apache.spark
1919

20+
import java.util.concurrent.ConcurrentHashMap
21+
2022
import scala.collection.JavaConverters._
21-
import scala.collection.concurrent.TrieMap
22-
import scala.collection.mutable.{HashMap, LinkedHashSet}
23+
import scala.collection.mutable.LinkedHashSet
24+
2325
import org.apache.spark.serializer.KryoSerializer
2426

2527
/**
@@ -47,12 +49,12 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging {
4749
/** Create a SparkConf that loads defaults from system properties and the classpath */
4850
def this() = this(true)
4951

50-
private[spark] val settings = new TrieMap[String, String]()
52+
private val settings = new ConcurrentHashMap[String, String]()
5153

5254
if (loadDefaults) {
5355
// Load any spark.* system properties
5456
for ((k, v) <- System.getProperties.asScala if k.startsWith("spark.")) {
55-
settings(k) = v
57+
set(k, v)
5658
}
5759
}
5860

@@ -64,7 +66,7 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging {
6466
if (value == null) {
6567
throw new NullPointerException("null value for " + key)
6668
}
67-
settings(key) = value
69+
settings.put(key, value)
6870
this
6971
}
7072

@@ -130,15 +132,13 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging {
130132

131133
/** Set multiple parameters together */
132134
def setAll(settings: Traversable[(String, String)]) = {
133-
this.settings ++= settings
135+
this.settings.putAll(settings.toMap.asJava)
134136
this
135137
}
136138

137139
/** Set a parameter if it isn't already configured */
138140
def setIfMissing(key: String, value: String): SparkConf = {
139-
if (!settings.contains(key)) {
140-
settings(key) = value
141-
}
141+
settings.putIfAbsent(key, value)
142142
this
143143
}
144144

@@ -164,21 +164,23 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging {
164164

165165
/** Get a parameter; throws a NoSuchElementException if it's not set */
166166
def get(key: String): String = {
167-
settings.getOrElse(key, throw new NoSuchElementException(key))
167+
getOption(key).getOrElse(throw new NoSuchElementException(key))
168168
}
169169

170170
/** Get a parameter, falling back to a default if not set */
171171
def get(key: String, defaultValue: String): String = {
172-
settings.getOrElse(key, defaultValue)
172+
getOption(key).getOrElse(defaultValue)
173173
}
174174

175175
/** Get a parameter as an Option */
176176
def getOption(key: String): Option[String] = {
177-
settings.get(key)
177+
Option(settings.get(key))
178178
}
179179

180180
/** Get all parameters as a list of pairs */
181-
def getAll: Array[(String, String)] = settings.toArray
181+
def getAll: Array[(String, String)] = {
182+
settings.entrySet().asScala.map(x => (x.getKey, x.getValue)).toArray
183+
}
182184

183185
/** Get a parameter as an integer, falling back to a default if not set */
184186
def getInt(key: String, defaultValue: Int): Int = {
@@ -225,11 +227,11 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging {
225227
def getAppId: String = get("spark.app.id")
226228

227229
/** Does the configuration contain a given parameter? */
228-
def contains(key: String): Boolean = settings.contains(key)
230+
def contains(key: String): Boolean = settings.containsKey(key)
229231

230232
/** Copy this object */
231233
override def clone: SparkConf = {
232-
new SparkConf(false).setAll(settings)
234+
new SparkConf(false).setAll(getAll)
233235
}
234236

235237
/**
@@ -241,7 +243,7 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging {
241243
/** Checks for illegal or deprecated config settings. Throws an exception for the former. Not
242244
* idempotent - may mutate this conf object to convert deprecated settings to supported ones. */
243245
private[spark] def validateSettings() {
244-
if (settings.contains("spark.local.dir")) {
246+
if (contains("spark.local.dir")) {
245247
val msg = "In Spark 1.0 and later spark.local.dir will be overridden by the value set by " +
246248
"the cluster manager (via SPARK_LOCAL_DIRS in mesos/standalone and LOCAL_DIRS in YARN)."
247249
logWarning(msg)
@@ -266,7 +268,7 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging {
266268
}
267269

268270
// Validate spark.executor.extraJavaOptions
269-
settings.get(executorOptsKey).map { javaOpts =>
271+
getOption(executorOptsKey).map { javaOpts =>
270272
if (javaOpts.contains("-Dspark")) {
271273
val msg = s"$executorOptsKey is not allowed to set Spark options (was '$javaOpts'). " +
272274
"Set them directly on a SparkConf or in a properties file when using ./bin/spark-submit."
@@ -346,7 +348,7 @@ class SparkConf(loadDefaults: Boolean) extends Cloneable with Logging {
346348
* configuration out for debugging.
347349
*/
348350
def toDebugString: String = {
349-
settings.toArray.sorted.map{case (k, v) => k + "=" + v}.mkString("\n")
351+
getAll.sorted.map{case (k, v) => k + "=" + v}.mkString("\n")
350352
}
351353
}
352354

0 commit comments

Comments
 (0)