You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@linkis.apache.org by pe...@apache.org on 2022/08/17 06:23:58 UTC
[incubator-linkis] branch dev-1.2.0 updated: jdbc get datasource info with published version info (#2823)
This is an automated email from the ASF dual-hosted git repository.
peacewong pushed a commit to branch dev-1.2.0
in repository https://gitbox.apache.org/repos/asf/incubator-linkis.git
The following commit(s) were added to refs/heads/dev-1.2.0 by this push:
new ae0ff1d51 jdbc get datasource info with published version info (#2823)
ae0ff1d51 is described below
commit ae0ff1d518c70c68d5e25fd65b2ab47a3fc92b42
Author: Casion <ca...@gmail.com>
AuthorDate: Wed Aug 17 14:23:53 2022 +0800
jdbc get datasource info with published version info (#2823)
---
.../jdbc/exception/JDBCDatasourceException.scala | 27 ++++++++++++++++++++++
.../jdbc/executer/JDBCEngineConnExecutor.scala | 24 +++++++++++++++----
.../jdbc/executer/JDBCMultiDatasourceParser.scala | 16 ++++++-------
3 files changed, 54 insertions(+), 13 deletions(-)
diff --git a/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/exception/JDBCDatasourceException.scala b/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/exception/JDBCDatasourceException.scala
new file mode 100644
index 000000000..f93a324a6
--- /dev/null
+++ b/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/exception/JDBCDatasourceException.scala
@@ -0,0 +1,27 @@
+/*
+ * 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.manager.engineplugin.jdbc.exception
+
+import org.apache.linkis.common.exception.ErrorException
+
+class JDBCGetDatasourceInfoException(errorDesc: String) extends ErrorException(70022, errorDesc) {
+ def this(errorDesc: String, t: Throwable) = {
+ this(errorDesc)
+ super.initCause(t)
+ }
+}
diff --git a/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/executer/JDBCEngineConnExecutor.scala b/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/executer/JDBCEngineConnExecutor.scala
index 031a9c602..1a0956b26 100644
--- a/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/executer/JDBCEngineConnExecutor.scala
+++ b/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/executer/JDBCEngineConnExecutor.scala
@@ -5,9 +5,9 @@
* 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.
@@ -19,6 +19,8 @@ package org.apache.linkis.manager.engineplugin.jdbc.executer
import java.sql.{Connection, ResultSet, SQLException, Statement}
import java.util
+import java.util.Collections
+
import org.apache.linkis.common.utils.{OverloadUtils, Utils}
import org.apache.linkis.engineconn.computation.executor.execute.{ConcurrentComputationExecutor, EngineExecutionContext}
import org.apache.linkis.engineconn.core.EngineConnObject
@@ -42,9 +44,9 @@ import org.apache.linkis.protocol.CacheableProtocol
import org.springframework.util.CollectionUtils
import org.apache.linkis.governance.common.paser.SQLCodeParser
import org.apache.linkis.manager.engineplugin.jdbc.constant.JDBCEngineConnConstant
+import org.apache.linkis.manager.engineplugin.jdbc.exception.JDBCGetDatasourceInfoException
import scala.collection.JavaConversions._
-
import scala.collection.mutable.ArrayBuffer
class JDBCEngineConnExecutor(override val outputPrintLimit: Int, val id: Int) extends ConcurrentComputationExecutor(outputPrintLimit) {
@@ -66,7 +68,18 @@ class JDBCEngineConnExecutor(override val outputPrintLimit: Int, val id: Int) ex
override def executeLine(engineExecutorContext: EngineExecutionContext, code: String): ExecuteResponse = {
val realCode = code.trim()
val taskId = engineExecutorContext.getJobId.get
- val properties: util.Map[String, String] = getJDBCRuntimeParams(engineExecutorContext)
+
+ var properties: util.Map[String, String] = Collections.emptyMap()
+
+
+ Utils.tryCatch({
+ properties = getJDBCRuntimeParams(engineExecutorContext)
+ }) {
+ e: Throwable =>
+ logger.error(s"try to build JDBC runtime params error! $e")
+ return ErrorExecuteResponse(e.getMessage, e)
+ }
+
logger.info(s"The jdbc properties is: $properties")
val dataSourceName = properties.get(JDBCEngineConnConstant.JDBC_ENGINE_RUN_TIME_DS)
val dataSourceMaxVersionId = properties.get(JDBCEngineConnConstant.JDBC_ENGINE_RUN_TIME_DS_MAX_VERSION_ID)
@@ -153,7 +166,8 @@ class JDBCEngineConnExecutor(override val outputPrintLimit: Int, val id: Int) ex
Utils.tryCatch {
dataSourceInfo = JDBCMultiDatasourceParser.queryDatasourceInfoByName(dataSourceName, execSqlUser, dataSourceQuerySystemParam)
} {
- e: Throwable => logger.error(s"Failed to get datasource info about [$dataSourceName] from datasource server.", e)
+ e: Throwable =>
+ throw new JDBCGetDatasourceInfoException(s"Failed to get datasource info about [$dataSourceName] from datasource server.", e)
}
}
if (StringUtils.isBlank(dataSourceName)) {
diff --git a/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/executer/JDBCMultiDatasourceParser.scala b/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/executer/JDBCMultiDatasourceParser.scala
index 560bccb92..06912f58f 100644
--- a/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/executer/JDBCMultiDatasourceParser.scala
+++ b/linkis-engineconn-plugins/jdbc/src/main/scala/org/apache/linkis/manager/engineplugin/jdbc/executer/JDBCMultiDatasourceParser.scala
@@ -18,14 +18,16 @@
package org.apache.linkis.manager.engineplugin.jdbc.executer
import java.util
+
import org.apache.commons.lang3.StringUtils
import org.apache.linkis.common.utils.{JsonUtils, Logging, Utils}
import org.apache.linkis.datasource.client.impl.LinkisDataSourceRemoteClient
-import org.apache.linkis.datasource.client.request.GetInfoByDataSourceNameAction
+import org.apache.linkis.datasource.client.request.GetInfoPublishedByDataSourceNameAction
import org.apache.linkis.datasourcemanager.common.domain.DataSource
import org.apache.linkis.manager.engineplugin.jdbc.JdbcAuthType
import org.apache.linkis.manager.engineplugin.jdbc.constant.JDBCEngineConnConstant
import org.apache.linkis.manager.engineplugin.jdbc.exception.JDBCParamsIllegalException
+
import scala.collection.JavaConversions._
object JDBCMultiDatasourceParser extends Logging {
@@ -34,15 +36,13 @@ object JDBCMultiDatasourceParser extends Logging {
logger.info(s"Starting query [$system, $username, $datasourceName] datasource info ......")
val dataSourceClient = new LinkisDataSourceRemoteClient()
var dataSource: DataSource = null
- Utils.tryCatch {
- dataSource = dataSourceClient.getInfoByDataSourceName(GetInfoByDataSourceNameAction.builder()
+
+ dataSource = dataSourceClient.getInfoPublishedByDataSourceName(GetInfoPublishedByDataSourceNameAction.builder()
.setSystem(system)
.setDataSourceName(datasourceName)
.setUser(username)
.build()).getDataSource
- } {
- case e: Exception => logger.warn(s"Get data source info error, $e")
- }
+
queryDatasourceInfo(datasourceName, dataSource)
}
@@ -58,8 +58,8 @@ object JDBCMultiDatasourceParser extends Logging {
}
var maxVersionId = "0"
- if (dataSource.getVersionId != null) {
- maxVersionId = dataSource.getVersionId.toString
+ if (dataSource.getPublishedVersionId != null) {
+ maxVersionId = dataSource.getPublishedVersionId.toString
}
dsConnInfo.put(JDBCEngineConnConstant.JDBC_ENGINE_RUN_TIME_DS_MAX_VERSION_ID, maxVersionId)
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@linkis.apache.org
For additional commands, e-mail: commits-help@linkis.apache.org