Skip to content

Commit

Permalink
appcon compatibility (#4420)
Browse files Browse the repository at this point in the history
* engine bml resource compatible prefix v format
  • Loading branch information
casionone authored Mar 28, 2023
1 parent 1004308 commit 8d21791
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/errorcode/linkis-engineconn-plugin-core-errorcode.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
| module name(模块名) | error code(错误码) | describe(描述) |enumeration name(枚举)| Exception Class(类名)|
| -------- | -------- | ----- |-----|-----|
|linkis-engineconn-plugin-core |10001|Failed to createEngineConnLaunchRequest(创建 EngineConnLaunchRequest失败)|FAILED_CREATE_ELR|EngineconnCoreErrorCodeSummary|
|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|
|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|
|linkis-engineconn-plugin-core |10001|EngineTypeLabel are requested(需要参数 EngineTypeLabel)|ETL_REQUESTED|EngineconnCoreErrorCodeSummary|
|linkis-engineconn-plugin-core |20000|Cannot instance EngineConnExecution(无法实例化 EngineConnExecution)|CANNOT_INSTANCE_ECE|EngineconnCoreErrorCodeSummary|
|linkis-engineconn-plugin-core |20000|Cannot find default ExecutorFactory(找不到默认的 ExecutorFactory)|CANNOT_DEFAULT_EF|EngineconnCoreErrorCodeSummary|
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,11 @@ object SecurityFilter {

def getLoginUsername(req: HttpServletRequest): String = {
if (Configuration.IS_TEST_MODE.getValue) {
ServerConfiguration.BDP_TEST_USER.getValue;
val testUser = ServerConfiguration.BDP_TEST_USER.getValue
if (StringUtils.isBlank(testUser)) {
throw new IllegalUserTicketException("Need to set test user when enable test module")
}
testUser
} else {
getLoginUser(req).getOrElse(
throw new IllegalUserTicketException(ILLEGAL_USER_TOKEN.getErrorDesc)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public enum EngineconnCoreErrorCodeSummary implements LinkisErrorCode {
FAILED_CREATE_ELR(10001, "Failed to createEngineConnLaunchRequest(创建 EngineConnLaunchRequest失败)"),
EN_PLUGIN_MATERIAL_SOURCE_EXCEPTION(
10001,
"The engine plug-in material is abnormal, please check whether the material is uploaded successfully(引擎插件物料异常,请检查物料是否上传成功)"),
"The engine plugin material is abnormal, please check whether the material is uploaded successfully(引擎插件物料异常,请检查物料是否上传成功)"),
ETL_REQUESTED(10001, "EngineTypeLabel are requested(需要参数 EngineTypeLabel)"),
CANNOT_INSTANCE_ECE(20000, "Cannot instance EngineConnExecution(无法实例化 EngineConnExecution)"),

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,8 @@ object EngineConnPluginConfiguration {
val ENABLED_BML_UPLOAD_FAILED_EXIT: CommonVars[Boolean] =
CommonVars("wds.linkis.engineconn.bml.upload.failed.enable", true)

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

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

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

import org.apache.linkis.engineplugin.server.conf.EngineConnPluginConfiguration
import org.apache.linkis.engineplugin.server.conf.EngineConnPluginConfiguration.ENGINE_CONN_HOME
import org.apache.linkis.engineplugin.server.localize.EngineConnBmlResourceGenerator.NO_VERSION_MARK
import org.apache.linkis.manager.engineplugin.common.exception.EngineConnPluginErrorException
Expand Down Expand Up @@ -53,13 +54,37 @@ abstract class AbstractEngineConnBmlResourceGenerator extends EngineConnBmlResou
val engineConnPackageHome = Paths.get(engineConnDistHome, version).toFile.getPath
logger.info("getEngineConnDistHome, engineConnPackageHome path:" + engineConnPackageHome)
val engineConnPackageHomeFile = new File(engineConnPackageHome)

if (!engineConnPackageHomeFile.exists()) {
throw new EngineConnPluginErrorException(
ENGINE_VERSION_NOT_FOUND.getErrorCode,
MessageFormat.format(ENGINE_VERSION_NOT_FOUND.getErrorDesc, version, engineConnType)
)
if (
!version.startsWith(
"v"
) && EngineConnPluginConfiguration.EC_BML_VERSION_MAY_WITH_PREFIX_V.getValue
) {
val versionOld = "v" + version
val engineConnPackageHomeOld = Paths.get(engineConnDistHome, versionOld).toFile.getPath
logger.info(
"try to getEngineConnDistHome with prefix v, engineConnPackageHome path:" + engineConnPackageHomeOld
)
val engineConnPackageHomeFileOld = new File(engineConnPackageHomeOld)
if (!engineConnPackageHomeFileOld.exists()) {
throw new EngineConnPluginErrorException(
ENGINE_VERSION_NOT_FOUND.getErrorCode,
MessageFormat.format(ENGINE_VERSION_NOT_FOUND.getErrorDesc, version, engineConnType)
)
} else {
engineConnPackageHomeOld
}
} else {
throw new EngineConnPluginErrorException(
ENGINE_VERSION_NOT_FOUND.getErrorCode,
MessageFormat.format(ENGINE_VERSION_NOT_FOUND.getErrorDesc, version, engineConnType)
)
}
} else {
engineConnPackageHome
}
engineConnPackageHome

}

private def checkEngineConnDistHome(engineConnPackageHomePath: String): Unit = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,8 +201,6 @@ class DefaultEngineConnResourceService extends EngineConnResourceService with Lo
engineConnBmlResource.setFileName(localizeResource.fileName)
engineConnBmlResource.setFileSize(localizeResource.fileSize)
engineConnBmlResource.setLastModified(localizeResource.lastModified)
if (version.startsWith("v")) engineConnBmlResource.setVersion(version.substring(1))
else engineConnBmlResource.setVersion(version)
engineConnBmlResource.setVersion(version)
engineConnBmlResourceDao.save(engineConnBmlResource)
} else {
Expand Down Expand Up @@ -241,9 +239,18 @@ class DefaultEngineConnResourceService extends EngineConnResourceService with Lo
): EngineConnResource = {
val engineConnType = engineConnBMLResourceRequest.getEngineConnType
val version = engineConnBMLResourceRequest.getVersion
val engineConnBmlResources = asScalaBufferConverter(
var engineConnBmlResources = asScalaBufferConverter(
engineConnBmlResourceDao.getAllEngineConnBmlResource(engineConnType, version)
)
if (
engineConnBmlResources.asScala.size == 0 && EngineConnPluginConfiguration.EC_BML_VERSION_MAY_WITH_PREFIX_V.getValue
) {
logger.info("Try to get engine conn bml resource with prefex v")
engineConnBmlResources = asScalaBufferConverter(
engineConnBmlResourceDao.getAllEngineConnBmlResource(engineConnType, "v" + version)
)
}

val confBmlResourceMap = engineConnBmlResources.asScala
.find(_.getFileName == LaunchConstants.ENGINE_CONN_CONF_DIR_NAME + ".zip")
.map(parseToBmlResource)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -710,7 +710,7 @@ class DefaultResourceManager extends ResourceManager with Logging with Initializ
var heartbeatMsgMetrics = ""
Utils.tryAndWarn {
val oldMetrics = nodeMetricManagerPersistence.getNodeMetrics(ecNode)
if (StringUtils.isNotBlank(oldMetrics.getHeartBeatMsg)) {
if (oldMetrics != null && StringUtils.isNotBlank(oldMetrics.getHeartBeatMsg)) {
heartbeatMsgMetrics = oldMetrics.getHeartBeatMsg
}
}
Expand Down
2 changes: 1 addition & 1 deletion linkis-web/src/apps/linkis/i18n/common/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -629,7 +629,7 @@
"versionList": "Version List",
"rollback": "Rollback",
"checkEngineConnTypeAndVersion": "Please select the engine type and version",
"upload": "Please click the button to upload the engine plug-in"
"upload": "Please click the button to upload the engine plugin"
}
}
}
Expand Down

0 comments on commit 8d21791

Please sign in to comment.