You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@systemml.apache.org by de...@apache.org on 2016/04/07 21:11:34 UTC
incubator-systemml git commit: [SYSTEMML-486] Java opts to standalone
scripts
Repository: incubator-systemml
Updated Branches:
refs/heads/master bdc1f4edb -> 1fc5ce121
[SYSTEMML-486] Java opts to standalone scripts
Allow Java options to be set via SYSTEMML_STANDALONE_OPTS env var.
Closes #81.
Project: http://git-wip-us.apache.org/repos/asf/incubator-systemml/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-systemml/commit/1fc5ce12
Tree: http://git-wip-us.apache.org/repos/asf/incubator-systemml/tree/1fc5ce12
Diff: http://git-wip-us.apache.org/repos/asf/incubator-systemml/diff/1fc5ce12
Branch: refs/heads/master
Commit: 1fc5ce12104f12b2c5689debc412296098ae73ef
Parents: bdc1f4e
Author: Deron Eriksson <de...@us.ibm.com>
Authored: Thu Apr 7 12:10:14 2016 -0700
Committer: Deron Eriksson <de...@us.ibm.com>
Committed: Thu Apr 7 12:10:14 2016 -0700
----------------------------------------------------------------------
bin/systemml.bat | 2 +-
src/main/standalone/runStandaloneSystemML.bat | 37 +++++++++++++++++++---
src/main/standalone/runStandaloneSystemML.sh | 29 ++++++++++++++---
3 files changed, 58 insertions(+), 10 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/1fc5ce12/bin/systemml.bat
----------------------------------------------------------------------
diff --git a/bin/systemml.bat b/bin/systemml.bat
index d369927..3fc86a8 100755
--- a/bin/systemml.bat
+++ b/bin/systemml.bat
@@ -60,7 +60,7 @@ IF "%USER_DIR%" == "%PROJECT_ROOT_DIR%\bin" (
)
-:: if the SystemML-config.xml does not exis, create it from the template
+:: if the SystemML-config.xml does not exist, create it from the template
IF NOT EXIST "%PROJECT_ROOT_DIR%\conf\SystemML-config.xml" (
copy "%PROJECT_ROOT_DIR%\conf\SystemML-config.xml.template" ^
"%PROJECT_ROOT_DIR%\conf\SystemML-config.xml" > nul
http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/1fc5ce12/src/main/standalone/runStandaloneSystemML.bat
----------------------------------------------------------------------
diff --git a/src/main/standalone/runStandaloneSystemML.bat b/src/main/standalone/runStandaloneSystemML.bat
index f837970..9275d9e 100644
--- a/src/main/standalone/runStandaloneSystemML.bat
+++ b/src/main/standalone/runStandaloneSystemML.bat
@@ -30,21 +30,48 @@ setLocal EnableDelayedExpansion
SET HADOOP_HOME=%CD%/lib/hadoop
set CLASSPATH=./lib/*
-echo !CLASSPATH!
set LOG4JPROP=log4j.properties
for /f "tokens=1,* delims= " %%a in ("%*") do set ALLBUTFIRST=%%b
-java -Xmx4g -Xms4g -Xmn400m -cp %CLASSPATH% -Dlog4j.configuration=file:%LOG4JPROP% org.apache.sysml.api.DMLScript -f %1 -exec singlenode -config=SystemML-config.xml %ALLBUTFIRST%
+IF "%SYSTEMML_STANDALONE_OPTS%" == "" (
+ SET SYSTEMML_STANDALONE_OPTS=-Xmx4g -Xms4g -Xmn400m
+)
+
+:: construct the java command with options and arguments
+set CMD=java %SYSTEMML_STANDALONE_OPTS% ^
+ -cp %CLASSPATH% ^
+ -Dlog4j.configuration=file:%LOG4JPROP% ^
+ org.apache.sysml.api.DMLScript ^
+ -f %1 ^
+ -exec singlenode ^
+ -config=SystemML-config.xml ^
+ %ALLBUTFIRST%
+
+:: execute the java command
+%CMD%
+
+:: if there was an error, display the full java command
+::IF ERRORLEVEL 1 (
+:: ECHO Failed to run SystemML. Exit code: %ERRORLEVEL%
+:: SET LF=^
+::
+::
+:: :: keep empty lines above for the line breaks
+:: ECHO %CMD: =!LF! %
+:: EXIT /B %ERRORLEVEL%
+::)
+
GOTO End
:Err
-ECHO "Wrong Usage. Please provide DML filename to be executed."
+ECHO Wrong Usage. Please provide DML filename to be executed.
GOTO Msg
:Msg
-ECHO "Usage: runStandaloneSystemML.bat <dml-filename> [arguments] [-help]"
-ECHO "Script internally invokes 'java -Xmx4g -Xms4g -Xmn400m -jar jSystemML.jar -f <dml-filename> -exec singlenode -config=SystemML-config.xml [Optional-Arguments]'"
+ECHO Usage: runStandaloneSystemML.bat ^<dml-filename^> [arguments] [-help]
+ECHO Default Java options (-Xmx4g -Xms4g -Xmn400m) can be overridden by setting SYSTEMML_STANDALONE_OPTS.
+ECHO Script internally invokes 'java [SYSTEMML_STANDALONE_OPTS] -cp ./lib/* -Dlog4j.configuration=file:log4j.properties org.apache.sysml.api.DMLScript -f ^<dml-filename^> -exec singlenode -config=SystemML-config.xml [arguments]'
:End
http://git-wip-us.apache.org/repos/asf/incubator-systemml/blob/1fc5ce12/src/main/standalone/runStandaloneSystemML.sh
----------------------------------------------------------------------
diff --git a/src/main/standalone/runStandaloneSystemML.sh b/src/main/standalone/runStandaloneSystemML.sh
index afd3db6..28000b4 100644
--- a/src/main/standalone/runStandaloneSystemML.sh
+++ b/src/main/standalone/runStandaloneSystemML.sh
@@ -26,10 +26,11 @@ printUsageExit()
cat << EOF
Usage: $0 <dml-filename> [arguments] [-help]
-help - Print this usage message and exit
+Default Java options (-Xmx4g -Xms4g -Xmn400m) can be overridden by setting SYSTEMML_STANDALONE_OPTS.
EOF
exit 1
}
-# Script internally invokes 'java -Xmx4g -Xms4g -Xmn400m -jar StandaloneSystemML.jar -f <dml-filename> -exec singlenode -config=SystemML-config.xml [Optional-Arguments]'
+# Script internally invokes 'java [SYSTEMML_STANDALONE_OPTS] -jar StandaloneSystemML.jar -f <dml-filename> -exec singlenode -config=SystemML-config.xml [arguments]'
while getopts "h:" options; do
case $options in
@@ -62,8 +63,28 @@ done
LOG4JPROP=log4j.properties
+# set default java opts if none supplied
+if [ -z "$SYSTEMML_STANDALONE_OPTS" ] ; then
+ SYSTEMML_STANDALONE_OPTS="-Xmx4g -Xms4g -Xmn400m"
+fi;
+
# invoke the jar with options and arguments
-java -Xmx4g -Xms4g -Xmn400m -cp ${CLASSPATH} -Dlog4j.configuration=file:${LOG4JPROP} org.apache.sysml.api.DMLScript \
- -f ${SCRIPT_FILE} -exec singlenode -config=$CURRENT_PATH"/SystemML-config.xml" \
- $@
+CMD="\
+java ${SYSTEMML_STANDALONE_OPTS} \
+-cp ${CLASSPATH} \
+-Dlog4j.configuration=file:${LOG4JPROP} \
+org.apache.sysml.api.DMLScript \
+-f ${SCRIPT_FILE} \
+-exec singlenode \
+-config=$CURRENT_PATH"/SystemML-config.xml" \
+$@"
+
+$CMD
+# if there was an error, display the full java command
+# RETURN_CODE=$?
+# if [ $RETURN_CODE -ne 0 ]
+# then
+# echo "Failed to run SystemML. Exit code: $RETURN_CODE"
+# echo ${CMD}
+# fi