only load grpc config from system one time.
This commit is contained in:
parent
3d7bda84f7
commit
1e9b18cd75
@ -32,7 +32,6 @@ import com.alibaba.nacos.api.remote.response.Response;
|
|||||||
import com.alibaba.nacos.common.lifecycle.Closeable;
|
import com.alibaba.nacos.common.lifecycle.Closeable;
|
||||||
import com.alibaba.nacos.common.remote.ConnectionType;
|
import com.alibaba.nacos.common.remote.ConnectionType;
|
||||||
import com.alibaba.nacos.common.remote.PayloadRegistry;
|
import com.alibaba.nacos.common.remote.PayloadRegistry;
|
||||||
import com.alibaba.nacos.common.remote.client.grpc.DefaultGrpcClientConfig;
|
|
||||||
import com.alibaba.nacos.common.utils.CollectionUtils;
|
import com.alibaba.nacos.common.utils.CollectionUtils;
|
||||||
import com.alibaba.nacos.common.utils.LoggerUtils;
|
import com.alibaba.nacos.common.utils.LoggerUtils;
|
||||||
import com.alibaba.nacos.common.utils.NumberUtils;
|
import com.alibaba.nacos.common.utils.NumberUtils;
|
||||||
@ -279,8 +278,8 @@ public abstract class RpcClient implements Closeable {
|
|||||||
if (isShutdown()) {
|
if (isShutdown()) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
ReconnectContext reconnectContext = reconnectionSignal.poll(rpcClientConfig.connectionKeepAlive(),
|
ReconnectContext reconnectContext = reconnectionSignal
|
||||||
TimeUnit.MILLISECONDS);
|
.poll(rpcClientConfig.connectionKeepAlive(), TimeUnit.MILLISECONDS);
|
||||||
if (reconnectContext == null) {
|
if (reconnectContext == null) {
|
||||||
// check alive time.
|
// check alive time.
|
||||||
if (System.currentTimeMillis() - lastActiveTimeStamp >= rpcClientConfig.connectionKeepAlive()) {
|
if (System.currentTimeMillis() - lastActiveTimeStamp >= rpcClientConfig.connectionKeepAlive()) {
|
||||||
@ -298,8 +297,8 @@ public abstract class RpcClient implements Closeable {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean statusFLowSuccess = RpcClient.this.rpcClientStatus.compareAndSet(
|
boolean statusFLowSuccess = RpcClient.this.rpcClientStatus
|
||||||
rpcClientStatus, RpcClientStatus.UNHEALTHY);
|
.compareAndSet(rpcClientStatus, RpcClientStatus.UNHEALTHY);
|
||||||
if (statusFLowSuccess) {
|
if (statusFLowSuccess) {
|
||||||
reconnectContext = new ReconnectContext(null, false);
|
reconnectContext = new ReconnectContext(null, false);
|
||||||
} else {
|
} else {
|
||||||
@ -366,9 +365,10 @@ public abstract class RpcClient implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (connectToServer != null) {
|
if (connectToServer != null) {
|
||||||
LoggerUtils.printIfInfoEnabled(LOGGER,
|
LoggerUtils
|
||||||
"[{}] Success to connect to server [{}] on start up, connectionId = {}", rpcClientConfig.name(),
|
.printIfInfoEnabled(LOGGER, "[{}] Success to connect to server [{}] on start up, connectionId = {}",
|
||||||
connectToServer.serverInfo.getAddress(), connectToServer.getConnectionId());
|
rpcClientConfig.name(), connectToServer.serverInfo.getAddress(),
|
||||||
|
connectToServer.getConnectionId());
|
||||||
this.currentConnection = connectToServer;
|
this.currentConnection = connectToServer;
|
||||||
rpcClientStatus.set(RpcClientStatus.RUNNING);
|
rpcClientStatus.set(RpcClientStatus.RUNNING);
|
||||||
eventLinkedBlockingQueue.offer(new ConnectionEvent(ConnectionEvent.CONNECTED));
|
eventLinkedBlockingQueue.offer(new ConnectionEvent(ConnectionEvent.CONNECTED));
|
||||||
@ -402,8 +402,8 @@ public abstract class RpcClient implements Closeable {
|
|||||||
ConnectResetRequest connectResetRequest = (ConnectResetRequest) request;
|
ConnectResetRequest connectResetRequest = (ConnectResetRequest) request;
|
||||||
if (StringUtils.isNotBlank(connectResetRequest.getServerIp())) {
|
if (StringUtils.isNotBlank(connectResetRequest.getServerIp())) {
|
||||||
ServerInfo serverInfo = resolveServerInfo(
|
ServerInfo serverInfo = resolveServerInfo(
|
||||||
connectResetRequest.getServerIp() + Constants.COLON
|
connectResetRequest.getServerIp() + Constants.COLON + connectResetRequest
|
||||||
+ connectResetRequest.getServerPort());
|
.getServerPort());
|
||||||
switchServerAsync(serverInfo, false);
|
switchServerAsync(serverInfo, false);
|
||||||
} else {
|
} else {
|
||||||
switchServerAsync();
|
switchServerAsync();
|
||||||
@ -439,8 +439,8 @@ public abstract class RpcClient implements Closeable {
|
|||||||
while (reTryTimes >= 0) {
|
while (reTryTimes >= 0) {
|
||||||
reTryTimes--;
|
reTryTimes--;
|
||||||
try {
|
try {
|
||||||
Response response = this.currentConnection.request(healthCheckRequest,
|
Response response = this.currentConnection
|
||||||
rpcClientConfig.healthCheckTimeOut());
|
.request(healthCheckRequest, rpcClientConfig.healthCheckTimeOut());
|
||||||
// not only check server is ok, also check connection is register.
|
// not only check server is ok, also check connection is register.
|
||||||
return response != null && response.isSuccess();
|
return response != null && response.isSuccess();
|
||||||
} catch (NacosException e) {
|
} catch (NacosException e) {
|
||||||
@ -496,9 +496,10 @@ public abstract class RpcClient implements Closeable {
|
|||||||
// 2.create a new channel to new server
|
// 2.create a new channel to new server
|
||||||
Connection connectionNew = connectToServer(serverInfo);
|
Connection connectionNew = connectToServer(serverInfo);
|
||||||
if (connectionNew != null) {
|
if (connectionNew != null) {
|
||||||
LoggerUtils.printIfInfoEnabled(LOGGER,
|
LoggerUtils
|
||||||
"[{}] Success to connect a server [{}], connectionId = {}", rpcClientConfig.name(),
|
.printIfInfoEnabled(LOGGER, "[{}] Success to connect a server [{}], connectionId = {}",
|
||||||
serverInfo.getAddress(), connectionNew.getConnectionId());
|
rpcClientConfig.name(), serverInfo.getAddress(),
|
||||||
|
connectionNew.getConnectionId());
|
||||||
// successfully create a new connect.
|
// successfully create a new connect.
|
||||||
if (currentConnection != null) {
|
if (currentConnection != null) {
|
||||||
LoggerUtils.printIfInfoEnabled(LOGGER,
|
LoggerUtils.printIfInfoEnabled(LOGGER,
|
||||||
@ -567,8 +568,9 @@ public abstract class RpcClient implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
LoggerUtils.printIfWarnEnabled(LOGGER, "[{}] Fail to reconnect to server, error is {}",
|
LoggerUtils
|
||||||
rpcClientConfig.name(), e);
|
.printIfWarnEnabled(LOGGER, "[{}] Fail to reconnect to server, error is {}", rpcClientConfig.name(),
|
||||||
|
e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -701,8 +703,8 @@ public abstract class RpcClient implements Closeable {
|
|||||||
|
|
||||||
Exception exceptionToThrow = null;
|
Exception exceptionToThrow = null;
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
while (retryTimes < rpcClientConfig.retryTimes()
|
while (retryTimes < rpcClientConfig.retryTimes() && System.currentTimeMillis() < start + callback
|
||||||
&& System.currentTimeMillis() < start + callback.getTimeout()) {
|
.getTimeout()) {
|
||||||
boolean waitReconnect = false;
|
boolean waitReconnect = false;
|
||||||
try {
|
try {
|
||||||
if (this.currentConnection == null || !isRunning()) {
|
if (this.currentConnection == null || !isRunning()) {
|
||||||
@ -751,8 +753,8 @@ public abstract class RpcClient implements Closeable {
|
|||||||
int retryTimes = 0;
|
int retryTimes = 0;
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
Exception exceptionToThrow = null;
|
Exception exceptionToThrow = null;
|
||||||
while (retryTimes < rpcClientConfig.retryTimes()
|
while (retryTimes < rpcClientConfig.retryTimes() && System.currentTimeMillis() < start + rpcClientConfig
|
||||||
&& System.currentTimeMillis() < start + rpcClientConfig.timeOutMills()) {
|
.timeOutMills()) {
|
||||||
boolean waitReconnect = false;
|
boolean waitReconnect = false;
|
||||||
try {
|
try {
|
||||||
if (this.currentConnection == null || !isRunning()) {
|
if (this.currentConnection == null || !isRunning()) {
|
||||||
|
@ -94,8 +94,7 @@ public class RpcClientFactory {
|
|||||||
return CLIENT_MAP.computeIfAbsent(clientName, clientNameInner -> {
|
return CLIENT_MAP.computeIfAbsent(clientName, clientNameInner -> {
|
||||||
LOGGER.info("[RpcClientFactory] create a new rpc client of " + clientName);
|
LOGGER.info("[RpcClientFactory] create a new rpc client of " + clientName);
|
||||||
try {
|
try {
|
||||||
GrpcClient client = new GrpcSdkClient(clientNameInner, threadPoolCoreSize, threadPoolMaxSize, labels);
|
return new GrpcSdkClient(clientNameInner, threadPoolCoreSize, threadPoolMaxSize, labels);
|
||||||
return client;
|
|
||||||
} catch (Throwable throwable) {
|
} catch (Throwable throwable) {
|
||||||
LOGGER.error("Error to init GrpcSdkClient for client name :" + clientName, throwable);
|
LOGGER.error("Error to init GrpcSdkClient for client name :" + clientName, throwable);
|
||||||
throw throwable;
|
throw throwable;
|
||||||
@ -131,10 +130,9 @@ public class RpcClientFactory {
|
|||||||
throw new UnsupportedOperationException("unsupported connection type :" + connectionType.getType());
|
throw new UnsupportedOperationException("unsupported connection type :" + connectionType.getType());
|
||||||
}
|
}
|
||||||
|
|
||||||
return CLIENT_MAP.computeIfAbsent(clientName, clientNameInner -> {
|
return CLIENT_MAP.computeIfAbsent(clientName,
|
||||||
GrpcClient client = new GrpcClusterClient(clientNameInner, threadPoolCoreSize, threadPoolMaxSize, labels);
|
clientNameInner -> new GrpcClusterClient(clientNameInner, threadPoolCoreSize, threadPoolMaxSize,
|
||||||
return client;
|
labels));
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -65,20 +65,32 @@ public class DefaultGrpcClientConfig implements GrpcClientConfig {
|
|||||||
*/
|
*/
|
||||||
private DefaultGrpcClientConfig(Builder builder) {
|
private DefaultGrpcClientConfig(Builder builder) {
|
||||||
this.name = builder.name;
|
this.name = builder.name;
|
||||||
this.retryTimes = builder.retryTimes;
|
this.retryTimes = loadIntegerConfig(GrpcConstants.GRPC_RETRY_TIMES, builder.retryTimes);
|
||||||
this.timeOutMills = builder.timeOutMills;
|
this.timeOutMills = loadLongConfig(GrpcConstants.GRPC_TIMEOUT_MILLS, builder.timeOutMills);
|
||||||
this.connectionKeepAlive = builder.connectionKeepAlive;
|
this.connectionKeepAlive = loadLongConfig(GrpcConstants.GRPC_CONNECT_KEEP_ALIVE_TIME,
|
||||||
this.threadPoolKeepAlive = builder.threadPoolKeepAlive;
|
builder.connectionKeepAlive);
|
||||||
this.threadPoolCoreSize = builder.threadPoolCoreSize;
|
this.threadPoolKeepAlive = loadLongConfig(GrpcConstants.GRPC_THREADPOOL_KEEPALIVETIME,
|
||||||
this.threadPoolMaxSize = builder.threadPoolMaxSize;
|
builder.threadPoolKeepAlive);
|
||||||
this.serverCheckTimeOut = builder.serverCheckTimeOut;
|
this.threadPoolCoreSize = loadIntegerConfig(GrpcConstants.GRPC_THREADPOOL_CORE_SIZE,
|
||||||
this.threadPoolQueueSize = builder.threadPoolQueueSize;
|
builder.threadPoolCoreSize);
|
||||||
this.maxInboundMessageSize = builder.maxInboundMessageSize;
|
this.threadPoolMaxSize = loadIntegerConfig(GrpcConstants.GRPC_THREADPOOL_MAX_SIZE, builder.threadPoolMaxSize);
|
||||||
this.channelKeepAlive = builder.channelKeepAlive;
|
this.serverCheckTimeOut = loadLongConfig(GrpcConstants.GRPC_SERVER_CHECK_TIMEOUT, builder.serverCheckTimeOut);
|
||||||
this.healthCheckRetryTimes = builder.healthCheckRetryTimes;
|
this.threadPoolQueueSize = loadIntegerConfig(GrpcConstants.GRPC_QUEUESIZE, builder.threadPoolQueueSize);
|
||||||
this.healthCheckTimeOut = builder.healthCheckTimeOut;
|
this.maxInboundMessageSize = loadIntegerConfig(GrpcConstants.GRPC_MAX_INBOUND_MESSAGE_SIZE,
|
||||||
|
builder.maxInboundMessageSize);
|
||||||
|
this.channelKeepAlive = loadIntegerConfig(GrpcConstants.GRPC_CHANNEL_KEEP_ALIVE_TIME, builder.channelKeepAlive);
|
||||||
|
this.healthCheckRetryTimes = loadIntegerConfig(GrpcConstants.GRPC_HEALTHCHECK_RETRY_TIMES,
|
||||||
|
builder.healthCheckRetryTimes);
|
||||||
|
this.healthCheckTimeOut = loadLongConfig(GrpcConstants.GRPC_HEALTHCHECK_TIMEOUT, builder.healthCheckTimeOut);
|
||||||
this.labels = builder.labels;
|
this.labels = builder.labels;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int loadIntegerConfig(String key, int builderValue) {
|
||||||
|
return Integer.getInteger(key, builderValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
private long loadLongConfig(String key, long builderValue) {
|
||||||
|
return Long.getLong(key, builderValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -88,74 +100,62 @@ public class DefaultGrpcClientConfig implements GrpcClientConfig {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int retryTimes() {
|
public int retryTimes() {
|
||||||
return Integer.parseInt(
|
return retryTimes;
|
||||||
System.getProperty(GrpcConstants.NACOS_CLIENT_GRPC_RETRY_TIMES, String.valueOf(this.retryTimes)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long timeOutMills() {
|
public long timeOutMills() {
|
||||||
return Long.parseLong(
|
return timeOutMills;
|
||||||
System.getProperty(GrpcConstants.NACOS_CLIENT_GRPC_TIMEOUT_MILLS, String.valueOf(this.timeOutMills)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long connectionKeepAlive() {
|
public long connectionKeepAlive() {
|
||||||
return Long.parseLong(System.getProperty(GrpcConstants.NACOS_CLIENT_GRPC_CONNECT_KEEP_ALIVE_TIME,
|
return connectionKeepAlive;
|
||||||
String.valueOf(this.connectionKeepAlive)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int threadPoolCoreSize() {
|
public int threadPoolCoreSize() {
|
||||||
return Integer.parseInt(System.getProperty(GrpcConstants.NACOS_CLIENT_GRPC_THREADPOOL_CORE_SIZE,
|
return threadPoolCoreSize;
|
||||||
String.valueOf(this.threadPoolCoreSize)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int threadPoolMaxSize() {
|
public int threadPoolMaxSize() {
|
||||||
return Integer.parseInt(System.getProperty(GrpcConstants.NACOS_CLIENT_GRPC_THREADPOOL_MAX_SIZE,
|
return threadPoolMaxSize;
|
||||||
String.valueOf(this.threadPoolMaxSize)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long threadPoolKeepAlive() {
|
public long threadPoolKeepAlive() {
|
||||||
return Long.parseLong(System.getProperty(GrpcConstants.NACOS_CLIENT_GRPC_THREADPOOL_KEEPALIVETIME,
|
return threadPoolKeepAlive;
|
||||||
String.valueOf(this.threadPoolKeepAlive)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long serverCheckTimeOut() {
|
public long serverCheckTimeOut() {
|
||||||
return Long.parseLong(System.getProperty(GrpcConstants.NACOS_CLIENT_GRPC_SERVER_CHECK_TIMEOUT,
|
return serverCheckTimeOut;
|
||||||
String.valueOf(this.serverCheckTimeOut)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int threadPoolQueueSize() {
|
public int threadPoolQueueSize() {
|
||||||
return Integer.parseInt(System.getProperty(GrpcConstants.NACOS_CLIENT_GRPC_QUEUESIZE,
|
return threadPoolQueueSize;
|
||||||
String.valueOf(this.threadPoolQueueSize)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int maxInboundMessageSize() {
|
public int maxInboundMessageSize() {
|
||||||
return Integer.parseInt(
|
return maxInboundMessageSize;
|
||||||
System.getProperty(GrpcConstants.MAX_INBOUND_MESSAGE_SIZE, String.valueOf(this.maxInboundMessageSize)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int channelKeepAlive() {
|
public int channelKeepAlive() {
|
||||||
return Integer.parseInt(
|
return channelKeepAlive;
|
||||||
System.getProperty(GrpcConstants.CHANNEL_KEEP_ALIVE_TIME, String.valueOf(this.channelKeepAlive)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int healthCheckRetryTimes() {
|
public int healthCheckRetryTimes() {
|
||||||
return Integer.parseInt(System.getProperty(GrpcConstants.NACOS_CLIENT_GRPC_HEALTHCHECK_RETRY_TIMES,
|
return healthCheckRetryTimes;
|
||||||
String.valueOf(this.healthCheckRetryTimes)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public long healthCheckTimeOut() {
|
public long healthCheckTimeOut() {
|
||||||
return Integer.parseInt(System.getProperty(GrpcConstants.NACOS_CLIENT_GRPC_HEALTHCHECK_TIMEOUT,
|
return healthCheckTimeOut;
|
||||||
String.valueOf(this.healthCheckTimeOut)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -199,7 +199,7 @@ public class DefaultGrpcClientConfig implements GrpcClientConfig {
|
|||||||
|
|
||||||
private Builder() {
|
private Builder() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set config from properties.
|
* Set config from properties.
|
||||||
*
|
*
|
||||||
@ -207,54 +207,53 @@ public class DefaultGrpcClientConfig implements GrpcClientConfig {
|
|||||||
* @return Builder
|
* @return Builder
|
||||||
*/
|
*/
|
||||||
public Builder fromProperties(Properties properties) {
|
public Builder fromProperties(Properties properties) {
|
||||||
if (properties.contains(GrpcConstants.NACOS_CLIENT_GRPC_NAME)) {
|
if (properties.contains(GrpcConstants.GRPC_NAME)) {
|
||||||
this.name = properties.getProperty(GrpcConstants.NACOS_CLIENT_GRPC_NAME);
|
this.name = properties.getProperty(GrpcConstants.GRPC_NAME);
|
||||||
}
|
}
|
||||||
if (properties.contains(GrpcConstants.NACOS_CLIENT_GRPC_RETRY_TIMES)) {
|
if (properties.contains(GrpcConstants.GRPC_RETRY_TIMES)) {
|
||||||
this.retryTimes = Integer.parseInt(properties.getProperty(GrpcConstants.NACOS_CLIENT_GRPC_RETRY_TIMES));
|
this.retryTimes = Integer.parseInt(properties.getProperty(GrpcConstants.GRPC_RETRY_TIMES));
|
||||||
}
|
}
|
||||||
if (properties.contains(GrpcConstants.NACOS_CLIENT_GRPC_TIMEOUT_MILLS)) {
|
if (properties.contains(GrpcConstants.GRPC_TIMEOUT_MILLS)) {
|
||||||
this.timeOutMills = Long.parseLong(
|
this.timeOutMills = Long.parseLong(properties.getProperty(GrpcConstants.GRPC_TIMEOUT_MILLS));
|
||||||
properties.getProperty(GrpcConstants.NACOS_CLIENT_GRPC_TIMEOUT_MILLS));
|
|
||||||
}
|
}
|
||||||
if (properties.contains(GrpcConstants.NACOS_CLIENT_GRPC_CONNECT_KEEP_ALIVE_TIME)) {
|
if (properties.contains(GrpcConstants.GRPC_CONNECT_KEEP_ALIVE_TIME)) {
|
||||||
this.connectionKeepAlive = Long.parseLong(
|
this.connectionKeepAlive = Long
|
||||||
properties.getProperty(GrpcConstants.NACOS_CLIENT_GRPC_CONNECT_KEEP_ALIVE_TIME));
|
.parseLong(properties.getProperty(GrpcConstants.GRPC_CONNECT_KEEP_ALIVE_TIME));
|
||||||
}
|
}
|
||||||
if (properties.contains(GrpcConstants.NACOS_CLIENT_GRPC_THREADPOOL_KEEPALIVETIME)) {
|
if (properties.contains(GrpcConstants.GRPC_THREADPOOL_KEEPALIVETIME)) {
|
||||||
this.threadPoolKeepAlive = Long.parseLong(
|
this.threadPoolKeepAlive = Long
|
||||||
properties.getProperty(GrpcConstants.NACOS_CLIENT_GRPC_THREADPOOL_KEEPALIVETIME));
|
.parseLong(properties.getProperty(GrpcConstants.GRPC_THREADPOOL_KEEPALIVETIME));
|
||||||
}
|
}
|
||||||
if (properties.contains(GrpcConstants.NACOS_CLIENT_GRPC_THREADPOOL_CORE_SIZE)) {
|
if (properties.contains(GrpcConstants.GRPC_THREADPOOL_CORE_SIZE)) {
|
||||||
this.threadPoolCoreSize = Integer.parseInt(
|
this.threadPoolCoreSize = Integer
|
||||||
properties.getProperty(GrpcConstants.NACOS_CLIENT_GRPC_THREADPOOL_CORE_SIZE));
|
.parseInt(properties.getProperty(GrpcConstants.GRPC_THREADPOOL_CORE_SIZE));
|
||||||
}
|
}
|
||||||
if (properties.contains(GrpcConstants.NACOS_CLIENT_GRPC_THREADPOOL_MAX_SIZE)) {
|
if (properties.contains(GrpcConstants.GRPC_THREADPOOL_MAX_SIZE)) {
|
||||||
this.threadPoolMaxSize = Integer.parseInt(
|
this.threadPoolMaxSize = Integer
|
||||||
properties.getProperty(GrpcConstants.NACOS_CLIENT_GRPC_THREADPOOL_MAX_SIZE));
|
.parseInt(properties.getProperty(GrpcConstants.GRPC_THREADPOOL_MAX_SIZE));
|
||||||
}
|
}
|
||||||
if (properties.contains(GrpcConstants.NACOS_CLIENT_GRPC_SERVER_CHECK_TIMEOUT)) {
|
if (properties.contains(GrpcConstants.GRPC_SERVER_CHECK_TIMEOUT)) {
|
||||||
this.serverCheckTimeOut = Long.parseLong(
|
this.serverCheckTimeOut = Long
|
||||||
properties.getProperty(GrpcConstants.NACOS_CLIENT_GRPC_SERVER_CHECK_TIMEOUT));
|
.parseLong(properties.getProperty(GrpcConstants.GRPC_SERVER_CHECK_TIMEOUT));
|
||||||
}
|
}
|
||||||
if (properties.contains(GrpcConstants.NACOS_CLIENT_GRPC_QUEUESIZE)) {
|
if (properties.contains(GrpcConstants.GRPC_QUEUESIZE)) {
|
||||||
this.threadPoolQueueSize = Integer.parseInt(
|
this.threadPoolQueueSize = Integer.parseInt(properties.getProperty(GrpcConstants.GRPC_QUEUESIZE));
|
||||||
properties.getProperty(GrpcConstants.NACOS_CLIENT_GRPC_QUEUESIZE));
|
|
||||||
}
|
}
|
||||||
if (properties.contains(GrpcConstants.MAX_INBOUND_MESSAGE_SIZE)) {
|
if (properties.contains(GrpcConstants.GRPC_MAX_INBOUND_MESSAGE_SIZE)) {
|
||||||
this.maxInboundMessageSize = Integer.parseInt(
|
this.maxInboundMessageSize = Integer
|
||||||
properties.getProperty(GrpcConstants.MAX_INBOUND_MESSAGE_SIZE));
|
.parseInt(properties.getProperty(GrpcConstants.GRPC_MAX_INBOUND_MESSAGE_SIZE));
|
||||||
}
|
}
|
||||||
if (properties.contains(GrpcConstants.CHANNEL_KEEP_ALIVE_TIME)) {
|
if (properties.contains(GrpcConstants.GRPC_CHANNEL_KEEP_ALIVE_TIME)) {
|
||||||
this.channelKeepAlive = Integer.parseInt(properties.getProperty(GrpcConstants.CHANNEL_KEEP_ALIVE_TIME));
|
this.channelKeepAlive = Integer
|
||||||
|
.parseInt(properties.getProperty(GrpcConstants.GRPC_CHANNEL_KEEP_ALIVE_TIME));
|
||||||
}
|
}
|
||||||
if (properties.contains(GrpcConstants.NACOS_CLIENT_GRPC_HEALTHCHECK_RETRY_TIMES)) {
|
if (properties.contains(GrpcConstants.GRPC_HEALTHCHECK_RETRY_TIMES)) {
|
||||||
this.healthCheckRetryTimes = Integer.parseInt(
|
this.healthCheckRetryTimes = Integer
|
||||||
properties.getProperty(GrpcConstants.NACOS_CLIENT_GRPC_HEALTHCHECK_RETRY_TIMES));
|
.parseInt(properties.getProperty(GrpcConstants.GRPC_HEALTHCHECK_RETRY_TIMES));
|
||||||
}
|
}
|
||||||
if (properties.contains(GrpcConstants.NACOS_CLIENT_GRPC_HEALTHCHECK_TIMEOUT)) {
|
if (properties.contains(GrpcConstants.GRPC_HEALTHCHECK_TIMEOUT)) {
|
||||||
this.healthCheckTimeOut = Long.parseLong(
|
this.healthCheckTimeOut = Long
|
||||||
properties.getProperty(GrpcConstants.NACOS_CLIENT_GRPC_HEALTHCHECK_TIMEOUT));
|
.parseLong(properties.getProperty(GrpcConstants.GRPC_HEALTHCHECK_TIMEOUT));
|
||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
@ -38,43 +38,43 @@ public class GrpcConstants {
|
|||||||
public static final String NACOS_CLIENT_GRPC = "nacos.remote.client.grpc";
|
public static final String NACOS_CLIENT_GRPC = "nacos.remote.client.grpc";
|
||||||
|
|
||||||
@GRpcConfigLabel
|
@GRpcConfigLabel
|
||||||
public static final String NACOS_CLIENT_GRPC_NAME = NACOS_CLIENT_GRPC + ".name";
|
public static final String GRPC_NAME = NACOS_CLIENT_GRPC + ".name";
|
||||||
|
|
||||||
@GRpcConfigLabel
|
@GRpcConfigLabel
|
||||||
public static final String NACOS_CLIENT_GRPC_THREADPOOL_KEEPALIVETIME = NACOS_CLIENT_GRPC + ".pool.alive";
|
public static final String GRPC_THREADPOOL_KEEPALIVETIME = NACOS_CLIENT_GRPC + ".pool.alive";
|
||||||
|
|
||||||
@GRpcConfigLabel
|
@GRpcConfigLabel
|
||||||
public static final String NACOS_CLIENT_GRPC_THREADPOOL_CORE_SIZE = NACOS_CLIENT_GRPC + ".pool.core.size";
|
public static final String GRPC_THREADPOOL_CORE_SIZE = NACOS_CLIENT_GRPC + ".pool.core.size";
|
||||||
|
|
||||||
@GRpcConfigLabel
|
@GRpcConfigLabel
|
||||||
public static final String NACOS_CLIENT_GRPC_RETRY_TIMES = NACOS_CLIENT_GRPC + ".retry.times";
|
public static final String GRPC_RETRY_TIMES = NACOS_CLIENT_GRPC + ".retry.times";
|
||||||
|
|
||||||
@GRpcConfigLabel
|
@GRpcConfigLabel
|
||||||
public static final String NACOS_CLIENT_GRPC_TIMEOUT_MILLS = NACOS_CLIENT_GRPC + ".timeout";
|
public static final String GRPC_TIMEOUT_MILLS = NACOS_CLIENT_GRPC + ".timeout";
|
||||||
|
|
||||||
@GRpcConfigLabel
|
@GRpcConfigLabel
|
||||||
public static final String NACOS_CLIENT_GRPC_CONNECT_KEEP_ALIVE_TIME = NACOS_CLIENT_GRPC + ".connect.keep.alive";
|
public static final String GRPC_CONNECT_KEEP_ALIVE_TIME = NACOS_CLIENT_GRPC + ".connect.keep.alive";
|
||||||
|
|
||||||
@GRpcConfigLabel
|
@GRpcConfigLabel
|
||||||
public static final String NACOS_CLIENT_GRPC_THREADPOOL_MAX_SIZE = NACOS_CLIENT_GRPC + ".pool.max.size";
|
public static final String GRPC_THREADPOOL_MAX_SIZE = NACOS_CLIENT_GRPC + ".pool.max.size";
|
||||||
|
|
||||||
@GRpcConfigLabel
|
@GRpcConfigLabel
|
||||||
public static final String NACOS_CLIENT_GRPC_SERVER_CHECK_TIMEOUT = NACOS_CLIENT_GRPC + ".server.check.timeout";
|
public static final String GRPC_SERVER_CHECK_TIMEOUT = NACOS_CLIENT_GRPC + ".server.check.timeout";
|
||||||
|
|
||||||
@GRpcConfigLabel
|
@GRpcConfigLabel
|
||||||
public static final String NACOS_CLIENT_GRPC_QUEUESIZE = NACOS_CLIENT_GRPC + ".queue.size";
|
public static final String GRPC_QUEUESIZE = NACOS_CLIENT_GRPC + ".queue.size";
|
||||||
|
|
||||||
@GRpcConfigLabel
|
@GRpcConfigLabel
|
||||||
public static final String NACOS_CLIENT_GRPC_HEALTHCHECK_RETRY_TIMES = NACOS_CLIENT_GRPC + ".health.retry";
|
public static final String GRPC_HEALTHCHECK_RETRY_TIMES = NACOS_CLIENT_GRPC + ".health.retry";
|
||||||
|
|
||||||
@GRpcConfigLabel
|
@GRpcConfigLabel
|
||||||
public static final String NACOS_CLIENT_GRPC_HEALTHCHECK_TIMEOUT = NACOS_CLIENT_GRPC + ".health.timeout";
|
public static final String GRPC_HEALTHCHECK_TIMEOUT = NACOS_CLIENT_GRPC + ".health.timeout";
|
||||||
|
|
||||||
@GRpcConfigLabel
|
@GRpcConfigLabel
|
||||||
public static final String MAX_INBOUND_MESSAGE_SIZE = NACOS_CLIENT_GRPC + ".maxinbound.message.size";
|
public static final String GRPC_MAX_INBOUND_MESSAGE_SIZE = NACOS_CLIENT_GRPC + ".maxinbound.message.size";
|
||||||
|
|
||||||
@GRpcConfigLabel
|
@GRpcConfigLabel
|
||||||
public static final String CHANNEL_KEEP_ALIVE_TIME = NACOS_CLIENT_GRPC + ".channel.keep.alive";
|
public static final String GRPC_CHANNEL_KEEP_ALIVE_TIME = NACOS_CLIENT_GRPC + ".channel.keep.alive";
|
||||||
|
|
||||||
private static final Set<String> CONFIG_NAMES = new HashSet<>();
|
private static final Set<String> CONFIG_NAMES = new HashSet<>();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user