Skip to content

Commit 8d21791

Browse files
authored
appcon compatibility (#4420)
* engine bml resource compatible prefix v format
1 parent 1004308 commit 8d21791

File tree

8 files changed

+53
-13
lines changed

8 files changed

+53
-13
lines changed

docs/errorcode/linkis-engineconn-plugin-core-errorcode.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
| module name(模块名) | error code(错误码) | describe(描述) |enumeration name(枚举)| Exception Class(类名)|
44
| -------- | -------- | ----- |-----|-----|
55
|linkis-engineconn-plugin-core |10001|Failed to createEngineConnLaunchRequest(创建 EngineConnLaunchRequest失败)|FAILED_CREATE_ELR|EngineconnCoreErrorCodeSummary|
6-
|linkis-engineconn-plugin-core |10001|The engine plug-in material is abnormal, please check whether the material is uploaded successfully(引擎插件物料异常,请检查物料是否上传成功)|EN_PLUGIN_MATERIAL_SOURCE_EXCEPTION|EngineconnCoreErrorCodeSummary|
6+
|linkis-engineconn-plugin-core |10001|The engine plugin material is abnormal, please check whether the material is uploaded successfully(引擎插件物料异常,请检查物料是否上传成功)|EN_PLUGIN_MATERIAL_SOURCE_EXCEPTION|EngineconnCoreErrorCodeSummary|
77
|linkis-engineconn-plugin-core |10001|EngineTypeLabel are requested(需要参数 EngineTypeLabel)|ETL_REQUESTED|EngineconnCoreErrorCodeSummary|
88
|linkis-engineconn-plugin-core |20000|Cannot instance EngineConnExecution(无法实例化 EngineConnExecution)|CANNOT_INSTANCE_ECE|EngineconnCoreErrorCodeSummary|
99
|linkis-engineconn-plugin-core |20000|Cannot find default ExecutorFactory(找不到默认的 ExecutorFactory)|CANNOT_DEFAULT_EF|EngineconnCoreErrorCodeSummary|

linkis-commons/linkis-module/src/main/scala/org/apache/linkis/server/security/SecurityFilter.scala

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,11 @@ object SecurityFilter {
199199

200200
def getLoginUsername(req: HttpServletRequest): String = {
201201
if (Configuration.IS_TEST_MODE.getValue) {
202-
ServerConfiguration.BDP_TEST_USER.getValue;
202+
val testUser = ServerConfiguration.BDP_TEST_USER.getValue
203+
if (StringUtils.isBlank(testUser)) {
204+
throw new IllegalUserTicketException("Need to set test user when enable test module")
205+
}
206+
testUser
203207
} else {
204208
getLoginUser(req).getOrElse(
205209
throw new IllegalUserTicketException(ILLEGAL_USER_TOKEN.getErrorDesc)

linkis-computation-governance/linkis-engineconn/linkis-engineconn-plugin-core/src/main/java/org/apache/linkis/manager/engineplugin/errorcode/EngineconnCoreErrorCodeSummary.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public enum EngineconnCoreErrorCodeSummary implements LinkisErrorCode {
2323
FAILED_CREATE_ELR(10001, "Failed to createEngineConnLaunchRequest(创建 EngineConnLaunchRequest失败)"),
2424
EN_PLUGIN_MATERIAL_SOURCE_EXCEPTION(
2525
10001,
26-
"The engine plug-in material is abnormal, please check whether the material is uploaded successfully(引擎插件物料异常,请检查物料是否上传成功)"),
26+
"The engine plugin material is abnormal, please check whether the material is uploaded successfully(引擎插件物料异常,请检查物料是否上传成功)"),
2727
ETL_REQUESTED(10001, "EngineTypeLabel are requested(需要参数 EngineTypeLabel)"),
2828
CANNOT_INSTANCE_ECE(20000, "Cannot instance EngineConnExecution(无法实例化 EngineConnExecution)"),
2929

linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/scala/org/apache/linkis/engineplugin/server/conf/EngineConnPluginConfiguration.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,8 @@ object EngineConnPluginConfiguration {
3535
val ENABLED_BML_UPLOAD_FAILED_EXIT: CommonVars[Boolean] =
3636
CommonVars("wds.linkis.engineconn.bml.upload.failed.enable", true)
3737

38+
// for third party eg appconn/datax, if all update, can set to false then to remove
39+
val EC_BML_VERSION_MAY_WITH_PREFIX_V: CommonVars[Boolean] =
40+
CommonVars("linkis.engineconn.bml.version.may.with.prefix", true)
41+
3842
}

linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/scala/org/apache/linkis/engineplugin/server/localize/AbstractEngineConnBmlResourceGenerator.scala

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
package org.apache.linkis.engineplugin.server.localize
1919

20+
import org.apache.linkis.engineplugin.server.conf.EngineConnPluginConfiguration
2021
import org.apache.linkis.engineplugin.server.conf.EngineConnPluginConfiguration.ENGINE_CONN_HOME
2122
import org.apache.linkis.engineplugin.server.localize.EngineConnBmlResourceGenerator.NO_VERSION_MARK
2223
import org.apache.linkis.manager.engineplugin.common.exception.EngineConnPluginErrorException
@@ -53,13 +54,37 @@ abstract class AbstractEngineConnBmlResourceGenerator extends EngineConnBmlResou
5354
val engineConnPackageHome = Paths.get(engineConnDistHome, version).toFile.getPath
5455
logger.info("getEngineConnDistHome, engineConnPackageHome path:" + engineConnPackageHome)
5556
val engineConnPackageHomeFile = new File(engineConnPackageHome)
57+
5658
if (!engineConnPackageHomeFile.exists()) {
57-
throw new EngineConnPluginErrorException(
58-
ENGINE_VERSION_NOT_FOUND.getErrorCode,
59-
MessageFormat.format(ENGINE_VERSION_NOT_FOUND.getErrorDesc, version, engineConnType)
60-
)
59+
if (
60+
!version.startsWith(
61+
"v"
62+
) && EngineConnPluginConfiguration.EC_BML_VERSION_MAY_WITH_PREFIX_V.getValue
63+
) {
64+
val versionOld = "v" + version
65+
val engineConnPackageHomeOld = Paths.get(engineConnDistHome, versionOld).toFile.getPath
66+
logger.info(
67+
"try to getEngineConnDistHome with prefix v, engineConnPackageHome path:" + engineConnPackageHomeOld
68+
)
69+
val engineConnPackageHomeFileOld = new File(engineConnPackageHomeOld)
70+
if (!engineConnPackageHomeFileOld.exists()) {
71+
throw new EngineConnPluginErrorException(
72+
ENGINE_VERSION_NOT_FOUND.getErrorCode,
73+
MessageFormat.format(ENGINE_VERSION_NOT_FOUND.getErrorDesc, version, engineConnType)
74+
)
75+
} else {
76+
engineConnPackageHomeOld
77+
}
78+
} else {
79+
throw new EngineConnPluginErrorException(
80+
ENGINE_VERSION_NOT_FOUND.getErrorCode,
81+
MessageFormat.format(ENGINE_VERSION_NOT_FOUND.getErrorDesc, version, engineConnType)
82+
)
83+
}
84+
} else {
85+
engineConnPackageHome
6186
}
62-
engineConnPackageHome
87+
6388
}
6489

6590
private def checkEngineConnDistHome(engineConnPackageHomePath: String): Unit = {

linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/scala/org/apache/linkis/engineplugin/server/service/DefaultEngineConnResourceService.scala

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,8 +201,6 @@ class DefaultEngineConnResourceService extends EngineConnResourceService with Lo
201201
engineConnBmlResource.setFileName(localizeResource.fileName)
202202
engineConnBmlResource.setFileSize(localizeResource.fileSize)
203203
engineConnBmlResource.setLastModified(localizeResource.lastModified)
204-
if (version.startsWith("v")) engineConnBmlResource.setVersion(version.substring(1))
205-
else engineConnBmlResource.setVersion(version)
206204
engineConnBmlResource.setVersion(version)
207205
engineConnBmlResourceDao.save(engineConnBmlResource)
208206
} else {
@@ -241,9 +239,18 @@ class DefaultEngineConnResourceService extends EngineConnResourceService with Lo
241239
): EngineConnResource = {
242240
val engineConnType = engineConnBMLResourceRequest.getEngineConnType
243241
val version = engineConnBMLResourceRequest.getVersion
244-
val engineConnBmlResources = asScalaBufferConverter(
242+
var engineConnBmlResources = asScalaBufferConverter(
245243
engineConnBmlResourceDao.getAllEngineConnBmlResource(engineConnType, version)
246244
)
245+
if (
246+
engineConnBmlResources.asScala.size == 0 && EngineConnPluginConfiguration.EC_BML_VERSION_MAY_WITH_PREFIX_V.getValue
247+
) {
248+
logger.info("Try to get engine conn bml resource with prefex v")
249+
engineConnBmlResources = asScalaBufferConverter(
250+
engineConnBmlResourceDao.getAllEngineConnBmlResource(engineConnType, "v" + version)
251+
)
252+
}
253+
247254
val confBmlResourceMap = engineConnBmlResources.asScala
248255
.find(_.getFileName == LaunchConstants.ENGINE_CONN_CONF_DIR_NAME + ".zip")
249256
.map(parseToBmlResource)

linkis-computation-governance/linkis-manager/linkis-application-manager/src/main/scala/org/apache/linkis/manager/rm/service/impl/DefaultResourceManager.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,7 @@ class DefaultResourceManager extends ResourceManager with Logging with Initializ
710710
var heartbeatMsgMetrics = ""
711711
Utils.tryAndWarn {
712712
val oldMetrics = nodeMetricManagerPersistence.getNodeMetrics(ecNode)
713-
if (StringUtils.isNotBlank(oldMetrics.getHeartBeatMsg)) {
713+
if (oldMetrics != null && StringUtils.isNotBlank(oldMetrics.getHeartBeatMsg)) {
714714
heartbeatMsgMetrics = oldMetrics.getHeartBeatMsg
715715
}
716716
}

linkis-web/src/apps/linkis/i18n/common/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@
629629
"versionList": "Version List",
630630
"rollback": "Rollback",
631631
"checkEngineConnTypeAndVersion": "Please select the engine type and version",
632-
"upload": "Please click the button to upload the engine plug-in"
632+
"upload": "Please click the button to upload the engine plugin"
633633
}
634634
}
635635
}

0 commit comments

Comments
 (0)