Unverified Commit cc00f4d6 authored by zhu-mingye's avatar zhu-mingye Committed by GitHub

[Refactor][admin] delete un use code (#2473)

* delete un use code * delete un use code * delete un use code
parent e506a272
...@@ -21,7 +21,6 @@ package org.dinky.assertion; ...@@ -21,7 +21,6 @@ package org.dinky.assertion;
import org.dinky.data.exception.BusException; import org.dinky.data.exception.BusException;
import org.dinky.data.model.ClusterInstance; import org.dinky.data.model.ClusterInstance;
import org.dinky.data.model.Jar;
import org.dinky.data.model.Task; import org.dinky.data.model.Task;
/** /**
...@@ -48,10 +47,4 @@ public interface Assert { ...@@ -48,10 +47,4 @@ public interface Assert {
throw new BusException("集群地址暂不可用"); throw new BusException("集群地址暂不可用");
} }
} }
static void check(Jar jar) {
if (jar == null) {
throw new BusException("自定义Jar不存在");
}
}
} }
/*
*
* 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.dinky.controller;
import org.dinky.data.annotation.Log;
import org.dinky.data.constant.UploadFileConstant;
import org.dinky.data.enums.BusinessType;
import org.dinky.data.result.Result;
import org.dinky.service.FileUploadService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
/** FileUploadController */
@Slf4j
@RestController
@Api(tags = "File Upload Controller")
@RequestMapping("/api/fileUpload")
@RequiredArgsConstructor
public class FileUploadController {
private final FileUploadService fileUploadService;
/**
* Upload file<br>
*
* @param files Multi files
* @param dir Dir, default is empty. If not provide, please provide the 'fileType' value
* @param fileType Please refer {@link UploadFileConstant}, default is -1. If not provide,
* please provide the 'dir' value
* @return {@link Result}
*/
@PostMapping
@Log(title = "Upload Files", businessType = BusinessType.UPLOAD)
@ApiOperation("Upload Files")
public Result<Void> upload(
@RequestPart("files") MultipartFile[] files,
@RequestParam(value = "dir", defaultValue = "", required = false) String dir,
@RequestParam(value = "fileType", defaultValue = "-1", required = false) Byte fileType) {
if (!StringUtils.isEmpty(dir) && fileType != -1) {
return Result.failed("不要同时指定 dir 和 fileType 参数");
} else if (StringUtils.isEmpty(dir) && fileType == -1) {
return Result.failed("dir 和 fileType 参数必选其一");
}
if (StringUtils.isEmpty(dir)) {
fileUploadService.upload(files, fileType);
} else {
fileUploadService.upload(files, dir, fileType);
}
return Result.succeed();
}
/**
* Upload hdfs file<br>
*
* @param files Multi files
* @param dir Dir, default is empty. If not provide, please provide the 'fileType' value
* @param hadoopConfigPath Please refer {@link UploadFileConstant}, default is -1. If not
* provide, please provide the 'dir' value
* @return {@link Result}
*/
@PostMapping(value = "hdfs")
@Log(title = "Upload File to Hdfs", businessType = BusinessType.UPLOAD)
@ApiOperation("Upload File to Hdfs")
public Result<Void> uploadHdfs(
@RequestPart("files") MultipartFile[] files,
@RequestParam(value = "dir", defaultValue = "", required = false) String dir,
@RequestParam(value = "hadoopConfigPath", required = false) String hadoopConfigPath) {
fileUploadService.uploadHdfs(files, dir, hadoopConfigPath);
return Result.succeed();
}
}
...@@ -19,14 +19,11 @@ ...@@ -19,14 +19,11 @@
package org.dinky.controller; package org.dinky.controller;
import org.dinky.data.model.Jar;
import org.dinky.data.model.Task; import org.dinky.data.model.Task;
import org.dinky.data.result.ProTableResult;
import org.dinky.data.result.Result; import org.dinky.data.result.Result;
import org.dinky.function.constant.PathConstant; import org.dinky.function.constant.PathConstant;
import org.dinky.function.data.model.UDF; import org.dinky.function.data.model.UDF;
import org.dinky.function.util.UDFUtil; import org.dinky.function.util.UDFUtil;
import org.dinky.service.JarService;
import org.dinky.service.TaskService; import org.dinky.service.TaskService;
import org.apache.flink.table.catalog.FunctionLanguage; import org.apache.flink.table.catalog.FunctionLanguage;
...@@ -35,15 +32,10 @@ import java.util.List; ...@@ -35,15 +32,10 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.fasterxml.jackson.databind.JsonNode;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
...@@ -62,34 +54,8 @@ import lombok.extern.slf4j.Slf4j; ...@@ -62,34 +54,8 @@ import lombok.extern.slf4j.Slf4j;
@RequiredArgsConstructor @RequiredArgsConstructor
public class JarController { public class JarController {
private final JarService jarService;
private final TaskService taskService; private final TaskService taskService;
/** 新增或者更新 */
@PutMapping
public Result<Void> saveOrUpdate(@RequestBody Jar jar) throws Exception {
if (jarService.saveOrUpdate(jar)) {
return Result.succeed("新增成功");
} else {
return Result.failed("新增失败");
}
}
/** 动态查询列表 */
@PostMapping
public ProTableResult<Jar> listJars(@RequestBody JsonNode para) {
return jarService.selectForProTable(para);
}
/** 获取可用的jar列表 */
@GetMapping("/listEnabledAll")
@ApiOperation("Query jar list enabled all")
public Result<List<Jar>> listEnabledAll() {
List<Jar> jars = jarService.listEnabledAll();
return Result.succeed(jars, "获取成功");
}
@PostMapping("/udf/generateJar") @PostMapping("/udf/generateJar")
@ApiOperation("Generate jar") @ApiOperation("Generate jar")
public Result<Map<String, List<String>>> generateJar() { public Result<Map<String, List<String>>> generateJar() {
......
/*
*
* 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.dinky.controller;
import org.dinky.data.model.UploadFileRecord;
import org.dinky.data.result.Result;
import org.dinky.service.UploadFileRecordService;
import java.util.List;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.hutool.json.JSONUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
/** FileUploadController */
@Slf4j
@Api(tags = "File Upload Controller")
@RestController
@SaCheckLogin
@RequestMapping("/api/uploadFileRecord")
public class UploadFileRecordController {
@Resource
private UploadFileRecordService uploadFileRecordService;
/** @param record {@link UploadFileRecord} */
@PostMapping("/list")
@ApiOperation("Get Upload List")
public Result<String> getUploadFileRecord(@RequestBody UploadFileRecord record) {
List<UploadFileRecord> records = uploadFileRecordService.list(new QueryWrapper<>(record));
return Result.succeed(JSONUtil.toJsonStr(records));
}
}
/*
*
* 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.dinky.data.constant;
import org.springframework.boot.system.ApplicationHome;
/** Upload file's some constant. */
public class UploadFileConstant {
// Upload file's type
// constant----------------------------------------------------------------------------------------
/** Not internal upload file type, this value represent upload the file to the specific dir. */
public static final byte TYPE_OTHER = -1;
public static final byte HADOOP_CONF_ID = 1;
public static final String HADOOP_CONF_NAME = "hadoop-conf";
public static final byte FLINK_CONF_ID = 2;
public static final String FLINK_CONF_NAME = "flink-conf";
public static final byte FLINK_LIB_ID = 3;
public static final String FLINK_LIB_NAME = "flink-lib";
public static final byte USER_JAR_ID = 4;
public static final String USER_JAR_NAME = "user-jar";
public static final byte DINKY_JAR_ID = 5;
public static final String DINKY_JAR_NAME = "dinky-jar";
// Upload file's dir
// constant----------------------------------------------------------------------------------------
static {
// Get admin jar's parent absolute path
DINKY_HOME_DIR =
new ApplicationHome(UploadFileConstant.class).getSource().getParent() + "/../";
}
public static final String DINKY_HOME_DIR;
public static final String HDFS_HOME_DIR = "hdfs:///";
public static final String HADOOP_CONF_DIR = DINKY_HOME_DIR + "/config/hadoop-conf";
public static final String FLINK_CONF_DIR = DINKY_HOME_DIR + "/config/flink-conf";
public static final String FLINK_LIB_DIR = HDFS_HOME_DIR + "dinky/jar/flink/lib";
public static final String DINKY_JAR_DIR = HDFS_HOME_DIR + "dinky/jar/dinky";
public static final String USER_JAR_DIR = HDFS_HOME_DIR + "dinky/jar/user";
// Upload file's target
// constant----------------------------------------------------------------------------------------
/** An unidentified upload file type */
public static final byte TARGET_OTHER = -1;
public static final byte TARGET_LOCAL = 1;
public static final byte TARGET_HDFS = 2;
/**
* Get internal upload file type's dir name
*
* @param fileType Upload file type id.
* @return Internal upload file dir name
*/
public static String getDirName(byte fileType) {
switch (fileType) {
case HADOOP_CONF_ID:
return HADOOP_CONF_NAME;
case FLINK_CONF_ID:
return FLINK_CONF_NAME;
case FLINK_LIB_ID:
return FLINK_LIB_NAME;
case USER_JAR_ID:
return USER_JAR_NAME;
case DINKY_JAR_ID:
return DINKY_JAR_NAME;
default:
return null;
}
}
/**
* Get internal upload file type's dir path
*
* @param fileType Upload file type id.
* @return Internal upload file dir path
*/
public static String getDirPath(byte fileType) {
switch (fileType) {
case HADOOP_CONF_ID:
return HADOOP_CONF_DIR;
case FLINK_CONF_ID:
return FLINK_CONF_DIR;
case FLINK_LIB_ID:
return FLINK_LIB_DIR;
case USER_JAR_ID:
return USER_JAR_DIR;
case DINKY_JAR_ID:
return DINKY_JAR_DIR;
default:
return "";
}
}
/**
* Get internal upload file type's target
*
* @param fileType Upload file type id.
* @return Upload file target
*/
public static byte getTarget(byte fileType) {
switch (fileType) {
case HADOOP_CONF_ID:
case FLINK_CONF_ID:
return TARGET_LOCAL;
case FLINK_LIB_ID:
case USER_JAR_ID:
case DINKY_JAR_ID:
return TARGET_HDFS;
default:
return TARGET_OTHER;
}
}
}
/*
*
* 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.dinky.data.dto;
import org.dinky.gateway.config.GatewayConfig;
import org.dinky.gateway.enums.SavePointStrategy;
import org.dinky.job.JobConfig;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
/**
* APIExecuteJarDTO
*
* @since 2021/12/12 19:46
*/
@Getter
@Setter
@ApiModel(value = "APIExecuteJarDTO", description = "API Execute JAR Data Transfer Object")
public class APIExecuteJarDTO {
@ApiModelProperty(
value = "Type",
dataType = "String",
example = "Flink",
notes = "The type of the JAR execution (e.g., 'Flink')")
private String type;
@ApiModelProperty(
value = "Job Name",
dataType = "String",
example = "MyJob",
notes = "The name of the job to execute")
private String jobName;
@ApiModelProperty(
value = "Savepoint Path",
dataType = "String",
example = "/path/to/savepoint",
notes = "The path to the savepoint to restore from (if applicable)")
private String savePointPath;
@ApiModelProperty(
value = "Gateway Configuration",
dataType = "GatewayConfig",
notes = "The configuration for the gateway")
private GatewayConfig gatewayConfig;
public JobConfig getJobConfig() {
JobConfig config = new JobConfig();
config.setType(type);
config.setJobName(jobName);
config.setSavePointStrategy(SavePointStrategy.CUSTOM);
config.setSavePointPath(savePointPath);
config.setGatewayConfig(gatewayConfig);
return config;
}
}
...@@ -27,14 +27,10 @@ import org.dinky.data.flink.job.FlinkJobDetailInfo; ...@@ -27,14 +27,10 @@ import org.dinky.data.flink.job.FlinkJobDetailInfo;
import org.dinky.data.model.JobHistory; import org.dinky.data.model.JobHistory;
import org.dinky.data.model.mapping.ClusterConfigurationMapping; import org.dinky.data.model.mapping.ClusterConfigurationMapping;
import org.dinky.data.model.mapping.ClusterInstanceMapping; import org.dinky.data.model.mapping.ClusterInstanceMapping;
import org.dinky.utils.JsonUtils;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import com.fasterxml.jackson.databind.JsonNode;
import cn.hutool.core.lang.Opt; import cn.hutool.core.lang.Opt;
import cn.hutool.json.JSONUtil;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
...@@ -76,9 +72,6 @@ public class JobDataDto { ...@@ -76,9 +72,6 @@ public class JobDataDto {
@ApiModelProperty(value = "JobConfigInfo", notes = "JobConfigInfo representing job configuration") @ApiModelProperty(value = "JobConfigInfo", notes = "JobConfigInfo representing job configuration")
private FlinkJobConfigInfo config; private FlinkJobConfigInfo config;
@ApiModelProperty(value = "Jar Object", notes = "Object representing the JAR used in the job")
private JsonNode jar;
@ApiModelProperty(value = "ClusterInstance Object", notes = "Object representing the cluster") @ApiModelProperty(value = "ClusterInstance Object", notes = "Object representing the cluster")
private ClusterInstanceMapping cluster; private ClusterInstanceMapping cluster;
...@@ -108,7 +101,6 @@ public class JobDataDto { ...@@ -108,7 +101,6 @@ public class JobDataDto {
.checkpointsJson(this.checkpoints) .checkpointsJson(this.checkpoints)
.checkpointsConfigJson(this.checkpointsConfig) .checkpointsConfigJson(this.checkpointsConfig)
.configJson(this.config) .configJson(this.config)
.jarJson(JSONUtil.toJsonStr(getJar()))
.clusterJson(this.cluster) .clusterJson(this.cluster)
.clusterConfigurationJson(this.clusterConfiguration) .clusterConfigurationJson(this.clusterConfiguration)
.updateTime(LocalDateTime.now()) .updateTime(LocalDateTime.now())
...@@ -125,7 +117,6 @@ public class JobDataDto { ...@@ -125,7 +117,6 @@ public class JobDataDto {
.checkpoints(jobHistory.getCheckpointsJson()) .checkpoints(jobHistory.getCheckpointsJson())
.checkpointsConfig(jobHistory.getCheckpointsConfigJson()) .checkpointsConfig(jobHistory.getCheckpointsConfigJson())
.config(jobHistory.getConfigJson()) .config(jobHistory.getConfigJson())
.jar(JsonUtils.parseToJsonNode(jobHistory.getJarJson()))
.cluster(jobHistory.getClusterJson()) .cluster(jobHistory.getClusterJson())
.clusterConfiguration(jobHistory.getClusterConfigurationJson()) .clusterConfiguration(jobHistory.getClusterConfigurationJson())
.build()) .build())
......
...@@ -96,9 +96,6 @@ public class TaskVersionConfigureDTO implements Serializable { ...@@ -96,9 +96,6 @@ public class TaskVersionConfigureDTO implements Serializable {
notes = "The ID of the database source") notes = "The ID of the database source")
private Integer databaseId; private Integer databaseId;
@ApiModelProperty(value = "Jar ID", dataType = "Integer", example = "6", notes = "The ID of the JAR file")
private Integer jarId;
@ApiModelProperty( @ApiModelProperty(
value = "Environment ID", value = "Environment ID",
dataType = "Integer", dataType = "Integer",
......
/*
*
* 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.dinky.data.model;
import org.dinky.mybatis.model.SuperEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* Jar
*
* @since 2021/11/13
*/
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("dinky_jar")
@ApiModel(value = "Jar", description = "Jar Information")
public class Jar extends SuperEntity {
private static final long serialVersionUID = 3769276772487490408L;
@ApiModelProperty(value = "Tenant ID", dataType = "Integer", example = "1", notes = "Tenant ID of the Jar")
private Integer tenantId;
@ApiModelProperty(value = "Type", dataType = "String", example = "type", notes = "Type of the Jar")
private String type;
@ApiModelProperty(value = "Path", dataType = "String", example = "/path/to/jar.jar", notes = "Path to the Jar file")
private String path;
@ApiModelProperty(
value = "Main Class",
dataType = "String",
example = "com.example.Main",
notes = "Main class of the Jar")
private String mainClass;
@ApiModelProperty(
value = "Parameters",
dataType = "String",
example = "--param1 value1 --param2 value2",
notes = "Parameters for running the Jar")
private String paras;
@ApiModelProperty(
value = "Note",
dataType = "String",
example = "This is a note about the Jar",
notes = "Additional notes or description")
private String note;
}
...@@ -109,13 +109,6 @@ public class JobHistory implements Serializable { ...@@ -109,13 +109,6 @@ public class JobHistory implements Serializable {
@TableField(typeHandler = JSONObjectHandler.class) @TableField(typeHandler = JSONObjectHandler.class)
private FlinkJobConfigInfo configJson; private FlinkJobConfigInfo configJson;
@ApiModelProperty(
value = "Jar JSON",
dataType = "String",
example = "{\"jarName\": \"example.jar\"}",
notes = "JSON representation of the JAR")
private String jarJson;
@ApiModelProperty( @ApiModelProperty(
value = "ClusterInstance JSON", value = "ClusterInstance JSON",
dataType = "String", dataType = "String",
......
...@@ -114,13 +114,6 @@ public class Task extends SuperEntity<Task> { ...@@ -114,13 +114,6 @@ public class Task extends SuperEntity<Task> {
notes = "ID of the database associated with the task") notes = "ID of the database associated with the task")
private Integer databaseId; private Integer databaseId;
@ApiModelProperty(
value = "JAR ID",
dataType = "Integer",
example = "5001",
notes = "ID of the JAR associated with the task")
private Integer jarId;
@ApiModelProperty( @ApiModelProperty(
value = "Environment ID", value = "Environment ID",
dataType = "Integer", dataType = "Integer",
......
/*
*
* 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.dinky.data.model;
import org.dinky.mybatis.model.SuperEntity;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import lombok.EqualsAndHashCode;
/** UploadFileRecord */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("dinky_upload_file_record")
@Deprecated
public class UploadFileRecord extends SuperEntity {
private static final long serialVersionUID = 3769285632787490408L;
/**
* File type id: hadoop-conf(1)、flink-conf(2)、flink-lib(3)、user-jar(4)、dinky-jar(5), -1
* represent no file type.
*/
private Byte fileType = -1;
private String fileName;
/** Where file upload to: local(1)、hdfs(2) */
private Byte target;
private String fileParentPath;
private String fileAbsolutePath;
private Boolean isFile = true;
}
...@@ -36,7 +36,6 @@ import org.dinky.gateway.enums.GatewayType; ...@@ -36,7 +36,6 @@ import org.dinky.gateway.enums.GatewayType;
import org.dinky.service.ClusterConfigurationService; import org.dinky.service.ClusterConfigurationService;
import org.dinky.service.ClusterInstanceService; import org.dinky.service.ClusterInstanceService;
import org.dinky.service.HistoryService; import org.dinky.service.HistoryService;
import org.dinky.service.JarService;
import org.dinky.service.JobHistoryService; import org.dinky.service.JobHistoryService;
import org.dinky.service.JobInstanceService; import org.dinky.service.JobInstanceService;
import org.dinky.service.TaskService; import org.dinky.service.TaskService;
...@@ -57,7 +56,6 @@ public class Job2MysqlHandler implements JobHandler { ...@@ -57,7 +56,6 @@ public class Job2MysqlHandler implements JobHandler {
private static final HistoryService historyService; private static final HistoryService historyService;
private static final ClusterInstanceService clusterInstanceService; private static final ClusterInstanceService clusterInstanceService;
private static final ClusterConfigurationService clusterConfigurationService; private static final ClusterConfigurationService clusterConfigurationService;
private static final JarService jarService;
private static final JobInstanceService jobInstanceService; private static final JobInstanceService jobInstanceService;
private static final JobHistoryService jobHistoryService; private static final JobHistoryService jobHistoryService;
private static final TaskService taskService; private static final TaskService taskService;
...@@ -67,7 +65,6 @@ public class Job2MysqlHandler implements JobHandler { ...@@ -67,7 +65,6 @@ public class Job2MysqlHandler implements JobHandler {
clusterInstanceService = SpringContextUtils.getBean("clusterInstanceServiceImpl", ClusterInstanceService.class); clusterInstanceService = SpringContextUtils.getBean("clusterInstanceServiceImpl", ClusterInstanceService.class);
clusterConfigurationService = clusterConfigurationService =
SpringContextUtils.getBean("clusterConfigurationServiceImpl", ClusterConfigurationService.class); SpringContextUtils.getBean("clusterConfigurationServiceImpl", ClusterConfigurationService.class);
jarService = SpringContextUtils.getBean("jarServiceImpl", JarService.class);
jobInstanceService = SpringContextUtils.getBean("jobInstanceServiceImpl", JobInstanceService.class); jobInstanceService = SpringContextUtils.getBean("jobInstanceServiceImpl", JobInstanceService.class);
jobHistoryService = SpringContextUtils.getBean("jobHistoryServiceImpl", JobHistoryService.class); jobHistoryService = SpringContextUtils.getBean("jobHistoryServiceImpl", JobHistoryService.class);
taskService = SpringContextUtils.getBean("taskServiceImpl", TaskService.class); taskService = SpringContextUtils.getBean("taskServiceImpl", TaskService.class);
...@@ -191,11 +188,6 @@ public class Job2MysqlHandler implements JobHandler { ...@@ -191,11 +188,6 @@ public class Job2MysqlHandler implements JobHandler {
JobHistory jobHistory = jobHistoryBuilder JobHistory jobHistory = jobHistoryBuilder
.id(jobInstance.getId()) .id(jobInstance.getId())
.clusterJson(ClusterInstanceMapping.getClusterInstanceMapping(clusterInstance)) .clusterJson(ClusterInstanceMapping.getClusterInstanceMapping(clusterInstance))
.jarJson(
Asserts.isNotNull(job.getJobConfig().getJarId())
? JsonUtils.toJsonString(
jarService.getById(job.getJobConfig().getJarId()))
: null)
.clusterConfigurationJson( .clusterConfigurationJson(
Asserts.isNotNull(clusterConfigurationId) Asserts.isNotNull(clusterConfigurationId)
? ClusterConfigurationMapping.getClusterConfigurationMapping( ? ClusterConfigurationMapping.getClusterConfigurationMapping(
......
/*
*
* 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.dinky.mapper;
import org.dinky.data.model.Jar;
import org.dinky.mybatis.mapper.SuperMapper;
import org.apache.ibatis.annotations.Mapper;
/**
* JarMapper
*
* @since 2021/11/13
*/
@Mapper
public interface JarMapper extends SuperMapper<Jar> {}
/*
*
* 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.dinky.mapper;
import org.dinky.data.model.UploadFileRecord;
import org.dinky.mybatis.mapper.SuperMapper;
import org.apache.ibatis.annotations.Mapper;
/** UploadFileRecordMapper */
@Mapper
public interface UploadFileRecordMapper extends SuperMapper<UploadFileRecord> {}
/*
*
* 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.dinky.service;
import org.dinky.data.constant.UploadFileConstant;
import org.springframework.web.multipart.MultipartFile;
/** File upload */
public interface FileUploadService {
/**
* Upload one file, if target file exists, will delete it first
*
* @param file {@link MultipartFile} instance
* @param fileType Upload file's type, refer ${@link UploadFileConstant}
*/
void upload(MultipartFile file, Byte fileType);
/**
* Upload multy file, if target file exists, will delete it first
*
* @param files {@link MultipartFile} instance
* @param fileType Upload file's type, refer ${@link UploadFileConstant}
*/
void upload(MultipartFile[] files, Byte fileType);
/**
* Upload one file, if target file exists, will delete it first
*
* @param file {@link MultipartFile} instance
* @param dir Local absolute dir
* @param fileType Upload file's type, refer ${@link UploadFileConstant}
*/
void upload(MultipartFile file, String dir, Byte fileType);
/**
* Upload multy file, if target file exists, will delete it first
*
* @param files {@link MultipartFile} instance
* @param dir Local absolute dir
* @param fileType Upload file's type, refer ${@link UploadFileConstant}
*/
void upload(MultipartFile[] files, String dir, Byte fileType);
/**
* Upload one hdfs file, if target file exists, will delete it first
*
* @param file {@link MultipartFile} instance
* @param hadoopConfigPath core-site.xml,hdfs-site.xml,yarn-site.xml
* @param dir dir
*/
void uploadHdfs(MultipartFile file, String dir, String hadoopConfigPath);
/**
* Upload multy hdfs file, if target file exists, will delete it first
*
* @param files {@link MultipartFile} instance
* @param hadoopConfigPath core-site.xml,hdfs-site.xml,yarn-site.xml
* @param dir dir
*/
void uploadHdfs(MultipartFile[] files, String dir, String hadoopConfigPath);
}
/*
*
* 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.dinky.service;
import org.dinky.data.model.Jar;
import org.dinky.mybatis.service.ISuperService;
import java.util.List;
/**
* JarService
*
* @since 2021/11/13
*/
public interface JarService extends ISuperService<Jar> {
/**
* List all enabled jar files.
*
* @return A list of {@link Jar} objects representing all enabled jar files.
*/
List<Jar> listEnabledAll();
}
/*
*
* 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.dinky.service;
import org.dinky.data.model.UploadFileRecord;
import org.dinky.mybatis.service.ISuperService;
/** UploadFileRecordService */
public interface UploadFileRecordService extends ISuperService<UploadFileRecord> {
/** Save or update base on file absolute path and file type. */
boolean saveOrUpdateFile(String fileName, String parentPath, String absolutePath, Byte fileType, Byte target);
/** Save or update base on file type. */
boolean saveOrUpdateDir(String parentPath, Byte fileType, Byte target);
}
/*
*
* 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.dinky.service.impl;
import org.dinky.assertion.Asserts;
import org.dinky.data.constant.UploadFileConstant;
import org.dinky.data.exception.BusException;
import org.dinky.service.FileUploadService;
import org.dinky.service.UploadFileRecordService;
import org.dinky.utils.FilePathUtil;
import org.dinky.utils.HdfsUtil;
import org.apache.commons.lang3.StringUtils;
import java.io.File;
import java.io.IOException;
import java.util.Objects;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;
import cn.hutool.core.io.FileUtil;
import lombok.extern.slf4j.Slf4j;
/** FileUploadServiceImpl */
@Slf4j
@Service
public class FileUploadServiceImpl implements FileUploadService {
@Resource
private UploadFileRecordService uploadFileRecordService;
@Override
public void upload(MultipartFile file, String dir, Byte fileType) {
byte target = getTarget(dir, fileType);
if (Objects.equals(target, UploadFileConstant.TARGET_LOCAL)) {
FileUtil.mkdir(dir);
}
String filePath = FilePathUtil.addFileSeparator(dir) + file.getOriginalFilename();
switch (target) {
case UploadFileConstant.TARGET_LOCAL: {
try {
file.transferTo(new File(filePath));
if (uploadFileRecordService.saveOrUpdateFile(
file.getOriginalFilename(), dir, filePath, fileType, UploadFileConstant.TARGET_LOCAL)) {
return;
} else {
throw BusException.valueOfMsg("database exception");
}
} catch (IOException e) {
throw BusException.valueOf("file.upload.failed", e);
}
}
case UploadFileConstant.TARGET_HDFS: {
HdfsUtil.uploadFile(filePath, file);
if (uploadFileRecordService.saveOrUpdateFile(
file.getOriginalFilename(), dir, filePath, fileType, UploadFileConstant.TARGET_HDFS)) {
return;
} else {
throw BusException.valueOfMsg("database exception");
}
}
default:
throw BusException.valueOfMsg("Illegal upload file destination");
}
}
@Override
public void upload(MultipartFile file, Byte fileType) {
String dir = UploadFileConstant.getDirPath(fileType);
if (StringUtils.isEmpty(dir)) {
throw BusException.valueOfMsg("Illegal upload file type");
}
upload(file, dir, fileType);
}
@Override
public void upload(MultipartFile[] files, String dir, Byte fileType) {
if (StringUtils.isEmpty(dir)) {
throw BusException.valueOfMsg("Illegal upload file type");
}
if (files.length > 0) {
for (MultipartFile file : files) {
upload(file, dir, fileType);
}
if (!uploadFileRecordService.saveOrUpdateDir(dir, fileType, getTarget(dir, fileType))) {
throw BusException.valueOfMsg("database exception");
}
} else {
throw BusException.valueOfMsg("No file detected for upload");
}
}
@Override
public void uploadHdfs(MultipartFile file, String dir, String hadoopConfigPath) {
if (Asserts.isNullString(dir)) {
dir = UploadFileConstant.getDirPath(UploadFileConstant.FLINK_LIB_ID);
}
String filePath = FilePathUtil.addFileSeparator(dir) + file.getOriginalFilename();
HdfsUtil.uploadFile(filePath, file, hadoopConfigPath);
if (!uploadFileRecordService.saveOrUpdateFile(
file.getOriginalFilename(),
dir,
filePath,
UploadFileConstant.FLINK_LIB_ID,
UploadFileConstant.TARGET_HDFS)) {
throw BusException.valueOfMsg("database exception");
}
}
@Override
public void uploadHdfs(MultipartFile[] files, String dir, String hadoopConfigPath) {
if (Asserts.isNotNull(files)) {
try {
for (MultipartFile file : files) {
uploadHdfs(file, dir, hadoopConfigPath);
}
if (!uploadFileRecordService.saveOrUpdateDir(
dir, UploadFileConstant.FLINK_LIB_ID, UploadFileConstant.TARGET_HDFS)) {
throw BusException.valueOfMsg("database exception");
}
} catch (Exception e) {
throw BusException.valueOf("unknown.error", e);
}
}
}
@Override
public void upload(MultipartFile[] files, Byte fileType) {
String dir = UploadFileConstant.getDirPath(fileType);
upload(files, dir, fileType);
}
/**
* Get upload file target.
*
* @param dir If null, will return -1
* @param fileType Internal upload file type, refer {@link UploadFileConstant}
* @return Upload file target, refer {@link UploadFileConstant}
*/
private byte getTarget(String dir, byte fileType) {
byte target = UploadFileConstant.getTarget(fileType);
if (target == -1) {
target = FilePathUtil.getDirTarget(dir);
}
return target;
}
}
/*
*
* 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.dinky.service.impl;
import org.dinky.data.model.Jar;
import org.dinky.mapper.JarMapper;
import org.dinky.mybatis.service.impl.SuperServiceImpl;
import org.dinky.service.JarService;
import java.util.List;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
/**
* JarServiceImpl
*
* @since 2021/11/13
*/
@Service
public class JarServiceImpl extends SuperServiceImpl<JarMapper, Jar> implements JarService {
@Override
public List<Jar> listEnabledAll() {
return list(new QueryWrapper<Jar>().eq("enabled", 1));
}
}
...@@ -42,7 +42,6 @@ import org.dinky.data.model.Catalogue; ...@@ -42,7 +42,6 @@ import org.dinky.data.model.Catalogue;
import org.dinky.data.model.ClusterConfiguration; import org.dinky.data.model.ClusterConfiguration;
import org.dinky.data.model.ClusterInstance; import org.dinky.data.model.ClusterInstance;
import org.dinky.data.model.DataBase; import org.dinky.data.model.DataBase;
import org.dinky.data.model.Jar;
import org.dinky.data.model.JobInstance; import org.dinky.data.model.JobInstance;
import org.dinky.data.model.JobModelOverview; import org.dinky.data.model.JobModelOverview;
import org.dinky.data.model.JobTypeOverView; import org.dinky.data.model.JobTypeOverView;
...@@ -75,7 +74,6 @@ import org.dinky.service.ClusterConfigurationService; ...@@ -75,7 +74,6 @@ import org.dinky.service.ClusterConfigurationService;
import org.dinky.service.ClusterInstanceService; import org.dinky.service.ClusterInstanceService;
import org.dinky.service.DataBaseService; import org.dinky.service.DataBaseService;
import org.dinky.service.FragmentVariableService; import org.dinky.service.FragmentVariableService;
import org.dinky.service.JarService;
import org.dinky.service.JobInstanceService; import org.dinky.service.JobInstanceService;
import org.dinky.service.SavepointsService; import org.dinky.service.SavepointsService;
import org.dinky.service.TaskService; import org.dinky.service.TaskService;
...@@ -139,7 +137,6 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -139,7 +137,6 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
private final SavepointsService savepointsService; private final SavepointsService savepointsService;
private final ClusterInstanceService clusterInstanceService; private final ClusterInstanceService clusterInstanceService;
private final ClusterConfigurationService clusterCfgService; private final ClusterConfigurationService clusterCfgService;
private final JarService jarService;
private final DataBaseService dataBaseService; private final DataBaseService dataBaseService;
private final JobInstanceService jobInstanceService; private final JobInstanceService jobInstanceService;
private final AlertGroupService alertGroupService; private final AlertGroupService alertGroupService;
...@@ -613,13 +610,6 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -613,13 +610,6 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
DataBase dataBase = dataBaseService.getById(task.getDatabaseId()); DataBase dataBase = dataBaseService.getById(task.getDatabaseId());
jsonNode.put("databaseName", Asserts.isNotNull(dataBase) ? dataBase.getName() : null); jsonNode.put("databaseName", Asserts.isNotNull(dataBase) ? dataBase.getName() : null);
} }
// jarName
if (Asserts.isNotNull(task.getJarId())) {
Jar jar = jarService.getById(task.getJarId());
jsonNode.put("jarName", Asserts.isNotNull(jar) ? jar.getName() : null);
}
// envName // envName
if (Asserts.isNotNull(task.getEnvId())) { if (Asserts.isNotNull(task.getEnvId())) {
Task envTask = getById(task.getEnvId()); Task envTask = getById(task.getEnvId());
...@@ -700,13 +690,6 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen ...@@ -700,13 +690,6 @@ public class TaskServiceImpl extends SuperServiceImpl<TaskMapper, Task> implemen
} }
} }
if (Asserts.isNotNull(task.getJarName())) {
Jar jar = jarService.getOne(new QueryWrapper<Jar>().eq("name", task.getJarName()));
if (Asserts.isNotNull(jar)) {
task.setJarId(jar.getId());
}
}
if (Asserts.isNotNull(task.getAlertGroupName())) { if (Asserts.isNotNull(task.getAlertGroupName())) {
AlertGroup alertGroup = AlertGroup alertGroup =
alertGroupService.getOne(new QueryWrapper<AlertGroup>().eq("name", task.getAlertGroupName())); alertGroupService.getOne(new QueryWrapper<AlertGroup>().eq("name", task.getAlertGroupName()));
......
/*
*
* 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.dinky.service.impl;
import org.dinky.data.constant.UploadFileConstant;
import org.dinky.data.model.UploadFileRecord;
import org.dinky.mapper.UploadFileRecordMapper;
import org.dinky.mybatis.service.impl.SuperServiceImpl;
import org.dinky.service.UploadFileRecordService;
import org.dinky.utils.FilePathUtil;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
/** UploadFileRecordServiceImpl */
@Service
public class UploadFileRecordServiceImpl extends SuperServiceImpl<UploadFileRecordMapper, UploadFileRecord>
implements UploadFileRecordService {
@Override
public boolean saveOrUpdateFile(
String fileName, String parentPath, String absolutePath, Byte fileType, Byte target) {
UploadFileRecord updateWrapper = new UploadFileRecord();
updateWrapper.setFileType(fileType);
updateWrapper.setTarget(target);
updateWrapper.setFileAbsolutePath(absolutePath);
UploadFileRecord entity = new UploadFileRecord();
entity.setFileType(fileType);
entity.setTarget(target);
entity.setName(UploadFileConstant.getDirName(fileType));
entity.setIsFile(true);
entity.setFileName(fileName);
entity.setFileParentPath(FilePathUtil.removeFileSeparator(parentPath));
entity.setFileAbsolutePath(absolutePath);
return saveOrUpdate(entity, new UpdateWrapper<>(updateWrapper));
}
@Override
public boolean saveOrUpdateDir(String parentPath, Byte fileType, Byte target) {
UploadFileRecord updateWrapper = new UploadFileRecord();
updateWrapper.setFileType(fileType);
updateWrapper.setTarget(target);
updateWrapper.setIsFile(false);
UploadFileRecord entity = new UploadFileRecord();
entity.setFileType(fileType);
entity.setTarget(target);
entity.setName(UploadFileConstant.getDirName(fileType));
entity.setIsFile(false);
entity.setFileParentPath(FilePathUtil.removeFileSeparator(parentPath));
return saveOrUpdate(entity, new UpdateWrapper<>(updateWrapper));
}
}
/*
*
* 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.dinky.utils;
import org.dinky.data.constant.UploadFileConstant;
import org.apache.commons.lang3.StringUtils;
/** File path handle */
public class FilePathUtil {
/**
* Add a file separator '/' at the end of the file path
*
* @param filePath File path
*/
public static String addFileSeparator(String filePath) {
if (StringUtils.isEmpty(filePath)) {
return filePath;
} else {
if (filePath.endsWith("/")) {
return filePath;
} else {
return filePath + "/";
}
}
}
/**
* Remove a file separator '/' at the end of the file path
*
* @param filePath File path
*/
public static String removeFileSeparator(String filePath) {
if (StringUtils.isEmpty(filePath)) {
return filePath;
} else {
if (filePath.endsWith("/")) {
return filePath.substring(0, filePath.length() - 1);
} else {
return filePath;
}
}
}
/**
* Get dir type, refer {@link UploadFileConstant}
*
* @param dir Directory
* @return Refer {@link UploadFileConstant}
*/
public static byte getDirTarget(String dir) {
if (StringUtils.isEmpty(dir)) {
return UploadFileConstant.TARGET_OTHER;
} else if (dir.contains("hdfs")) {
return UploadFileConstant.TARGET_HDFS;
} else {
return UploadFileConstant.TARGET_LOCAL;
}
}
}
/*
*
* 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.dinky.utils;
import org.dinky.assertion.Asserts;
import org.dinky.data.constant.UploadFileConstant;
import org.dinky.data.exception.BusException;
import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.FSDataOutputStream;
import org.apache.hadoop.fs.FileSystem;
import org.apache.hadoop.fs.Path;
import java.io.File;
import java.io.IOException;
import org.springframework.web.multipart.MultipartFile;
import cn.hutool.core.exceptions.ExceptionUtil;
import lombok.extern.slf4j.Slf4j;
/** Hdfs Handle */
@Slf4j
public class HdfsUtil {
/**
* Init internal hdfs client
*
* @param hadoopConfigPath HDFS config path
*/
private static FileSystem init(String hadoopConfigPath) {
FileSystem hdfs;
if (Asserts.isNullString(hadoopConfigPath)) {
hadoopConfigPath = FilePathUtil.removeFileSeparator(UploadFileConstant.HADOOP_CONF_DIR);
}
String coreSiteFilePath = hadoopConfigPath + "/core-site.xml";
String hdfsSiteFilePath = hadoopConfigPath + "/hdfs-site.xml";
if (!new File(coreSiteFilePath).exists() || !new File(hdfsSiteFilePath).exists()) {
throw BusException.valueOf("hdfs.file.lose");
}
try {
final Configuration configuration = new Configuration();
configuration.addResource(new Path(coreSiteFilePath));
configuration.addResource(new Path(hdfsSiteFilePath));
hdfs = FileSystem.get(configuration);
} catch (IOException e) {
String msg = ExceptionUtil.stacktraceToString(e);
log.error(msg);
throw BusException.valueOf("hdfs.init.failed", e);
}
log.info("hdfs client initialized successfully");
return hdfs;
}
/**
* Upload file byte content to HDFS
*
* @param path HDFS path
* @param bytes File byte content
* @param hadoopConfigPath hdfs config path
*/
public static void uploadFile(String path, byte[] bytes, String hadoopConfigPath) {
try (FileSystem hdfs = init(hadoopConfigPath);
FSDataOutputStream stream = hdfs.create(new Path(path), true)) {
stream.write(bytes);
stream.flush();
} catch (IOException e) {
throw BusException.valueOf("file.upload.failed", e);
}
}
/**
* Upload file byte content to HDFS
*
* @param path HDFS path
* @param file MultipartFile instance
*/
public static void uploadFile(String path, MultipartFile file) {
try {
uploadFile(path, file.getBytes(), null);
} catch (IOException e) {
throw BusException.valueOf("file.upload.failed", e);
}
}
/**
* Upload file byte content to HDFS
*
* @param path HDFS path
* @param file MultipartFile instance
* @param hadoopConfigPath hdfs config path
*/
public static void uploadFile(String path, MultipartFile file, String hadoopConfigPath) {
try {
uploadFile(path, file.getBytes(), hadoopConfigPath);
} catch (IOException e) {
throw BusException.valueOf("file.upload.failed", e);
}
}
}
This source diff could not be displayed because it is too large. You can view the blob instead.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.dinky.mapper.JarMapper">
<select id="selectForProTable" resultType="org.dinky.data.model.Jar">
select
a.*
from
dinky_jar a
<where>
1=1
<if test='param.name!=null and param.name!=""'>
and a.name like "%${param.name}%"
</if>
<if test='param.path!=null and param.path!=""'>
and a.path like "%${param.path}%"
</if>
<if test='param.mainClass!=null and param.mainClass!=""'>
and a.main_class like "%${param.mainClass}%"
</if>
<if test='param.createTime!=null and param.createTime!=""'>
and a.create_time <![CDATA[>=]]> str_to_date( #{param.createTime},'%Y-%m-%d %H:%i:%s')
</if>
<if test='param.updateTime!=null and param.updateTime!=""'>
and a.update_time <![CDATA[>=]]> str_to_date( #{param.updateTime},'%Y-%m-%d %H:%i:%s')
</if>
<if test='ew.sqlSegment!=null and ew.sqlSegment!="" and !ew.sqlSegment.startsWith(" ORDER BY")'>
and
</if>
<if test='ew.sqlSegment!=null and ew.sqlSegment!=""'>
${ew.sqlSegment}
</if>
</where>
</select>
</mapper>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="org.dinky.mapper.UploadFileRecordMapper">
</mapper>
...@@ -144,11 +144,6 @@ unknown.i18n=Unknown i18n information, please check. . . ...@@ -144,11 +144,6 @@ unknown.i18n=Unknown i18n information, please check. . .
file.upload.failed=File upload failed, reason: {0} file.upload.failed=File upload failed, reason: {0}
hdfs.init.failed=Internal hdfs client initialization error, reason: {0}
hdfs.file.lose=The core-site.xml/hdfs-site.xml/yarn-site.xml files were not found in the project root directory, please upload these files first
# dinky-alert # dinky-alert
alert.rule.jobFail=Job Failure alert.rule.jobFail=Job Failure
alert.rule.getJobInfoFail=Get Job Info Fail alert.rule.getJobInfoFail=Get Job Info Fail
......
...@@ -144,9 +144,6 @@ unknown.i18n=\u672A\u77E5 i18n \u4FE1\u606F,\u8BF7\u68C0\u67E5. . . ...@@ -144,9 +144,6 @@ unknown.i18n=\u672A\u77E5 i18n \u4FE1\u606F,\u8BF7\u68C0\u67E5. . .
file.upload.failed=\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25, \u539F\u56E0: {0} file.upload.failed=\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25, \u539F\u56E0: {0}
hdfs.init.failed=\u5185\u90E8hdfs\u4FE1\u606F\u9519\u8BEF, \u539F\u56E0: {0}
hdfs.file.lose= \u5728\u5DE5\u7A0B\u6839\u76EE\u5F55\u4E0B\u6CA1\u6709\u627E\u5230core-site.xml/hdfs-site.xml/yarn-site.xml\u6587\u4EF6, \u8BF7\u5148\u4E0A\u4F20\u8FD9\u4E9B\u6587\u4EF6
daemon.task.config.not.exist=\u7EBF\u7A0B\u4EFB\u52A1\u914D\u7F6E\u4E0D\u80FD\u4E3A\u7A7A daemon.task.config.not.exist=\u7EBF\u7A0B\u4EFB\u52A1\u914D\u7F6E\u4E0D\u80FD\u4E3A\u7A7A
daemon.task.not.support=\u4E0D\u652F\u6301\u7EBF\u7A0B\u4EFB\u52A1\u7C7B\u578B\uFF1A daemon.task.not.support=\u4E0D\u652F\u6301\u7EBF\u7A0B\u4EFB\u52A1\u7C7B\u578B\uFF1A
......
...@@ -816,6 +816,18 @@ ...@@ -816,6 +816,18 @@
<replacement>project</replacement> <replacement>project</replacement>
</replace> </replace>
</pom> </pom>
<typescript>
<includes>
<!-- You have to set the target manually -->
<include>dinky-web/src/**/*.ts</include>
<include>dinky-web/src/**/*.tsx</include>
<include>dinky-web/src/**/*.js</include>
</includes>
<licenseHeader>
<file>style/license_header</file>
<delimiter>(import|const|declare|let|export|export const|export default)</delimiter>
</licenseHeader>
</typescript>
</configuration> </configuration>
<executions> <executions>
<execution> <execution>
......
This source diff could not be displayed because it is too large. You can view the blob instead.
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -292,4 +292,9 @@ CREATE TABLE `dinky_sys_token` ( ...@@ -292,4 +292,9 @@ CREATE TABLE `dinky_sys_token` (
drop table if exists dinky_task_statement;
drop table if exists dinky_jar;
drop table if exists dinky_schema_history;
drop table if exists dinky_upload_file_record;
SET FOREIGN_KEY_CHECKS = 1; SET FOREIGN_KEY_CHECKS = 1;
...@@ -274,4 +274,408 @@ LEFT JOIN ...@@ -274,4 +274,408 @@ LEFT JOIN
dinky_task_statement AS s ON t.id = s.id; dinky_task_statement AS s ON t.id = s.id;
drop table if exists dinky_task_statement; -- 删除dinky_job_history 的 jar_json 字段
\ No newline at end of file alter table dinky_job_history drop column jar_json;
alter table dinky_task drop column jar_id;
insert into `dinky_flink_document` values (218, 'Reference', '建表语句', 'Streaming', 'EXECUTE CDCSOURCE print', 'Whole library synchronization print', 'EXECUTE CDCSOURCE demo_print WITH (
''connector'' = ''mysql-cdc'',
''hostname'' = ''127.0.0.1'',
''port'' = ''3306'',
''username'' = ''root'',
''password'' = ''123456'',
''checkpoint'' = ''10000'',
''scan.startup.mode'' = ''initial'',
''parallelism'' = ''1'',
''table-name'' = ''test\\.student,test\\.score'',
''sink.connector'' = ''print''
);', 'All Versions', 0, 1, '2023-10-31 16:01:45', '2023-10-31 16:02:56');
insert into `dinky_flink_document` values (219, 'Reference', '建表语句', 'Streaming', 'EXECUTE CDCSOURCE doris', 'Whole library synchronization doris', 'EXECUTE CDCSOURCE demo_print WITH (
''connector'' = ''mysql-cdc'',
''hostname'' = ''127.0.0.1'',
''port'' = ''3306'',
''username'' = ''root'',
''password'' = ''123456'',
''checkpoint'' = ''10000'',
''scan.startup.mode'' = ''initial'',
''parallelism'' = ''1'',
''table-name'' = ''test\\.student,test\\.score'',
''sink.connector'' = ''print''
);', 'All Versions', 0, 1, '2023-10-31 16:02:21', '2023-10-31 16:03:09');
insert into `dinky_flink_document` values (220, 'Reference', '建表语句', 'Batch/Streaming', 'EXECUTE CDCSOURCE demo_doris_schema_evolution', 'The entire library is synchronized to doris tape mode evolution', 'EXECUTE CDCSOURCE demo_doris_schema_evolution WITH (
''connector'' = ''mysql-cdc'',
''hostname'' = ''127.0.0.1'',
''port'' = ''3306'',
''username'' = ''root'',
''password'' = ''123456'',
''checkpoint'' = ''10000'',
''scan.startup.mode'' = ''initial'',
''parallelism'' = ''1'',
''table-name'' = ''test\\.student,test\\.score'',
''sink.connector'' = ''datastream-doris-schema-evolution'',
''sink.fenodes'' = ''127.0.0.1:8030'',
''sink.username'' = ''root'',
''sink.password'' = ''123456'',
''sink.doris.batch.size'' = ''1000'',
''sink.sink.max-retries'' = ''1'',
''sink.sink.batch.interval'' = ''60000'',
''sink.sink.db'' = ''test'',
''sink.table.identifier'' = ''${schemaName}.${tableName}''
);', 'All Versions', 0, 1, '2023-10-31 16:04:53', '2023-10-31 16:04:53');
insert into `dinky_flink_document` values (221, 'Reference', '建表语句', 'Batch/Streaming', 'EXECUTE CDCSOURCE StarRocks ', 'The entire library is synchronized to StarRocks
', 'EXECUTE CDCSOURCE demo_hudi WITH (
''connector'' = ''mysql-cdc'',
''hostname'' = ''127.0.0.1'',
''port'' = ''3306'',
''username'' = ''root'',
''password'' = ''123456'',
''checkpoint'' = ''10000'',
''scan.startup.mode'' = ''initial'',
''parallelism'' = ''1'',
''database-name''=''bigdata'',
''table-name''=''bigdata\\.products,bigdata\\.orders'',
''sink.connector''=''hudi'',
''sink.path''=''hdfs://nameservice1/data/hudi/${tableName}'',
''sink.hoodie.datasource.write.recordkey.field''=''${pkList}'',
''sink.hoodie.parquet.max.file.size''=''268435456'',
''sink.write.tasks''=''1'',
''sink.write.bucket_assign.tasks''=''2'',
''sink.write.precombine''=''true'',
''sink.compaction.async.enabled''=''true'',
''sink.write.task.max.size''=''1024'',
''sink.write.rate.limit''=''3000'',
''sink.write.operation''=''upsert'',
''sink.table.type''=''COPY_ON_WRITE'',
''sink.compaction.tasks''=''1'',
''sink.compaction.delta_seconds''=''20'',
''sink.compaction.async.enabled''=''true'',
''sink.read.streaming.skip_compaction''=''true'',
''sink.compaction.delta_commits''=''20'',
''sink.compaction.trigger.strategy''=''num_or_time'',
''sink.compaction.max_memory''=''500'',
''sink.changelog.enabled''=''true'',
''sink.read.streaming.enabled''=''true'',
''sink.read.streaming.check.interval''=''3'',
''sink.hive_sync.skip_ro_suffix'' = ''true'',
''sink.hive_sync.enable''=''true'',
''sink.hive_sync.mode''=''hms'',
''sink.hive_sync.metastore.uris''=''thrift://bigdata1:9083'',
''sink.hive_sync.db''=''qhc_hudi_ods'',
''sink.hive_sync.table''=''${tableName}'',
''sink.table.prefix.schema''=''true''
);', 'All Versions', 0, 1, '2023-10-31 16:05:50', '2023-10-31 16:08:53');
insert into `dinky_flink_document` values (222, 'Reference', '建表语句', 'Batch/Streaming', 'EXECUTE CDCSOURCE cdc_mysql', 'The entire library is synchronized to mysql', 'EXECUTE CDCSOURCE demo_startrocks WITH (
''connector'' = ''mysql-cdc'',
''hostname'' = ''127.0.0.1'',
''port'' = ''3306'',
''username'' = ''root'',
''password'' = ''123456'',
''checkpoint'' = ''3000'',
''scan.startup.mode'' = ''initial'',
''parallelism'' = ''1'',
''table-name'' = ''bigdata\\.products,bigdata\\.orders'',
''sink.connector'' = ''starrocks'',
''sink.jdbc-url'' = ''jdbc:mysql://127.0.0.1:19035'',
''sink.load-url'' = ''127.0.0.1:18035'',
''sink.username'' = ''root'',
''sink.password'' = ''123456'',
''sink.sink.db'' = ''ods'',
''sink.table.prefix'' = ''ods_'',
''sink.table.lower'' = ''true'',
''sink.database-name'' = ''ods'',
''sink.table-name'' = ''${tableName}'',
''sink.sink.properties.format'' = ''json'',
''sink.sink.properties.strip_outer_array'' = ''true'',
''sink.sink.max-retries'' = ''10'',
''sink.sink.buffer-flush.interval-ms'' = ''15000'',
''sink.sink.parallelism'' = ''1''
);', 'All Versions', 0, 1, '2023-10-31 16:07:08', '2023-10-31 16:08:46');
insert into `dinky_flink_document` values (223, 'Reference', '建表语句', 'Streaming', 'EXECUTE CDCSOURCE demo_doris', 'The entire library is synchronized to mysql', 'EXECUTE CDCSOURCE cdc_mysql WITH (
''connector'' = ''mysql-cdc'',
''hostname'' = ''127.0.0.1'',
''port'' = ''3306'',
''username'' = ''root'',
''password'' = ''123456'',
''checkpoint'' = ''3000'',
''scan.startup.mode'' = ''initial'',
''parallelism'' = ''1'',
''table-name'' = ''bigdata\\.products,bigdata\\.orders'',
''sink.connector'' = ''jdbc'',
''sink.url'' = ''jdbc:mysql://127.0.0.1:3306/test?characterEncoding=utf-8&useSSL=false'',
''sink.username'' = ''root'',
''sink.password'' = ''123456'',
''sink.sink.db'' = ''test'',
''sink.table.prefix'' = ''test_'',
''sink.table.lower'' = ''true'',
''sink.table-name'' = ''${tableName}'',
''sink.driver'' = ''com.mysql.jdbc.Driver'',
''sink.sink.buffer-flush.interval'' = ''2s'',
''sink.sink.buffer-flush.max-rows'' = ''100'',
''sink.sink.max-retries'' = ''5'',
''sink.auto.create'' = ''true''
);', 'All Versions', 0, 1, '2023-10-31 16:07:47', '2023-10-31 16:08:39');
insert into `dinky_flink_document` values (224, 'Reference', '建表语句', 'Batch/Streaming', 'EXECUTE CDCSOURCE cdc_oracle', 'The entire library is synchronized to cdc_oracle', 'EXECUTE CDCSOURCE cdc_oracle WITH (
''connector'' = ''oracle-cdc'',
''hostname'' = ''127.0.0.1'',
''port'' = ''1521'',
''username''=''root'',
''password''=''123456'',
''database-name''=''ORCL'',
''checkpoint'' = ''3000'',
''scan.startup.mode'' = ''initial'',
''parallelism'' = ''1'',
''table-name'' = ''TEST\\..*'',
''connector'' = ''jdbc'',
''url'' = ''jdbc:oracle:thin:@127.0.0.1:1521:orcl'',
''username'' = ''root'',
''password'' = ''123456'',
''table-name'' = ''TEST2.${tableName}''
);', 'All Versions', 0, 1, '2023-10-31 16:08:30', '2023-10-31 16:08:30');
insert into `dinky_flink_document` values (225, 'Reference', '建表语句', 'Batch/Streaming', 'EXECUTE CDCSOURCE cdc_kafka_one', 'The entire library is synchronized to a topic in kafka', 'EXECUTE CDCSOURCE cdc_kafka_one WITH (
''connector'' = ''mysql-cdc'',
''hostname'' = ''127.0.0.1'',
''port'' = ''3306'',
''username'' = ''root'',
''password'' = ''123456'',
''checkpoint'' = ''3000'',
''scan.startup.mode'' = ''initial'',
''parallelism'' = ''1'',
''table-name'' = ''bigdata\\.products,bigdata\\.orders'',
''sink.connector''=''datastream-kafka'',
''sink.topic''=''cdctest'',
''sink.brokers''=''bigdata2:9092,bigdata3:9092,bigdata4:9092''
);', 'All Versions', 0, 1, '2023-10-31 16:10:13', '2023-10-31 16:10:13');
insert into `dinky_flink_document` values (226, 'Reference', '建表语句', 'Batch/Streaming', 'EXECUTE CDCSOURCE cdc_kafka_mul', 'The entire library is synchronized to a single topic in kafka', 'EXECUTE CDCSOURCE cdc_kafka_mul WITH (
''connector'' = ''mysql-cdc'',
''hostname'' = ''127.0.0.1'',
''port'' = ''3306'',
''username'' = ''root'',
''password'' = ''123456'',
''checkpoint'' = ''3000'',
''scan.startup.mode'' = ''initial'',
''parallelism'' = ''1'',
''table-name'' = ''bigdata\\.products,bigdata\\.orders'',
''sink.connector''=''datastream-kafka'',
''sink.brokers''=''bigdata2:9092,bigdata3:9092,bigdata4:9092''
)', 'All Versions', 0, 1, '2023-10-31 16:10:59', '2023-10-31 16:10:59');
insert into `dinky_flink_document` values (227, 'Reference', '建表语句', 'Batch/Streaming', 'EXECUTE CDCSOURCE cdc_upsert_kafka', 'The entire library is synchronized to kafka primary key mode', 'EXECUTE CDCSOURCE cdc_upsert_kafka WITH (
''connector'' = ''mysql-cdc'',
''hostname'' = ''127.0.0.1'',
''port'' = ''3306'',
''username'' = ''root'',
''password'' = ''123456'',
''checkpoint'' = ''3000'',
''scan.startup.mode'' = ''initial'',
''parallelism'' = ''1'',
''table-name'' = ''bigdata\\.products,bigdata\\.orders'',
''sink.connector'' = ''upsert-kafka'',
''sink.topic'' = ''${tableName}'',
''sink.properties.bootstrap.servers'' = ''bigdata2:9092,bigdata3:9092,bigdata4:9092'',
''sink.key.format'' = ''json'',
''sink.value.format'' = ''json''
);', 'All Versions', 0, 1, '2023-10-31 16:12:14', '2023-10-31 16:12:14');
insert into `dinky_flink_document` values (228, 'Reference', '建表语句', 'Batch/Streaming', 'EXECUTE CDCSOURCE cdc_postgresql ', 'The entire library is synchronized to postgresql', 'EXECUTE CDCSOURCE cdc_postgresql WITH (
''connector'' = ''mysql-cdc'',
''hostname'' = ''127.0.0.1'',
''port'' = ''3306'',
''username'' = ''root'',
''password'' = ''123456'',
''checkpoint'' = ''3000'',
''scan.startup.mode'' = ''initial'',
''parallelism'' = ''1'',
''table-name'' = ''bigdata\\.products,bigdata\\.orders'',
''sink.connector'' = ''jdbc'',
''sink.url'' = ''jdbc:postgresql://127.0.0.1:5432/test'',
''sink.username'' = ''test'',
''sink.password'' = ''123456'',
''sink.sink.db'' = ''test'',
''sink.table.prefix'' = ''test_'',
''sink.table.lower'' = ''true'',
''sink.table-name'' = ''${tableName}'',
''sink.driver'' = ''org.postgresql.Driver'',
''sink.sink.buffer-flush.interval'' = ''2s'',
''sink.sink.buffer-flush.max-rows'' = ''100'',
''sink.sink.max-retries'' = ''5''
)', 'All Versions', 0, 1, '2023-10-31 16:12:54', '2023-10-31 16:12:54');
insert into `dinky_flink_document` values (229, 'Reference', '建表语句', 'Batch/Streaming', 'EXECUTE CDCSOURCE cdc_clickhouse', 'Sync the entire library to clickhouse', 'EXECUTE CDCSOURCE cdc_clickhouse WITH (
''connector'' = ''mysql-cdc'',
''hostname'' = ''127.0.0.1'',
''port'' = ''3306'',
''username'' = ''root'',
''password'' = ''123456'',
''checkpoint'' = ''3000'',
''scan.startup.mode'' = ''initial'',
''parallelism'' = ''1'',
''table-name'' = ''bigdata\\.products,bigdata\\.orders'',
''sink.connector'' = ''clickhouse'',
''sink.url'' = ''clickhouse://127.0.0.1:8123'',
''sink.username'' = ''default'',
''sink.password'' = ''123456'',
''sink.sink.db'' = ''test'',
''sink.table.prefix'' = ''test_'',
''sink.table.lower'' = ''true'',
''sink.database-name'' = ''test'',
''sink.table-name'' = ''${tableName}'',
''sink.sink.batch-size'' = ''500'',
''sink.sink.flush-interval'' = ''1000'',
''sink.sink.max-retries'' = ''3''
);', 'All Versions', 0, 1, '2023-10-31 16:13:33', '2023-10-31 16:13:33');
insert into `dinky_flink_document` values (230, 'Reference', '建表语句', 'Batch/Streaming', 'EXECUTE CDCSOURCE mysql2hive', 'The entire library is synchronized to the sql-catalog of hive', 'EXECUTE CDCSOURCE mysql2hive WITH (
''connector'' = ''mysql-cdc'',
''hostname'' = ''127.0.0.1'',
''port'' = ''3306'',
''username'' = ''root'',
''password'' = ''123456'',
''checkpoint'' = ''10000'',
''scan.startup.mode'' = ''initial'',
''parallelism'' = ''1'',
''table-name'' = ''test\\..*'',
''sink.connector'' = ''sql-catalog'',
''sink.catalog.name'' = ''hive'',
''sink.catalog.type'' = ''hive'',
''sink.default-database'' = ''hdb'',
''sink.hive-conf-dir'' = ''/usr/local/dlink/hive-conf''
);', 'All Versions', 0, 1, '2023-10-31 16:14:31', '2023-10-31 16:14:31');
insert into `dinky_flink_document` values (231, 'Reference', '建表语句', 'Batch/Streaming', 'EXECUTE CDCSOURCE mysql2paimon', 'The entire library is synchronized to paimon', 'EXECUTE CDCSOURCE mysql2paimon WITH (
''connector'' = ''mysql-cdc'',
''hostname'' = ''127.0.0.1'',
''port'' = ''3306'',
''username'' = ''root'',
''password'' = ''123456'',
''checkpoint'' = ''10000'',
''scan.startup.mode'' = ''initial'',
''parallelism'' = ''1'',
''table-name'' = ''test\\..*'',
''sink.connector'' = ''sql-catalog'',
''sink.catalog.name'' = ''fts'',
''sink.catalog.type'' = ''table-store'',
''sink.catalog.warehouse''=''file:/tmp/table_store''
);', 'All Versions', 0, 1, '2023-10-31 16:15:22', '2023-10-31 16:28:52');
insert into `dinky_flink_document` values (232, 'Reference', '建表语句', 'Batch/Streaming', 'EXECUTE CDCSOURCE mysql2dinky_catalog', 'The entire library is synchronized to dinky''s built-in catalog', 'EXECUTE CDCSOURCE mysql2dinky_catalog WITH (
''connector'' = ''mysql-cdc'',
''hostname'' = ''127.0.0.1'',
''port'' = ''3306'',
''username'' = ''root'',
''password'' = ''123456'',
''checkpoint'' = ''10000'',
''scan.startup.mode'' = ''initial'',
''parallelism'' = ''1'',
''table-name'' = ''test\\..*'',
''sink.connector'' = ''sql-catalog'',
''sink.catalog.name'' = ''dlinkmysql'',
''sink.catalog.type'' = ''dlink_mysql'',
''sink.catalog.username'' = ''dlink'',
''sink.catalog.password'' = ''dlink'',
''sink.catalog.url'' = ''jdbc:mysql://127.0.0.1:3306/dlink?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC'',
''sink.sink.db'' = ''default_database''
);', 'All Versions', 0, 1, '2023-10-31 16:16:22', '2023-10-31 16:16:22');
insert into `dinky_flink_document` values (233, 'Reference', '建表语句', 'Batch/Streaming', 'EXECUTE CDCSOURCE mysql2multiple_sink', 'Synchronization of the entire library to multiple data sources (sink)', 'EXECUTE CDCSOURCE mysql2multiple_sink WITH (
''connector'' = ''mysql-cdc'',
''hostname'' = ''127.0.0.1'',
''port'' = ''3306'',
''username'' = ''root'',
''password'' = ''123456'',
''checkpoint'' = ''3000'',
''scan.startup.mode'' = ''initial'',
''parallelism'' = ''1'',
''table-name'' = ''test\\.student,test\\.score'',
''sink[0].connector'' = ''doris'',
''sink[0].fenodes'' = ''127.0.0.1:8030'',
''sink[0].username'' = ''root'',
''sink[0].password'' = ''dw123456'',
''sink[0].sink.batch.size'' = ''1'',
''sink[0].sink.max-retries'' = ''1'',
''sink[0].sink.batch.interval'' = ''60000'',
''sink[0].sink.db'' = ''test'',
''sink[0].table.prefix'' = ''ODS_'',
''sink[0].table.upper'' = ''true'',
''sink[0].table.identifier'' = ''${schemaName}.${tableName}'',
''sink[0].sink.label-prefix'' = ''${schemaName}_${tableName}_1'',
''sink[0].sink.enable-delete'' = ''true'',
''sink[1].connector''=''datastream-kafka'',
''sink[1].topic''=''cdc'',
''sink[1].brokers''=''127.0.0.1:9092''
)', 'All Versions', 0, 1, '2023-10-31 16:17:27', '2023-10-31 16:17:27');
insert into `dinky_flink_document` values (234, 'Reference', '建表语句', 'Batch/Streaming', 'ADD JAR', 'ADD JAR', 'ADD JAR ${1:}; -- str path ', 'All Versions', 0, 1, '2023-10-31 16:19:52', '2023-10-31 16:23:16');
insert into `dinky_flink_document` values (235, 'Function', 'Other', 'Batch/Streaming', 'SHOW FRAGMENTS', 'SHOW FRAGMENTS', 'SHOW FRAGMENTS;', 'All Versions', 0, 1, '2023-10-31 16:20:30', '2023-10-31 16:20:30');
insert into `dinky_flink_document` values (236, 'Function', 'Other', 'Batch/Streaming', 'SHOW FRAGMENT var1', 'SHOW FRAGMENT var1', 'SHOW FRAGMENT ${1:};', 'All Versions', 0, 1, '2023-10-31 16:21:23', '2023-10-31 16:21:23');
insert into `dinky_flink_document` values (237, 'Reference', '建表语句', 'Batch/Streaming', 'EXECUTE CDCSOURCE demo_hudi', 'The entire library is synchronized to hudi', 'EXECUTE CDCSOURCE demo_hudi WITH (
''connector'' = ''mysql-cdc'',
''hostname'' = ''127.0.0.1'',
''port'' = ''3306'',
''username'' = ''root'',
''password'' = ''123456'',
''checkpoint'' = ''10000'',
''scan.startup.mode'' = ''initial'',
''parallelism'' = ''1'',
''database-name''=''bigdata'',
''table-name''=''bigdata\\.products,bigdata\\.orders'',
''sink.connector''=''hudi'',
''sink.path''=''hdfs://nameservice1/data/hudi/${tableName}'',
''sink.hoodie.datasource.write.recordkey.field''=''${pkList}'',
''sink.hoodie.parquet.max.file.size''=''268435456'',
''sink.write.tasks''=''1'',
''sink.write.bucket_assign.tasks''=''2'',
''sink.write.precombine''=''true'',
''sink.compaction.async.enabled''=''true'',
''sink.write.task.max.size''=''1024'',
''sink.write.rate.limit''=''3000'',
''sink.write.operation''=''upsert'',
''sink.table.type''=''COPY_ON_WRITE'',
''sink.compaction.tasks''=''1'',
''sink.compaction.delta_seconds''=''20'',
''sink.compaction.async.enabled''=''true'',
''sink.read.streaming.skip_compaction''=''true'',
''sink.compaction.delta_commits''=''20'',
''sink.compaction.trigger.strategy''=''num_or_time'',
''sink.compaction.max_memory''=''500'',
''sink.changelog.enabled''=''true'',
''sink.read.streaming.enabled''=''true'',
''sink.read.streaming.check.interval''=''3'',
''sink.hive_sync.skip_ro_suffix'' = ''true'',
''sink.hive_sync.enable''=''true'',
''sink.hive_sync.mode''=''hms'',
''sink.hive_sync.metastore.uris''=''thrift://bigdata1:9083'',
''sink.hive_sync.db''=''qhc_hudi_ods'',
''sink.hive_sync.table''=''${tableName}'',
''sink.table.prefix.schema''=''true''
);', 'All Versions', 0, 1, '2023-10-31 16:24:47', '2023-10-31 16:24:47');
insert into `dinky_flink_document` values (238, 'Reference', 'Other', 'Batch/Streaming', 'EXECUTE JAR ', 'EXECUTE JAR use sql', 'EXECUTE JAR WITH (
''uri''=''file:///opt/flink/lib/paimon-flink-1.16-0.5-20230818.001833-127.jar'',
''main-class''=''org.apache.paimon.flink.action.FlinkActions'',
''args''=''mysql-sync-table --warehouse hdfs:///save --database cdc-test --table cdc_test1 --primary-keys id --mysql-conf hostname=121.5.136.161 --mysql-conf port=3371 --mysql-conf username=root --mysql-conf password=dinky --mysql-conf database-name=cdc-test --mysql-conf table-name=table_1 --mysql-conf server-time-zone=Asia/Shanghai --table-conf bucket=4 --table-conf changelog-producer=input --table-conf sink.parallelism=1'',
''parallelism''='''',
''savepoint-path''=''''
);', 'All Versions', 0, 1, '2023-10-31 16:27:53', '2023-10-31 16:27:53');
insert into `dinky_flink_document` values (239, 'Reference', '内置函数', 'Streaming', 'PRINT tablename', 'PRINT table data', 'PRINT ${1:}', 'All Versions', 0, 1, '2023-10-31 16:30:22', '2023-10-31 16:30:22');
insert into `dinky_flink_document` values (240, 'Reference', '建表语句', 'Batch/Streaming', 'CREATE TABLE Like', 'CREATE TABLE Like source table', 'DROP TABLE IF EXISTS sink_table;
CREATE TABLE IF not EXISTS sink_table
WITH (
''topic'' = ''motor_vehicle_error''
)
LIKE source_table;', 'All Versions', 0, 1, '2023-10-31 16:33:38', '2023-10-31 16:33:38');
insert into `dinky_flink_document` values (241, 'Reference', '建表语句', 'Batch/Streaming', 'CREATE TABLE like source_table EXCLUDING', 'CREATE TABLE like source_table EXCLUDING', 'DROP TABLE IF EXISTS sink_table;
CREATE TABLE IF not EXISTS sink_table(
-- Add watermark definition
WATERMARK FOR order_time AS order_time - INTERVAL ''5'' SECOND
)
WITH (
''topic'' = ''motor_vehicle_error''
)
LIKE source_table (
-- Exclude everything besides the computed columns which we need to generate the watermark for.
-- We do not want to have the partitions or filesystem options as those do not apply to kafka.
EXCLUDING ALL
INCLUDING GENERATED
);', 'All Versions', 0, 1, '2023-10-31 16:36:13', '2023-10-31 16:36:13');
insert into `dinky_flink_document` values (242, 'Reference', '建表语句', 'Batch/Streaming', 'CREATE TABLE ctas_kafka', 'CREATE TABLE ctas_kafka', 'CREATE TABLE my_ctas_table
WITH (
''connector'' = ''kafka''
)
AS SELECT id, name, age FROM source_table WHERE mod(id, 10) = 0;', 'All Versions', 0, 1, '2023-10-31 16:37:33', '2023-10-31 16:47:17');
insert into `dinky_flink_document` values (243, 'Reference', '建表语句', 'Batch/Streaming', 'CREATE TABLE rtas_kafka', 'CREATE TABLE rtas_kafka', 'CREATE OR REPLACE TABLE my_ctas_table
WITH (
''connector'' = ''kafka''
)
AS SELECT id, name, age FROM source_table WHERE mod(id, 10) = 0;', 'All Versions', 0, 1, '2023-10-31 16:41:46', '2023-10-31 16:43:29');
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