Pre Merge pull request !75 from liying-poison/feature/1.1.1-integration-kingbase
This commit is contained in:
commit
bcd78d6b38
6967
doc/sql/snail_job_kingbase8.sql
Normal file
6967
doc/sql/snail_job_kingbase8.sql
Normal file
File diff suppressed because it is too large
Load Diff
5
pom.xml
5
pom.xml
@ -191,6 +191,11 @@
|
||||
<version>${commons-logging.version}</version>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aizuda</groupId>
|
||||
<artifactId>snail-job-kingbase-datasource</artifactId>
|
||||
<version>${revision}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
|
@ -28,6 +28,7 @@
|
||||
<module>snail-job-sqlserver-datasource</module>
|
||||
<module>snail-job-dm8-datasource</module>
|
||||
<module>snail-job-datasource-template</module>
|
||||
<module>snail-job-kingbase-datasource</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
||||
|
@ -49,7 +49,9 @@ public abstract class AbstractConfigAccess<T> implements ConfigAccess<T> {
|
||||
DbTypeEnum.POSTGRES.getDb(),
|
||||
DbTypeEnum.ORACLE.getDb(),
|
||||
DbTypeEnum.SQLSERVER.getDb(),
|
||||
DbTypeEnum.DM.getDb());
|
||||
DbTypeEnum.DM.getDb(),
|
||||
DbTypeEnum.KINGBASE_ES.getDb()
|
||||
);
|
||||
|
||||
protected DbTypeEnum getDbType() {
|
||||
return DbUtils.getDbType();
|
||||
|
@ -23,7 +23,9 @@ public abstract class AbstractTaskAccess<T> implements TaskAccess<T> {
|
||||
DbTypeEnum.POSTGRES.getDb(),
|
||||
DbTypeEnum.ORACLE.getDb(),
|
||||
DbTypeEnum.SQLSERVER.getDb(),
|
||||
DbTypeEnum.DM.getDb());
|
||||
DbTypeEnum.DM.getDb(),
|
||||
DbTypeEnum.KINGBASE_ES.getDb()
|
||||
);
|
||||
|
||||
protected DbTypeEnum getDbType() {
|
||||
return DbUtils.getDbType();
|
||||
|
@ -20,7 +20,8 @@ public enum DbTypeEnum {
|
||||
POSTGRES("postgresql", "Postgres数据库", DbType.POSTGRE_SQL),
|
||||
ORACLE("oracle", "Oracle数据库", DbType.ORACLE_12C),
|
||||
SQLSERVER("sqlserver", "SQLServer数据库", DbType.SQL_SERVER),
|
||||
DM("dm", "达梦数据库", DbType.DM);
|
||||
DM("dm", "达梦数据库", DbType.DM),
|
||||
KINGBASE_ES("kingbase", "人大金仓数据库", DbType.KINGBASE_ES);
|
||||
|
||||
private final String db;
|
||||
private final String desc;
|
||||
|
35
snail-job-datasource/snail-job-kingbase-datasource/.gitignore
vendored
Normal file
35
snail-job-datasource/snail-job-kingbase-datasource/.gitignore
vendored
Normal file
@ -0,0 +1,35 @@
|
||||
HELP.md
|
||||
target/
|
||||
!.mvn/wrapper/maven-wrapper.jar
|
||||
!**/src/main/**/target/
|
||||
!**/src/test/**/target/
|
||||
|
||||
### STS ###
|
||||
.apt_generated
|
||||
.classpath
|
||||
.factorypath
|
||||
.project
|
||||
.settings
|
||||
.springBeans
|
||||
.sts4-cache
|
||||
|
||||
### IntelliJ IDEA ###
|
||||
.idea
|
||||
*.iws
|
||||
*.iml
|
||||
*.ipr
|
||||
|
||||
### NetBeans ###
|
||||
/nbproject/private/
|
||||
/nbbuild/
|
||||
/dist/
|
||||
/nbdist/
|
||||
/.nb-gradle/
|
||||
build/
|
||||
!**/src/main/**/build/
|
||||
!**/src/test/**/build/
|
||||
|
||||
### VS Code ###
|
||||
.vscode/
|
||||
|
||||
.flattened-pom.xml
|
60
snail-job-datasource/snail-job-kingbase-datasource/pom.xml
Normal file
60
snail-job-datasource/snail-job-kingbase-datasource/pom.xml
Normal file
@ -0,0 +1,60 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.aizuda</groupId>
|
||||
<artifactId>snail-job-datasource</artifactId>
|
||||
<version>${revision}</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>snail-job-kingbase-datasource</artifactId>
|
||||
<name>snail-job-kingbase-datasource</name>
|
||||
<description>snail-job-kingbase-datasource</description>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<properties>
|
||||
<java.version>17</java.version>
|
||||
<kingbase.version>8.6.0</kingbase.version>
|
||||
</properties>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aizuda</groupId>
|
||||
<artifactId>snail-job-datasource-template</artifactId>
|
||||
</dependency>
|
||||
<!-- KingBase Connector -->
|
||||
<dependency>
|
||||
<groupId>cn.com.kingbase</groupId>
|
||||
<artifactId>kingbase8</artifactId>
|
||||
<version>${kingbase.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-maven-plugin</artifactId>
|
||||
<configuration>
|
||||
<mainClass>none</mainClass> <!-- 取消查找本项目下的Main方法:为了解决Unable to find main class的问题 -->
|
||||
<classifier>execute</classifier> <!-- 为了解决依赖模块找不到此模块中的类或属性 -->
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<goals>
|
||||
<goal>repackage</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -0,0 +1,25 @@
|
||||
<?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="com.aizuda.snailjob.template.datasource.persistence.mapper.JobLogMessageMapper">
|
||||
|
||||
<!-- 定义批量新增的 SQL 映射 -->
|
||||
<insert id="insertBatch" parameterType="java.util.List">
|
||||
INSERT INTO sj_job_log_message (namespace_id, group_name, job_id, task_batch_id, task_id, log_num,
|
||||
message, create_dt, real_time)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.namespaceId},
|
||||
#{item.groupName},
|
||||
#{item.jobId},
|
||||
#{item.taskBatchId},
|
||||
#{item.taskId},
|
||||
#{item.logNum},
|
||||
#{item.message},
|
||||
#{item.createDt},
|
||||
#{item.realTime}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,18 @@
|
||||
<?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="com.aizuda.snailjob.template.datasource.persistence.mapper.JobMapper">
|
||||
|
||||
<update id="updateBatchNextTriggerAtById" parameterType="java.util.List">
|
||||
UPDATE sj_job AS rt
|
||||
SET next_trigger_at = tt.next_trigger_at
|
||||
FROM (
|
||||
<foreach collection="list" item="item" index="index" separator="UNION ALL">
|
||||
SELECT
|
||||
#{item.id} AS id,
|
||||
#{item.nextTriggerAt} AS next_trigger_at
|
||||
</foreach>
|
||||
) AS tt
|
||||
WHERE rt.id = tt.id
|
||||
</update>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,97 @@
|
||||
<?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="com.aizuda.snailjob.template.datasource.persistence.mapper.JobSummaryMapper">
|
||||
|
||||
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO sj_job_summary (namespace_id, group_name, business_id, trigger_at, system_task_type,
|
||||
success_num,fail_num,fail_reason,stop_num,stop_reason, cancel_num,cancel_reason)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.namespaceId},
|
||||
#{item.groupName},
|
||||
#{item.businessId},
|
||||
#{item.triggerAt},
|
||||
#{item.systemTaskType},
|
||||
#{item.successNum},
|
||||
#{item.failNum},
|
||||
#{item.failReason},
|
||||
#{item.stopNum},
|
||||
#{item.stopReason},
|
||||
#{item.cancelNum},
|
||||
#{item.cancelReason}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="updateBatch" parameterType="java.util.List">
|
||||
UPDATE sj_job_summary AS rt
|
||||
SET success_num = tt.success_num,
|
||||
fail_num = tt.fail_num,
|
||||
fail_reason = tt.fail_reason,
|
||||
stop_num = tt.stop_num,
|
||||
stop_reason = tt.stop_reason,
|
||||
cancel_num = tt.cancel_num,
|
||||
cancel_reason = tt.cancel_reason
|
||||
FROM (
|
||||
<foreach collection="list" item="item" index="index" separator="UNION ALL">
|
||||
SELECT
|
||||
#{item.successNum} AS success_num,
|
||||
#{item.failNum} AS fail_num,
|
||||
#{item.failReason} AS fail_reason,
|
||||
#{item.stopNum} AS stop_num,
|
||||
#{item.stopReason} AS stop_reason,
|
||||
#{item.cancelNum} AS cancel_num,
|
||||
#{item.cancelReason} AS cancel_reason,
|
||||
#{item.systemTaskType} AS system_task_type,
|
||||
#{item.businessId} AS business_id,
|
||||
#{item.triggerAt} AS trigger_at
|
||||
</foreach>
|
||||
) AS tt
|
||||
WHERE rt.system_task_type = tt.system_task_type
|
||||
AND rt.business_id = tt.business_id
|
||||
AND rt.trigger_at = tt.trigger_at
|
||||
</update>
|
||||
|
||||
<select id="selectJobLineList"
|
||||
resultType="com.aizuda.snailjob.template.datasource.persistence.dataobject.DashboardLineResponseDO">
|
||||
SELECT TO_CHAR(trigger_at, #{dateFormat}) AS createDt,
|
||||
COALESCE(SUM(success_num), 0) AS success,
|
||||
COALESCE(SUM(fail_num), 0) AS failNum,
|
||||
COALESCE(SUM(stop_num), 0) AS stop,
|
||||
COALESCE(SUM(cancel_num), 0) AS cancel,
|
||||
COALESCE(SUM(fail_num + stop_num + cancel_num), 0) AS fail,
|
||||
COALESCE(SUM(success_num + fail_num + stop_num + cancel_num), 0) AS total
|
||||
FROM sj_job_summary
|
||||
${ew.customSqlSegment}
|
||||
GROUP BY createDt
|
||||
</select>
|
||||
|
||||
<select id="selectJobTask"
|
||||
resultType="com.aizuda.snailjob.template.datasource.persistence.dataobject.DashboardCardResponseDO$JobTask">
|
||||
SELECT COALESCE(SUM(success_num), 0) AS successNum,
|
||||
COALESCE(SUM(stop_num), 0) AS stopNum,
|
||||
COALESCE(SUM(cancel_num), 0) AS cancelNum,
|
||||
COALESCE(SUM(fail_num), 0) AS failNum,
|
||||
COALESCE(SUM(success_num + fail_num + stop_num + cancel_num), 0) AS totalNum
|
||||
FROM sj_job_summary
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
<select id="selectDashboardRankList"
|
||||
resultType="com.aizuda.snailjob.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO$Rank">
|
||||
SELECT
|
||||
<if test="systemTaskType == 3">
|
||||
CONCAT(group_name, '/', (SELECT job_name FROM sj_job WHERE id = business_id)) AS name,
|
||||
</if>
|
||||
<if test="systemTaskType == 4">
|
||||
CONCAT(group_name, '/', (SELECT workflow_name FROM sj_workflow WHERE id = business_id)) AS name,
|
||||
</if>
|
||||
SUM(fail_num) AS total
|
||||
FROM sj_job_summary
|
||||
${ew.customSqlSegment}
|
||||
HAVING SUM(fail_num) > 0
|
||||
ORDER BY total DESC LIMIT 10
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,21 @@
|
||||
<?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="com.aizuda.snailjob.template.datasource.persistence.mapper.RetryDeadLetterMapper">
|
||||
|
||||
<insert id="insertBatch">
|
||||
INSERT INTO sj_retry_dead_letter (namespace_id, unique_id, group_name, scene_name,
|
||||
idempotent_id, biz_no, executor_name, args_str,
|
||||
ext_attrs, create_dt)
|
||||
VALUES
|
||||
<foreach collection="retryDeadLetters" item="retryDeadLetter" separator=",">
|
||||
(
|
||||
#{retryDeadLetter.namespaceId,jdbcType=VARCHAR}, #{retryDeadLetter.uniqueId,jdbcType=VARCHAR},
|
||||
#{retryDeadLetter.groupName,jdbcType=VARCHAR}, #{retryDeadLetter.sceneName,jdbcType=VARCHAR},
|
||||
#{retryDeadLetter.idempotentId,jdbcType=VARCHAR}, #{retryDeadLetter.bizNo,jdbcType=VARCHAR},
|
||||
#{retryDeadLetter.executorName,jdbcType=VARCHAR}, #{retryDeadLetter.argsStr,jdbcType=VARCHAR},
|
||||
#{retryDeadLetter.extAttrs,jdbcType=VARCHAR}, #{retryDeadLetter.createDt,jdbcType=TIMESTAMP}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,94 @@
|
||||
<?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="com.aizuda.snailjob.template.datasource.persistence.mapper.RetrySummaryMapper">
|
||||
|
||||
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO sj_retry_summary (namespace_id, group_name, scene_name, trigger_at,
|
||||
running_num, finish_num, max_count_num, suspend_num)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.namespaceId},
|
||||
#{item.groupName},
|
||||
#{item.sceneName},
|
||||
#{item.triggerAt},
|
||||
#{item.runningNum},
|
||||
#{item.finishNum},
|
||||
#{item.maxCountNum},
|
||||
#{item.suspendNum}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="updateBatch" parameterType="java.util.List">
|
||||
UPDATE sj_retry_summary AS rt
|
||||
SET running_num = tt.running_num,
|
||||
finish_num = tt.finish_num,
|
||||
max_count_num = tt.max_count_num,
|
||||
suspend_num = tt.suspend_num
|
||||
FROM (
|
||||
<foreach collection="list" item="item" index="index" separator="UNION ALL">
|
||||
SELECT
|
||||
#{item.runningNum} AS running_num,
|
||||
#{item.finishNum} AS finish_num,
|
||||
#{item.maxCountNum} AS max_count_num,
|
||||
#{item.suspendNum} AS suspend_num,
|
||||
#{item.triggerAt} AS trigger_at,
|
||||
#{item.sceneName} AS scene_name,
|
||||
#{item.namespaceId} AS namespace_id,
|
||||
#{item.groupName} AS group_name
|
||||
</foreach>
|
||||
) AS tt
|
||||
WHERE rt.trigger_at = tt.trigger_at
|
||||
AND rt.group_name = tt.group_name
|
||||
AND rt.namespace_id = tt.namespace_id
|
||||
AND rt.scene_name = tt.scene_name
|
||||
</update>
|
||||
|
||||
<select id="selectRetryTask"
|
||||
resultType="com.aizuda.snailjob.template.datasource.persistence.dataobject.DashboardCardResponseDO$RetryTask">
|
||||
SELECT COALESCE(sum(running_num), 0) AS runningNum,
|
||||
COALESCE(sum(finish_num), 0) AS finishNum,
|
||||
COALESCE(sum(max_count_num), 0) AS maxCountNum,
|
||||
COALESCE(sum(suspend_num), 0) AS suspendNum,
|
||||
COALESCE(sum(running_num + finish_num + max_count_num + suspend_num), 0) AS totalNum
|
||||
FROM sj_retry_summary
|
||||
${ew.customSqlSegment}
|
||||
</select>
|
||||
|
||||
<select id="selectRetryTaskBarList"
|
||||
resultType="com.aizuda.snailjob.template.datasource.persistence.dataobject.DashboardCardResponseDO$RetryTask">
|
||||
SELECT trigger_at,
|
||||
running_num,
|
||||
finish_num,
|
||||
max_count_num,
|
||||
suspend_num
|
||||
FROM sj_retry_summary
|
||||
${ew.customSqlSegment}
|
||||
LIMIT 7
|
||||
</select>
|
||||
|
||||
<select id="selectRetryLineList"
|
||||
resultType="com.aizuda.snailjob.template.datasource.persistence.dataobject.DashboardLineResponseDO">
|
||||
SELECT TO_CHAR(create_dt, #{dateFormat}) AS createDt,
|
||||
COALESCE(SUM(finish_num), 0) AS successNum,
|
||||
COALESCE(SUM(running_num), 0) AS runningNum,
|
||||
COALESCE(SUM(max_count_num), 0) AS maxCountNum,
|
||||
COALESCE(SUM(suspend_num), 0) AS suspendNum,
|
||||
COALESCE(SUM(finish_num + running_num + max_count_num + suspend_num), 0) AS total
|
||||
FROM sj_retry_summary
|
||||
${ew.customSqlSegment}
|
||||
GROUP BY createDt
|
||||
</select>
|
||||
|
||||
<select id="selectDashboardRankList"
|
||||
resultType="com.aizuda.snailjob.template.datasource.persistence.dataobject.DashboardRetryLineResponseDO$Rank">
|
||||
SELECT CONCAT(group_name, '/', scene_name) AS name,
|
||||
SUM(running_num + finish_num + max_count_num + suspend_num) AS total
|
||||
FROM sj_retry_summary
|
||||
${ew.customSqlSegment}
|
||||
HAVING SUM(running_num + finish_num + max_count_num + suspend_num) > 0
|
||||
ORDER BY total DESC LIMIT 10
|
||||
</select>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,19 @@
|
||||
<?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="com.aizuda.snailjob.template.datasource.persistence.mapper.RetryTaskLogMapper">
|
||||
|
||||
<!-- 定义批量新增的 SQL 映射 -->
|
||||
<insert id="insertBatch" parameterType="java.util.List">
|
||||
INSERT INTO sj_retry_task_log (unique_id, group_name, scene_name, idempotent_id, biz_no, executor_name,
|
||||
args_str, ext_attrs, task_type, create_dt, namespace_id)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.uniqueId}, #{item.groupName}, #{item.sceneName}, #{item.idempotentId},
|
||||
#{item.bizNo}, #{item.executorName}, #{item.argsStr}, #{item.extAttrs},
|
||||
#{item.taskType}, #{item.createDt}, #{item.namespaceId}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,37 @@
|
||||
<?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="com.aizuda.snailjob.template.datasource.persistence.mapper.RetryTaskLogMessageMapper">
|
||||
|
||||
<insert id="insertBatch" parameterType="java.util.List">
|
||||
INSERT INTO sj_retry_task_log_message (namespace_id, group_name, unique_id, log_num, message,
|
||||
create_dt, real_time)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.namespaceId},
|
||||
#{item.groupName},
|
||||
#{item.uniqueId},
|
||||
#{item.logNum},
|
||||
#{item.message},
|
||||
#{item.createDt},
|
||||
#{item.realTime}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="updateBatch" parameterType="java.util.List">
|
||||
UPDATE sj_retry_task_log_message rt,
|
||||
(
|
||||
<foreach collection="list" item="item" index="index" separator="UNION ALL">
|
||||
SELECT
|
||||
#{item.id} AS id,
|
||||
#{item.message} AS message,
|
||||
#{item.logNum} AS log_num
|
||||
</foreach>
|
||||
) tt
|
||||
SET rt.message = tt.message,
|
||||
rt.log_num = tt.log_num
|
||||
WHERE rt.id = tt.id
|
||||
</update>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,32 @@
|
||||
<?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="com.aizuda.snailjob.template.datasource.persistence.mapper.RetryTaskMapper">
|
||||
|
||||
<!-- 定义批量新增的 SQL 映射 -->
|
||||
<insert id="insertBatch" parameterType="java.util.List">
|
||||
INSERT INTO sj_retry_task (namespace_id, unique_id, group_name, scene_name,
|
||||
idempotent_id, biz_no, executor_name, args_str, ext_attrs,
|
||||
next_trigger_at, task_type, retry_status, create_dt)
|
||||
VALUES
|
||||
<foreach collection="list" item="item" separator=",">
|
||||
(
|
||||
#{item.namespaceId}, #{item.uniqueId}, #{item.groupName},
|
||||
#{item.sceneName}, #{item.idempotentId}, #{item.bizNo}, #{item.executorName}, #{item.argsStr},
|
||||
#{item.extAttrs}, #{item.nextTriggerAt}, #{item.taskType}, #{item.retryStatus}, #{item.createDt}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="updateBatchNextTriggerAtById" parameterType="java.util.List">
|
||||
UPDATE sj_retry_task_${partition} AS rt
|
||||
SET next_trigger_at = tt.next_trigger_at
|
||||
FROM (
|
||||
<foreach collection="list" item="item" index="index" separator="UNION ALL">
|
||||
SELECT
|
||||
#{item.id} AS id,
|
||||
#{item.nextTriggerAt} AS next_trigger_at
|
||||
</foreach>
|
||||
) AS tt
|
||||
WHERE rt.id = tt.id
|
||||
</update>
|
||||
</mapper>
|
@ -0,0 +1,39 @@
|
||||
<?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="com.aizuda.snailjob.template.datasource.persistence.mapper.ServerNodeMapper">
|
||||
|
||||
<insert id="insertBatch" parameterType="java.util.List" useGeneratedKeys="true" keyProperty="id">
|
||||
INSERT INTO sj_server_node (namespace_id, group_name, host_id, host_ip, host_port,
|
||||
expire_at, node_type, ext_attrs, create_dt)
|
||||
VALUES
|
||||
<foreach collection="records" item="item" index="index" separator=",">
|
||||
(
|
||||
#{item.namespaceId,jdbcType=VARCHAR},
|
||||
#{item.groupName,jdbcType=VARCHAR},
|
||||
#{item.hostId,jdbcType=VARCHAR},
|
||||
#{item.hostIp,jdbcType=VARCHAR},
|
||||
#{item.hostPort,jdbcType=INTEGER},
|
||||
#{item.expireAt,jdbcType=TIMESTAMP},
|
||||
#{item.nodeType,jdbcType=TINYINT},
|
||||
#{item.extAttrs,jdbcType=VARCHAR},
|
||||
#{item.createDt,jdbcType=TIMESTAMP}
|
||||
)
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<update id="updateBatchExpireAt" parameterType="java.util.List">
|
||||
UPDATE sj_server_node AS rt
|
||||
SET expire_at = tt.expire_at
|
||||
FROM (
|
||||
<foreach collection="list" item="item" index="index" separator="UNION ALL">
|
||||
SELECT
|
||||
#{item.hostId} AS host_id,
|
||||
#{item.hostIp} AS host_ip,
|
||||
#{item.expireAt} AS expire_at
|
||||
</foreach>
|
||||
) AS tt
|
||||
WHERE rt.host_id = tt.host_id
|
||||
AND rt.host_ip = tt.host_ip
|
||||
</update>
|
||||
|
||||
</mapper>
|
@ -0,0 +1,18 @@
|
||||
<?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="com.aizuda.snailjob.template.datasource.persistence.mapper.WorkflowMapper">
|
||||
|
||||
<update id="updateBatchNextTriggerAtById" parameterType="java.util.List">
|
||||
UPDATE sj_workflow AS rt
|
||||
SET next_trigger_at = tt.next_trigger_at
|
||||
FROM (
|
||||
<foreach collection="list" item="item" index="index" separator="UNION ALL">
|
||||
SELECT
|
||||
#{item.id} AS id,
|
||||
#{item.nextTriggerAt} AS next_trigger_at
|
||||
</foreach>
|
||||
) AS tt
|
||||
WHERE rt.id = tt.id
|
||||
</update>
|
||||
|
||||
</mapper>
|
@ -46,7 +46,10 @@ public class JdbcLockProvider implements LockStorage, Lifecycle {
|
||||
DbTypeEnum.POSTGRES.getDb(),
|
||||
DbTypeEnum.ORACLE.getDb(),
|
||||
DbTypeEnum.SQLSERVER.getDb(),
|
||||
DbTypeEnum.DM.getDb());
|
||||
DbTypeEnum.DM.getDb(),
|
||||
DbTypeEnum.KINGBASE_ES.getDb()
|
||||
);
|
||||
|
||||
|
||||
private final DistributedLockMapper distributedLockMapper;
|
||||
private final PlatformTransactionManager platformTransactionManager;
|
||||
|
@ -9,12 +9,18 @@ spring:
|
||||
profiles:
|
||||
active: dev
|
||||
datasource:
|
||||
#kingbase
|
||||
name: snail_job
|
||||
## mysql
|
||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
url: jdbc:mysql://localhost:3306/snail_job?useSSL=false&characterEncoding=utf8&useUnicode=true
|
||||
username: root
|
||||
password: root
|
||||
driver-class-name: com.kingbase8.Driver
|
||||
url: jdbc:kingbase8://192.168.1.40:54321/snail_job?currentSchema=public&useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
|
||||
username: kingbase
|
||||
password: 123456
|
||||
# name: snail_job
|
||||
# ## mysql
|
||||
# driver-class-name: com.mysql.cj.jdbc.Driver
|
||||
# url: jdbc:mysql://localhost:3306/snail_job?useSSL=false&characterEncoding=utf8&useUnicode=true
|
||||
# username: root
|
||||
# password: root
|
||||
## postgres
|
||||
# driver-class-name: org.postgresql.Driver
|
||||
# url: jdbc:postgresql://localhost:5432/snail_job?useUnicode=true&characterEncoding=utf8&useSSL=true&autoReconnect=true&reWriteBatchedInserts=true
|
||||
|
@ -91,6 +91,10 @@
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-crypto</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.aizuda</groupId>
|
||||
<artifactId>snail-job-kingbase-datasource</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
Loading…
Reference in New Issue
Block a user