feat: 2.4.0
1. 优化客户端注册续约问题 2. 优化客户端配置不提示问题
This commit is contained in:
parent
0d5ae2fbc7
commit
ee7634b2b4
@ -41,6 +41,11 @@
|
|||||||
<groupId>com.aizuda</groupId>
|
<groupId>com.aizuda</groupId>
|
||||||
<artifactId>easy-retry-common-server-api</artifactId>
|
<artifactId>easy-retry-common-server-api</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||||
|
<optional>true</optional>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -29,7 +29,7 @@ public class ThreadPoolCache {
|
|||||||
};
|
};
|
||||||
|
|
||||||
ThreadPoolExecutor threadPoolExecutor = supplier.get();
|
ThreadPoolExecutor threadPoolExecutor = supplier.get();
|
||||||
CACHE_THREAD_POOL.putIfAbsent(taskBatchId, supplier.get());
|
CACHE_THREAD_POOL.putIfAbsent(taskBatchId, threadPoolExecutor);
|
||||||
return threadPoolExecutor;
|
return threadPoolExecutor;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ public abstract class AbstractRegister implements Register, Lifecycle {
|
|||||||
protected void refreshExpireAt(ServerNode serverNode) {
|
protected void refreshExpireAt(ServerNode serverNode) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
serverNode.setExpireAt(getExpireAt());
|
||||||
serverNodeMapper.insertOrUpdate(serverNode);
|
serverNodeMapper.insertOrUpdate(serverNode);
|
||||||
// 刷新本地缓存过期时间
|
// 刷新本地缓存过期时间
|
||||||
CacheRegisterTable.refreshExpireAt(serverNode.getGroupName(), serverNode);
|
CacheRegisterTable.refreshExpireAt(serverNode.getGroupName(), serverNode);
|
||||||
@ -56,13 +57,12 @@ public abstract class AbstractRegister implements Register, Lifecycle {
|
|||||||
serverNode.setNodeType(getNodeType());
|
serverNode.setNodeType(getNodeType());
|
||||||
serverNode.setCreateDt(LocalDateTime.now());
|
serverNode.setCreateDt(LocalDateTime.now());
|
||||||
serverNode.setContextPath(context.getContextPath());
|
serverNode.setContextPath(context.getContextPath());
|
||||||
serverNode.setExpireAt(getExpireAt(context));
|
|
||||||
serverNode.setExtAttrs(context.getExtAttrs());
|
serverNode.setExtAttrs(context.getExtAttrs());
|
||||||
|
|
||||||
return serverNode;
|
return serverNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract LocalDateTime getExpireAt(RegisterContext context);
|
protected abstract LocalDateTime getExpireAt();
|
||||||
|
|
||||||
|
|
||||||
protected abstract boolean doRegister(RegisterContext context, ServerNode serverNode);
|
protected abstract boolean doRegister(RegisterContext context, ServerNode serverNode);
|
||||||
|
@ -41,11 +41,10 @@ public class ClientRegister extends AbstractRegister implements Runnable {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void beforeProcessor(RegisterContext context) {
|
protected void beforeProcessor(RegisterContext context) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected LocalDateTime getExpireAt(RegisterContext context) {
|
protected LocalDateTime getExpireAt() {
|
||||||
return LocalDateTime.now().plusSeconds(DELAY_TIME);
|
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) {
|
} catch (Exception e) {
|
||||||
LogUtils.error(log, "client refresh expireAt error.");
|
LogUtils.error(log, "client refresh expireAt error.");
|
||||||
} finally {
|
} finally {
|
||||||
// 防止刷的过快
|
// 防止刷的过快
|
||||||
try {
|
try {
|
||||||
TimeUnit.MILLISECONDS.sleep(1000);
|
TimeUnit.MILLISECONDS.sleep(5000);
|
||||||
} catch (InterruptedException ignored) {
|
} catch (InterruptedException ignored) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -70,7 +70,7 @@ public class ServerRegister extends AbstractRegister {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected LocalDateTime getExpireAt(RegisterContext context) {
|
protected LocalDateTime getExpireAt() {
|
||||||
return LocalDateTime.now().plusSeconds(DELAY_TIME);
|
return LocalDateTime.now().plusSeconds(DELAY_TIME);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user