feat:(1.3.0-beta1): 优化续租逻辑

This commit is contained in:
opensnail 2024-12-11 22:30:03 +08:00
parent 5367009a78
commit edf4f0f80c
5 changed files with 8 additions and 7 deletions

View File

@ -120,7 +120,10 @@ public interface SystemConstants {
*/
String RETRY_CALLBACK = "/retry/callback/v1";
String GET_REG_NODES_AND_REFRESH = "/server/regAndRefresh/v1";
/**
* 拉取注册的信息
*/
String GET_REG_NODES_AND_REFRESH = "/pull/register/queue/v1";
/**
* 获取重试幂等id

View File

@ -42,7 +42,6 @@ import java.util.concurrent.TimeUnit;
public class GrpcChannel {
private GrpcChannel() {
}
private static final String HOST_ID = IdUtil.getSnowflake().nextIdStr();
private static final ThreadPoolExecutor grpcExecutor = createGrpcExecutor();
private static ConcurrentHashMap<Pair<String, String>, ManagedChannel> CHANNEL_MAP = new ConcurrentHashMap<>(16);
@ -79,7 +78,7 @@ public class GrpcChannel {
return null;
}
}
headersMap.put(HeadersEnum.HOST_ID.getKey(), HOST_ID);
headersMap.put(HeadersEnum.HOST_ID.getKey(), ServerRegister.CURRENT_CID);
headersMap.put(HeadersEnum.HOST_IP.getKey(), NetUtil.getLocalIpStr());
headersMap.put(HeadersEnum.GROUP_NAME.getKey(), ServerRegister.GROUP_NAME);
headersMap.put(HeadersEnum.HOST_PORT.getKey(), getServerPort());

View File

@ -32,7 +32,6 @@ import java.util.concurrent.TimeUnit;
@Slf4j
public class NettyChannel {
private static Bootstrap bootstrap;
private static final String HOST_ID = IdUtil.getSnowflake().nextIdStr();
private static ConcurrentHashMap<Pair<String, String>, Channel> CHANNEL_MAP = new ConcurrentHashMap<>(16);
private NettyChannel() {
}
@ -85,7 +84,7 @@ public class NettyChannel {
.set(HttpHeaderNames.CONNECTION, HttpHeaderValues.KEEP_ALIVE)
// 设置传递请求内容的长度
.set(HttpHeaderNames.CONTENT_LENGTH, request.content().readableBytes())
.set(HeadersEnum.HOST_ID.getKey(), HOST_ID)
.set(HeadersEnum.HOST_ID.getKey(), ServerRegister.CURRENT_CID)
.set(HeadersEnum.HOST_IP.getKey(), NetUtil.getLocalIpStr())
.set(HeadersEnum.GROUP_NAME.getKey(), ServerRegister.GROUP_NAME)
.set(HeadersEnum.HOST_PORT.getKey(), getServerPort())

View File

@ -15,6 +15,6 @@ import static com.aizuda.snailjob.common.core.constant.SystemConstants.HTTP_PATH
* @FilenameServerRpcClient
*/
public interface ServerRpcClient {
@Mapping(path = GET_REG_NODES_AND_REFRESH, method = RequestMethod.GET)
@Mapping(path = GET_REG_NODES_AND_REFRESH, method = RequestMethod.POST)
Result<String> getRegNodesAndFlush();
}

View File

@ -36,7 +36,7 @@ public class GetRegNodesPostHttpRequestHandler extends GetHttpRequestHandler {
@Override
public HttpMethod method() {
return HttpMethod.GET;
return HttpMethod.POST;
}
@Override