diff --git a/tools/gluten-it/common/src/main/java/org/apache/gluten/integration/SparkJvmOptions.java b/tools/gluten-it/common/src/main/java/org/apache/gluten/integration/SparkJvmOptions.java new file mode 100644 index 0000000000000..85c0912fd7c7a --- /dev/null +++ b/tools/gluten-it/common/src/main/java/org/apache/gluten/integration/SparkJvmOptions.java @@ -0,0 +1,42 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.gluten.integration; + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; + +public class SparkJvmOptions { + private static final String MODULE_OPTIONS_CLASS_NAME = "org.apache.spark.launcher.JavaModuleOptions"; + + public static String read() { + try { + final Class clazz = Class.forName("org.apache.spark.launcher.JavaModuleOptions"); + final Method method = clazz.getMethod("defaultModuleOptions"); + return (String) method.invoke(null); + } catch (ClassNotFoundException e) { + // Could happen in Spark 3.2 which doesn't have this class yet. + return ""; + } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { + throw new RuntimeException(e); + } + } + + public static void main(String[] args) { + System.out.println(read()); + } +} diff --git a/tools/gluten-it/sbin/gluten-it.sh b/tools/gluten-it/sbin/gluten-it.sh index 347ec9b461bb6..c5b60c49bec82 100755 --- a/tools/gluten-it/sbin/gluten-it.sh +++ b/tools/gluten-it/sbin/gluten-it.sh @@ -16,8 +16,6 @@ set -euf -GLUTEN_IT_JVM_ARGS=${GLUTEN_IT_JVM_ARGS:-"-Xmx2G -XX:ErrorFile=/var/log/java/hs_err_pid%p.log"} - BASEDIR=$(dirname $0) LIB_DIR=$BASEDIR/../package/target/lib @@ -28,6 +26,8 @@ fi JAR_PATH=$LIB_DIR/* +SPARK_JVM_OPTIONS=$($JAVA_HOME/bin/java -cp $JAR_PATH org.apache.gluten.integration.SparkJvmOptions) + EMBEDDED_SPARK_HOME=$BASEDIR/../spark-home export SPARK_HOME=${SPARK_HOME:-$EMBEDDED_SPARK_HOME} @@ -36,25 +36,10 @@ export SPARK_SCALA_VERSION=${SPARK_SCALA_VERSION:-'2.12'} echo "SPARK_HOME set at [$SPARK_HOME]." echo "SPARK_SCALA_VERSION set at [$SPARK_SCALA_VERSION]." -$JAVA_HOME/bin/java $GLUTEN_IT_JVM_ARGS \ - -XX:+IgnoreUnrecognizedVMOptions \ - --add-modules=jdk.incubator.vector \ - --add-opens=java.base/java.lang=ALL-UNNAMED \ - --add-opens=java.base/java.lang.invoke=ALL-UNNAMED \ - --add-opens=java.base/java.lang.reflect=ALL-UNNAMED \ - --add-opens=java.base/java.io=ALL-UNNAMED \ - --add-opens=java.base/java.net=ALL-UNNAMED \ - --add-opens=java.base/java.nio=ALL-UNNAMED \ - --add-opens=java.base/java.util=ALL-UNNAMED \ - --add-opens=java.base/java.util.concurrent=ALL-UNNAMED \ - --add-opens=java.base/java.util.concurrent.atomic=ALL-UNNAMED \ - --add-opens=java.base/jdk.internal.ref=ALL-UNNAMED \ - --add-opens=java.base/sun.nio.ch=ALL-UNNAMED \ - --add-opens=java.base/sun.nio.cs=ALL-UNNAMED \ - --add-opens=java.base/sun.security.action=ALL-UNNAMED \ - --add-opens=java.base/sun.util.calendar=ALL-UNNAMED \ - --add-opens=java.security.jgss/sun.security.krb5=ALL-UNNAMED \ - -Djdk.reflect.useDirectMethodHandle=false \ - -Dio.netty.tryReflectionSetAccessible=true \ +GLUTEN_IT_JVM_ARGS=${GLUTEN_IT_JVM_ARGS:-"-Xmx2G -XX:ErrorFile=/var/log/java/hs_err_pid%p.log"} + +$JAVA_HOME/bin/java \ + $SPARK_JVM_OPTIONS \ + $GLUTEN_IT_JVM_ARGS \ -cp $JAR_PATH \ org.apache.gluten.integration.Cli $@