mirror of
https://github.com/enso-org/enso.git
synced 2024-11-26 08:52:58 +03:00
Open Java modules for Snowflake setup (#9664)
# Important Notes Some workarounds are being considered but we need this change sooner than later.
This commit is contained in:
parent
fda41cbfd1
commit
d6f7afc624
@ -7,6 +7,6 @@ for opt in "$@"; do
|
||||
fi
|
||||
done
|
||||
|
||||
|
||||
JAVA_OPTS="--add-opens=java.base/java.nio=ALL-UNNAMED $JAVA_OPTS"
|
||||
exec java --module-path $COMP_PATH -Dorg.graalvm.language.enso.home=$COMP_PATH $EXTRA_OPTS $JAVA_OPTS -m org.enso.runtime/org.enso.EngineRunnerBootLoader "$@"
|
||||
exit
|
||||
|
@ -6,5 +6,6 @@ if /I %%A==--dump-graphs (
|
||||
set EXTRA_OPTS=%EXTRA_OPTS% -Dgraal.Dump=Truffle:1
|
||||
)
|
||||
)
|
||||
set JAVA_OPTS=%JAVA_OPTS% --add-opens=java.base/java.nio=ALL-UNNAMED
|
||||
java --module-path %comp-dir% -Dorg.graalvm.language.enso.home=%comp-dir% -Dpolyglot.compiler.IterativePartialEscape=true %EXTRA_OPTS% %JAVA_OPTS% -m org.enso.runtime/org.enso.EngineRunnerBootLoader %*
|
||||
exit /B %errorlevel%
|
||||
|
@ -45,8 +45,10 @@ type Snowflake_Details
|
||||
Provides the properties for the connection.
|
||||
jdbc_properties : Vector (Pair Text Text)
|
||||
jdbc_properties self =
|
||||
## Avoid the Arrow dependency (https://community.snowflake.com/s/article/SAP-BW-Java-lang-NoClassDefFoundError-for-Apache-arrow)
|
||||
no_arrow = [Pair.new 'jdbc_query_result_format' 'json']
|
||||
## If Arrow dependency is to be avoided (https://community.snowflake.com/s/article/SAP-BW-Java-lang-NoClassDefFoundError-for-Apache-arrow)
|
||||
## [Pair.new 'jdbc_query_result_format' 'json']
|
||||
## should be prepended to properties. That would make it fallback to plain `json`.
|
||||
|
||||
account = [Pair.new 'account' self.account]
|
||||
credentials = [Pair.new 'user' self.credentials.username, Pair.new 'password' self.credentials.password]
|
||||
database = [Pair.new 'db' self.database]
|
||||
@ -55,4 +57,4 @@ type Snowflake_Details
|
||||
|
||||
## Control the format of TIMESTAMP and TIME fields
|
||||
formats = [Pair.new "TIME_OUTPUT_FORMAT" "HH24:MI:SS.FF9", Pair.new "TIMESTAMP_OUTPUT_FORMAT" "YYYY-MM-DD HH24:MI:SS.FF9 TZHTZM", Pair.new "TIMESTAMP_NTZ_OUTPUT_FORMAT" "YYYY-MM-DD HH24:MI:SS.FF9", Pair.new "TIMESTAMP_LTZ_OUTPUT_FORMAT" "YYYY-MM-DD HH24:MI:SS.FF9"]
|
||||
no_arrow + account + credentials + database + schema + warehouse + formats
|
||||
account + credentials + database + schema + warehouse + formats
|
||||
|
@ -96,7 +96,7 @@ case class Launcher(cliOptions: GlobalCLIOptions) {
|
||||
additionalArguments = additionalArguments
|
||||
)
|
||||
.get,
|
||||
JVMSettings(useSystemJVM, jvmOpts)
|
||||
JVMSettings(useSystemJVM, jvmOpts, extraOptions = Seq.empty)
|
||||
) { command =>
|
||||
command.run().get
|
||||
}
|
||||
@ -223,7 +223,7 @@ case class Launcher(cliOptions: GlobalCLIOptions) {
|
||||
additionalArguments
|
||||
)
|
||||
.get,
|
||||
JVMSettings(useSystemJVM, jvmOpts)
|
||||
JVMSettings(useSystemJVM, jvmOpts, extraOptions = Seq())
|
||||
) { command =>
|
||||
command.run().get
|
||||
}
|
||||
@ -267,7 +267,7 @@ case class Launcher(cliOptions: GlobalCLIOptions) {
|
||||
additionalArguments
|
||||
)
|
||||
.get,
|
||||
JVMSettings(useSystemJVM, jvmOpts)
|
||||
JVMSettings(useSystemJVM, jvmOpts, extraOptions = Seq())
|
||||
) { command =>
|
||||
command.run().get
|
||||
}
|
||||
@ -310,7 +310,7 @@ case class Launcher(cliOptions: GlobalCLIOptions) {
|
||||
additionalArguments
|
||||
)
|
||||
.get,
|
||||
JVMSettings(useSystemJVM, jvmOpts)
|
||||
JVMSettings(useSystemJVM, jvmOpts, Seq())
|
||||
) { command =>
|
||||
command.run().get
|
||||
}
|
||||
@ -346,7 +346,7 @@ case class Launcher(cliOptions: GlobalCLIOptions) {
|
||||
additionalArguments = additionalArguments
|
||||
)
|
||||
.get,
|
||||
JVMSettings(useSystemJVM, jvmOpts)
|
||||
JVMSettings(useSystemJVM, jvmOpts, extraOptions = Seq())
|
||||
) { command =>
|
||||
command.run().get
|
||||
}
|
||||
@ -413,8 +413,11 @@ case class Launcher(cliOptions: GlobalCLIOptions) {
|
||||
)
|
||||
.get
|
||||
|
||||
runner.withCommand(settings, JVMSettings(useSystemJVM, jvmOpts)) {
|
||||
command => command.run().get
|
||||
runner.withCommand(
|
||||
settings,
|
||||
JVMSettings(useSystemJVM, jvmOpts, extraOptions = Seq())
|
||||
) { command =>
|
||||
command.run().get
|
||||
}
|
||||
}
|
||||
|
||||
@ -530,7 +533,11 @@ case class Launcher(cliOptions: GlobalCLIOptions) {
|
||||
val runtimeVersionString = if (isEngineInstalled) {
|
||||
val output = runner.withCommand(
|
||||
runtimeVersionRunSettings,
|
||||
JVMSettings(useSystemJVM = false, jvmOptions = Seq.empty)
|
||||
JVMSettings(
|
||||
useSystemJVM = false,
|
||||
jvmOptions = Seq(),
|
||||
extraOptions = Seq()
|
||||
)
|
||||
) { runtimeVersionCommand =>
|
||||
runtimeVersionCommand.captureOutput().get
|
||||
}
|
||||
|
@ -92,7 +92,11 @@ class LauncherRunnerSpec extends RuntimeVersionManagerTest with FlakySpec {
|
||||
|
||||
runner.withCommand(
|
||||
runSettings,
|
||||
JVMSettings(useSystemJVM = true, jvmOptions = jvmOptions)
|
||||
JVMSettings(
|
||||
useSystemJVM = true,
|
||||
jvmOptions = jvmOptions,
|
||||
extraOptions = Seq()
|
||||
)
|
||||
) { systemCommand =>
|
||||
systemCommand.command.head shouldEqual "java"
|
||||
checkCommandLine(systemCommand)
|
||||
@ -100,7 +104,11 @@ class LauncherRunnerSpec extends RuntimeVersionManagerTest with FlakySpec {
|
||||
|
||||
runner.withCommand(
|
||||
runSettings,
|
||||
JVMSettings(useSystemJVM = false, jvmOptions = jvmOptions)
|
||||
JVMSettings(
|
||||
useSystemJVM = false,
|
||||
jvmOptions = jvmOptions,
|
||||
extraOptions = Seq()
|
||||
)
|
||||
) { managedCommand =>
|
||||
managedCommand.command.head should include("java")
|
||||
val javaHome =
|
||||
|
@ -100,7 +100,8 @@ class TestDistributionConfiguration(
|
||||
val javaCommand = JavaCommand(currentProcess, None)
|
||||
new JVMSettings(
|
||||
javaCommandOverride = Some(javaCommand),
|
||||
jvmOptions = Seq()
|
||||
jvmOptions = Seq(),
|
||||
extraOptions = Seq()
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,8 @@ class ProjectCreateHandleMissingRuntimeSpec
|
||||
) {
|
||||
override def defaultJVMSettings: JVMSettings = JVMSettings(
|
||||
javaCommandOverride = None,
|
||||
jvmOptions = Seq()
|
||||
jvmOptions = Seq(),
|
||||
extraOptions = Seq()
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -6,11 +6,13 @@ package org.enso.runtimeversionmanager.runner
|
||||
* instead of the default JVM provided with the
|
||||
* release; it can be an absolute path to a java
|
||||
* executable
|
||||
* @param jvmOptions options that should be added to the launched JVM
|
||||
* @param jvmOptions options that should be added to the launched JVM, will be prefixed with `-D`
|
||||
* @param extraOptions extra options that should be added to the launched JVM
|
||||
*/
|
||||
case class JVMSettings(
|
||||
javaCommandOverride: Option[JavaCommand],
|
||||
jvmOptions: Seq[(String, String)]
|
||||
jvmOptions: Seq[(String, String)],
|
||||
extraOptions: Seq[(String, String)]
|
||||
)
|
||||
|
||||
object JVMSettings {
|
||||
@ -19,20 +21,31 @@ object JVMSettings {
|
||||
*
|
||||
* @param useSystemJVM if set, the system configured JVM is used instead of
|
||||
* the one managed by the launcher
|
||||
* @param jvmOptions options that should be added to the launched JVM
|
||||
* @param jvmOptions options that should be added to the launched JVM, will be prefixed with `-D`
|
||||
* @param extraOptions extra options that should be added to the launched JVM
|
||||
*/
|
||||
def apply(
|
||||
useSystemJVM: Boolean,
|
||||
jvmOptions: Seq[(String, String)]
|
||||
jvmOptions: Seq[(String, String)],
|
||||
extraOptions: Seq[(String, String)]
|
||||
): JVMSettings =
|
||||
new JVMSettings(
|
||||
if (useSystemJVM) Some(JavaCommand.systemJavaCommand) else None,
|
||||
jvmOptions
|
||||
jvmOptions,
|
||||
extraOptions
|
||||
)
|
||||
|
||||
// See propositions in #9475 for alternatives
|
||||
private val nioOpen: (String, String) =
|
||||
("add-opens", "java.base/java.nio=ALL-UNNAMED")
|
||||
|
||||
/** Creates a default instance of [[JVMSettings]] that just use the default
|
||||
* JVM with no options overrides.
|
||||
*/
|
||||
def default: JVMSettings =
|
||||
JVMSettings(useSystemJVM = false, jvmOptions = Seq())
|
||||
JVMSettings(
|
||||
useSystemJVM = false,
|
||||
jvmOptions = Seq(),
|
||||
extraOptions = Seq(nioOpen)
|
||||
)
|
||||
}
|
||||
|
@ -168,10 +168,13 @@ class Runner(
|
||||
)
|
||||
}
|
||||
|
||||
def translateJVMOption(option: (String, String)): String = {
|
||||
def translateJVMOption(
|
||||
option: (String, String),
|
||||
standardOption: Boolean
|
||||
): String = {
|
||||
val name = option._1
|
||||
val value = option._2
|
||||
s"-D$name=$value"
|
||||
if (standardOption) s"-D$name=$value" else s"--$name=$value"
|
||||
}
|
||||
|
||||
val context = JVMOptionsContext(enginePackagePath = engine.path)
|
||||
@ -180,7 +183,12 @@ class Runner(
|
||||
engine.defaultJVMOptions.filter(_.isRelevant).map(_.substitute(context))
|
||||
val environmentOptions =
|
||||
jvmOptsFromEnvironment.map(_.split(' ').toIndexedSeq).getOrElse(Seq())
|
||||
val commandLineOptions = jvmSettings.jvmOptions.map(translateJVMOption)
|
||||
val commandLineOptions = jvmSettings.jvmOptions.map(
|
||||
translateJVMOption(_, standardOption = true)
|
||||
) ++
|
||||
jvmSettings.extraOptions.map(
|
||||
translateJVMOption(_, standardOption = false)
|
||||
)
|
||||
val shouldInvokeViaModulePath = engine.graalRuntimeVersion.isUnchained
|
||||
|
||||
var jvmArguments =
|
||||
|
Loading…
Reference in New Issue
Block a user