This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch 3.0
in repository https://gitbox.apache.org/repos/asf/dubbo.git
The following commit(s) were added to refs/heads/3.0 by this push:
new 6a994ac Replace with ring for registry notification & suppress
property checker (#8282)
6a994ac is described below
commit 6a994ac9a6882ac6a70ceea642c72085e14fc085
Author: Albumen Kevin <[email protected]>
AuthorDate: Tue Jul 13 16:33:35 2021 +0800
Replace with ring for registry notification & suppress property checker
(#8282)
* Replace with ring for registry notification & suppress property checker
* FIX UT
---
.../manager/DefaultExecutorRepository.java | 27 ++++++++++++++--------
.../dubbo/config/utils/ConfigValidationUtils.java | 2 +-
.../apache/dubbo/config/AbstractConfigTest.java | 5 ++--
3 files changed, 22 insertions(+), 12 deletions(-)
diff --git
a/dubbo-common/src/main/java/org/apache/dubbo/common/threadpool/manager/DefaultExecutorRepository.java
b/dubbo-common/src/main/java/org/apache/dubbo/common/threadpool/manager/DefaultExecutorRepository.java
index 9ef1cd3..cc76257 100644
---
a/dubbo-common/src/main/java/org/apache/dubbo/common/threadpool/manager/DefaultExecutorRepository.java
+++
b/dubbo-common/src/main/java/org/apache/dubbo/common/threadpool/manager/DefaultExecutorRepository.java
@@ -62,11 +62,11 @@ public class DefaultExecutorRepository implements
ExecutorRepository {
private volatile ScheduledExecutorService exportReferExecutor;
- public ScheduledExecutorService registryNotificationExecutor;
-
private ScheduledExecutorService reconnectScheduledExecutor;
- private ScheduledExecutorService
serviceDiscoveryAddressNotificationExecutor;
+ public Ring<ScheduledExecutorService> registryNotificationExecutorRing =
new Ring<>();
+
+ private Ring<ScheduledExecutorService>
serviceDiscoveryAddressNotificationExecutorRing = new Ring<>();
private ScheduledExecutorService metadataRetryExecutor;
@@ -93,8 +93,17 @@ public class DefaultExecutorRepository implements
ExecutorRepository {
// reconnectScheduledExecutor =
Executors.newSingleThreadScheduledExecutor(new
NamedThreadFactory("Dubbo-reconnect-scheduler"));
poolRouterExecutor = new ThreadPoolExecutor(1, 10, 0L,
TimeUnit.MILLISECONDS, new LinkedBlockingQueue<Runnable>(1024),
new NamedInternalThreadFactory("Dubbo-state-router-pool-router",
true), new ThreadPoolExecutor.AbortPolicy());
- serviceDiscoveryAddressNotificationExecutor =
Executors.newSingleThreadScheduledExecutor(new
NamedThreadFactory("Dubbo-SD-address-refresh"));
- registryNotificationExecutor =
Executors.newSingleThreadScheduledExecutor(new
NamedThreadFactory("Dubbo-registry-notification"));
+
+ for (int i = 0; i < DEFAULT_SCHEDULER_SIZE; i++) {
+ ScheduledExecutorService
serviceDiscoveryAddressNotificationExecutor =
+ Executors.newSingleThreadScheduledExecutor(new
NamedThreadFactory("Dubbo-SD-address-refresh-" + i));
+ ScheduledExecutorService registryNotificationExecutor =
+ Executors.newSingleThreadScheduledExecutor(new
NamedThreadFactory("Dubbo-registry-notification-" + i));
+
+
serviceDiscoveryAddressNotificationExecutorRing.addItem(serviceDiscoveryAddressNotificationExecutor);
+
registryNotificationExecutorRing.addItem(registryNotificationExecutor);
+ }
+
metadataRetryExecutor = Executors.newSingleThreadScheduledExecutor(new
NamedThreadFactory("Dubbo-metadata-retry"));
}
@@ -235,11 +244,11 @@ public class DefaultExecutorRepository implements
ExecutorRepository {
@Override
public ScheduledExecutorService getRegistryNotificationExecutor() {
- return registryNotificationExecutor;
+ return registryNotificationExecutorRing.pollItem();
}
public ScheduledExecutorService
getServiceDiscoveryAddressNotificationExecutor() {
- return serviceDiscoveryAddressNotificationExecutor;
+ return serviceDiscoveryAddressNotificationExecutorRing.pollItem();
}
@Override
@@ -264,8 +273,8 @@ public class DefaultExecutorRepository implements
ExecutorRepository {
@Override
public void destroyAll() {
poolRouterExecutor.shutdown();
- serviceDiscoveryAddressNotificationExecutor.shutdown();
- registryNotificationExecutor.shutdown();
+// serviceDiscoveryAddressNotificationExecutor.shutdown();
+// registryNotificationExecutor.shutdown();
metadataRetryExecutor.shutdown();
shutdownExportReferExecutor();
diff --git
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/utils/ConfigValidationUtils.java
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/utils/ConfigValidationUtils.java
index 7f8ea5a..20c8e1a 100644
---
a/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/utils/ConfigValidationUtils.java
+++
b/dubbo-config/dubbo-config-api/src/main/java/org/apache/dubbo/config/utils/ConfigValidationUtils.java
@@ -707,7 +707,7 @@ public class ConfigValidationUtils {
if (pattern != null) {
Matcher matcher = pattern.matcher(value);
if (!matcher.matches()) {
- throw new IllegalStateException("Invalid " + property + "=\""
+ value + "\" contains illegal " +
+ logger.error("Invalid " + property + "=\"" + value + "\"
contains illegal " +
"character, only digit, letter, '-', '_' or '.' is
legal.");
}
}
diff --git
a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractConfigTest.java
b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractConfigTest.java
index a3dfe46..2cb5c78 100644
---
a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractConfigTest.java
+++
b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/AbstractConfigTest.java
@@ -23,6 +23,7 @@ import org.apache.dubbo.config.bootstrap.DubboBootstrap;
import org.apache.dubbo.config.support.Parameter;
import org.apache.dubbo.config.utils.ConfigValidationUtils;
import org.apache.dubbo.rpc.model.ApplicationModel;
+
import org.hamcrest.Matchers;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
@@ -229,7 +230,7 @@ public class AbstractConfigTest {
@Test
public void checkName() throws Exception {
- Assertions.assertThrows(IllegalStateException.class, () ->
ConfigValidationUtils.checkName("hello", "world%"));
+ Assertions.assertDoesNotThrow(() ->
ConfigValidationUtils.checkName("hello", "world%"));
}
@Test
@@ -279,9 +280,9 @@ public class AbstractConfigTest {
try {
ConfigValidationUtils.checkMethodName("hello", "0a");
- fail("the value should be illegal.");
} catch (Exception e) {
// ignore
+ fail("the value should be legal.");
}
}