From 07e26a85e0f4e7722a7c37d195e660751efee178 Mon Sep 17 00:00:00 2001 From: fwang12 Date: Fri, 5 May 2023 10:07:22 +0800 Subject: [PATCH] [KYUUBI #4786] Support yarn-client and yarn-cluster for YarnApplicationOperation ### _Why are the changes needed?_ The spark master might be yarn-client and yarn-cluster ### _How was this patch tested?_ - [ ] Add some test cases that check the changes thoroughly including negative and positive cases if possible - [ ] Add screenshots for manual tests if appropriate - [x] [Run test](https://kyuubi.readthedocs.io/en/master/develop_tools/testing.html#running-tests) locally before make a pull request Closes #4786 from turboFei/yarn_client_cluster. Closes #4786 accab6b81 [fwang12] Support yarn-client and yarn-cluster Authored-by: fwang12 Signed-off-by: fwang12 --- .../apache/kyuubi/engine/KubernetesApplicationOperation.scala | 4 ++-- .../org/apache/kyuubi/engine/YarnApplicationOperation.scala | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala index 83792f52f..c569dc9dc 100644 --- a/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala +++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KubernetesApplicationOperation.scala @@ -17,6 +17,7 @@ package org.apache.kyuubi.engine +import java.util.Locale import java.util.concurrent.{ConcurrentHashMap, TimeUnit} import com.google.common.cache.{Cache, CacheBuilder, RemovalNotification} @@ -74,8 +75,7 @@ class KubernetesApplicationOperation extends ApplicationOperation with Logging { override def isSupported(clusterManager: Option[String]): Boolean = { // TODO add deploy mode to check whether is supported - kubernetesClient != null && clusterManager.nonEmpty && - clusterManager.get.toLowerCase.startsWith("k8s") + kubernetesClient != null && clusterManager.exists(_.toLowerCase(Locale.ROOT).startsWith("k8s")) } override def killApplicationByTag(tag: String): KillResponse = { diff --git a/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/YarnApplicationOperation.scala b/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/YarnApplicationOperation.scala index 446314208..ea2bf6dcd 100644 --- a/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/YarnApplicationOperation.scala +++ b/kyuubi-server/src/main/scala/org/apache/kyuubi/engine/YarnApplicationOperation.scala @@ -17,6 +17,8 @@ package org.apache.kyuubi.engine +import java.util.Locale + import scala.collection.JavaConverters._ import org.apache.hadoop.yarn.api.records.{FinalApplicationStatus, YarnApplicationState} @@ -46,7 +48,7 @@ class YarnApplicationOperation extends ApplicationOperation with Logging { } override def isSupported(clusterManager: Option[String]): Boolean = { - yarnClient != null && clusterManager.nonEmpty && "yarn".equalsIgnoreCase(clusterManager.get) + yarnClient != null && clusterManager.exists(_.toLowerCase(Locale.ROOT).startsWith("yarn")) } override def killApplicationByTag(tag: String): KillResponse = {