2012-09-24 18:43:19 -04:00
|
|
|
@echo off
|
|
|
|
|
2013-07-16 20:21:33 -04:00
|
|
|
rem
|
|
|
|
rem Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
rem contributor license agreements. See the NOTICE file distributed with
|
|
|
|
rem this work for additional information regarding copyright ownership.
|
|
|
|
rem The ASF licenses this file to You under the Apache License, Version 2.0
|
|
|
|
rem (the "License"); you may not use this file except in compliance with
|
|
|
|
rem the License. You may obtain a copy of the License at
|
|
|
|
rem
|
|
|
|
rem http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
rem
|
|
|
|
rem Unless required by applicable law or agreed to in writing, software
|
|
|
|
rem distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
rem See the License for the specific language governing permissions and
|
|
|
|
rem limitations under the License.
|
|
|
|
rem
|
|
|
|
|
2012-09-24 18:43:19 -04:00
|
|
|
rem Figure out where the Spark framework is installed
|
2015-03-11 04:03:01 -04:00
|
|
|
set SPARK_HOME=%~dp0..
|
2012-09-24 18:43:19 -04:00
|
|
|
|
2016-02-10 04:54:22 -05:00
|
|
|
call "%SPARK_HOME%\bin\load-spark-env.cmd"
|
2012-09-24 18:43:19 -04:00
|
|
|
|
2013-02-07 00:56:00 -05:00
|
|
|
rem Test that an argument was given
|
2015-03-11 04:03:01 -04:00
|
|
|
if "x%1"=="x" (
|
2013-09-01 19:45:57 -04:00
|
|
|
echo Usage: spark-class ^<class^> [^<args^>]
|
2015-03-11 04:03:01 -04:00
|
|
|
exit /b 1
|
2014-03-09 14:08:39 -04:00
|
|
|
)
|
|
|
|
|
2016-03-14 14:13:26 -04:00
|
|
|
rem Find Spark jars.
|
2015-03-29 07:40:37 -04:00
|
|
|
if exist "%SPARK_HOME%\RELEASE" (
|
2016-04-04 19:52:21 -04:00
|
|
|
set SPARK_JARS_DIR="%SPARK_HOME%\jars"
|
2015-03-29 07:40:37 -04:00
|
|
|
) else (
|
2016-04-04 19:52:21 -04:00
|
|
|
set SPARK_JARS_DIR="%SPARK_HOME%\assembly\target\scala-%SPARK_SCALA_VERSION%\jars"
|
2014-03-09 14:08:39 -04:00
|
|
|
)
|
2012-09-24 18:43:19 -04:00
|
|
|
|
2016-03-14 14:13:26 -04:00
|
|
|
if not exist "%SPARK_JARS_DIR%"\ (
|
2016-04-14 21:51:43 -04:00
|
|
|
echo Failed to find Spark jars directory.
|
2015-03-11 04:03:01 -04:00
|
|
|
echo You need to build Spark before running this program.
|
|
|
|
exit /b 1
|
2013-11-09 16:37:11 -05:00
|
|
|
)
|
|
|
|
|
2016-03-14 14:13:26 -04:00
|
|
|
set LAUNCH_CLASSPATH=%SPARK_JARS_DIR%\*
|
2015-04-14 21:51:39 -04:00
|
|
|
|
|
|
|
rem Add the launcher build dir to the classpath if requested.
|
|
|
|
if not "x%SPARK_PREPEND_CLASSES%"=="x" (
|
2016-02-10 04:54:22 -05:00
|
|
|
set LAUNCH_CLASSPATH="%SPARK_HOME%\launcher\target\scala-%SPARK_SCALA_VERSION%\classes;%LAUNCH_CLASSPATH%"
|
2015-04-14 21:51:39 -04:00
|
|
|
)
|
|
|
|
|
2013-09-01 19:45:57 -04:00
|
|
|
rem Figure out where java is.
|
|
|
|
set RUNNER=java
|
|
|
|
if not "x%JAVA_HOME%"=="x" set RUNNER=%JAVA_HOME%\bin\java
|
2012-09-24 18:43:19 -04:00
|
|
|
|
2015-03-11 04:03:01 -04:00
|
|
|
rem The launcher library prints the command to be executed in a single line suitable for being
|
|
|
|
rem executed by the batch interpreter. So read all the output of the launcher into a variable.
|
2015-04-28 07:55:21 -04:00
|
|
|
set LAUNCHER_OUTPUT=%temp%\spark-class-launcher-output-%RANDOM%.txt
|
2016-02-10 04:54:22 -05:00
|
|
|
"%RUNNER%" -cp "%LAUNCH_CLASSPATH%" org.apache.spark.launcher.Main %* > %LAUNCHER_OUTPUT%
|
2015-04-28 07:55:21 -04:00
|
|
|
for /f "tokens=*" %%i in (%LAUNCHER_OUTPUT%) do (
|
2015-03-11 04:03:01 -04:00
|
|
|
set SPARK_CMD=%%i
|
2014-08-27 01:52:16 -04:00
|
|
|
)
|
2015-04-28 07:55:21 -04:00
|
|
|
del %LAUNCHER_OUTPUT%
|
2015-03-11 04:03:01 -04:00
|
|
|
%SPARK_CMD%
|