You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@linkis.apache.org by "peacewong (via GitHub)" <gi...@apache.org> on 2023/03/14 07:06:30 UTC

[GitHub] [linkis] peacewong commented on a diff in pull request #4359: feat: HiveEngineConn supports concurrency.(#4175)

peacewong commented on code in PR #4359:
URL: https://github.com/apache/linkis/pull/4359#discussion_r1134866630


##########
linkis-engineconn-plugins/hive/src/main/scala/org/apache/linkis/engineplugin/hive/creation/HiveEngineConnFactory.scala:
##########
@@ -64,17 +68,22 @@ class HiveEngineConnFactory extends ComputationSingleExecutorEngineConnFactory w
           hiveSession.baos
         )
       case _ =>
-        throw HiveSessionStartFailedException(
-          CREATE_HIVE_EXECUTOR_ERROR.getErrorCode,
-          CREATE_HIVE_EXECUTOR_ERROR.getErrorDesc
-        )
+        new HiveEngineConcurrentConnExecutor(id)
     }
   }
 
   override protected def createEngineConnSession(
       engineCreationContext: EngineCreationContext
   ): HiveSession = {
-    val options = engineCreationContext.getOptions
+    // if hive engine support concurrent, hive session should init later
+    if (HiveEngineConfiguration.HIVE_ENGINE_CONCURRENT_SUPPORT) {
+      return null

Review Comment:
   This should return a concurrent session better, so that newExecutor can case the new session and keep the case _



##########
linkis-engineconn-plugins/hive/src/main/scala/org/apache/linkis/engineplugin/hive/conf/HiveEngineConfiguration.scala:
##########
@@ -40,4 +40,11 @@ object HiveEngineConfiguration {
   ).getValue
 
   val HIVE_ENGINE_TYPE = CommonVars[String]("wds.linkis.hive.engine.type", "mr").getValue
+
+  val HIVE_ENGINE_CONCURRENT_LIMIT =
+    CommonVars[Int]("wds.linkis.hive.engineconn.concurrent.limit", 10).getValue

Review Comment:
   The new parameter can remove the wds prefix



##########
linkis-engineconn-plugins/hive/src/main/scala/org/apache/linkis/engineplugin/hive/hook/HiveExecutionContextPropertyPrepareHook.scala:
##########
@@ -0,0 +1,62 @@
+/*
+ * 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.linkis.engineplugin.hive.hook
+
+import org.apache.linkis.common.utils.Logging
+import org.apache.linkis.engineconn.common.creation.EngineCreationContext
+import org.apache.linkis.engineconn.computation.executor.execute.EngineExecutionContext
+import org.apache.linkis.engineconn.computation.executor.hook.ComputationExecutorHook
+import org.apache.linkis.governance.common.utils.EngineConnArgumentsParser
+
+import scala.collection.JavaConverters._
+
+import org.slf4j.LoggerFactory
+
+class HiveExecutionContextPropertyPrepareHook extends ComputationExecutorHook with Logging {
+
+  private val LOG = LoggerFactory.getLogger(getClass)
+
+  override def getHookName(): String = "Prepare HiveExecutionContext Property."
+
+  override def beforeExecutorExecute(
+      engineExecutionContext: EngineExecutionContext,
+      engineCreationContext: EngineCreationContext,
+      codeBeforeHook: String
+  ): String = {
+    LOG.info(s"execute HiveExecutionContextInitHook beforeExecutorExecute")
+    val labels = engineCreationContext.getLabels.asScala
+      .map(l => EngineConnArgumentsParser.LABEL_PREFIX + l.getLabelKey -> l.getStringValue)
+      .toMap
+    var engineConnConf =
+      Map("ticketId" -> engineCreationContext.getTicketId, "user" -> engineCreationContext.getUser)
+    engineConnConf = engineConnConf ++: labels

Review Comment:
   labels can remove?



##########
linkis-engineconn-plugins/hive/src/main/scala/org/apache/linkis/engineplugin/hive/hook/HiveExecutionContextPropertyPrepareHook.scala:
##########
@@ -0,0 +1,62 @@
+/*
+ * 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.linkis.engineplugin.hive.hook
+
+import org.apache.linkis.common.utils.Logging
+import org.apache.linkis.engineconn.common.creation.EngineCreationContext
+import org.apache.linkis.engineconn.computation.executor.execute.EngineExecutionContext
+import org.apache.linkis.engineconn.computation.executor.hook.ComputationExecutorHook
+import org.apache.linkis.governance.common.utils.EngineConnArgumentsParser
+
+import scala.collection.JavaConverters._
+
+import org.slf4j.LoggerFactory
+
+class HiveExecutionContextPropertyPrepareHook extends ComputationExecutorHook with Logging {
+
+  private val LOG = LoggerFactory.getLogger(getClass)
+
+  override def getHookName(): String = "Prepare HiveExecutionContext Property."
+
+  override def beforeExecutorExecute(
+      engineExecutionContext: EngineExecutionContext,
+      engineCreationContext: EngineCreationContext,
+      codeBeforeHook: String
+  ): String = {
+    LOG.info(s"execute HiveExecutionContextInitHook beforeExecutorExecute")
+    val labels = engineCreationContext.getLabels.asScala
+      .map(l => EngineConnArgumentsParser.LABEL_PREFIX + l.getLabelKey -> l.getStringValue)
+      .toMap
+    var engineConnConf =
+      Map("ticketId" -> engineCreationContext.getTicketId, "user" -> engineCreationContext.getUser)
+    engineConnConf = engineConnConf ++: labels
+    engineConnConf = engineConnConf ++: engineCreationContext.getOptions.asScala
+      .filterNot(_._1.startsWith("spring."))
+      .toMap
+
+    for (kv <- engineConnConf) {
+      LOG.info(
+        s"beforeExecutorExecute engineExecutionContext addProperty key: ${kv._1} value: ${kv._2}"
+      )
+      engineExecutionContext.addProperty(kv._1, kv._2)

Review Comment:
   Is the priority of engineExecutionContext higher than engineCreationContext?



##########
linkis-computation-governance/linkis-engineconn/linkis-engineconn-core/pom.xml:
##########
@@ -34,6 +34,12 @@
       <version>${project.version}</version>
     </dependency>
 
+    <dependency>
+      <groupId>org.apache.linkis</groupId>
+      <artifactId>linkis-common</artifactId>

Review Comment:
   Is this import necessary? I saw it was fine 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@linkis.apache.org

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


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