Skip to content

Commit 34b1a9a

Browse files
committed
Merge pull request apache#8 from apache/master
merge lastest spark
2 parents 802261c + 15e0d2b commit 34b1a9a

File tree

318 files changed

+8239
-3337
lines changed

Some content is hidden

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

318 files changed

+8239
-3337
lines changed

bin/load-spark-env.cmd

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
@echo off
2+
3+
rem
4+
rem Licensed to the Apache Software Foundation (ASF) under one or more
5+
rem contributor license agreements. See the NOTICE file distributed with
6+
rem this work for additional information regarding copyright ownership.
7+
rem The ASF licenses this file to You under the Apache License, Version 2.0
8+
rem (the "License"); you may not use this file except in compliance with
9+
rem the License. You may obtain a copy of the License at
10+
rem
11+
rem http://www.apache.org/licenses/LICENSE-2.0
12+
rem
13+
rem Unless required by applicable law or agreed to in writing, software
14+
rem distributed under the License is distributed on an "AS IS" BASIS,
15+
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
rem See the License for the specific language governing permissions and
17+
rem limitations under the License.
18+
rem
19+
20+
rem This script loads spark-env.cmd if it exists, and ensures it is only loaded once.
21+
rem spark-env.cmd is loaded from SPARK_CONF_DIR if set, or within the current directory's
22+
rem conf/ subdirectory.
23+
24+
if [%SPARK_ENV_LOADED%] == [] (
25+
set SPARK_ENV_LOADED=1
26+
27+
if not [%SPARK_CONF_DIR%] == [] (
28+
set user_conf_dir=%SPARK_CONF_DIR%
29+
) else (
30+
set user_conf_dir=%~dp0..\..\conf
31+
)
32+
33+
call :LoadSparkEnv
34+
)
35+
36+
rem Setting SPARK_SCALA_VERSION if not already set.
37+
38+
set ASSEMBLY_DIR2=%SPARK_HOME%/assembly/target/scala-2.11
39+
set ASSEMBLY_DIR1=%SPARK_HOME%/assembly/target/scala-2.10
40+
41+
if [%SPARK_SCALA_VERSION%] == [] (
42+
43+
if exist %ASSEMBLY_DIR2% if exist %ASSEMBLY_DIR1% (
44+
echo "Presence of build for both scala versions(SCALA 2.10 and SCALA 2.11) detected."
45+
echo "Either clean one of them or, set SPARK_SCALA_VERSION=2.11 in spark-env.cmd."
46+
exit 1
47+
)
48+
if exist %ASSEMBLY_DIR2% (
49+
set SPARK_SCALA_VERSION=2.11
50+
) else (
51+
set SPARK_SCALA_VERSION=2.10
52+
)
53+
)
54+
exit /b 0
55+
56+
:LoadSparkEnv
57+
if exist "%user_conf_dir%\spark-env.cmd" (
58+
call "%user_conf_dir%\spark-env.cmd"
59+
)

bin/pyspark2.cmd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ rem
2020
rem Figure out where the Spark framework is installed
2121
set SPARK_HOME=%~dp0..
2222

23-
rem Load environment variables from conf\spark-env.cmd, if it exists
24-
if exist "%SPARK_HOME%\conf\spark-env.cmd" call "%SPARK_HOME%\conf\spark-env.cmd"
23+
call %SPARK_HOME%\bin\load-spark-env.cmd
2524

