feat(sj_1.0.0): 优化同步配置逻辑
This commit is contained in:
parent
0005ce430d
commit
2a18fbc944
@ -4,8 +4,6 @@ import com.aizuda.snailjob.client.common.annotation.Mapping;
|
||||
import com.aizuda.snailjob.client.common.rpc.client.RequestMethod;
|
||||
import com.aizuda.snailjob.common.core.constant.SystemConstants.HTTP_PATH;
|
||||
import com.aizuda.snailjob.common.core.model.Result;
|
||||
import com.aizuda.snailjob.client.common.annotation.Mapping;
|
||||
import com.aizuda.snailjob.client.common.rpc.client.RequestMethod;
|
||||
|
||||
|
||||
/**
|
||||
@ -18,7 +16,7 @@ import com.aizuda.snailjob.client.common.rpc.client.RequestMethod;
|
||||
public interface NettyClient {
|
||||
|
||||
@Mapping(method = RequestMethod.GET, path = HTTP_PATH.SYNC_CONFIG)
|
||||
Result getConfig(Integer version);
|
||||
Result syncRemoteConfig();
|
||||
|
||||
@Mapping(method = RequestMethod.GET, path = HTTP_PATH.BEAT)
|
||||
Result beat(String mark);
|
||||
|
@ -31,23 +31,18 @@ public class SyncRemoteConfig implements Lifecycle {
|
||||
|
||||
SCHEDULE_EXECUTOR.scheduleAtFixedRate(() -> {
|
||||
try {
|
||||
try {
|
||||
NettyClient client = RequestBuilder.<NettyClient, NettyResult>newBuilder()
|
||||
.client(NettyClient.class)
|
||||
.callback(nettyResult -> {
|
||||
if (Objects.isNull(nettyResult.getData())) {
|
||||
SnailJobLog.LOCAL.error("获取配置结果为null");
|
||||
return;
|
||||
}
|
||||
NettyClient client = RequestBuilder.<NettyClient, NettyResult>newBuilder()
|
||||
.client(NettyClient.class)
|
||||
.callback(nettyResult -> {
|
||||
if (Objects.isNull(nettyResult.getData())) {
|
||||
SnailJobLog.LOCAL.error("获取配置结果为null");
|
||||
return;
|
||||
}
|
||||
|
||||
GroupVersionCache.setConfig(
|
||||
JsonUtil.parseObject(nettyResult.getData().toString(), ConfigDTO.class));
|
||||
})
|
||||
.build();
|
||||
client.getConfig(0);
|
||||
} catch (Exception e) {
|
||||
SnailJobLog.LOCAL.error("同步版本失败", e);
|
||||
}
|
||||
GroupVersionCache.setConfig(
|
||||
JsonUtil.parseObject(nettyResult.getData().toString(), ConfigDTO.class));
|
||||
}).build();
|
||||
client.syncRemoteConfig();
|
||||
} catch (Exception e) {
|
||||
SnailJobLog.LOCAL.error("通知配置失败", e);
|
||||
}
|
||||
|
@ -37,7 +37,6 @@ public class ConfigHttpRequestHandler extends GetHttpRequestHandler {
|
||||
|
||||
@Override
|
||||
public String doHandler(String content, UrlQuery urlQuery, HttpHeaders headers) {
|
||||
SnailJobLog.LOCAL.info("版本同步 content:[{}]", urlQuery.toString());
|
||||
SnailJobRequest retryRequest = JsonUtil.parseObject(content, SnailJobRequest.class);
|
||||
String groupName = headers.get(HeadersEnum.GROUP_NAME.getKey());
|
||||
String namespace = headers.get(HeadersEnum.NAMESPACE.getKey());
|
||||
|
Loading…
Reference in New Issue
Block a user