feat: 2.4.0

1. 优化客户端注册续约问题
2. 优化客户端配置不提示问题
This commit is contained in:
byteblogs168 2023-11-09 14:23:10 +08:00
parent 6747dcf20f
commit ce6e5febd6
5 changed files with 11 additions and 9 deletions

View File

@ -41,6 +41,11 @@
<groupId>com.aizuda</groupId>
<artifactId>easy-retry-common-server-api</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-configuration-processor</artifactId>
<optional>true</optional>
</dependency>
</dependencies>
</project>

View File

@ -29,7 +29,7 @@ public class ThreadPoolCache {
};
ThreadPoolExecutor threadPoolExecutor = supplier.get();
CACHE_THREAD_POOL.putIfAbsent(taskBatchId, supplier.get());
CACHE_THREAD_POOL.putIfAbsent(taskBatchId, threadPoolExecutor);
return threadPoolExecutor;
}

View File

@ -35,6 +35,7 @@ public abstract class AbstractRegister implements Register, Lifecycle {
protected void refreshExpireAt(ServerNode serverNode) {
try {
serverNode.setExpireAt(getExpireAt());
serverNodeMapper.insertOrUpdate(serverNode);
// 刷新本地缓存过期时间
CacheRegisterTable.refreshExpireAt(serverNode.getGroupName(), serverNode);
@ -56,13 +57,12 @@ public abstract class AbstractRegister implements Register, Lifecycle {
serverNode.setNodeType(getNodeType());
serverNode.setCreateDt(LocalDateTime.now());
serverNode.setContextPath(context.getContextPath());
serverNode.setExpireAt(getExpireAt(context));
serverNode.setExtAttrs(context.getExtAttrs());
return serverNode;
}
protected abstract LocalDateTime getExpireAt(RegisterContext context);
protected abstract LocalDateTime getExpireAt();
protected abstract boolean doRegister(RegisterContext context, ServerNode serverNode);

View File

@ -41,11 +41,10 @@ public class ClientRegister extends AbstractRegister implements Runnable {
@Override
protected void beforeProcessor(RegisterContext context) {
}
@Override
protected LocalDateTime getExpireAt(RegisterContext context) {
protected LocalDateTime getExpireAt() {
return LocalDateTime.now().plusSeconds(DELAY_TIME);
}
@ -93,14 +92,12 @@ public class ClientRegister extends AbstractRegister implements Runnable {
}
}
}catch (InterruptedException e) {
LogUtils.info(log, "[{}] thread stop.", Thread.currentThread().getName());
} catch (Exception e) {
LogUtils.error(log, "client refresh expireAt error.");
} finally {
// 防止刷的过快
try {
TimeUnit.MILLISECONDS.sleep(1000);
TimeUnit.MILLISECONDS.sleep(5000);
} catch (InterruptedException ignored) {
}
}

View File

@ -70,7 +70,7 @@ public class ServerRegister extends AbstractRegister {
}
@Override
protected LocalDateTime getExpireAt(RegisterContext context) {
protected LocalDateTime getExpireAt() {
return LocalDateTime.now().plusSeconds(DELAY_TIME);
}