You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@kyuubi.apache.org by GitBox <gi...@apache.org> on 2022/04/22 10:08:24 UTC

[GitHub] [incubator-kyuubi] yaooqinn opened a new pull request, #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

yaooqinn opened a new pull request, #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447

   …
   
   <!--
   Thanks for sending a pull request!
   
   Here are some tips for you:
     1. If this is your first time, please read our contributor guidelines: https://kyuubi.readthedocs.io/en/latest/community/contributions.html
     2. If the PR is related to an issue in https://github.com/apache/incubator-kyuubi/issues, add '[KYUUBI #XXXX]' in your PR title, e.g., '[KYUUBI #XXXX] Your PR title ...'.
     3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][KYUUBI #XXXX] Your PR title ...'.
   -->
   
   ### _Why are the changes needed?_
   <!--
   Please clarify why the changes are needed. For instance,
     1. If you add a feature, you can talk about the use case of it.
     2. If you fix a bug, you can clarify why it is a bug.
   -->
   
   Add KyuubiApplicationManager in SessionManager for application management, currently support kill and get application information.
   
   The underlying cluster manager operation added in this PR are
   - local jps with SIG TERM KILL
   - YARN-client
   
   
   ### _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
   
   - [ ] [Run test](https://kyuubi.apache.org/docs/latest/develop_tools/testing.html#running-tests) locally before make a pull request
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] yaooqinn commented on pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#issuecomment-1107805049

   Yes. Only if we expose these APIs in the FE in the future, then we need to handle special strings


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] turboFei commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
turboFei commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r857078795


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/operation/BatchJobSubmission.scala:
##########
@@ -107,7 +107,7 @@ class BatchJobSubmission(session: KyuubiBatchSessionImpl, batchRequest: BatchReq
         Thread.sleep(applicationCheckInterval)
       }
       val state = applicationStatus.get(ApplicationOperation.APP_STATE_KEY)
