Configure Environment for Interactive Debugging
Supported Platform: Linux® only.
Before you can interactively debug your applications using the MATLAB® API for Spark™, you must configure your MATLAB environment by adding the location of the Spark assembly jar to the front of MATLAB's static Java class path.
A Spark assembly JAR file includes all the Spark dependencies, including some internal Hadoop® dependencies. This JAR file is created during Spark installation and is specific to a particular combination of
Spark and Hadoop versions. For example, using Spark version 1.4.0 and Hadoop version 2.4.0 creates the file
spark-assembly-1.4.0-hadoop2.4.0.jar.
To add the location of the Spark assembly jar to the front of MATLAB’s static Java® class path, use the following procedure:
Open a Linux terminal.
Navigate to the directory
, where<matlabroot>/binis the location where MATLAB is installed.<matlabroot>Set the environment variable
SPARK_HOMEto point to the Spark installation directory. For example:Shell Command zsh / csh / tcsh % setenv SPARK_HOME /share/spark
bash $ export SPARK_HOME=/share/spark
From the directory
, execute the shell script<matlabroot>/bingeneratesparkjcpath. For example:$ ./generatesparkjcpath
This will create a file called
javaclasspath.txtin yourdirectory. The contents of a sample<matlabroot>/binjavaclasspath.txtfile look like this:<before> /share/spark/conf/ /share/spark/lib/spark-assembly-1.4.0-hadoop2.4.0.jar /share/spark/lib/datanucleus-rdbms-3.2.9.jar /share/spark/lib/datanucleus-api-jdo-3.2.6.jar /share/spark/lib/datanucleus-core-3.2.10.jar
The
<before>tag ensures thatspark-assembly-1.4.0-hadoop2.4.0.jaris added to the front of the Java class path.Start MATLAB from the
directory.<matlabroot>/bin
Note
You can create the javaclasspath.txt file in a directory
other than by
specifying the <matlabroot>/bin-o option. The file must be named
javaclasspath.txt. For
example:
$ ./generatesparkjcpath -o /home/user/javaclasspath.txt
javaclasspath.txt file. You can verify whether spark-assembly-1.4.0-hadoop2.4.0.jar was
added to the front of the Java class path by typing the following at the MATLAB command
prompt:
>> spath = javaclasspath('-static') ;
>> spath(1:5)
/share/spark/lib/spark-assembly-1.4.0-hadoop2.4.0.jar on the
top of the list.You need to complete this configuration just once. Subsequent usage only requires
that you start MATLAB from the folder containing the javaclasspath.txt
file.
Note
You may instead place the generated javaclasspath.txt in
your prefdir. If you do so, MATLAB adds the necessary libraries to the static path at launch.