Unverified Commit 7a4bf38b authored by ZackYoung's avatar ZackYoung Committed by GitHub

[fix][UDF]修复udf重构后,导致session模式无法使用udf (#1199)

* 修复udf重构后,导致session模式无法使用udf * 修复udf重构后,导致session模式无法使用udf * 修复udf重构后,导致session模式无法使用udf
parent c7a7f2c4
...@@ -145,10 +145,6 @@ ...@@ -145,10 +145,6 @@
<groupId>com.dlink</groupId> <groupId>com.dlink</groupId>
<artifactId>dlink-core</artifactId> <artifactId>dlink-core</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-function</artifactId>
</dependency>
<dependency> <dependency>
<groupId>com.dlink</groupId> <groupId>com.dlink</groupId>
<artifactId>dlink-common</artifactId> <artifactId>dlink-common</artifactId>
......
...@@ -19,8 +19,6 @@ ...@@ -19,8 +19,6 @@
package com.dlink.service; package com.dlink.service;
import com.dlink.executor.Executor;
import com.dlink.gateway.GatewayType;
import com.dlink.job.JobConfig; import com.dlink.job.JobConfig;
/** /**
...@@ -30,12 +28,8 @@ import com.dlink.job.JobConfig; ...@@ -30,12 +28,8 @@ import com.dlink.job.JobConfig;
public interface UDFService { public interface UDFService {
/** /**
* * @param statement sql语句
* @param statement sql语句 * @param config job配置
* @param gatewayType flink 网关提交类型
* @param missionId 任务id
* @param executor flink执行器
* @param config job配置
*/ */
void initUDF(String statement, GatewayType gatewayType, Integer missionId,Executor executor, JobConfig config); void init(String statement, JobConfig config);
} }
...@@ -209,12 +209,10 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -209,12 +209,10 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
task.getDatabaseId(), null)); task.getDatabaseId(), null));
} }
JobConfig config = buildJobConfig(task); JobConfig config = buildJobConfig(task);
// init UDF
udfService.init(task.getStatement(), config);
JobManager jobManager = JobManager.build(config); JobManager jobManager = JobManager.build(config);
// initUDF
udfService.initUDF(task.getStatement(), GatewayType.get(config.getType()), id, jobManager.getExecutor(),
config);
if (!config.isJarTask()) { if (!config.isJarTask()) {
return jobManager.executeSql(task.getStatement()); return jobManager.executeSql(task.getStatement());
} else { } else {
......
...@@ -19,32 +19,12 @@ ...@@ -19,32 +19,12 @@
package com.dlink.service.impl; package com.dlink.service.impl;
import com.dlink.exception.BusException;
import com.dlink.executor.Executor;
import com.dlink.function.FunctionFactory;
import com.dlink.function.data.model.Env;
import com.dlink.function.data.model.UDF;
import com.dlink.function.data.model.UDFPath;
import com.dlink.gateway.GatewayType;
import com.dlink.job.JobConfig; import com.dlink.job.JobConfig;
import com.dlink.process.context.ProcessContextHolder;
import com.dlink.process.model.ProcessEntity;
import com.dlink.service.TaskService;
import com.dlink.service.UDFService; import com.dlink.service.UDFService;
import com.dlink.utils.UDFUtils; import com.dlink.utils.UDFUtils;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import javax.annotation.Resource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import cn.hutool.core.util.ArrayUtil;
/** /**
* @author ZackYoung * @author ZackYoung
* @since 0.6.8 * @since 0.6.8
...@@ -52,56 +32,14 @@ import cn.hutool.core.util.ArrayUtil; ...@@ -52,56 +32,14 @@ import cn.hutool.core.util.ArrayUtil;
@Service @Service
public class UDFServiceImpl implements UDFService { public class UDFServiceImpl implements UDFService {
private static final String YARN = "YARN";
private static final String APPLICATION = "APPLICATION";
/**
* 网关类型 map
* 快速获取 session 与 application 等类型,为了减少判断
*/
private static final Map<String, List<GatewayType>> GATEWAY_TYPE_MAP = MapUtil
.builder("session",
Arrays.asList(GatewayType.YARN_SESSION, GatewayType.KUBERNETES_SESSION, GatewayType.STANDALONE))
.put(YARN,
Arrays.asList(GatewayType.YARN_APPLICATION, GatewayType.YARN_PER_JOB))
.put(APPLICATION,
Arrays.asList(GatewayType.YARN_APPLICATION, GatewayType.KUBERNETES_APPLICATION))
.build();
@Resource
TaskService taskService;
/** /**
* @param statement sql语句 * 获取所有udf相关的代码
* @param gatewayType flink 网关提交类型 *
* @param missionId 任务id * @param statement sql语句
* @param executor flink执行器 * @return jobManage
* @param config job配置
*/ */
@Override @Override
public void initUDF(String statement, GatewayType gatewayType, Integer missionId, Executor executor, public void init(String statement, JobConfig config) {
JobConfig config) { config.setUdfList(UDFUtils.getUDF(statement));
ProcessEntity process = ProcessContextHolder.getProcess();
process.info("Initializing Flink UDF...Start");
List<UDF> udf = UDFUtils.getUDF(statement);
if (CollUtil.isNotEmpty(udf)) {
if (gatewayType == GatewayType.KUBERNETES_APPLICATION) {
throw new BusException("udf 暂不支持k8s application");
}
} else {
return;
}
UDFPath udfPath = FunctionFactory.initUDF(udf, missionId, executor);
executor.initUDF(udfPath.getJarPaths());
executor.initPyUDF(Env.getPath(), udfPath.getPyPaths());
//
if (GATEWAY_TYPE_MAP.get(YARN).contains(gatewayType)) {
config.getGatewayConfig().setJarPaths(ArrayUtil.append(udfPath.getJarPaths(), udfPath.getPyPaths()));
}
process.info("Initializing Flink UDF...Finish");
} }
} }
...@@ -28,6 +28,7 @@ import com.dlink.assertion.Asserts; ...@@ -28,6 +28,7 @@ import com.dlink.assertion.Asserts;
* @since 2021/12/13 * @since 2021/12/13
**/ **/
public enum Dialect { public enum Dialect {
FLINKSQL("FlinkSql"), FLINKSQL("FlinkSql"),
FLINKJAR("FlinkJar"), FLINKJAR("FlinkJar"),
FLINKSQLENV("FlinkSqlEnv"), FLINKSQLENV("FlinkSqlEnv"),
...@@ -110,4 +111,3 @@ public enum Dialect { ...@@ -110,4 +111,3 @@ public enum Dialect {
} }
} }
} }
...@@ -182,5 +182,9 @@ ...@@ -182,5 +182,9 @@
<groupId>com.dlink</groupId> <groupId>com.dlink</groupId>
<artifactId>dlink-process</artifactId> <artifactId>dlink-process</artifactId>
</dependency> </dependency>
<dependency>
<groupId>com.dlink</groupId>
<artifactId>dlink-function</artifactId>
</dependency>
</dependencies> </dependencies>
</project> </project>
...@@ -21,6 +21,7 @@ package com.dlink.job; ...@@ -21,6 +21,7 @@ package com.dlink.job;
import com.dlink.assertion.Asserts; import com.dlink.assertion.Asserts;
import com.dlink.executor.ExecutorSetting; import com.dlink.executor.ExecutorSetting;
import com.dlink.function.data.model.UDF;
import com.dlink.gateway.GatewayType; import com.dlink.gateway.GatewayType;
import com.dlink.gateway.config.AppConfig; import com.dlink.gateway.config.AppConfig;
import com.dlink.gateway.config.ClusterConfig; import com.dlink.gateway.config.ClusterConfig;
...@@ -64,6 +65,7 @@ public class JobConfig { ...@@ -64,6 +65,7 @@ public class JobConfig {
private boolean isJarTask = false; private boolean isJarTask = false;
private String address; private String address;
private Integer taskId; private Integer taskId;
private List<UDF> udfList;
private String[] jarFiles; private String[] jarFiles;
private String[] pyFiles; private String[] pyFiles;
private String jobName; private String jobName;
...@@ -82,7 +84,8 @@ public class JobConfig { ...@@ -82,7 +84,8 @@ public class JobConfig {
public JobConfig() { public JobConfig() {
} }
public JobConfig(String type, boolean useSession, boolean useRemote, boolean useSqlFragment, boolean useStatementSet, Integer parallelism, Map<String, String> config) { public JobConfig(String type, boolean useSession, boolean useRemote, boolean useSqlFragment,
boolean useStatementSet, Integer parallelism, Map<String, String> config) {
this.type = type; this.type = type;
this.useSession = useSession; this.useSession = useSession;
this.useRemote = useRemote; this.useRemote = useRemote;
...@@ -92,10 +95,14 @@ public class JobConfig { ...@@ -92,10 +95,14 @@ public class JobConfig {
this.config = config; this.config = config;
} }
public JobConfig(String type, boolean useResult, boolean useChangeLog, boolean useAutoCancel, boolean useSession, String session, Integer clusterId, public JobConfig(String type, boolean useResult, boolean useChangeLog, boolean useAutoCancel, boolean useSession,
Integer clusterConfigurationId, Integer jarId, Integer taskId, String jobName, boolean useSqlFragment, String session, Integer clusterId,
boolean useStatementSet, boolean useBatchModel, Integer maxRowNum, Integer checkpoint, Integer parallelism, Integer clusterConfigurationId, Integer jarId, Integer taskId, String jobName,
Integer savePointStrategyValue, String savePointPath, Map<String, String> variables, Map<String, String> config) { boolean useSqlFragment,
boolean useStatementSet, boolean useBatchModel, Integer maxRowNum, Integer checkpoint,
Integer parallelism,
Integer savePointStrategyValue, String savePointPath, Map<String, String> variables,
Map<String, String> config) {
this.type = type; this.type = type;
this.useResult = useResult; this.useResult = useResult;
this.useChangeLog = useChangeLog; this.useChangeLog = useChangeLog;
...@@ -120,10 +127,12 @@ public class JobConfig { ...@@ -120,10 +127,12 @@ public class JobConfig {
this.config = config; this.config = config;
} }
public JobConfig(String type, boolean useResult, boolean useChangeLog, boolean useAutoCancel, boolean useSession, String session, boolean useRemote, String address, public JobConfig(String type, boolean useResult, boolean useChangeLog, boolean useAutoCancel, boolean useSession,
String session, boolean useRemote, String address,
String jobName, boolean useSqlFragment, String jobName, boolean useSqlFragment,
boolean useStatementSet, Integer maxRowNum, Integer checkpoint, Integer parallelism, boolean useStatementSet, Integer maxRowNum, Integer checkpoint, Integer parallelism,
Integer savePointStrategyValue, String savePointPath, Map<String, String> config, GatewayConfig gatewayConfig) { Integer savePointStrategyValue, String savePointPath, Map<String, String> config,
GatewayConfig gatewayConfig) {
this.type = type; this.type = type;
this.useResult = useResult; this.useResult = useResult;
this.useChangeLog = useChangeLog; this.useChangeLog = useChangeLog;
...@@ -144,7 +153,8 @@ public class JobConfig { ...@@ -144,7 +153,8 @@ public class JobConfig {
this.gatewayConfig = gatewayConfig; this.gatewayConfig = gatewayConfig;
} }
public JobConfig(String type, boolean useResult, boolean useSession, String session, boolean useRemote, Integer clusterId, Integer maxRowNum) { public JobConfig(String type, boolean useResult, boolean useSession, String session, boolean useRemote,
Integer clusterId, Integer maxRowNum) {
this.type = type; this.type = type;
this.useResult = useResult; this.useResult = useResult;
this.useSession = useSession; this.useSession = useSession;
...@@ -154,9 +164,12 @@ public class JobConfig { ...@@ -154,9 +164,12 @@ public class JobConfig {
this.maxRowNum = maxRowNum; this.maxRowNum = maxRowNum;
} }
public JobConfig(String type, Integer step, boolean useResult, boolean useSession, boolean useRemote, Integer clusterId, public JobConfig(String type, Integer step, boolean useResult, boolean useSession, boolean useRemote,
Integer clusterConfigurationId, Integer jarId, Integer taskId, String jobName, boolean useSqlFragment, Integer clusterId,
boolean useStatementSet, boolean useBatchModel, Integer checkpoint, Integer parallelism, Integer savePointStrategyValue, Integer clusterConfigurationId, Integer jarId, Integer taskId, String jobName,
boolean useSqlFragment,
boolean useStatementSet, boolean useBatchModel, Integer checkpoint, Integer parallelism,
Integer savePointStrategyValue,
String savePointPath, Map<String, String> config) { String savePointPath, Map<String, String> config) {
this.type = type; this.type = type;
this.step = step; this.step = step;
...@@ -179,7 +192,8 @@ public class JobConfig { ...@@ -179,7 +192,8 @@ public class JobConfig {
} }
public ExecutorSetting getExecutorSetting() { public ExecutorSetting getExecutorSetting() {
return new ExecutorSetting(checkpoint, parallelism, useSqlFragment, useStatementSet, useBatchModel, savePointPath, jobName, config); return new ExecutorSetting(checkpoint, parallelism, useSqlFragment, useStatementSet, useBatchModel,
savePointPath, jobName, config);
} }
public void setSessionConfig(SessionConfig sessionConfig) { public void setSessionConfig(SessionConfig sessionConfig) {
...@@ -194,19 +208,20 @@ public class JobConfig { ...@@ -194,19 +208,20 @@ public class JobConfig {
gatewayConfig = new GatewayConfig(); gatewayConfig = new GatewayConfig();
if (config.containsKey("hadoopConfigPath")) { if (config.containsKey("hadoopConfigPath")) {
gatewayConfig.setClusterConfig(ClusterConfig.build(config.get("flinkConfigPath").toString(), gatewayConfig.setClusterConfig(ClusterConfig.build(config.get("flinkConfigPath").toString(),
config.get("flinkLibPath").toString(), config.get("flinkLibPath").toString(),
config.get("hadoopConfigPath").toString())); config.get("hadoopConfigPath").toString()));
} else { } else {
gatewayConfig.setClusterConfig(ClusterConfig.build(config.get("flinkConfigPath").toString())); gatewayConfig.setClusterConfig(ClusterConfig.build(config.get("flinkConfigPath").toString()));
} }
AppConfig appConfig = new AppConfig(); AppConfig appConfig = new AppConfig();
if (config.containsKey("userJarPath") && Asserts.isNotNullString((String) config.get("userJarPath"))) { if (config.containsKey("userJarPath") && Asserts.isNotNullString((String) config.get("userJarPath"))) {
appConfig.setUserJarPath(config.get("userJarPath").toString()); appConfig.setUserJarPath(config.get("userJarPath").toString());
if (config.containsKey("userJarMainAppClass") && Asserts.isNotNullString((String) config.get("userJarMainAppClass"))) { if (config.containsKey("userJarMainAppClass")
&& Asserts.isNotNullString((String) config.get("userJarMainAppClass"))) {
appConfig.setUserJarMainAppClass(config.get("userJarMainAppClass").toString()); appConfig.setUserJarMainAppClass(config.get("userJarMainAppClass").toString());
} }
if (config.containsKey("userJarParas") && Asserts.isNotNullString((String) config.get("userJarParas"))) { if (config.containsKey("userJarParas") && Asserts.isNotNullString((String) config.get("userJarParas"))) {
//There may be multiple spaces between the parameter and value during user input, // There may be multiple spaces between the parameter and value during user input,
// which will directly lead to a parameter passing error and needs to be eliminated // which will directly lead to a parameter passing error and needs to be eliminated
String[] temp = config.get("userJarParas").toString().split(" "); String[] temp = config.get("userJarParas").toString().split(" ");
List<String> paraSplit = new ArrayList<>(); List<String> paraSplit = new ArrayList<>();
...@@ -219,12 +234,13 @@ public class JobConfig { ...@@ -219,12 +234,13 @@ public class JobConfig {
} }
gatewayConfig.setAppConfig(appConfig); gatewayConfig.setAppConfig(appConfig);
} }
if (config.containsKey("flinkConfig") && Asserts.isNotNullMap((Map<String, String>) config.get("flinkConfig"))) { if (config.containsKey("flinkConfig")
&& Asserts.isNotNullMap((Map<String, String>) config.get("flinkConfig"))) {
gatewayConfig.setFlinkConfig(FlinkConfig.build((Map<String, String>) config.get("flinkConfig"))); gatewayConfig.setFlinkConfig(FlinkConfig.build((Map<String, String>) config.get("flinkConfig")));
} }
if (config.containsKey("kubernetesConfig")) { if (config.containsKey("kubernetesConfig")) {
Map<String, Object> kubernetesConfig = (Map<String, Object>) config.get("kubernetesConfig"); Map<String, Object> kubernetesConfig = (Map<String, Object>) config.get("kubernetesConfig");
//构建GatewayConfig时,将k8s集群默认配置和自定义参数配置加载到FlinkConfig里 // 构建GatewayConfig时,将k8s集群默认配置和自定义参数配置加载到FlinkConfig里
for (Map.Entry<String, Object> entry : kubernetesConfig.entrySet()) { for (Map.Entry<String, Object> entry : kubernetesConfig.entrySet()) {
gatewayConfig.getFlinkConfig().getConfiguration().put(entry.getKey(), entry.getValue().toString()); gatewayConfig.getFlinkConfig().getConfiguration().put(entry.getKey(), entry.getValue().toString());
} }
......
...@@ -15,16 +15,14 @@ ...@@ -15,16 +15,14 @@
~ See the License for the specific language governing permissions and ~ See the License for the specific language governing permissions and
~ limitations under the License. ~ limitations under the License.
--> -->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent> <parent>
<artifactId>dlink</artifactId>
<groupId>com.dlink</groupId> <groupId>com.dlink</groupId>
<artifactId>dlink</artifactId>
<version>0.6.8-SNAPSHOT</version> <version>0.6.8-SNAPSHOT</version>
</parent> </parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>dlink-function</artifactId> <artifactId>dlink-function</artifactId>
...@@ -46,14 +44,25 @@ ...@@ -46,14 +44,25 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.dlink</groupId> <groupId>com.dlink</groupId>
<artifactId>dlink-core</artifactId> <artifactId>dlink-gateway</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.dlink</groupId> <groupId>com.dlink</groupId>
<artifactId>dlink-executor</artifactId> <artifactId>dlink-process</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.codehaus.groovy</groupId>
<artifactId>groovy</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-context</artifactId>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file
...@@ -19,12 +19,13 @@ ...@@ -19,12 +19,13 @@
package com.dlink.function; package com.dlink.function;
import com.dlink.executor.Executor;
import com.dlink.function.compiler.FunctionCompiler; import com.dlink.function.compiler.FunctionCompiler;
import com.dlink.function.compiler.FunctionPackage; import com.dlink.function.compiler.FunctionPackage;
import com.dlink.function.data.model.UDF; import com.dlink.function.data.model.UDF;
import com.dlink.function.data.model.UDFPath; import com.dlink.function.data.model.UDFPath;
import org.apache.flink.configuration.Configuration;
import java.util.List; import java.util.List;
/** /**
...@@ -35,15 +36,15 @@ public class FunctionFactory { ...@@ -35,15 +36,15 @@ public class FunctionFactory {
/** /**
* udf编译 & 打包 初始化 * udf编译 & 打包 初始化
*
* @param udfClassList udf列表 * @param udfClassList udf列表
* @param missionId 当前任务id * @param missionId 当前任务id
* @param executor flink执行器
* @return 打包过后的路径 * @return 打包过后的路径
*/ */
public static UDFPath initUDF(List<UDF> udfClassList, Integer missionId, Executor executor) { public static UDFPath initUDF(List<UDF> udfClassList, Integer missionId, Configuration configuration) {
// 编译 // 编译
FunctionCompiler.getCompiler(udfClassList, executor.getTableConfig().getConfiguration(), missionId); FunctionCompiler.getCompiler(udfClassList, configuration, missionId);
// 打包 // 打包
return FunctionPackage.bale(udfClassList, missionId); return FunctionPackage.bale(udfClassList, missionId);
......
...@@ -66,7 +66,7 @@ public class JVMPackage implements FunctionPackage { ...@@ -66,7 +66,7 @@ public class JVMPackage implements FunctionPackage {
fileInputStreams[i] = FileUtil.getInputStream(absoluteFilePath); fileInputStreams[i] = FileUtil.getInputStream(absoluteFilePath);
} }
String jarPath = PathConstant.getUdfPackagePath(missionId, PathConstant.UDF_JAR_NAME); String jarPath = PathConstant.getUdfPackagePath(missionId) + PathConstant.UDF_JAR_NAME;
// 编译好的文件打包jar // 编译好的文件打包jar
File file = FileUtil.file(jarPath); File file = FileUtil.file(jarPath);
FileUtil.del(file); FileUtil.del(file);
......
...@@ -19,8 +19,10 @@ ...@@ -19,8 +19,10 @@
package com.dlink.function.data.model; package com.dlink.function.data.model;
import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
/** /**
...@@ -30,6 +32,8 @@ import lombok.Setter; ...@@ -30,6 +32,8 @@ import lombok.Setter;
@Getter @Getter
@Setter @Setter
@Builder @Builder
@NoArgsConstructor
@AllArgsConstructor
public class UDFPath { public class UDFPath {
String[] jarPaths; String[] jarPaths;
......
...@@ -21,13 +21,16 @@ package com.dlink.function.util; ...@@ -21,13 +21,16 @@ package com.dlink.function.util;
import com.dlink.assertion.Asserts; import com.dlink.assertion.Asserts;
import com.dlink.config.Dialect; import com.dlink.config.Dialect;
import com.dlink.function.FunctionFactory;
import com.dlink.function.compiler.CustomStringJavaCompiler; import com.dlink.function.compiler.CustomStringJavaCompiler;
import com.dlink.function.compiler.CustomStringScalaCompiler; import com.dlink.function.compiler.CustomStringScalaCompiler;
import com.dlink.function.constant.PathConstant; import com.dlink.function.constant.PathConstant;
import com.dlink.function.data.model.UDF; import com.dlink.function.data.model.UDF;
import com.dlink.gateway.GatewayType;
import com.dlink.pool.ClassEntity; import com.dlink.pool.ClassEntity;
import com.dlink.pool.ClassPool; import com.dlink.pool.ClassPool;
import org.apache.flink.configuration.Configuration;
import org.apache.flink.table.catalog.FunctionLanguage; import org.apache.flink.table.catalog.FunctionLanguage;
import java.io.InputStream; import java.io.InputStream;
...@@ -65,6 +68,23 @@ import groovy.lang.GroovyClassLoader; ...@@ -65,6 +68,23 @@ import groovy.lang.GroovyClassLoader;
*/ */
public class UDFUtil { public class UDFUtil {
public static final String SESSION = "SESSION";
public static final String YARN = "YARN";
public static final String APPLICATION = "APPLICATION";
/**
* 网关类型 map
* 快速获取 session 与 application 等类型,为了减少判断
*/
public static final Map<String, List<GatewayType>> GATEWAY_TYPE_MAP = MapUtil
.builder(SESSION,
Arrays.asList(GatewayType.YARN_SESSION, GatewayType.KUBERNETES_SESSION, GatewayType.STANDALONE))
.put(YARN,
Arrays.asList(GatewayType.YARN_APPLICATION, GatewayType.YARN_PER_JOB))
.put(APPLICATION,
Arrays.asList(GatewayType.YARN_APPLICATION, GatewayType.KUBERNETES_APPLICATION))
.build();
protected static final Logger log = LoggerFactory.getLogger(UDFUtil.class); protected static final Logger log = LoggerFactory.getLogger(UDFUtil.class);
/** /**
* 存放 udf md5与版本对应的k,v值 * 存放 udf md5与版本对应的k,v值
...@@ -108,6 +128,19 @@ public class UDFUtil { ...@@ -108,6 +128,19 @@ public class UDFUtil {
} }
} }
public static String[] initJavaUDF(List<UDF> udf, GatewayType gatewayType, Integer missionId) {
return FunctionFactory.initUDF(
CollUtil.newArrayList(CollUtil.filterNew(udf, x -> x.getFunctionLanguage() != FunctionLanguage.PYTHON)),
missionId, null).getJarPaths();
}
public static String[] initPythonUDF(List<UDF> udf, GatewayType gatewayType, Integer missionId,
Configuration configuration) {
return FunctionFactory.initUDF(
CollUtil.newArrayList(CollUtil.filterNew(udf, x -> x.getFunctionLanguage() == FunctionLanguage.PYTHON)),
missionId, configuration).getPyPaths();
}
public static String getPyFileName(String className) { public static String getPyFileName(String className) {
Asserts.checkNullString(className, "类名不能为空"); Asserts.checkNullString(className, "类名不能为空");
return StrUtil.split(className, ".").get(0); return StrUtil.split(className, ".").get(0);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment