feat: 3.2.0
1. 优化启动类,避免重复加载
This commit is contained in:
parent
dcb2a008d6
commit
8df9755d9f
@ -7,6 +7,7 @@ import com.aizuda.easy.retry.common.core.constant.SystemConstants;
|
||||
import com.aizuda.easy.retry.common.core.context.SpringContext;
|
||||
import com.aizuda.easy.retry.common.core.util.EasyRetryVersion;
|
||||
import com.aizuda.easy.retry.common.log.EasyRetryLog;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.slf4j.helpers.MessageFormatter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.ApplicationArguments;
|
||||
@ -22,19 +23,24 @@ import java.util.List;
|
||||
* @date : 2021-11-19 19:00
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
public class EasyRetryStartListener implements ApplicationRunner {
|
||||
|
||||
@Autowired
|
||||
private List<Lifecycle> lifecycleList;
|
||||
private final List<Lifecycle> lifecycleList;
|
||||
private volatile boolean isStarted = false;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) throws Exception {
|
||||
System.out.println(MessageFormatter.format(SystemConstants.LOGO, EasyRetryVersion.getVersion()).getMessage());
|
||||
if (isStarted) {
|
||||
EasyRetryLog.LOCAL.info("Easy-Retry client already started v{}", EasyRetryVersion.getVersion());
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println(MessageFormatter.format(SystemConstants.LOGO, EasyRetryVersion.getVersion()).getMessage());
|
||||
EasyRetryLog.LOCAL.info("Easy-Retry client is preparing to start... v{}", EasyRetryVersion.getVersion());
|
||||
SpringContext.CONTEXT.publishEvent(new EasyRetryStartingEvent());
|
||||
lifecycleList.forEach(Lifecycle::start);
|
||||
SpringContext.CONTEXT.publishEvent(new EasyRetryStartedEvent());
|
||||
isStarted = true;
|
||||
EasyRetryLog.LOCAL.info("Easy-Retry client started successfully v{}", EasyRetryVersion.getVersion());
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.aizuda.easy.retry.client.common.report;
|
||||
|
||||
import com.aizuda.easy.retry.common.log.dto.LogContentDTO;
|
||||
|
||||
/**
|
||||
* @author xiaowoniu
|
||||
* @date 2024-03-20 22:56:53
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public abstract class AbstractLogReport implements LogReport{
|
||||
@Override
|
||||
public void report(LogContentDTO logContentDTO) {
|
||||
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@ import java.util.Objects;
|
||||
*/
|
||||
@Component
|
||||
@Slf4j
|
||||
public class AsyncReportLog implements Lifecycle, Report {
|
||||
public class AsyncReportLog implements Lifecycle {
|
||||
|
||||
@Autowired
|
||||
private EasyRetryProperties easyRetryProperties;
|
||||
@ -85,14 +85,4 @@ public class AsyncReportLog implements Lifecycle, Report {
|
||||
logTaskDTO.setFieldList(logContentDTO.getFieldList());
|
||||
return logTaskDTO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean supports(boolean async) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean report(String scene, String targetClassName, Object[] args) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,13 @@
|
||||
package com.aizuda.easy.retry.client.common.report;
|
||||
|
||||
import com.aizuda.easy.retry.common.log.dto.LogContentDTO;
|
||||
|
||||
/**
|
||||
* @author xiaowoniu
|
||||
* @date 2024-03-20 22:56:53
|
||||
* @since 3.2.0
|
||||
*/
|
||||
public interface LogReport {
|
||||
|
||||
void report(LogContentDTO logContentDTO);
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package com.aizuda.easy.retry.server.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author xiaowoniu
|
||||
* @date 2024-03-20 23:08:26
|
||||
* @since 3.2.0
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class JobLogTaskDTO extends LogTaskDTO {
|
||||
|
||||
/**
|
||||
* 任务信息id
|
||||
*/
|
||||
private Long jobId;
|
||||
|
||||
/**
|
||||
* 任务实例id
|
||||
*/
|
||||
private Long taskBatchId;
|
||||
|
||||
/**
|
||||
* 调度任务id
|
||||
*/
|
||||
private Long taskId;
|
||||
}
|
@ -16,11 +16,6 @@ import java.util.List;
|
||||
@Data
|
||||
public class LogTaskDTO implements Serializable {
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 命名空间
|
||||
*/
|
||||
@ -34,16 +29,19 @@ public class LogTaskDTO implements Serializable {
|
||||
/**
|
||||
* 任务信息id
|
||||
*/
|
||||
@Deprecated
|
||||
private Long jobId;
|
||||
|
||||
/**
|
||||
* 任务实例id
|
||||
*/
|
||||
@Deprecated
|
||||
private Long taskBatchId;
|
||||
|
||||
/**
|
||||
* 调度任务id
|
||||
*/
|
||||
@Deprecated
|
||||
private Long taskId;
|
||||
|
||||
/**
|
||||
|
@ -0,0 +1,15 @@
|
||||
package com.aizuda.easy.retry.server.model.dto;
|
||||
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author xiaowoniu
|
||||
* @date 2024-03-20 23:08:26
|
||||
* @since 3.2.0
|
||||
*/
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Data
|
||||
public class RetryLogTaskDTO extends LogTaskDTO {
|
||||
|
||||
}
|
@ -27,7 +27,7 @@ public class EasyRetryServerApplication {
|
||||
return args -> {
|
||||
// 最长自旋10秒,保证nettyHttpServer启动完成
|
||||
int waitCount = 0;
|
||||
while (!nettyHttpServer.isStarted() || waitCount > 100) {
|
||||
while (!nettyHttpServer.isStarted() && waitCount < 100) {
|
||||
log.info("--------> easy-retry netty server is staring....");
|
||||
TimeUnit.MILLISECONDS.sleep(100);
|
||||
waitCount++;
|
||||
|
@ -4,6 +4,7 @@ import com.aizuda.easy.retry.common.core.constant.SystemConstants;
|
||||
import com.aizuda.easy.retry.common.log.EasyRetryLog;
|
||||
import com.aizuda.easy.retry.common.core.util.EasyRetryVersion;
|
||||
import com.aizuda.easy.retry.server.common.Lifecycle;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.slf4j.helpers.MessageFormatter;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -20,17 +21,23 @@ import java.util.List;
|
||||
* @date : 2021-11-19 19:00
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@Slf4j
|
||||
public class StartListener implements ApplicationListener<ContextRefreshedEvent> {
|
||||
|
||||
@Autowired
|
||||
private List<Lifecycle> lifecycleList;
|
||||
private final List<Lifecycle> lifecycleList;
|
||||
private volatile boolean isStarted = false;
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ContextRefreshedEvent event) {
|
||||
if (isStarted) {
|
||||
EasyRetryLog.LOCAL.info("Easy-Retry server already started v{}", EasyRetryVersion.getVersion());
|
||||
return;
|
||||
}
|
||||
|
||||
System.out.println(MessageFormatter.format(SystemConstants.LOGO, EasyRetryVersion.getVersion()).getMessage());
|
||||
EasyRetryLog.LOCAL.info("easy-retry-server v{} starting...", EasyRetryVersion.getVersion());
|
||||
EasyRetryLog.LOCAL.info("Easy-Retry server is preparing to start... v{}", EasyRetryVersion.getVersion());
|
||||
lifecycleList.forEach(Lifecycle::start);
|
||||
EasyRetryLog.LOCAL.info("easy-retry-server v{} start completed", EasyRetryVersion.getVersion());
|
||||
EasyRetryLog.LOCAL.info("Easy-Retry server started successfully v{}", EasyRetryVersion.getVersion());
|
||||
isStarted = true;
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,11 @@ public class NettyHttpServer implements Runnable, Lifecycle {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
// 防止重复启动
|
||||
if (started) {
|
||||
return;
|
||||
}
|
||||
|
||||
EventLoopGroup bossGroup = new NioEventLoopGroup();
|
||||
EventLoopGroup workerGroup = new NioEventLoopGroup();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user