修复几个问题
@@ -1,5 +1,10 @@
|
|||||||
# 异构数据库数据与结构同步工具
|
# 异构数据库数据与结构同步工具
|
||||||
|
|
||||||
|

|
||||||
|

|
||||||
|
|
||||||
|

|
||||||
|
|
||||||
## 一、工具介绍
|
## 一、工具介绍
|
||||||
|
|
||||||
### 1、功能描述
|
### 1、功能描述
|
||||||
|
@@ -28,7 +28,7 @@ mybatis:
|
|||||||
lazy-loading-enabled: true
|
lazy-loading-enabled: true
|
||||||
aggressive-lazy-loading: false
|
aggressive-lazy-loading: false
|
||||||
map-underscore-to-camel-case: true
|
map-underscore-to-camel-case: true
|
||||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
|
|
||||||
dbswitch:
|
dbswitch:
|
||||||
configuration:
|
configuration:
|
||||||
|
@@ -30,6 +30,7 @@ import java.sql.Timestamp;
|
|||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.locks.ReentrantLock;
|
import java.util.concurrent.locks.ReentrantLock;
|
||||||
|
import lombok.Getter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.core.task.AsyncTaskExecutor;
|
import org.springframework.core.task.AsyncTaskExecutor;
|
||||||
|
|
||||||
@@ -55,7 +56,7 @@ public class ExecuteJobTaskRunnable implements Runnable {
|
|||||||
|
|
||||||
private AsyncTaskExecutor migrationTaskExecutor;
|
private AsyncTaskExecutor migrationTaskExecutor;
|
||||||
|
|
||||||
private Long taskId;
|
@Getter private Long taskId;
|
||||||
|
|
||||||
private Integer schedule;
|
private Integer schedule;
|
||||||
|
|
||||||
|
@@ -85,8 +85,12 @@ public class AssignmentService {
|
|||||||
.convert(assignmentTaskDAO.getById(assignment.getId()));
|
.convert(assignmentTaskDAO.getById(assignment.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Transactional(rollbackFor = Exception.class)
|
|
||||||
public void deleteAssignment(Long id) {
|
public void deleteAssignment(Long id) {
|
||||||
|
AssignmentTaskEntity taskEntity = assignmentTaskDAO.getById(id);
|
||||||
|
if (null != taskEntity && null != taskEntity.getPublished() && taskEntity.getPublished()) {
|
||||||
|
throw new DbswitchException(ResultCode.ERROR_RESOURCE_HAS_DEPLOY,
|
||||||
|
"已经发布的任务需先下线后方可执行删除操作");
|
||||||
|
}
|
||||||
assignmentTaskDAO.deleteById(id);
|
assignmentTaskDAO.deleteById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -194,7 +198,9 @@ public class AssignmentService {
|
|||||||
AssignmentTaskEntity assignmentTaskEntity = assignmentTaskDAO.getById(id);
|
AssignmentTaskEntity assignmentTaskEntity = assignmentTaskDAO.getById(id);
|
||||||
if (Objects.nonNull(assignmentTaskEntity.getPublished())
|
if (Objects.nonNull(assignmentTaskEntity.getPublished())
|
||||||
&& assignmentTaskEntity.getPublished()) {
|
&& assignmentTaskEntity.getPublished()) {
|
||||||
scheduleService.cancelByJobKey(assignmentTaskEntity.getJobKey());
|
String jobKey = assignmentTaskEntity.getJobKey();
|
||||||
|
scheduleService.cancelByJobKey(jobKey);
|
||||||
|
scheduleService.cancelManualJob(id);
|
||||||
assignmentTaskEntity.setPublished(Boolean.FALSE);
|
assignmentTaskEntity.setPublished(Boolean.FALSE);
|
||||||
assignmentTaskEntity.setContent("{}");
|
assignmentTaskEntity.setContent("{}");
|
||||||
assignmentTaskEntity.setJobKey("");
|
assignmentTaskEntity.setJobKey("");
|
||||||
|
@@ -18,6 +18,7 @@ import com.gitee.dbswitch.admin.type.JobStatusEnum;
|
|||||||
import com.gitee.dbswitch.admin.type.ScheduleModeEnum;
|
import com.gitee.dbswitch.admin.type.ScheduleModeEnum;
|
||||||
import com.gitee.dbswitch.common.event.TaskEventHub;
|
import com.gitee.dbswitch.common.event.TaskEventHub;
|
||||||
import com.gitee.dbswitch.common.util.UuidUtils;
|
import com.gitee.dbswitch.common.util.UuidUtils;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
@@ -111,13 +112,22 @@ public class ScheduleService {
|
|||||||
AssignmentTaskEntity task = assignmentTaskDAO.getById(taskId);
|
AssignmentTaskEntity task = assignmentTaskDAO.getById(taskId);
|
||||||
if (ScheduleModeEnum.MANUAL == scheduleMode) {
|
if (ScheduleModeEnum.MANUAL == scheduleMode) {
|
||||||
manualRunEvenHub.notify(evenName, taskId, jobKeyName);
|
manualRunEvenHub.notify(evenName, taskId, jobKeyName);
|
||||||
//scheduleOnce(jobBuilder.storeDurably(false).build(), triggerKey);
|
|
||||||
} else {
|
} else {
|
||||||
scheduleCron(jobBuilder.storeDurably(true).build(), triggerKey, task.getCronExpression());
|
scheduleCron(jobBuilder.storeDurably(true).build(), triggerKey, task.getCronExpression());
|
||||||
}
|
|
||||||
|
|
||||||
task.setJobKey(jobKeyName);
|
task.setJobKey(jobKeyName);
|
||||||
assignmentTaskDAO.updateById(task);
|
assignmentTaskDAO.updateById(task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancelManualJob(Long taskId) {
|
||||||
|
Sets.newHashSet(taskRunnableMap.values()).forEach(
|
||||||
|
runnable -> {
|
||||||
|
if (taskId == runnable.getTaskId()) {
|
||||||
|
runnable.interrupt();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cancelByJobKey(String jobKeyName) {
|
public void cancelByJobKey(String jobKeyName) {
|
||||||
@@ -165,24 +175,6 @@ public class ScheduleService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// private void scheduleOnce(JobDetail jobDetail, TriggerKey triggerKey) {
|
|
||||||
// Scheduler scheduler = schedulerFactoryBean.getScheduler();
|
|
||||||
// Trigger simpleTrigger = TriggerBuilder.newTrigger()
|
|
||||||
// .startAt(new Date())
|
|
||||||
// .withIdentity(triggerKey)
|
|
||||||
// .withSchedule(SimpleScheduleBuilder.simpleSchedule().withRepeatCount(0))
|
|
||||||
// .build();
|
|
||||||
//
|
|
||||||
// try {
|
|
||||||
// scheduler.scheduleJob(jobDetail, simpleTrigger);
|
|
||||||
// } catch (SchedulerException e) {
|
|
||||||
// log.error("Quartz schedule task by manual failed, taskId: {}.",
|
|
||||||
// jobDetail.getJobDataMap().get(JobExecutorService.TASK_ID), e);
|
|
||||||
// throw new RuntimeException(e);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
|
|
||||||
private void scheduleCron(JobDetail jobDetail, TriggerKey triggerKey, String cronExpression) {
|
private void scheduleCron(JobDetail jobDetail, TriggerKey triggerKey, String cronExpression) {
|
||||||
Scheduler scheduler = schedulerFactoryBean.getScheduler();
|
Scheduler scheduler = schedulerFactoryBean.getScheduler();
|
||||||
Trigger cronTrigger = TriggerBuilder.newTrigger()
|
Trigger cronTrigger = TriggerBuilder.newTrigger()
|
||||||
|
@@ -28,7 +28,7 @@ mybatis:
|
|||||||
lazy-loading-enabled: true
|
lazy-loading-enabled: true
|
||||||
aggressive-lazy-loading: false
|
aggressive-lazy-loading: false
|
||||||
map-underscore-to-camel-case: true
|
map-underscore-to-camel-case: true
|
||||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
|
|
||||||
dbswitch:
|
dbswitch:
|
||||||
configuration:
|
configuration:
|
||||||
|
@@ -28,7 +28,7 @@ mybatis:
|
|||||||
lazy-loading-enabled: true
|
lazy-loading-enabled: true
|
||||||
aggressive-lazy-loading: false
|
aggressive-lazy-loading: false
|
||||||
map-underscore-to-camel-case: true
|
map-underscore-to-camel-case: true
|
||||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
|
|
||||||
dbswitch:
|
dbswitch:
|
||||||
configuration:
|
configuration:
|
||||||
|
@@ -28,7 +28,7 @@ mybatis:
|
|||||||
lazy-loading-enabled: true
|
lazy-loading-enabled: true
|
||||||
aggressive-lazy-loading: false
|
aggressive-lazy-loading: false
|
||||||
map-underscore-to-camel-case: true
|
map-underscore-to-camel-case: true
|
||||||
log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
#log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
|
||||||
|
|
||||||
dbswitch:
|
dbswitch:
|
||||||
configuration:
|
configuration:
|
||||||
|
@@ -1,5 +1,6 @@
|
|||||||
package com.gitee.dbswitch.common.util;
|
package com.gitee.dbswitch.common.util;
|
||||||
|
|
||||||
|
import cn.hutool.core.codec.Base64;
|
||||||
import cn.hutool.json.JSONUtil;
|
import cn.hutool.json.JSONUtil;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.ObjectOutputStream;
|
import java.io.ObjectOutputStream;
|
||||||
@@ -829,6 +830,8 @@ public final class ObjectCastUtils {
|
|||||||
return in.toString();
|
return in.toString();
|
||||||
} else if (in instanceof java.sql.Clob) {
|
} else if (in instanceof java.sql.Clob) {
|
||||||
return clob2Str((java.sql.Clob) in);
|
return clob2Str((java.sql.Clob) in);
|
||||||
|
} else if (in instanceof java.sql.Blob) {
|
||||||
|
return Base64.encode(blob2Bytes((java.sql.Blob) in));
|
||||||
} else if (in instanceof java.lang.Number) {
|
} else if (in instanceof java.lang.Number) {
|
||||||
return in.toString();
|
return in.toString();
|
||||||
} else if (in instanceof java.sql.RowId) {
|
} else if (in instanceof java.sql.RowId) {
|
||||||
|
@@ -100,7 +100,7 @@ public final class GenerateSqlUtils {
|
|||||||
|
|
||||||
sb.append(")");
|
sb.append(")");
|
||||||
if (type.isLikeMysql()) {
|
if (type.isLikeMysql()) {
|
||||||
sb.append("ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin");
|
sb.append("ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin");
|
||||||
if (withRemarks && StringUtils.isNotBlank(tableRemarks)) {
|
if (withRemarks && StringUtils.isNotBlank(tableRemarks)) {
|
||||||
sb.append(String.format(" COMMENT='%s' ", tableRemarks.replace("'", "\\'")));
|
sb.append(String.format(" COMMENT='%s' ", tableRemarks.replace("'", "\\'")));
|
||||||
}
|
}
|
||||||
|
@@ -25,7 +25,7 @@ import org.springframework.context.annotation.PropertySource;
|
|||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@Data
|
@Data
|
||||||
@ConfigurationProperties(prefix = "dbswitch", ignoreUnknownFields = false)
|
@ConfigurationProperties(prefix = "dbswitch")
|
||||||
@PropertySource(
|
@PropertySource(
|
||||||
value = {"classpath:config.properties", "classpath:config.yml", "classpath:config.yaml"},
|
value = {"classpath:config.properties", "classpath:config.yml", "classpath:config.yaml"},
|
||||||
ignoreResourceNotFound = true,
|
ignoreResourceNotFound = true,
|
||||||
|
@@ -29,7 +29,7 @@ public class TargetDataSourceProperties {
|
|||||||
private CaseConvertEnum columnNameCase = CaseConvertEnum.NONE;
|
private CaseConvertEnum columnNameCase = CaseConvertEnum.NONE;
|
||||||
private Boolean targetDrop = Boolean.TRUE;
|
private Boolean targetDrop = Boolean.TRUE;
|
||||||
private Boolean onlyCreate = Boolean.FALSE;
|
private Boolean onlyCreate = Boolean.FALSE;
|
||||||
private Boolean createTableAutoIncrement = Boolean.TRUE;
|
private Boolean createTableAutoIncrement = Boolean.FALSE;
|
||||||
private Boolean writerEngineInsert = Boolean.FALSE;
|
private Boolean writerEngineInsert = Boolean.FALSE;
|
||||||
private Boolean changeDataSync = Boolean.FALSE;
|
private Boolean changeDataSync = Boolean.FALSE;
|
||||||
}
|
}
|
||||||
|
@@ -124,7 +124,7 @@ public class SqliteMetadataQueryProvider extends AbstractMetadataProvider {
|
|||||||
if (null != pks && !pks.isEmpty() && pks.contains(fieldname)) {
|
if (null != pks && !pks.isEmpty() && pks.contains(fieldname)) {
|
||||||
// 关键字 AUTOINCREMENT 只能⽤于整型(INTEGER)字段。
|
// 关键字 AUTOINCREMENT 只能⽤于整型(INTEGER)字段。
|
||||||
if (useAutoInc) {
|
if (useAutoInc) {
|
||||||
retval += "INTEGER PRIMARY KEY AUTOINCREMENT";
|
retval += "INTEGER AUTOINCREMENT";
|
||||||
} else {
|
} else {
|
||||||
retval += "BIGINT ";
|
retval += "BIGINT ";
|
||||||
}
|
}
|
||||||
|
Before Width: | Height: | Size: 75 KiB After Width: | Height: | Size: 98 KiB |
Before Width: | Height: | Size: 19 KiB |
Before Width: | Height: | Size: 23 KiB |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 18 KiB |