feat:(1.3.0-beta1): nettyPort废弃改为serverPort

This commit is contained in:
opensnail 2024-12-28 21:50:24 +08:00
parent 5abd1be3f1
commit 45af9d09b9
8 changed files with 26 additions and 13 deletions

View File

@ -55,7 +55,7 @@ public class SnailJobServerLogbackAppender<E> extends UnsynchronizedAppenderBase
logContentDTO.addLocationField(getLocationField(event));
logContentDTO.addThrowableField(getThrowableField(event));
logContentDTO.addHostField(NetUtil.getLocalIpStr());
logContentDTO.addPortField(SnailSpringContext.getBean(SystemProperties.class).getNettyPort());
logContentDTO.addPortField(SnailSpringContext.getBean(SystemProperties.class).getServerPort());
LogMetaDTO logMetaDTO = null;
try {

View File

@ -11,6 +11,7 @@ import org.springframework.context.annotation.Configuration;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.Objects;
import java.util.concurrent.TimeUnit;
/**
@ -41,8 +42,23 @@ public class SystemProperties {
/**
* netty 端口
* see: serverPort
*/
private int nettyPort = 1788;
@Deprecated
private Integer nettyPort;
/**
* 服务端端口
*/
private int serverPort = 17888;
/**
* 获取服务端端口
*/
public int getServerPort() {
// since: 1.3.0-beta1 兼容nettyPort
return Objects.isNull(nettyPort) ? serverPort : nettyPort;
}
/**
* server token

View File

@ -66,7 +66,7 @@ public class ServerRegister extends AbstractRegister {
context.setGroupName(GROUP_NAME);
context.setHostId(CURRENT_CID);
context.setHostIp(NetUtil.getLocalIpStr());
context.setHostPort(systemProperties.getNettyPort());
context.setHostPort(systemProperties.getServerPort());
context.setContextPath(Optional.ofNullable(serverProperties.getServlet().getContextPath()).orElse(StrUtil.EMPTY));
context.setNamespaceId(NAMESPACE_ID);
context.setExtAttrs(JsonUtil.toJsonString(serverNodeExtAttrs));

View File

@ -1,6 +1,5 @@
package com.aizuda.snailjob.server.common.rpc.client;
import cn.hutool.core.util.IdUtil;
import com.aizuda.snailjob.common.core.constant.SystemConstants;
import com.aizuda.snailjob.common.core.context.SnailSpringContext;
import com.aizuda.snailjob.common.core.enums.HeadersEnum;
@ -119,7 +118,7 @@ public class GrpcChannel {
private static String getServerPort() {
SystemProperties properties = SnailSpringContext.getBean(SystemProperties.class);
return String.valueOf(properties.getNettyPort());
return String.valueOf(properties.getServerPort());
}
/**

View File

@ -1,6 +1,5 @@
package com.aizuda.snailjob.server.common.rpc.client;
import cn.hutool.core.util.IdUtil;
import com.aizuda.snailjob.common.core.constant.SystemConstants;
import com.aizuda.snailjob.common.core.context.SnailSpringContext;
import com.aizuda.snailjob.common.core.enums.HeadersEnum;
@ -20,7 +19,6 @@ import java.net.ConnectException;
import java.nio.channels.ClosedChannelException;
import java.nio.charset.StandardCharsets;
import java.util.Objects;
import java.util.Optional;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit;
@ -104,7 +102,7 @@ public class NettyChannel {
private static String getServerPort() {
SystemProperties properties = SnailSpringContext.getBean(SystemProperties.class);
return String.valueOf(properties.getNettyPort());
return String.valueOf(properties.getServerPort());
}
/**

View File

@ -66,7 +66,7 @@ public class GrpcServer implements Lifecycle {
final MutableHandlerRegistry handlerRegistry = new MutableHandlerRegistry();
addServices(handlerRegistry, new GrpcInterceptor());
NettyServerBuilder builder = NettyServerBuilder.forPort(systemProperties.getNettyPort())
NettyServerBuilder builder = NettyServerBuilder.forPort(systemProperties.getServerPort())
.executor(createGrpcExecutor(grpc.getDispatcherTp()));
Duration keepAliveTime = grpc.getKeepAliveTime();
@ -84,7 +84,7 @@ public class GrpcServer implements Lifecycle {
server.start();
this.started = true;
SnailJobLog.LOCAL.info("------> snail-job remoting server start success, grpc = {}, port = {}",
GrpcServer.class.getName(), systemProperties.getNettyPort());
GrpcServer.class.getName(), systemProperties.getServerPort());
} catch (IOException e) {
SnailJobLog.LOCAL.error("--------> snail-job remoting server error.", e);
started = false;

View File

@ -65,10 +65,10 @@ public class NettyHttpServer implements Runnable, Lifecycle {
});
// 在特定端口绑定并启动服务器 默认是17888
ChannelFuture future = bootstrap.bind(systemProperties.getNettyPort()).sync();
ChannelFuture future = bootstrap.bind(systemProperties.getServerPort()).sync();
SnailJobLog.LOCAL.info("------> snail-job remoting server start success, nettype = {}, port = {}",
NettyHttpServer.class.getName(), systemProperties.getNettyPort());
NettyHttpServer.class.getName(), systemProperties.getServerPort());
started = true;
future.channel().closeFuture().sync();

View File

@ -79,7 +79,7 @@ logging:
snail-job:
retry-pull-page-size: 1000 # 拉取重试数据的每批次的大小
job-pull-page-size: 1000 # 拉取重试数据的每批次的大小
netty-port: 17888 # 服务端netty端口
server-port: 17888 # 服务端netty端口
limiter: 1000 # 一个客户端每秒最多接收的重试数量指令
step: 100 # 号段模式下步长配置
log-storage: 45 # 日志保存时间(单位: day)