[KYUUBI #6549] Correctly handle empty Java options for engines

[KYUUBI #6549] Fix 'Could not find or load main class when launching engine'

# 🔍 Description
## Issue References 🔗

This pull request fixes #6549

## Describe Your Solution 🔧

When obtaining configuration items, if it is null or empty, return none

## Types of changes 🔖

- [ ] Bugfix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to change)

## Test Plan 🧪

#### Behavior Without This Pull Request ⚰️

#### Behavior With This Pull Request 🎉

#### Related Unit Tests

---

# Checklist 📝

- [ ] This patch was not authored or co-authored using [Generative Tooling](https://www.apache.org/legal/generative-tooling.html)

**Be nice. Be informative.**

Closes #6556 from LiJie20190102/launch_engine.

Closes #6549

c57a08aff [lijie0203] [KYUUBI #6549] Fix 'Could not find or load main class when launching engine'
642d807e2 [lijie0203] [KYUUBI #6549] Fix 'Could not find or load main class when launching engine'
67926094c [lijie0203] [KYUUBI #6549] Fix 'Could not find or load main class when launching engine'
4ba9fb587 [lijie0203] [KYUUBI #6549] Fix 'Could not find or load main class when launching engine'

Authored-by: lijie0203 <lijie@qishudi.com>
Signed-off-by: Cheng Pan <chengpan@apache.org>
This commit is contained in:
lijie0203 2024-08-05 15:47:35 +08:00 committed by Cheng Pan
parent 2a990beb71
commit edff97d3e9
No known key found for this signature in database
GPG Key ID: 8001952629BCC75D
8 changed files with 18 additions and 8 deletions

View File

@ -25,6 +25,7 @@ import java.nio.file.{Files, Paths}
import scala.collection.JavaConverters._
import scala.collection.mutable
import org.apache.commons.lang3.StringUtils
import org.apache.flink.configuration.{Configuration, RestOptions}
import org.apache.flink.runtime.minicluster.{MiniCluster, MiniClusterConfiguration}
@ -119,7 +120,7 @@ trait WithFlinkSQLEngineLocal extends KyuubiFunSuite with WithFlinkTestResources
val memory = conf.get(ENGINE_FLINK_MEMORY)
command += s"-Xmx$memory"
val javaOptions = conf.get(ENGINE_FLINK_JAVA_OPTIONS)
val javaOptions = conf.get(ENGINE_FLINK_JAVA_OPTIONS).filter(StringUtils.isNotBlank(_))
if (javaOptions.isDefined) {
command += javaOptions.get
}

View File

@ -29,6 +29,7 @@ import scala.collection.JavaConverters._
import scala.collection.mutable
import scala.collection.mutable.ListBuffer
import org.apache.commons.lang3.StringUtils
import org.apache.hadoop.conf.Configuration
import org.apache.hadoop.fs.{FileSystem, Path}
import org.apache.hadoop.fs.permission.FsPermission
@ -201,7 +202,8 @@ abstract class EngineYarnModeSubmitter extends Logging {
val javaOpts = ListBuffer[String]()
val javaOptions = kyuubiConf.get(ENGINE_DEPLOY_YARN_MODE_JAVA_OPTIONS)
val javaOptions =
kyuubiConf.get(ENGINE_DEPLOY_YARN_MODE_JAVA_OPTIONS).filter(StringUtils.isNotBlank(_))
if (javaOptions.isDefined) {
javaOpts += javaOptions.get
}

View File

@ -23,6 +23,7 @@ import java.nio.file.{Files, Paths}
import scala.collection.mutable
import com.google.common.annotations.VisibleForTesting
import org.apache.commons.lang3.StringUtils
import org.apache.kyuubi.{Logging, SCALA_COMPILE_VERSION, Utils}
import org.apache.kyuubi.config.KyuubiConf
@ -65,7 +66,7 @@ class ChatProcessBuilder(
val memory = conf.get(ENGINE_CHAT_MEMORY)
buffer += s"-Xmx$memory"
val javaOptions = conf.get(ENGINE_CHAT_JAVA_OPTIONS)
val javaOptions = conf.get(ENGINE_CHAT_JAVA_OPTIONS).filter(StringUtils.isNotBlank(_))
javaOptions.foreach(buffer += _)
val classpathEntries = new mutable.LinkedHashSet[String]

View File

@ -23,6 +23,7 @@ import java.nio.file.{Files, Paths}
import scala.collection.mutable
import com.google.common.annotations.VisibleForTesting
import org.apache.commons.lang3.StringUtils
import org.apache.kyuubi._
import org.apache.kyuubi.config.KyuubiConf
@ -152,7 +153,7 @@ class FlinkProcessBuilder(
val memory = conf.get(ENGINE_FLINK_MEMORY)
buffer += s"-Xmx$memory"
val javaOptions = conf.get(ENGINE_FLINK_JAVA_OPTIONS)
val javaOptions = conf.get(ENGINE_FLINK_JAVA_OPTIONS).filter(StringUtils.isNotBlank(_))
if (javaOptions.isDefined) {
buffer += javaOptions.get
}

View File

@ -23,6 +23,7 @@ import java.nio.file.{Files, Paths}
import scala.collection.mutable
import com.google.common.annotations.VisibleForTesting
import org.apache.commons.lang3.StringUtils
import org.apache.hadoop.security.UserGroupInformation
import org.apache.kyuubi._
@ -62,7 +63,7 @@ class HiveProcessBuilder(
val memory = conf.get(ENGINE_HIVE_MEMORY)
buffer += s"-Xmx$memory"
val javaOptions = conf.get(ENGINE_HIVE_JAVA_OPTIONS)
val javaOptions = conf.get(ENGINE_HIVE_JAVA_OPTIONS).filter(StringUtils.isNotBlank(_))
if (javaOptions.isDefined) {
buffer += javaOptions.get
}

View File

@ -23,6 +23,7 @@ import java.nio.file.Paths
import scala.collection.mutable
import com.google.common.annotations.VisibleForTesting
import org.apache.commons.lang3.StringUtils
import org.apache.hadoop.security.UserGroupInformation
import org.apache.kyuubi.{KyuubiException, Logging, SCALA_COMPILE_VERSION, Utils}
@ -71,7 +72,7 @@ class JdbcProcessBuilder(
val memory = conf.get(ENGINE_JDBC_MEMORY)
buffer += s"-Xmx$memory"
val javaOptions = conf.get(ENGINE_JDBC_JAVA_OPTIONS)
val javaOptions = conf.get(ENGINE_JDBC_JAVA_OPTIONS).filter(StringUtils.isNotBlank(_))
javaOptions.foreach(buffer += _)
val classpathEntries = new mutable.LinkedHashSet[String]

View File

@ -23,6 +23,8 @@ import java.util
import scala.collection.JavaConverters._
import scala.collection.mutable.ArrayBuffer
import org.apache.commons.lang3.StringUtils
import org.apache.kyuubi.{Logging, SCALA_COMPILE_VERSION, Utils}
import org.apache.kyuubi.config.KyuubiConf
import org.apache.kyuubi.config.KyuubiConf.{ENGINE_JDBC_EXTRA_CLASSPATH, ENGINE_JDBC_MEMORY}
@ -93,7 +95,7 @@ class JdbcYarnModeProcessBuilder(
private def jarFiles(isClasspath: Boolean): util.LinkedHashSet[String] = {
val jarEntries = new util.LinkedHashSet[String]
mainResource.foreach(jarEntries.add)
val javaOptions = conf.get(ENGINE_JDBC_EXTRA_CLASSPATH)
val javaOptions = conf.get(ENGINE_JDBC_EXTRA_CLASSPATH).filter(StringUtils.isNotBlank(_))
if (isClasspath) {
javaOptions.foreach(jarEntries.add)
}

View File

@ -23,6 +23,7 @@ import java.nio.file.Paths
import scala.collection.mutable
import com.google.common.annotations.VisibleForTesting
import org.apache.commons.lang3.StringUtils
import org.apache.kyuubi.{Logging, SCALA_COMPILE_VERSION, Utils}
import org.apache.kyuubi.config.KyuubiConf
@ -62,7 +63,7 @@ class TrinoProcessBuilder(
val memory = conf.get(ENGINE_TRINO_MEMORY)
buffer += s"-Xmx$memory"
val javaOptions = conf.get(ENGINE_TRINO_JAVA_OPTIONS)
val javaOptions = conf.get(ENGINE_TRINO_JAVA_OPTIONS).filter(StringUtils.isNotBlank(_))
if (javaOptions.isDefined) {
buffer += javaOptions.get
}