Add some nacos connection logs (#12494)
This commit is contained in:
parent
c7a69a60a8
commit
8a2dffd55e
|
|
@ -17,11 +17,6 @@
|
||||||
|
|
||||||
package org.apache.dubbo.configcenter.support.nacos;
|
package org.apache.dubbo.configcenter.support.nacos;
|
||||||
|
|
||||||
import com.alibaba.nacos.api.NacosFactory;
|
|
||||||
import com.alibaba.nacos.api.PropertyKeyConst;
|
|
||||||
import com.alibaba.nacos.api.config.ConfigService;
|
|
||||||
import com.alibaba.nacos.api.config.listener.AbstractSharedListener;
|
|
||||||
import com.alibaba.nacos.api.exception.NacosException;
|
|
||||||
import org.apache.dubbo.common.URL;
|
import org.apache.dubbo.common.URL;
|
||||||
import org.apache.dubbo.common.config.configcenter.ConfigChangeType;
|
import org.apache.dubbo.common.config.configcenter.ConfigChangeType;
|
||||||
import org.apache.dubbo.common.config.configcenter.ConfigChangedEvent;
|
import org.apache.dubbo.common.config.configcenter.ConfigChangedEvent;
|
||||||
|
|
@ -38,6 +33,12 @@ import org.apache.dubbo.metrics.config.event.ConfigCenterEvent;
|
||||||
import org.apache.dubbo.metrics.event.MetricsEventBus;
|
import org.apache.dubbo.metrics.event.MetricsEventBus;
|
||||||
import org.apache.dubbo.rpc.model.ApplicationModel;
|
import org.apache.dubbo.rpc.model.ApplicationModel;
|
||||||
|
|
||||||
|
import com.alibaba.nacos.api.NacosFactory;
|
||||||
|
import com.alibaba.nacos.api.PropertyKeyConst;
|
||||||
|
import com.alibaba.nacos.api.config.ConfigService;
|
||||||
|
import com.alibaba.nacos.api.config.listener.AbstractSharedListener;
|
||||||
|
import com.alibaba.nacos.api.exception.NacosException;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
@ -107,11 +108,15 @@ public class NacosDynamicConfiguration implements DynamicConfiguration {
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < retryTimes + 1; i++) {
|
for (int i = 0; i < retryTimes + 1; i++) {
|
||||||
tmpConfigServices = NacosFactory.createConfigService(nacosProperties);
|
tmpConfigServices = NacosFactory.createConfigService(nacosProperties);
|
||||||
if (!check || (UP.equals(tmpConfigServices.getServerStatus()) && testConfigService(tmpConfigServices))) {
|
String serverStatus = tmpConfigServices.getServerStatus();
|
||||||
|
boolean configServiceAvailable = testConfigService(tmpConfigServices);
|
||||||
|
if (!check || (UP.equals(serverStatus) && configServiceAvailable)) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
logger.warn(LoggerCodeConstants.CONFIG_ERROR_NACOS, "", "",
|
logger.warn(LoggerCodeConstants.CONFIG_ERROR_NACOS, "", "",
|
||||||
"Failed to connect to nacos config server. " +
|
"Failed to connect to nacos config server. " +
|
||||||
|
"Server status: " + serverStatus + ". " +
|
||||||
|
"Config Service Available: " + configServiceAvailable + ". " +
|
||||||
(i < retryTimes ? "Dubbo will try to retry in " + sleepMsBetweenRetries + ". " : "Exceed retry max times.") +
|
(i < retryTimes ? "Dubbo will try to retry in " + sleepMsBetweenRetries + ". " : "Exceed retry max times.") +
|
||||||
"Try times: " + (i + 1));
|
"Try times: " + (i + 1));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -121,11 +121,15 @@ public class NacosConnectionManager {
|
||||||
try {
|
try {
|
||||||
for (int i = 0; i < retryTimes + 1; i++) {
|
for (int i = 0; i < retryTimes + 1; i++) {
|
||||||
namingService = NacosFactory.createNamingService(nacosProperties);
|
namingService = NacosFactory.createNamingService(nacosProperties);
|
||||||
if (!check || (UP.equals(namingService.getServerStatus()) && testNamingService(namingService))) {
|
String serverStatus = namingService.getServerStatus();
|
||||||
|
boolean namingServiceAvailable = testNamingService(namingService);
|
||||||
|
if (!check || (UP.equals(serverStatus) && namingServiceAvailable)) {
|
||||||
break;
|
break;
|
||||||
} else {
|
} else {
|
||||||
logger.warn(LoggerCodeConstants.REGISTRY_NACOS_EXCEPTION, "", "",
|
logger.warn(LoggerCodeConstants.REGISTRY_NACOS_EXCEPTION, "", "",
|
||||||
"Failed to connect to nacos naming server. " +
|
"Failed to connect to nacos naming server. " +
|
||||||
|
"Server status: " + serverStatus + ". " +
|
||||||
|
"Naming Service Available: " + namingServiceAvailable + ". " +
|
||||||
(i < retryTimes ? "Dubbo will try to retry in " + sleepMsBetweenRetries + ". " : "Exceed retry max times.") +
|
(i < retryTimes ? "Dubbo will try to retry in " + sleepMsBetweenRetries + ". " : "Exceed retry max times.") +
|
||||||
"Try times: " + (i + 1));
|
"Try times: " + (i + 1));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue