Solve conflict from develop

This commit is contained in:
KomachiSion 2021-01-13 16:08:54 +08:00
parent 902f501fac
commit 995dce0bc0
3 changed files with 23 additions and 1 deletions

View File

@ -54,6 +54,8 @@ public class ServiceInfoHolder implements Closeable {
private final FailoverReactor failoverReactor;
private final boolean pushEmptyProtection;
private String cacheDir;
public ServiceInfoHolder(String namespace, Properties properties) {
@ -64,6 +66,7 @@ public class ServiceInfoHolder implements Closeable {
this.serviceInfoMap = new ConcurrentHashMap<String, ServiceInfo>(16);
}
this.failoverReactor = new FailoverReactor(this, cacheDir);
this.pushEmptyProtection = isPushEmptyProtect(properties);
}
private void initCacheDir(String namespace) {
@ -87,6 +90,16 @@ public class ServiceInfoHolder implements Closeable {
return loadCacheAtStart;
}
private boolean isPushEmptyProtect(Properties properties) {
boolean pushEmptyProtection = false;
if (properties != null && StringUtils
.isNotEmpty(properties.getProperty(PropertyKeyConst.NAMING_PUSH_EMPTY_PROTECTION))) {
pushEmptyProtection = ConvertUtils
.toBoolean(properties.getProperty(PropertyKeyConst.NAMING_PUSH_EMPTY_PROTECTION));
}
return pushEmptyProtection;
}
public Map<String, ServiceInfo> getServiceInfoMap() {
return serviceInfoMap;
}
@ -121,7 +134,7 @@ public class ServiceInfoHolder implements Closeable {
*/
public ServiceInfo processServiceInfo(ServiceInfo serviceInfo) {
ServiceInfo oldService = serviceInfoMap.get(serviceInfo.getKey());
if (serviceInfo.getHosts() == null || !serviceInfo.validate()) {
if (null == serviceInfo.getHosts() || (pushEmptyProtection && !serviceInfo.validate())) {
//empty or error push, just ignore
return oldService;
}

View File

@ -312,6 +312,9 @@ public class UdpPushService implements ApplicationContextAware, ApplicationListe
} else if (ClientInfo.ClientType.GO == clientInfo.type
&& clientInfo.version.compareTo(VersionUtil.parseVersion(switchDomain.getPushGoVersion())) >= 0) {
return true;
} else if (ClientInfo.ClientType.CSHARP == clientInfo.type
&& clientInfo.version.compareTo(VersionUtil.parseVersion(switchDomain.getPushCSharpVersion())) >= 0) {
return true;
}
return false;

View File

@ -61,6 +61,10 @@ public class ClientInfo {
* C client type.
*/
C(ClientTypeDescription.C_CLIENT),
/**
* CSharp client type.
*/
CSHARP(ClientTypeDescription.CSHARP_CLIENT),
/**
* php client type.
*/
@ -123,6 +127,8 @@ public class ClientInfo {
public static final String GO_CLIENT = "Nacos-Go-Client";
public static final String PHP_CLIENT = "Nacos-Php-Client";
public static final String CSHARP_CLIENT = "Nacos-CSharp-Client";
}
}