-      if (state == "KILLED" || state == "FINISHED") {
+      if (state == "KILLED" || state == "FINISHED" || state == "FAILED") {
         process.destroyForcibly()
         throw new RuntimeException("Batch job failed:" + applicationStatus.get.mkString(","))

Review Comment:
   why we throw RuntimeException if the application state is `FINISHED`?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] SteNicholas commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
SteNicholas commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r856133066


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/flink/FlinkProcessBuilder.scala:
##########
@@ -78,34 +75,6 @@ class FlinkProcessBuilder(
 
   override protected def commands: Array[String] = Array(executable)
 
-  override def killApplication(clue: Either[String, String]): String = clue match {
-    case Left(_) => ""
-    case Right(line) => killApplicationByLog(line)
-  }
-
-  def killApplicationByLog(line: String = lastRowsOfLog.toArray.mkString("\n")): String = {
-    "Job ID: .*".r.findFirstIn(line) match {

Review Comment:
   Because of the invalid implementations, I would like to open a pull request to support this. You could delete it directly.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] yaooqinn commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r857058899


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/KyuubiApplicationManager.scala:
##########
@@ -0,0 +1,129 @@
+/*
+ * 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.kyuubi.engine
+
+import java.util.ServiceLoader
+
+import scala.collection.JavaConverters._
+import scala.util.control.NonFatal
+
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.service.AbstractService
+
+class KyuubiApplicationManager extends AbstractService("KyuubiApplicationManager") {
+
+  // TODO: maybe add a configuration is better
+  private val operations = {
+    ServiceLoader.load(classOf[ApplicationOperation], getClass.getClassLoader)
+      .iterator().asScala.toSeq
+  }
+
+  override def initialize(conf: KyuubiConf): Unit = {
+    operations.foreach { op =>
+      try {
+        op.initialize(conf)
+      } catch {
+        case NonFatal(e) => warn(s"Error starting ${op.getClass.getSimpleName}: ${e.getMessage}")
+      }
+    }
+    super.initialize(conf)
+  }
+
+  override def stop(): Unit = {
+    operations.foreach { op =>
+      try {
+        op.stop()
+      } catch {
+        case NonFatal(e) => warn(s"Error stopping ${op.getClass.getSimpleName}: ${e.getMessage}")
+      }
+    }
+    super.stop()
+  }
+
+  def killApplication(resourceManager: Option[String], tag: String): KillResponse = {
+    var (killed, lastMessage): KillResponse = (false, null)
+    for (operation <- operations if !killed) {
+      if (operation.isSupported(resourceManager)) {
+        val (k, m) = operation.killApplicationByTag(tag)
+        killed = k
+        lastMessage = m
+      }
+    }
+
+    val finalMessage =
+      if (lastMessage == null) {
+        s"No ${classOf[ApplicationOperation]} Service found in ServiceLoader" +
+          s" for $resourceManager"
+      } else {
+        lastMessage
+      }
+    (killed, finalMessage)
+  }
+
+  def getApplicationInfo(
+      clusterManager: Option[String],
+      tag: String): Option[Map[String, String]] = {
+    operations.find(_.isSupported(clusterManager)).map(_.getApplicationInfoByTag(tag))
+  }
+}
+
+object KyuubiApplicationManager {
+  private def setupSparkYarnTag(tag: String, conf: KyuubiConf): Unit = {
+    val originalTag = conf.getOption("spark.yarn.tags").map(_ + ",").getOrElse("")
+    val newTag = s"${originalTag}KYUUBI,$tag"
+    conf.set("spark.yarn.tags", newTag)
+  }
+
+  private def setupSparkK8sTag(tag: String, conf: KyuubiConf): Unit = {
+    conf.set("spark.kubernetes.driver.label.kyuubi_unique_tag", tag)
+  }
+
+  private def setupFlinkK8sTag(tag: String, conf: KyuubiConf): Unit = {
+    // TODO: yarn.tags or flink.yarn.tags, the mess of flink settings confuses me now.

Review Comment:
   cc @deadwind4 @SteNicholas 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] yaooqinn commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r857079143


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/operation/BatchJobSubmission.scala:
##########
@@ -107,7 +107,7 @@ class BatchJobSubmission(session: KyuubiBatchSessionImpl, batchRequest: BatchReq
         Thread.sleep(applicationCheckInterval)
       }
       val state = applicationStatus.get(ApplicationOperation.APP_STATE_KEY)
-      if (state == "KILLED" || state == "FINISHED") {
+      if (state == "KILLED" || state == "FINISHED" || state == "FAILED") {
         process.destroyForcibly()
         throw new RuntimeException("Batch job failed:" + applicationStatus.get.mkString(","))

Review Comment:
   my mistake



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] yaooqinn commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r856136612


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/flink/FlinkProcessBuilder.scala:
##########
@@ -78,34 +75,6 @@ class FlinkProcessBuilder(
 
   override protected def commands: Array[String] = Array(executable)
 
-  override def killApplication(clue: Either[String, String]): String = clue match {
-    case Left(_) => ""
-    case Right(line) => killApplicationByLog(line)
-  }
-
-  def killApplicationByLog(line: String = lastRowsOfLog.toArray.mkString("\n")): String = {
-    "Job ID: .*".r.findFirstIn(line) match {

Review Comment:
   thanks @SteNicholas 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] ulysses-you commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
ulysses-you commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r856198013


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/ApplicationOperation.scala:
##########
@@ -0,0 +1,75 @@
+/*
+ * 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.kyuubi.engine
+
+import org.apache.kyuubi.config.KyuubiConf
+
+trait ApplicationOperation {
+
+  /**
+   * Step for initializing the instance.
+   */
+  def initialize(conf: KyuubiConf): Unit
+
+  /**
+   * Step to clean up the instance
+   */
+  def stop(): Unit
+
+  /**
+   * Called before other method to do a quick skip
+   *
+   * @param clusterManager the underlying cluster manager or just local instance
+   */
+  def isSupported(clusterManager: Option[String]): Boolean

Review Comment:
   shall we pass engine type as a input parameter ?  for example: it's obvious that we can not kill trino with jps operation.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] yaooqinn commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r856225516


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/ApplicationOperation.scala:
##########
@@ -0,0 +1,75 @@
+/*
+ * 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.kyuubi.engine
+
+import org.apache.kyuubi.config.KyuubiConf
+
+trait ApplicationOperation {
+
+  /**
+   * Step for initializing the instance.
+   */
+  def initialize(conf: KyuubiConf): Unit
+
+  /**
+   * Step to clean up the instance
+   */
+  def stop(): Unit
+
+  /**
+   * Called before other method to do a quick skip
+   *
+   * @param clusterManager the underlying cluster manager or just local instance
+   */
+  def isSupported(clusterManager: Option[String]): Boolean

Review Comment:
   we are going to support launching the engine instance like hive/trino/flink via yarn or k8s



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] turboFei commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
turboFei commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r856884267


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/YarnApplicationOperation.scala:
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.kyuubi.engine
+
+import scala.collection.JavaConverters._
+
+import org.apache.hadoop.yarn.client.api.YarnClient
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.engine.ApplicationOperation._
+import org.apache.kyuubi.util.KyuubiHadoopUtils
+
+class YarnApplicationOperation extends ApplicationOperation with Logging {
+
+  @volatile private var yarnClient: YarnClient = _

Review Comment:
   It seems that the `YarnApplicationOperation` is singleton, should we use a global yarnClient?
   
   
   Is it better to use temporary yarnClient per request?
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] yaooqinn commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r857060362


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/YarnApplicationOperation.scala:
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.kyuubi.engine
+
+import scala.collection.JavaConverters._
+
+import org.apache.hadoop.yarn.client.api.YarnClient
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.engine.ApplicationOperation._
+import org.apache.kyuubi.util.KyuubiHadoopUtils
+
+class YarnApplicationOperation extends ApplicationOperation with Logging {
+
+  @volatile private var yarnClient: YarnClient = _

Review Comment:
   We can add ThreadedYarnApplicationOperation later. For most use case the current implementation is enough



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] turboFei commented on pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
turboFei commented on PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#issuecomment-1107804236

   > this is intentional. `jps -ml | grep have a space` to test error handling
   
   I see it should be 
   
   ```
   jps -ml | grep 'have a space'
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] turboFei commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
turboFei commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r856884267


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/YarnApplicationOperation.scala:
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.kyuubi.engine
+
+import scala.collection.JavaConverters._
+
+import org.apache.hadoop.yarn.client.api.YarnClient
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.engine.ApplicationOperation._
+import org.apache.kyuubi.util.KyuubiHadoopUtils
+
+class YarnApplicationOperation extends ApplicationOperation with Logging {
+
+  @volatile private var yarnClient: YarnClient = _

Review Comment:
   It seems that the `YarnApplicationOperation` is singleton.
   
   
   Is it better to use temporary yarnClient per request?
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] turboFei commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
turboFei commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r857058710


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/YarnApplicationOperation.scala:
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.kyuubi.engine
+
+import scala.collection.JavaConverters._
+
+import org.apache.hadoop.yarn.client.api.YarnClient
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.engine.ApplicationOperation._
+import org.apache.kyuubi.util.KyuubiHadoopUtils
+
+class YarnApplicationOperation extends ApplicationOperation with Logging {
+
+  @volatile private var yarnClient: YarnClient = _

Review Comment:
   thread-sharing yarn client sounds good



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] yaooqinn commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r857078685


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/operation/BatchJobSubmission.scala:
##########
@@ -97,34 +101,29 @@ class BatchJobSubmission(session: KyuubiBatchSessionImpl, batchRequest: BatchReq
     try {
       info(s"Submitting ${batchRequest.batchType} batch job: $builder")
       val process = builder.start
-      while (appIdAndUrl.isEmpty) {
-        try {
-          builder match {
-            case sparkBatchProcessBuilder: SparkBatchProcessBuilder =>
-              sparkBatchProcessBuilder.getApplicationIdAndUrl() match {
-                case Some(appInfo) => appIdAndUrl = Some(appInfo)
-                case _ =>
-              }
-
-            case _ =>
-          }
-        } catch {
-          case e: Exception => error(s"Failed to check batch application", e)
-        }
+      var applicationStatus = currentApplicationState
+      while (applicationStatus.isEmpty) {
+        applicationStatus = currentApplicationState
         Thread.sleep(applicationCheckInterval)
       }
-      process.waitFor()
-      if (process.exitValue() != 0) {
-        throw new KyuubiException(s"Process exit with value ${process.exitValue()}")
+      val state = applicationStatus.get(ApplicationOperation.APP_STATE_KEY)
+      if (state == "KILLED" || state == "FINISHED") {

Review Comment:
   FAILED added



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] turboFei commented on pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
turboFei commented on PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#issuecomment-1107801932

   There is still some abnormal log:
   
   ```
   JpsApplicationOperationSuite:
   grep: a: No such file or directory
   grep: space: No such file or directory
   I/O error Pipe closed for process: [jps, -ml]
   java.io.IOException: Pipe closed
   	at java.io.PipedInputStream.checkStateForReceive(PipedInputStream.java:260)
   	at java.io.PipedInputStream.receive(PipedInputStream.java:226)
   	at java.io.PipedOutputStream.write(PipedOutputStream.java:149)
   	at scala.sys.process.BasicIO$.loop$1(BasicIO.scala:240)
   	at scala.sys.process.BasicIO$.transferFullyImpl(BasicIO.scala:246)
   	at scala.sys.process.BasicIO$.transferFully(BasicIO.scala:227)
   	at scala.sys.process.ProcessImpl$PipeThread.runloop(ProcessImpl.scala:170)
   	at scala.sys.process.ProcessImpl$PipeSource.run(ProcessImpl.scala:188)
     S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT     GCT   
    70.36   0.00  75.90  32.61  96.28  96.58     22    0.214     4    0.463    0.677
   - JpsApplicationOperation with jstat
   - JpsApplicationOperation with spark local mode
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] turboFei commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
turboFei commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r857078043


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/operation/BatchJobSubmission.scala:
##########
@@ -97,34 +101,29 @@ class BatchJobSubmission(session: KyuubiBatchSessionImpl, batchRequest: BatchReq
     try {
       info(s"Submitting ${batchRequest.batchType} batch job: $builder")
       val process = builder.start
-      while (appIdAndUrl.isEmpty) {
-        try {
-          builder match {
-            case sparkBatchProcessBuilder: SparkBatchProcessBuilder =>
-              sparkBatchProcessBuilder.getApplicationIdAndUrl() match {
-                case Some(appInfo) => appIdAndUrl = Some(appInfo)
-                case _ =>
-              }
-
-            case _ =>
-          }
-        } catch {
-          case e: Exception => error(s"Failed to check batch application", e)
-        }
+      var applicationStatus = currentApplicationState
+      while (applicationStatus.isEmpty) {
+        applicationStatus = currentApplicationState
         Thread.sleep(applicationCheckInterval)
       }
-      process.waitFor()
-      if (process.exitValue() != 0) {
-        throw new KyuubiException(s"Process exit with value ${process.exitValue()}")
+      val state = applicationStatus.get(ApplicationOperation.APP_STATE_KEY)
+      if (state == "KILLED" || state == "FINISHED") {

Review Comment:
   it should be `if (state == "KILLED" || state == "FAILED") `?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] yaooqinn commented on pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#issuecomment-1107802417

   this is intentional. `jps -ml | grep have a space`


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] yaooqinn commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r857077410


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/JpsApplicationOperation.scala:
##########
@@ -0,0 +1,92 @@
+/*
+ * 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.kyuubi.engine
+
+import java.nio.file.Paths
+
+import scala.sys.process._
+
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.engine.ApplicationOperation.NOT_FOUND
+
+class JpsApplicationOperation extends ApplicationOperation {
+
+  private val runner = {
+    val jps = sys.env.get("JAVA_HOME").orElse(sys.props.get("java.home"))
+      .map(Paths.get(_, "bin", "jps").toString)
+      .getOrElse("jps")
+    try {
+      jps.!!
+      jps
+    } catch {
+      case _: Throwable => null
+    }
+  }
+
+  override def initialize(conf: KyuubiConf): Unit = {}
+
+  override def isSupported(clusterManager: Option[String]): Boolean = {
+    runner != null && clusterManager.isEmpty || clusterManager.get == "local"

Review Comment:
   thanks, changed to var



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] yaooqinn commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r857056966


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/YarnApplicationOperation.scala:
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.kyuubi.engine
+
+import scala.collection.JavaConverters._
+
+import org.apache.hadoop.yarn.client.api.YarnClient
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.engine.ApplicationOperation._
+import org.apache.kyuubi.util.KyuubiHadoopUtils
+
+class YarnApplicationOperation extends ApplicationOperation with Logging {
+
+  @volatile private var yarnClient: YarnClient = _

Review Comment:
   I guess you are suggesting per thread not per request?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] cfmcgrady commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
cfmcgrady commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r857061526


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/JpsApplicationOperation.scala:
##########
@@ -0,0 +1,92 @@
+/*
+ * 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.kyuubi.engine
+
+import java.nio.file.Paths
+
+import scala.sys.process._
+
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.engine.ApplicationOperation.NOT_FOUND
+
+class JpsApplicationOperation extends ApplicationOperation {
+
+  private val runner = {
+    val jps = sys.env.get("JAVA_HOME").orElse(sys.props.get("java.home"))
+      .map(Paths.get(_, "bin", "jps").toString)
+      .getOrElse("jps")
+    try {
+      jps.!!
+      jps
+    } catch {
+      case _: Throwable => null
+    }
+  }
+
+  override def initialize(conf: KyuubiConf): Unit = {}
+
+  override def isSupported(clusterManager: Option[String]): Boolean = {
+    runner != null && clusterManager.isEmpty || clusterManager.get == "local"

Review Comment:
   nit: `clusterManager.isEmpty` is cheaper than `runner != null`
   
   ```scala
   clusterManager.isEmpty && runner != null
   ```
   
   and make `runner` lazy
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] yaooqinn commented on pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#issuecomment-1107781950

   > ```
   > JpsApplicationOperationSuite:
   > grep: a: No such file or directory
   > grep: space: No such file or directory
   > I/O error Pipe closed for process: [jps, -ml]
   > java.io.IOException: Pipe closed
   > 	at java.io.PipedInputStream.checkStateForReceive(PipedInputStream.java:260)
   > 	at java.io.PipedInputStream.receive(PipedInputStream.java:226)
   > 	at java.io.PipedOutputStream.write(PipedOutputStream.java:149)
   > 	at scala.sys.process.BasicIO$.loop$1(BasicIO.scala:240)
   > 	at scala.sys.process.BasicIO$.transferFullyImpl(BasicIO.scala:246)
   > 	at scala.sys.process.BasicIO$.transferFully(BasicIO.scala:227)
   > 	at scala.sys.process.ProcessImpl$PipeThread.runloop(ProcessImpl.scala:170)
   > 	at scala.sys.process.ProcessImpl$PipeSource.run(ProcessImpl.scala:188)
   >   S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT     GCT   
   >  64.63   0.00  74.70  36.03  96.31  96.42     18    0.218     4    0.427    0.646
   > - JpsApplicationOperation with jstat
   > - JpsApplicationOperation with spark local mode *** FAILED ***
   >   response._1 was false APPLICATION_NOT_FOUND (JpsApplicationOperationSuite.scala:89)
   > ```
   
   an invalid conf was introduced before


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] turboFei commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
turboFei commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r857058710


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/YarnApplicationOperation.scala:
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.kyuubi.engine
+
+import scala.collection.JavaConverters._
+
+import org.apache.hadoop.yarn.client.api.YarnClient
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.engine.ApplicationOperation._
+import org.apache.kyuubi.util.KyuubiHadoopUtils
+
+class YarnApplicationOperation extends ApplicationOperation with Logging {
+
+  @volatile private var yarnClient: YarnClient = _

Review Comment:
   thread shared yarn client sounds good



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] yaooqinn commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r856068147


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/flink/FlinkProcessBuilder.scala:
##########
@@ -78,34 +75,6 @@ class FlinkProcessBuilder(
 
   override protected def commands: Array[String] = Array(executable)
 
-  override def killApplication(clue: Either[String, String]): String = clue match {
-    case Left(_) => ""
-    case Right(line) => killApplicationByLog(line)
-  }
-
-  def killApplicationByLog(line: String = lastRowsOfLog.toArray.mkString("\n")): String = {
-    "Job ID: .*".r.findFirstIn(line) match {

Review Comment:
   this is an invalid implementation so I didn't move it somewhere but deleted it directly.
   
   
   
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] yaooqinn commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r856226960


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/ApplicationOperation.scala:
##########
@@ -0,0 +1,75 @@
+/*
+ * 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.kyuubi.engine
+
+import org.apache.kyuubi.config.KyuubiConf
+
+trait ApplicationOperation {
+
+  /**
+   * Step for initializing the instance.
+   */
+  def initialize(conf: KyuubiConf): Unit
+
+  /**
+   * Step to clean up the instance
+   */
+  def stop(): Unit
+
+  /**
+   * Called before other method to do a quick skip
+   *
+   * @param clusterManager the underlying cluster manager or just local instance
+   */
+  def isSupported(clusterManager: Option[String]): Boolean

Review Comment:
   we can add this whenever we found it's necessary, for the current status, this just makes the PR larger and harder to review. WDYT?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] turboFei commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
turboFei commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r856882720


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/operation/BatchJobSubmission.scala:
##########
@@ -43,12 +43,14 @@ class BatchJobSubmission(session: KyuubiBatchSessionImpl, batchRequest: BatchReq
 
   private lazy val _operationLog = OperationLog.createOperationLog(session, getHandle)
 
-  private var builder: ProcBuilder = _
+  private val applicationManager =
+    session.sessionManager.asInstanceOf[KyuubiSessionManager].applicationManager
 
-  @volatile
-  private[kyuubi] var appIdAndUrl: Option[(String, String)] = None
+  private var builder: ProcBuilder = _
 
-  private var resultFetched: Boolean = _
+  private[kyuubi] def currentApplicationState: Option[Map[String, String]] = {
+    applicationManager.getApplicationInfo(builder.clusterManager(), statementId)

Review Comment:
   Here the statementId is the Operation handle identifier not KyuubiBatchSession handle identifier.
   
   I think that it is better to use KyuubiBatchSession handle identifier, so that customers can also check batch job application by batch id.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] turboFei commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
turboFei commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r856884267


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/YarnApplicationOperation.scala:
##########
@@ -0,0 +1,107 @@
+/*
+ * 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.kyuubi.engine
+
+import scala.collection.JavaConverters._
+
+import org.apache.hadoop.yarn.client.api.YarnClient
+
+import org.apache.kyuubi.Logging
+import org.apache.kyuubi.config.KyuubiConf
+import org.apache.kyuubi.engine.ApplicationOperation._
+import org.apache.kyuubi.util.KyuubiHadoopUtils
+
+class YarnApplicationOperation extends ApplicationOperation with Logging {
+
+  @volatile private var yarnClient: YarnClient = _

Review Comment:
   It seems that the `YarnApplicationOperation` is singleton, should we use a global yarnClient?
   
   
   Is it better to use temporary yarnClient for per request?
   



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] yaooqinn closed pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
yaooqinn closed pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation
URL: https://github.com/apache/incubator-kyuubi/pull/2447


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] codecov-commenter commented on pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
codecov-commenter commented on PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#issuecomment-1106459758

   # [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/2447?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) Report
   > Merging [#2447](https://codecov.io/gh/apache/incubator-kyuubi/pull/2447?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (baac7f0) into [master](https://codecov.io/gh/apache/incubator-kyuubi/commit/6017917100c59e444dd7a9f89845106cd8616735?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) (6017917) will **increase** coverage by `0.29%`.
   > The diff coverage is `62.65%`.
   
   ```diff
   @@             Coverage Diff              @@
   ##             master    #2447      +/-   ##
   ============================================
   + Coverage     62.92%   63.22%   +0.29%     
     Complexity       69       69              
   ============================================
     Files           362      371       +9     
     Lines         17293    17493     +200     
     Branches       2334     2335       +1     
   ============================================
   + Hits          10882    11060     +178     
   - Misses         5387     5414      +27     
   + Partials       1024     1019       -5     
   ```
   
   
   | [Impacted Files](https://codecov.io/gh/apache/incubator-kyuubi/pull/2447?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | Coverage Δ | |
   |---|---|---|
   | [...n/scala/org/apache/kyuubi/engine/ProcBuilder.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2447/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9lbmdpbmUvUHJvY0J1aWxkZXIuc2NhbGE=) | `80.62% <0.00%> (+0.50%)` | :arrow_up: |
   | [...ache/kyuubi/engine/flink/FlinkProcessBuilder.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2447/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9lbmdpbmUvZmxpbmsvRmxpbmtQcm9jZXNzQnVpbGRlci5zY2FsYQ==) | `80.00% <ø> (+5.35%)` | :arrow_up: |
   | [.../main/scala/org/apache/kyuubi/engine/package.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2447/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9lbmdpbmUvcGFja2FnZS5zY2FsYQ==) | `0.00% <0.00%> (ø)` | |
   | [...apache/kyuubi/session/KyuubiBatchSessionImpl.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2447/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9zZXNzaW9uL0t5dXViaUJhdGNoU2Vzc2lvbkltcGwuc2NhbGE=) | `82.60% <ø> (-0.73%)` | :arrow_down: |
   | [...ache/kyuubi/engine/spark/SparkProcessBuilder.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2447/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9lbmdpbmUvc3BhcmsvU3BhcmtQcm9jZXNzQnVpbGRlci5zY2FsYQ==) | `78.68% <28.57%> (-0.14%)` | :arrow_down: |
   | [...pache/kyuubi/engine/KyuubiApplicationManager.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2447/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9lbmdpbmUvS3l1dWJpQXBwbGljYXRpb25NYW5hZ2VyLnNjYWxh) | `30.95% <30.95%> (ø)` | |
   | [...g/apache/kyuubi/operation/BatchJobSubmission.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2447/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9vcGVyYXRpb24vQmF0Y2hKb2JTdWJtaXNzaW9uLnNjYWxh) | `71.42% <60.00%> (+5.54%)` | :arrow_up: |
   | [...ain/scala/org/apache/kyuubi/engine/EngineRef.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2447/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9lbmdpbmUvRW5naW5lUmVmLnNjYWxh) | `77.22% <66.66%> (+1.73%)` | :arrow_up: |
   | [...pache/kyuubi/engine/YarnApplicationOperation.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2447/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9lbmdpbmUvWWFybkFwcGxpY2F0aW9uT3BlcmF0aW9uLnNjYWxh) | `78.04% <78.04%> (ø)` | |
   | [...apache/kyuubi/engine/JpsApplicationOperation.scala](https://codecov.io/gh/apache/incubator-kyuubi/pull/2447/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation#diff-a3l1dWJpLXNlcnZlci9zcmMvbWFpbi9zY2FsYS9vcmcvYXBhY2hlL2t5dXViaS9lbmdpbmUvSnBzQXBwbGljYXRpb25PcGVyYXRpb24uc2NhbGE=) | `83.87% <83.87%> (ø)` | |
   | ... and [26 more](https://codecov.io/gh/apache/incubator-kyuubi/pull/2447/diff?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation) | |
   
   ------
   
   [Continue to review full report at Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/2447?src=pr&el=continue&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   > **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation)
   > `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
   > Powered by [Codecov](https://codecov.io/gh/apache/incubator-kyuubi/pull/2447?src=pr&el=footer&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Last update [6017917...baac7f0](https://codecov.io/gh/apache/incubator-kyuubi/pull/2447?src=pr&el=lastupdated&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=The+Apache+Software+Foundation).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] yaooqinn commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r856202564


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/ApplicationOperation.scala:
##########
@@ -0,0 +1,75 @@
+/*
+ * 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.kyuubi.engine
+
+import org.apache.kyuubi.config.KyuubiConf
+
+trait ApplicationOperation {
+
+  /**
+   * Step for initializing the instance.
+   */
+  def initialize(conf: KyuubiConf): Unit
+
+  /**
+   * Step to clean up the instance
+   */
+  def stop(): Unit
+
+  /**
+   * Called before other method to do a quick skip
+   *
+   * @param clusterManager the underlying cluster manager or just local instance
+   */
+  def isSupported(clusterManager: Option[String]): Boolean

Review Comment:
   we can kill trino via jps



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] turboFei commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
turboFei commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r857078043


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/operation/BatchJobSubmission.scala:
##########
@@ -97,34 +101,29 @@ class BatchJobSubmission(session: KyuubiBatchSessionImpl, batchRequest: BatchReq
     try {
       info(s"Submitting ${batchRequest.batchType} batch job: $builder")
       val process = builder.start
-      while (appIdAndUrl.isEmpty) {
-        try {
-          builder match {
-            case sparkBatchProcessBuilder: SparkBatchProcessBuilder =>
-              sparkBatchProcessBuilder.getApplicationIdAndUrl() match {
-                case Some(appInfo) => appIdAndUrl = Some(appInfo)
-                case _ =>
-              }
-
-            case _ =>
-          }
-        } catch {
-          case e: Exception => error(s"Failed to check batch application", e)
-        }
+      var applicationStatus = currentApplicationState
+      while (applicationStatus.isEmpty) {
+        applicationStatus = currentApplicationState
         Thread.sleep(applicationCheckInterval)
       }
-      process.waitFor()
-      if (process.exitValue() != 0) {
-        throw new KyuubiException(s"Process exit with value ${process.exitValue()}")
+      val state = applicationStatus.get(ApplicationOperation.APP_STATE_KEY)
+      if (state == "KILLED" || state == "FINISHED") {

Review Comment:
   it should be `if (state == "KILLED" || state == "FAILED") `.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] turboFei commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
turboFei commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r856883170


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/operation/BatchJobSubmission.scala:
##########
@@ -86,7 +88,7 @@ class BatchJobSubmission(session: KyuubiBatchSessionImpl, batchRequest: BatchReq
         new SparkBatchProcessBuilder(
           session.user,
           session.sessionConf,
-          session.batchId,
+          statementId,

Review Comment:
   I think it is better to use batchId as tag instead of internal operation id.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] turboFei commented on pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
turboFei commented on PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#issuecomment-1107780818

   ```
   JpsApplicationOperationSuite:
   grep: a: No such file or directory
   grep: space: No such file or directory
   I/O error Pipe closed for process: [jps, -ml]
   java.io.IOException: Pipe closed
   	at java.io.PipedInputStream.checkStateForReceive(PipedInputStream.java:260)
   	at java.io.PipedInputStream.receive(PipedInputStream.java:226)
   	at java.io.PipedOutputStream.write(PipedOutputStream.java:149)
   	at scala.sys.process.BasicIO$.loop$1(BasicIO.scala:240)
   	at scala.sys.process.BasicIO$.transferFullyImpl(BasicIO.scala:246)
   	at scala.sys.process.BasicIO$.transferFully(BasicIO.scala:227)
   	at scala.sys.process.ProcessImpl$PipeThread.runloop(ProcessImpl.scala:170)
   	at scala.sys.process.ProcessImpl$PipeSource.run(ProcessImpl.scala:188)
     S0     S1     E      O      M     CCS    YGC     YGCT    FGC    FGCT     GCT   
    64.63   0.00  74.70  36.03  96.31  96.42     18    0.218     4    0.427    0.646
   - JpsApplicationOperation with jstat
   - JpsApplicationOperation with spark local mode *** FAILED ***
     response._1 was false APPLICATION_NOT_FOUND (JpsApplicationOperationSuite.scala:89)
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] ulysses-you commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
ulysses-you commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r856222925


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/ApplicationOperation.scala:
##########
@@ -0,0 +1,75 @@
+/*
+ * 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.kyuubi.engine
+
+import org.apache.kyuubi.config.KyuubiConf
+
+trait ApplicationOperation {
+
+  /**
+   * Step for initializing the instance.
+   */
+  def initialize(conf: KyuubiConf): Unit
+
+  /**
+   * Step to clean up the instance
+   */
+  def stop(): Unit
+
+  /**
+   * Called before other method to do a quick skip
+   *
+   * @param clusterManager the underlying cluster manager or just local instance
+   */
+  def isSupported(clusterManager: Option[String]): Boolean

Review Comment:
   oh .. I mean yarn



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] ulysses-you commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
ulysses-you commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r857061451


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/ApplicationOperation.scala:
##########
@@ -0,0 +1,75 @@
+/*
+ * 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.kyuubi.engine
+
+import org.apache.kyuubi.config.KyuubiConf
+
+trait ApplicationOperation {
+
+  /**
+   * Step for initializing the instance.
+   */
+  def initialize(conf: KyuubiConf): Unit
+
+  /**
+   * Step to clean up the instance
+   */
+  def stop(): Unit
+
+  /**
+   * Called before other method to do a quick skip
+   *
+   * @param clusterManager the underlying cluster manager or just local instance
+   */
+  def isSupported(clusterManager: Option[String]): Boolean

Review Comment:
   > we can add this whenever we found it's necessary
   
   I'm fine with it if now here we do not require



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] yaooqinn commented on pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#issuecomment-1107991312

   thanks, merged to master


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] yaooqinn commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r856236503


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/engine/ApplicationOperation.scala:
##########
@@ -0,0 +1,75 @@
+/*
+ * 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.kyuubi.engine
+
+import org.apache.kyuubi.config.KyuubiConf
+
+trait ApplicationOperation {
+
+  /**
+   * Step for initializing the instance.
+   */
+  def initialize(conf: KyuubiConf): Unit
+
+  /**
+   * Step to clean up the instance
+   */
+  def stop(): Unit
+
+  /**
+   * Called before other method to do a quick skip
+   *
+   * @param clusterManager the underlying cluster manager or just local instance
+   */
+  def isSupported(clusterManager: Option[String]): Boolean

Review Comment:
   Besides, `clusterManager` for hive/trino/flink now are all None which bypassing for yarn operation.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org


[GitHub] [incubator-kyuubi] yaooqinn commented on a diff in pull request #2447: [KYUUBI #2445] Implement ApplicationManager and Yarn/ JPS-local Application Operation

Posted by GitBox <gi...@apache.org>.
yaooqinn commented on code in PR #2447:
URL: https://github.com/apache/incubator-kyuubi/pull/2447#discussion_r857060371


##########
kyuubi-server/src/main/scala/org/apache/kyuubi/operation/BatchJobSubmission.scala:
##########
@@ -43,12 +43,14 @@ class BatchJobSubmission(session: KyuubiBatchSessionImpl, batchRequest: BatchReq
 
   private lazy val _operationLog = OperationLog.createOperationLog(session, getHandle)
 
-  private var builder: ProcBuilder = _
+  private val applicationManager =
+    session.sessionManager.asInstanceOf[KyuubiSessionManager].applicationManager
 
-  @volatile
-  private[kyuubi] var appIdAndUrl: Option[(String, String)] = None
+  private var builder: ProcBuilder = _
 
-  private var resultFetched: Boolean = _
+  private[kyuubi] def currentApplicationState: Option[Map[String, String]] = {
+    applicationManager.getApplicationInfo(builder.clusterManager(), statementId)

Review Comment:
   updated



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@kyuubi.apache.org
For additional commands, e-mail: notifications-help@kyuubi.apache.org