yaooqinn commented on code in PR #3178:
URL: https://github.com/apache/incubator-kyuubi/pull/3178#discussion_r936536320
##########
docs/extensions/server/applications.rst:
##########
@@ -20,5 +20,116 @@ Manage Applications against Extra Cluster Managers
.. caution:: unstable
-.. warning::
- This page is still in-progress.
+Kyuubi supports configuring custom ``ApplicationOperation`` for certain extra
cluster manager which provides an ability to control application, including
getting information, killing.
+
+ .. code-block:: scala
+
+ 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
+
+ /**
+ * Kill the app/engine by the unique application tag
+ *
+ * @param tag the unique application tag for engine instance.
+ * For example,
+ * if the Hadoop Yarn is used, for spark applications,
+ * the tag will be preset via spark.yarn.tags
+ * @return a message contains response describing how the kill process.
+ *
+ * @note For implementations, please suppress exceptions and always
return KillResponse
+ */
+ def killApplicationByTag(tag: String): KillResponse
+
+ /**
+ * Get the engine/application status by the unique application tag
+ *
+ * @param tag the unique application tag for engine instance.
+ * @return [[ApplicationInfo]]
+ */
+ def getApplicationInfoByTag(tag: String): ApplicationInfo
+ }
+
+ /**
+ * (killed or not, hint message)
+ */
+ type KillResponse = (Boolean, String)
+
+ object ApplicationState extends Enumeration {
+ type ApplicationState = Value
+ val PENDING, RUNNING, FINISHED, KILLED, FAILED, ZOMBIE, NOT_FOUND,
UNKNOWN = Value
+ }
+
+ case class ApplicationInfo(
+ id: String,
+ name: String,
+ state: ApplicationState,
+ url: Option[String] = None,
+ error: Option[String] = None)
+
+For application state mapping, you can reference the implementation of yarn:
+
+ .. code-block:: scala
+
+ def toApplicationState(state: YarnApplicationState): ApplicationState =
state match {
+ case YarnApplicationState.NEW => ApplicationState.PENDING
+ case YarnApplicationState.NEW_SAVING => ApplicationState.PENDING
+ case YarnApplicationState.SUBMITTED => ApplicationState.PENDING
+ case YarnApplicationState.ACCEPTED => ApplicationState.PENDING
+ case YarnApplicationState.RUNNING => ApplicationState.RUNNING
+ case YarnApplicationState.FINISHED => ApplicationState.FINISHED
+ case YarnApplicationState.FAILED => ApplicationState.FAILED
+ case YarnApplicationState.KILLED => ApplicationState.KILLED
+ case _ =>
+ warn(s"The yarn driver state: $state is not supported, " +
+ "mark the application state as UNKNOWN.")
+ ApplicationState.UNKNOWN
+ }
+
+Build A Custom Application Operation
+------------------------------------
+
+- reference kyuubi-server
+
+ .. code-block:: xml
+
+ <dependency>
+ <groupId>org.apache.kyuubi</groupId>
+ <artifactId>kyuubi-server_2.12</artifactId>
+ <version>1.5.2-incubating</version>
+ <scope>provided</scope>
+ </dependency>
+
+- create a custom class which implements the
``org.apache.kyuubi.engine.ApplicationOperation``.
Review Comment:
It's ok to use FQCN here. and tt's also much better to use
`org.apache.kyuubi.engine.ApplicationOperation` the first time when it shows in
this page.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]