2625
rem Figure out which Python to use.
2726
if "x%PYSPARK_DRIVER_PYTHON%"=="x" (

bin/run-example2.cmd

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ set FWDIR=%~dp0..\
2525
rem Export this as SPARK_HOME
2626
set SPARK_HOME=%FWDIR%
2727

28-
rem Load environment variables from conf\spark-env.cmd, if it exists
29-
if exist "%FWDIR%conf\spark-env.cmd" call "%FWDIR%conf\spark-env.cmd"
28+
call %SPARK_HOME%\bin\load-spark-env.cmd
3029

3130
rem Test that an argument was given
3231
if not "x%1"=="x" goto arg_given

bin/spark-class

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -40,35 +40,46 @@ else
4040
fi
4141
fi
4242

43-
# Look for the launcher. In non-release mode, add the compiled classes directly to the classpath
44-
# instead of looking for a jar file.
45-
SPARK_LAUNCHER_CP=
46-
if [ -f $SPARK_HOME/RELEASE ]; then
47-
LAUNCHER_DIR="$SPARK_HOME/lib"
48-
num_jars="$(ls -1 "$LAUNCHER_DIR" | grep "^spark-launcher.*\.jar$" | wc -l)"
49-
if [ "$num_jars" -eq "0" -a -z "$SPARK_LAUNCHER_CP" ]; then
50-
echo "Failed to find Spark launcher in $LAUNCHER_DIR." 1>&2
51-
echo "You need to build Spark before running this program." 1>&2
52-
exit 1
53-
fi
43+
# Find assembly jar
44+
SPARK_ASSEMBLY_JAR=
45+
if [ -f "$SPARK_HOME/RELEASE" ]; then
46+
ASSEMBLY_DIR="$SPARK_HOME/lib"
47+
else
48+
ASSEMBLY_DIR="$SPARK_HOME/assembly/target/scala-$SPARK_SCALA_VERSION"
49+
fi
5450

55-
LAUNCHER_JARS="$(ls -1 "$LAUNCHER_DIR" | grep "^spark-launcher.*\.jar$" || true)"
56-
if [ "$num_jars" -gt "1" ]; then
57-
echo "Found multiple Spark launcher jars in $LAUNCHER_DIR:" 1>&2
58-
echo "$LAUNCHER_JARS" 1>&2
59-
echo "Please remove all but one jar." 1>&2
60-
exit 1
61-
fi
51+
num_jars="$(ls -1 "$ASSEMBLY_DIR" | grep "^spark-assembly.*hadoop.*\.jar$" | wc -l)"
52+
if [ "$num_jars" -eq "0" -a -z "$SPARK_ASSEMBLY_JAR" ]; then
53+
echo "Failed to find Spark assembly in $ASSEMBLY_DIR." 1>&2
54+
echo "You need to build Spark before running this program." 1>&2
55+
exit 1
56+
fi
57+
ASSEMBLY_JARS="$(ls -1 "$ASSEMBLY_DIR" | grep "^spark-assembly.*hadoop.*\.jar$" || true)"
58+
if [ "$num_jars" -gt "1" ]; then
59+
echo "Found multiple Spark assembly jars in $ASSEMBLY_DIR:" 1>&2
60+
echo "$ASSEMBLY_JARS" 1>&2
61+
echo "Please remove all but one jar." 1>&2
62+
exit 1
63+
fi
6264

63-
SPARK_LAUNCHER_CP="${LAUNCHER_DIR}/${LAUNCHER_JARS}"
65+
SPARK_ASSEMBLY_JAR="${ASSEMBLY_DIR}/${ASSEMBLY_JARS}"
66+
67+
# Verify that versions of java used to build the jars and run Spark are compatible
68+
if [ -n "$JAVA_HOME" ]; then
69+
JAR_CMD="$JAVA_HOME/bin/jar"
6470
else
65-
LAUNCHER_DIR="$SPARK_HOME/launcher/target/scala-$SPARK_SCALA_VERSION"
66-
if [ ! -d "$LAUNCHER_DIR/classes" ]; then
67-
echo "Failed to find Spark launcher classes in $LAUNCHER_DIR." 1>&2
68-
echo "You need to build Spark before running this program." 1>&2
71+
JAR_CMD="jar"
72+
fi
73+
74+
if [ $(command -v "$JAR_CMD") ] ; then
75+
jar_error_check=$("$JAR_CMD" -tf "$SPARK_ASSEMBLY_JAR" nonexistent/class/path 2>&1)
76+
if [[ "$jar_error_check" =~ "invalid CEN header" ]]; then
77+
echo "Loading Spark jar with '$JAR_CMD' failed. " 1>&2
78+
echo "This is likely because Spark was compiled with Java 7 and run " 1>&2
79+
echo "with Java 6. (see SPARK-1703). Please use Java 7 to run Spark " 1>&2
80+
echo "or build Spark with Java 6." 1>&2
6981
exit 1
7082
fi
71-
SPARK_LAUNCHER_CP="$LAUNCHER_DIR/classes"
7283
fi
7384

7485
# The launcher library will print arguments separated by a NULL character, to allow arguments with
@@ -77,7 +88,7 @@ fi
7788
CMD=()
7889
while IFS= read -d '' -r ARG; do
7990
CMD+=("$ARG")
80-
done < <("$RUNNER" -cp "$SPARK_LAUNCHER_CP" org.apache.spark.launcher.Main "$@")
91+
done < <("$RUNNER" -cp "$SPARK_ASSEMBLY_JAR" org.apache.spark.launcher.Main "$@")
8192

8293
if [ "${CMD[0]}" = "usage" ]; then
8394
"${CMD[@]}"

bin/spark-class2.cmd

Lines changed: 12 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,40 +20,28 @@ rem
2020
rem Figure out where the Spark framework is installed
2121
set SPARK_HOME=%~dp0..
2222

23-
rem Load environment variables from conf\spark-env.cmd, if it exists
24-
if exist "%SPARK_HOME%\conf\spark-env.cmd" call "%SPARK_HOME%\conf\spark-env.cmd"
23+
call %SPARK_HOME%\bin\load-spark-env.cmd
2524

2625
rem Test that an argument was given
2726
if "x%1"=="x" (
2827
echo Usage: spark-class ^<class^> [^<args^>]
2928
exit /b 1
3029
)
3130

32-
set LAUNCHER_CP=0
33-
if exist %SPARK_HOME%\RELEASE goto find_release_launcher
31+
rem Find assembly jar
32+
set SPARK_ASSEMBLY_JAR=0
3433

35-
rem Look for the Spark launcher in both Scala build directories. The launcher doesn't use Scala so
36-
rem it doesn't really matter which one is picked up. Add the compiled classes directly to the
37-
rem classpath instead of looking for a jar file, since it's very common for people using sbt to use
38-
rem the "assembly" target instead of "package".
39-
set LAUNCHER_CLASSES=%SPARK_HOME%\launcher\target\scala-2.10\classes
40-
if exist %LAUNCHER_CLASSES% (
41-
set LAUNCHER_CP=%LAUNCHER_CLASSES%
34+
if exist "%SPARK_HOME%\RELEASE" (
35+
set ASSEMBLY_DIR=%SPARK_HOME%\lib
36+
) else (
37+
set ASSEMBLY_DIR=%SPARK_HOME%\assembly\target\scala-%SPARK_SCALA_VERSION%
4238
)
43-
set LAUNCHER_CLASSES=%SPARK_HOME%\launcher\target\scala-2.11\classes
44-
if exist %LAUNCHER_CLASSES% (
45-
set LAUNCHER_CP=%LAUNCHER_CLASSES%
46-
)
47-
goto check_launcher
4839

49-
:find_release_launcher
50-
for %%d in (%SPARK_HOME%\lib\spark-launcher*.jar) do (
51-
set LAUNCHER_CP=%%d
40+
for %%d in (%ASSEMBLY_DIR%\spark-assembly*hadoop*.jar) do (
41+
set SPARK_ASSEMBLY_JAR=%%d
5242
)
53-
54-
:check_launcher
55-
if "%LAUNCHER_CP%"=="0" (
56-
echo Failed to find Spark launcher JAR.
43+
if "%SPARK_ASSEMBLY_JAR%"=="0" (
44+
echo Failed to find Spark assembly JAR.
5745
echo You need to build Spark before running this program.
5846
exit /b 1
5947
)
@@ -64,7 +52,7 @@ if not "x%JAVA_HOME%"=="x" set RUNNER=%JAVA_HOME%\bin\java
6452

6553
rem The launcher library prints the command to be executed in a single line suitable for being
6654
rem executed by the batch interpreter. So read all the output of the launcher into a variable.
67-
for /f "tokens=*" %%i in ('cmd /C ""%RUNNER%" -cp %LAUNCHER_CP% org.apache.spark.launcher.Main %*"') do (
55+
for /f "tokens=*" %%i in ('cmd /C ""%RUNNER%" -cp %SPARK_ASSEMBLY_JAR% org.apache.spark.launcher.Main %*"') do (
6856
set SPARK_CMD=%%i
6957
)
7058
%SPARK_CMD%

core/src/main/resources/org/apache/spark/ui/static/additional-metrics.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ $(function() {
3030

3131
stripeSummaryTable();
3232

33-
$("input:checkbox").click(function() {
33+
$('input[type="checkbox"]').click(function() {
3434
var column = "table ." + $(this).attr("name");
3535
$(column).toggle();
3636
stripeSummaryTable();
@@ -39,15 +39,15 @@ $(function() {
3939
$("#select-all-metrics").click(function() {
4040
if (this.checked) {
4141
// Toggle all un-checked options.
42-
$('input:checkbox:not(:checked)').trigger('click');
42+
$('input[type="checkbox"]:not(:checked)').trigger('click');
4343
} else {
4444
// Toggle all checked options.
45-
$('input:checkbox:checked').trigger('click');
45+
$('input[type="checkbox"]:checked').trigger('click');
4646
}
4747
});
4848

4949
// Trigger a click on the checkbox if a user clicks the label next to it.
5050
$("span.additional-metric-title").click(function() {
51-
$(this).parent().find('input:checkbox').trigger('click');
51+
$(this).parent().find('input[type="checkbox"]').trigger('click');
5252
});
5353
});

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

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

1818
package org.apache.spark
1919

20+
import java.util.concurrent.{Executors, TimeUnit}
21+
2022
import scala.collection.mutable
2123

2224
import org.apache.spark.scheduler._
23-
import org.apache.spark.util.{SystemClock, Clock}
25+
import org.apache.spark.util.{Clock, SystemClock, Utils}
2426

2527
/**
2628
* An agent that dynamically allocates and removes executors based on the workload.
@@ -129,6 +131,10 @@ private[spark] class ExecutorAllocationManager(
129131
// Listener for Spark events that impact the allocation policy
130132
private val listener = new ExecutorAllocationListener
131133

134+
// Executor that handles the scheduling task.
135+
private val executor = Executors.newSingleThreadScheduledExecutor(
136+
Utils.namedThreadFactory("spark-dynamic-executor-allocation"))
137+
132138
/**
133139
* Verify that the settings specified through the config are valid.
134140
* If not, throw an appropriate exception.
@@ -173,32 +179,24 @@ private[spark] class ExecutorAllocationManager(
173179
}
174180

175181
/**
176-
* Register for scheduler callbacks to decide when to add and remove executors.
182+
* Register for scheduler callbacks to decide when to add and remove executors, and start
183+
* the scheduling task.
177184
*/
178185
def start(): Unit = {
179186
listenerBus.addListener(listener)
180-
startPolling()
187+
188+
val scheduleTask = new Runnable() {
189+
override def run(): Unit = Utils.logUncaughtExceptions(schedule())
190+
}
191+
executor.scheduleAtFixedRate(scheduleTask, 0, intervalMillis, TimeUnit.MILLISECONDS)
181192
}
182193

183194
/**
184-
* Start the main polling thread that keeps track of when to add and remove executors.
195+
* Stop the allocation manager.
185196
*/
186-
private def startPolling(): Unit = {
187-
val t = new Thread {
188-
override def run(): Unit = {
189-
while (true) {
190-
try {
191-
schedule()
192-
} catch {
193-
case e: Exception => logError("Exception in dynamic executor allocation thread!", e)
194-
}
195-
Thread.sleep(intervalMillis)
196-
}
197-
}
198-
}
199-
t.setName("spark-dynamic-executor-allocation")
200-
t.setDaemon(true)
201-
t.start()
197+
def stop(): Unit = {
198+
executor.shutdown()
199+
executor.awaitTermination(10, TimeUnit.SECONDS)
202200
}
203201

204202
/**

0 commit comments

Comments
 (0)