!58 update 优化 自动判断数据库类型

* fix 修复 自动装配无法获取spring上下问题问题
* remove 删除无用导包和bean注入
* update 优化 自动判断数据库类型
This commit is contained in:
疯狂的狮子Li 2024-03-27 07:19:48 +00:00 committed by byteblogs168
parent 473e1de682
commit a0d0c91a78
46 changed files with 75 additions and 123 deletions

View File

@ -2,6 +2,9 @@ package com.aizuda.easy.retry.common.core.context;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.factory.ListableBeanFactory;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware; import org.springframework.context.ApplicationContextAware;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
@ -15,23 +18,42 @@ import org.springframework.stereotype.Component;
@Component @Component
@Order(Ordered.HIGHEST_PRECEDENCE) @Order(Ordered.HIGHEST_PRECEDENCE)
@Slf4j @Slf4j
public class SpringContext implements ApplicationContextAware { public class SpringContext implements BeanFactoryPostProcessor, ApplicationContextAware {
public static ApplicationContext CONTEXT; private static ConfigurableListableBeanFactory FACTORY;
private static ApplicationContext CONTEXT;
@Override @Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) {
SpringContext.FACTORY = beanFactory;
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) {
SpringContext.CONTEXT = applicationContext; SpringContext.CONTEXT = applicationContext;
} }
public static ListableBeanFactory getBeanFactory() {
final ListableBeanFactory factory = null == FACTORY ? CONTEXT : FACTORY;
if (null == factory) {
throw new RuntimeException("No ConfigurableListableBeanFactory or ApplicationContext injected, maybe not in the Spring environment?");
}
return factory;
}
public static ApplicationContext getContext() {
return CONTEXT;
}
public static <T> T getBeanByType(Class<T> clazz) { public static <T> T getBeanByType(Class<T> clazz) {
return CONTEXT.getBean(clazz); return getBeanFactory().getBean(clazz);
} }
public static synchronized <T> T getBean(String name) { public static synchronized <T> T getBean(String name) {
try { try {
return (T) CONTEXT.getBean(name); return (T) getBeanFactory().getBean(name);
} catch (BeansException | NullPointerException exception) { } catch (BeansException | NullPointerException exception) {
log.error(" BeanName:{} not existException => {}", name, exception.getMessage()); log.error(" BeanName:{} not existException => {}", name, exception.getMessage());
return null; return null;
@ -40,7 +62,7 @@ public class SpringContext implements ApplicationContextAware {
public static synchronized <T> T getBean(Class<T> requiredType) { public static synchronized <T> T getBean(Class<T> requiredType) {
try { try {
return CONTEXT.getBean(requiredType); return getBeanFactory().getBean(requiredType);
} catch (BeansException | NullPointerException exception) { } catch (BeansException | NullPointerException exception) {
log.error(" BeanName:{} not existException => {}", requiredType.getName(), exception.getMessage()); log.error(" BeanName:{} not existException => {}", requiredType.getName(), exception.getMessage());
return null; return null;
@ -49,7 +71,7 @@ public class SpringContext implements ApplicationContextAware {
public static synchronized <T> T getBean(String name, Class<T> requiredType) { public static synchronized <T> T getBean(String name, Class<T> requiredType) {
try { try {
return CONTEXT.getBean(name, requiredType); return getBeanFactory().getBean(name, requiredType);
} catch (BeansException | NullPointerException exception) { } catch (BeansException | NullPointerException exception) {
log.error(" BeanName:{} not existException => {}", name, exception.getMessage()); log.error(" BeanName:{} not existException => {}", name, exception.getMessage());
return null; return null;

View File

@ -69,7 +69,7 @@ public class LogUtils {
private static Boolean getLogStatus() { private static Boolean getLogStatus() {
try { try {
Environment environment = SpringContext.CONTEXT.getBean(Environment.class); Environment environment = SpringContext.getBean(Environment.class);
return environment.getProperty("easy-retry.log.status", Boolean.class, Boolean.TRUE); return environment.getProperty("easy-retry.log.status", Boolean.class, Boolean.TRUE);
} catch (Exception ignored) { } catch (Exception ignored) {
} }

View File

@ -12,6 +12,7 @@ import com.aizuda.easy.retry.template.datasource.persistence.mapper.SceneConfigM
import com.aizuda.easy.retry.template.datasource.persistence.po.GroupConfig; import com.aizuda.easy.retry.template.datasource.persistence.po.GroupConfig;
import com.aizuda.easy.retry.template.datasource.persistence.po.NotifyConfig; import com.aizuda.easy.retry.template.datasource.persistence.po.NotifyConfig;
import com.aizuda.easy.retry.template.datasource.persistence.po.SceneConfig; import com.aizuda.easy.retry.template.datasource.persistence.po.SceneConfig;
import com.aizuda.easy.retry.template.datasource.utils.DbUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
@ -34,8 +35,6 @@ public abstract class AbstractConfigAccess<T> implements ConfigAccess<T> {
protected SceneConfigMapper sceneConfigMapper; protected SceneConfigMapper sceneConfigMapper;
@Autowired @Autowired
protected GroupConfigMapper groupConfigMapper; protected GroupConfigMapper groupConfigMapper;
@Autowired
protected Environment environment;
protected static final List<String> ALLOW_DB = Arrays.asList( protected static final List<String> ALLOW_DB = Arrays.asList(
DbTypeEnum.MYSQL.getDb(), DbTypeEnum.MYSQL.getDb(),
@ -45,8 +44,7 @@ public abstract class AbstractConfigAccess<T> implements ConfigAccess<T> {
DbTypeEnum.SQLSERVER.getDb()); DbTypeEnum.SQLSERVER.getDb());
protected DbTypeEnum getDbType() { protected DbTypeEnum getDbType() {
String dbType = environment.getProperty("easy-retry.db-type"); return DbUtils.getDbType();
return DbTypeEnum.modeOf(dbType);
} }
protected List<NotifyConfig> getByGroupIdAndNotifyScene(String groupName, Integer notifyScene, String namespaceId) { protected List<NotifyConfig> getByGroupIdAndNotifyScene(String groupName, Integer notifyScene, String namespaceId) {

View File

@ -2,6 +2,7 @@ package com.aizuda.easy.retry.template.datasource.access.task;
import com.aizuda.easy.retry.template.datasource.access.TaskAccess; import com.aizuda.easy.retry.template.datasource.access.TaskAccess;
import com.aizuda.easy.retry.template.datasource.enums.DbTypeEnum; import com.aizuda.easy.retry.template.datasource.enums.DbTypeEnum;
import com.aizuda.easy.retry.template.datasource.utils.DbUtils;
import com.aizuda.easy.retry.template.datasource.utils.RequestDataHelper; import com.aizuda.easy.retry.template.datasource.utils.RequestDataHelper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
@ -18,9 +19,6 @@ import java.util.List;
*/ */
public abstract class AbstractTaskAccess<T> implements TaskAccess<T> { public abstract class AbstractTaskAccess<T> implements TaskAccess<T> {
@Autowired
protected Environment environment;
protected static final List<String> ALLOW_DB = Arrays.asList( protected static final List<String> ALLOW_DB = Arrays.asList(
DbTypeEnum.MYSQL.getDb(), DbTypeEnum.MYSQL.getDb(),
DbTypeEnum.MARIADB.getDb(), DbTypeEnum.MARIADB.getDb(),
@ -29,8 +27,7 @@ public abstract class AbstractTaskAccess<T> implements TaskAccess<T> {
DbTypeEnum.SQLSERVER.getDb()); DbTypeEnum.SQLSERVER.getDb());
protected DbTypeEnum getDbType() { protected DbTypeEnum getDbType() {
String dbType = environment.getProperty("easy-retry.db-type"); return DbUtils.getDbType();
return DbTypeEnum.modeOf(dbType);
} }
/** /**

View File

@ -2,6 +2,7 @@ package com.aizuda.easy.retry.template.datasource.config;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.aizuda.easy.retry.template.datasource.enums.DbTypeEnum; import com.aizuda.easy.retry.template.datasource.enums.DbTypeEnum;
import com.aizuda.easy.retry.template.datasource.utils.DbUtils;
import com.aizuda.easy.retry.template.datasource.utils.RequestDataHelper; import com.aizuda.easy.retry.template.datasource.utils.RequestDataHelper;
import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties; import com.baomidou.mybatisplus.autoconfigure.MybatisPlusProperties;
import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor; import com.baomidou.mybatisplus.extension.plugins.MybatisPlusInterceptor;
@ -36,8 +37,7 @@ public class EasyRetryTemplateAutoConfiguration {
public SqlSessionFactory sqlSessionFactory(DataSource dataSource, Environment environment, MybatisPlusInterceptor mybatisPlusInterceptor, MybatisPlusProperties mybatisPlusProperties) throws Exception { public SqlSessionFactory sqlSessionFactory(DataSource dataSource, Environment environment, MybatisPlusInterceptor mybatisPlusInterceptor, MybatisPlusProperties mybatisPlusProperties) throws Exception {
MybatisSqlSessionFactoryBean factoryBean = new MybatisSqlSessionFactoryBean(); MybatisSqlSessionFactoryBean factoryBean = new MybatisSqlSessionFactoryBean();
factoryBean.setDataSource(dataSource); factoryBean.setDataSource(dataSource);
String dbType = environment.getProperty("easy-retry.db-type"); DbTypeEnum dbTypeEnum = DbUtils.getDbType();
DbTypeEnum dbTypeEnum = DbTypeEnum.modeOf(dbType);
factoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(MessageFormat.format("classpath*:/{0}/mapper/*.xml", dbTypeEnum.getDb()))); factoryBean.setMapperLocations(new PathMatchingResourcePatternResolver().getResources(MessageFormat.format("classpath*:/{0}/mapper/*.xml", dbTypeEnum.getDb())));
factoryBean.setPlugins(mybatisPlusInterceptor); factoryBean.setPlugins(mybatisPlusInterceptor);
factoryBean.setTypeAliasesPackage(mybatisPlusProperties.getTypeAliasesPackage()); factoryBean.setTypeAliasesPackage(mybatisPlusProperties.getTypeAliasesPackage());
@ -58,8 +58,7 @@ public class EasyRetryTemplateAutoConfiguration {
MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor(); MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
String tablePrefix = Optional.ofNullable(environment.getProperty("mybatis-plus.global-config.db-config.table-prefix")).orElse(StrUtil.EMPTY); String tablePrefix = Optional.ofNullable(environment.getProperty("mybatis-plus.global-config.db-config.table-prefix")).orElse(StrUtil.EMPTY);
interceptor.addInnerInterceptor(dynamicTableNameInnerInterceptor(tablePrefix)); interceptor.addInnerInterceptor(dynamicTableNameInnerInterceptor(tablePrefix));
String dbType = environment.getProperty("easy-retry.db-type"); DbTypeEnum dbTypeEnum = DbUtils.getDbType();
DbTypeEnum dbTypeEnum = DbTypeEnum.modeOf(dbType);
interceptor.addInnerInterceptor(new PaginationInnerInterceptor(dbTypeEnum.getMpDbType())); interceptor.addInnerInterceptor(new PaginationInnerInterceptor(dbTypeEnum.getMpDbType()));
return interceptor; return interceptor;

View File

@ -19,7 +19,7 @@ import java.util.Objects;
public enum DbTypeEnum { public enum DbTypeEnum {
MYSQL("mysql", "MySql数据库", DbType.MYSQL), MYSQL("mysql", "MySql数据库", DbType.MYSQL),
MARIADB("mariadb", "MariaDB数据库", DbType.MARIADB), MARIADB("mariadb", "MariaDB数据库", DbType.MARIADB),
POSTGRES("postgres", "Postgres数据库", DbType.POSTGRE_SQL), POSTGRES("postgresql", "Postgres数据库", DbType.POSTGRE_SQL),
ORACLE("oracle", "Oracle数据库", DbType.ORACLE_12C), ORACLE("oracle", "Oracle数据库", DbType.ORACLE_12C),
SQLSERVER("sqlserver", "SQLServer数据库", DbType.SQL_SERVER); SQLSERVER("sqlserver", "SQLServer数据库", DbType.SQL_SERVER);
@ -29,7 +29,7 @@ public enum DbTypeEnum {
public static DbTypeEnum modeOf(String db) { public static DbTypeEnum modeOf(String db) {
for (DbTypeEnum value : DbTypeEnum.values()) { for (DbTypeEnum value : DbTypeEnum.values()) {
if (Objects.equals(value.getDb(), db)) { if (db.contains(value.getDb())) {
return value; return value;
} }
} }

View File

@ -0,0 +1,21 @@
package com.aizuda.easy.retry.template.datasource.utils;
import com.aizuda.easy.retry.common.core.context.SpringContext;
import com.aizuda.easy.retry.template.datasource.enums.DbTypeEnum;
import org.springframework.core.env.Environment;
/**
* 数据库工具
*
* @author: 疯狂的狮子Li
* @date : 2024-03-27 14:17
*/
public class DbUtils {
public static DbTypeEnum getDbType() {
Environment environment = SpringContext.getBean(Environment.class);
String url = environment.getProperty("spring.datasource.url");
return DbTypeEnum.modeOf(url);
}
}

View File

@ -1,16 +0,0 @@
package com.aizuda.easy.retry.mariadb.datasource.config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
/**
* @author: www.byteblogs.com
* @date : 2023-08-04 12:37
*/
@Configuration
@ComponentScan("com.aizuda.easy.retry.mariadb.datasource.*")
@ConditionalOnProperty(prefix = "easy-retry", name = "db-type", havingValue = "mariadb")
public class EasyRetryMariadbAutoConfiguration {
}

View File

@ -1 +0,0 @@
com.aizuda.easy.retry.mariadb.datasource.config.EasyRetryMariadbAutoConfiguration

View File

@ -1,16 +0,0 @@
package com.aizuda.easy.retry.mysql.datasource.config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
/**
* @author: www.byteblogs.com
* @date : 2023-08-04 12:37
*/
@Configuration
@ComponentScan("com.aizuda.easy.retry.mysql.datasource")
@ConditionalOnProperty(prefix = "easy-retry", name = "db-type", havingValue = "mysql")
public class EasyRetryMysqlAutoConfiguration {
}

View File

@ -1 +0,0 @@
com.aizuda.easy.retry.mysql.datasource.config.EasyRetryMysqlAutoConfiguration

View File

@ -1,16 +0,0 @@
package com.aizuda.easy.retry.oracle.datasource.config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
/**
* @author: www.byteblogs.com
* @date : 2023-08-04 12:37
*/
@Configuration
@ComponentScan("com.aizuda.easy.retry.oracle.datasource.*")
@ConditionalOnProperty(prefix = "easy-retry", name = "db-type", havingValue = "oracle")
public class EasyRetryOracleAutoConfiguration {
}

View File

@ -1 +0,0 @@
com.aizuda.easy.retry.oracle.datasource.config.EasyRetryOracleAutoConfiguration

View File

@ -1,17 +0,0 @@
package com.aizuda.easy.retry.postgres.datasource.config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
/**
* @author: www.byteblogs.com
* @date : 2023-08-04 12:37
*/
@Configuration
@ComponentScan("com.aizuda.easy.retry.postgres.datasource.*")
@ConditionalOnProperty(prefix = "easy-retry", name = "db-type", havingValue = "postgres")
public class EasyRetryPostgresAutoConfiguration {
}

View File

@ -1 +0,0 @@
com.aizuda.easy.retry.postgres.datasource.config.EasyRetryPostgresAutoConfiguration

View File

@ -1,16 +0,0 @@
package com.aizuda.easy.retry.sqlserver.datasource.config;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
/**
* @author: www.byteblogs.com
* @date : 2024-03-19 22:05
*/
@Configuration
@ComponentScan("com.aizuda.easy.retry.sqlserver.datasource.*")
@ConditionalOnProperty(prefix = "easy-retry", name = "db-type", havingValue = "sqlserver")
public class EasyRetrySqlServerAutoConfiguration {
}

View File

@ -1 +0,0 @@
com.aizuda.easy.retry.sqlserver.datasource.config.EasyRetrySqlServerAutoConfiguration

View File

@ -133,7 +133,7 @@ public class RpcClientInvokeHandler implements InvocationHandler {
Assert.notNull(parasResult.body, () -> new EasyRetryServerException("body cannot be null")); Assert.notNull(parasResult.body, () -> new EasyRetryServerException("body cannot be null"));
} }
RestTemplate restTemplate = SpringContext.CONTEXT.getBean(RestTemplate.class); RestTemplate restTemplate = SpringContext.getBean(RestTemplate.class);
Retryer<Result> retryer = buildResultRetryer(); Retryer<Result> retryer = buildResultRetryer();
@ -169,7 +169,7 @@ public class RpcClientInvokeHandler implements InvocationHandler {
// 进行路由剔除处理 // 进行路由剔除处理
CacheRegisterTable.remove(groupName, namespaceId, hostId); CacheRegisterTable.remove(groupName, namespaceId, hostId);
// 重新选一个可用的客户端节点 // 重新选一个可用的客户端节点
ClientNodeAllocateHandler clientNodeAllocateHandler = SpringContext.CONTEXT.getBean( ClientNodeAllocateHandler clientNodeAllocateHandler = SpringContext.getBean(
ClientNodeAllocateHandler.class); ClientNodeAllocateHandler.class);
RegisterNodeInfo serverNode = clientNodeAllocateHandler.getServerNode(allocKey, groupName, namespaceId, RegisterNodeInfo serverNode = clientNodeAllocateHandler.getServerNode(allocKey, groupName, namespaceId,
routeKey); routeKey);

View File

@ -75,7 +75,10 @@ public class SystemProperties {
/** /**
* 数据库类型 * 数据库类型
*
* @deprecated 废弃 新版本通过数据源url自动判断
*/ */
@Deprecated
private DbTypeEnum dbType = DbTypeEnum.MYSQL; private DbTypeEnum dbType = DbTypeEnum.MYSQL;
/** /**

View File

@ -1,9 +1,8 @@
package com.aizuda.easy.retry.server.common.lock.persistence; package com.aizuda.easy.retry.server.common.lock.persistence;
import com.aizuda.easy.retry.common.core.context.SpringContext;
import com.aizuda.easy.retry.server.common.config.SystemProperties;
import com.aizuda.easy.retry.server.common.exception.EasyRetryServerException; import com.aizuda.easy.retry.server.common.exception.EasyRetryServerException;
import com.aizuda.easy.retry.server.common.lock.LockProvider; import com.aizuda.easy.retry.template.datasource.enums.DbTypeEnum;
import com.aizuda.easy.retry.template.datasource.utils.DbUtils;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import java.util.List; import java.util.List;
@ -22,9 +21,9 @@ public final class LockStorageFactory {
} }
public static LockStorage getLockStorage() { public static LockStorage getLockStorage() {
SystemProperties systemProperties = SpringContext.getBeanByType(SystemProperties.class); DbTypeEnum db = DbUtils.getDbType();
return LOCK_STORAGES.stream() return LOCK_STORAGES.stream()
.filter(lockProvider -> lockProvider.supports(systemProperties.getDbType().getDb())) .filter(lockProvider -> lockProvider.supports(db.getDb()))
.findFirst().orElseThrow(() -> new EasyRetryServerException("未找到合适锁处理器")); .findFirst().orElseThrow(() -> new EasyRetryServerException("未找到合适锁处理器"));
} }

View File

@ -91,7 +91,7 @@ public class JobExecutorActor extends AbstractActor {
} catch (Exception e) { } catch (Exception e) {
EasyRetryLog.LOCAL.error("job executor exception. [{}]", taskExecute, e); EasyRetryLog.LOCAL.error("job executor exception. [{}]", taskExecute, e);
handlerTaskBatch(taskExecute, JobTaskBatchStatusEnum.FAIL.getStatus(), JobOperationReasonEnum.TASK_EXECUTION_ERROR.getReason()); handlerTaskBatch(taskExecute, JobTaskBatchStatusEnum.FAIL.getStatus(), JobOperationReasonEnum.TASK_EXECUTION_ERROR.getReason());
SpringContext.CONTEXT.publishEvent(new JobTaskFailAlarmEvent(taskExecute.getTaskBatchId())); SpringContext.getContext().publishEvent(new JobTaskFailAlarmEvent(taskExecute.getTaskBatchId()));
} finally { } finally {
getContext().stop(getSelf()); getContext().stop(getSelf());
} }

View File

@ -65,7 +65,7 @@ public class JobTaskBatchHandler {
if (failCount > 0) { if (failCount > 0) {
jobTaskBatch.setTaskBatchStatus(JobTaskBatchStatusEnum.FAIL.getStatus()); jobTaskBatch.setTaskBatchStatus(JobTaskBatchStatusEnum.FAIL.getStatus());
SpringContext.CONTEXT.publishEvent(new JobTaskFailAlarmEvent(completeJobBatchDTO.getTaskBatchId())); SpringContext.getContext().publishEvent(new JobTaskFailAlarmEvent(completeJobBatchDTO.getTaskBatchId()));
} else if (stopCount > 0) { } else if (stopCount > 0) {
jobTaskBatch.setTaskBatchStatus(JobTaskBatchStatusEnum.STOP.getStatus()); jobTaskBatch.setTaskBatchStatus(JobTaskBatchStatusEnum.STOP.getStatus());
} else { } else {

View File

@ -104,7 +104,7 @@ public class RequestHandlerActor extends AbstractActor {
} }
UrlBuilder builder = UrlBuilder.ofHttp(uri); UrlBuilder builder = UrlBuilder.ofHttp(uri);
Collection<HttpRequestHandler> httpRequestHandlers = SpringContext.CONTEXT Collection<HttpRequestHandler> httpRequestHandlers = SpringContext.getContext()
.getBeansOfType(HttpRequestHandler.class).values(); .getBeansOfType(HttpRequestHandler.class).values();
for (HttpRequestHandler httpRequestHandler : httpRequestHandlers) { for (HttpRequestHandler httpRequestHandler : httpRequestHandlers) {
if (httpRequestHandler.supports(builder.getPathStr()) && method.name() if (httpRequestHandler.supports(builder.getPathStr()) && method.name()

View File

@ -6,7 +6,6 @@ import com.aizuda.easy.retry.common.core.model.Result;
import com.aizuda.easy.retry.common.core.util.JsonUtil; import com.aizuda.easy.retry.common.core.util.JsonUtil;
import com.aizuda.easy.retry.common.core.util.NetUtil; import com.aizuda.easy.retry.common.core.util.NetUtil;
import com.aizuda.easy.retry.common.log.EasyRetryLog; import com.aizuda.easy.retry.common.log.EasyRetryLog;
import com.aizuda.easy.retry.server.common.config.SystemProperties;
import com.aizuda.easy.retry.server.common.dto.DistributeInstance; import com.aizuda.easy.retry.server.common.dto.DistributeInstance;
import com.aizuda.easy.retry.server.common.dto.ServerNodeExtAttrs; import com.aizuda.easy.retry.server.common.dto.ServerNodeExtAttrs;
import com.aizuda.easy.retry.server.common.enums.DashboardLineEnum; import com.aizuda.easy.retry.server.common.enums.DashboardLineEnum;
@ -34,6 +33,7 @@ import com.aizuda.easy.retry.template.datasource.persistence.mapper.JobSummaryMa
import com.aizuda.easy.retry.template.datasource.persistence.mapper.RetrySummaryMapper; import com.aizuda.easy.retry.template.datasource.persistence.mapper.RetrySummaryMapper;
import com.aizuda.easy.retry.template.datasource.persistence.mapper.ServerNodeMapper; import com.aizuda.easy.retry.template.datasource.persistence.mapper.ServerNodeMapper;
import com.aizuda.easy.retry.template.datasource.persistence.po.ServerNode; import com.aizuda.easy.retry.template.datasource.persistence.po.ServerNode;
import com.aizuda.easy.retry.template.datasource.utils.DbUtils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils; import com.baomidou.mybatisplus.core.toolkit.StringUtils;
@ -65,7 +65,6 @@ public class DashBoardServiceImpl implements DashBoardService {
private static final String DASHBOARD_CONSUMER_BUCKET = "/dashboard/consumer/bucket"; private static final String DASHBOARD_CONSUMER_BUCKET = "/dashboard/consumer/bucket";
private final SystemProperties systemProperties;
private final ServerNodeMapper serverNodeMapper; private final ServerNodeMapper serverNodeMapper;
private final RestTemplate restTemplate; private final RestTemplate restTemplate;
private final JobSummaryMapper jobSummaryMapper; private final JobSummaryMapper jobSummaryMapper;
@ -131,7 +130,7 @@ public class DashBoardServiceImpl implements DashBoardService {
// 重试任务列表 // 重试任务列表
Page<Object> pager = new Page<>(baseQueryVO.getPage(), baseQueryVO.getSize()); Page<Object> pager = new Page<>(baseQueryVO.getPage(), baseQueryVO.getSize());
// 针对SQL Server的分页COUNT, 自定义statement ID // 针对SQL Server的分页COUNT, 自定义statement ID
if (DbTypeEnum.SQLSERVER.equals(systemProperties.getDbType())) { if (DbTypeEnum.SQLSERVER == DbUtils.getDbType()) {
pager.setCountId("sqlServer_jobTaskList_Count"); pager.setCountId("sqlServer_jobTaskList_Count");
} }
IPage<DashboardRetryLineResponseDO.Task> IPage = retrySummaryMapper.retryTaskList(namespaceId, groupNames, pager); IPage<DashboardRetryLineResponseDO.Task> IPage = retrySummaryMapper.retryTaskList(namespaceId, groupNames, pager);
@ -167,7 +166,7 @@ public class DashBoardServiceImpl implements DashBoardService {
// 重试任务列表 // 重试任务列表
Page<Object> pager = new Page<>(baseQueryVO.getPage(), baseQueryVO.getSize()); Page<Object> pager = new Page<>(baseQueryVO.getPage(), baseQueryVO.getSize());
// 针对SQL Server的分页COUNT, 自定义statement ID // 针对SQL Server的分页COUNT, 自定义statement ID
if (DbTypeEnum.SQLSERVER.equals(systemProperties.getDbType())) { if (DbTypeEnum.SQLSERVER == DbUtils.getDbType()) {
pager.setCountId("sqlServer_jobTaskList_Count"); pager.setCountId("sqlServer_jobTaskList_Count");
} }
// 任务类型 // 任务类型