diff --git a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/ProviderConstants.java b/dubbo-common/src/main/java/org/apache/dubbo/common/constants/ProviderConstants.java
deleted file mode 100644
index e94540d328..0000000000
--- a/dubbo-common/src/main/java/org/apache/dubbo/common/constants/ProviderConstants.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.common.constants;
-
-/**
- * Provider Constants
- */
-public interface ProviderConstants {
-
- /**
- * Default prefer serialization,multiple separated by commas
- */
- String DEFAULT_PREFER_SERIALIZATION = "fastjson2,hessian2";
-}
diff --git a/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/util/XdsListener.java b/dubbo-common/src/main/java/org/apache/dubbo/common/serialization/PreferSerializationProvider.java
similarity index 80%
rename from dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/util/XdsListener.java
rename to dubbo-common/src/main/java/org/apache/dubbo/common/serialization/PreferSerializationProvider.java
index 233d92198a..ee97ba58ce 100644
--- a/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/util/XdsListener.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/common/serialization/PreferSerializationProvider.java
@@ -14,10 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.registry.xds.util;
+package org.apache.dubbo.common.serialization;
-import io.envoyproxy.envoy.service.discovery.v3.DiscoveryResponse;
-
-public interface XdsListener {
- void process(DiscoveryResponse discoveryResponse);
+public interface PreferSerializationProvider {
+ String getPreferSerialization();
}
diff --git a/dubbo-common/src/main/java/org/apache/dubbo/config/ProtocolConfig.java b/dubbo-common/src/main/java/org/apache/dubbo/config/ProtocolConfig.java
index eb358a79f7..1d0b5918a0 100644
--- a/dubbo-common/src/main/java/org/apache/dubbo/config/ProtocolConfig.java
+++ b/dubbo-common/src/main/java/org/apache/dubbo/config/ProtocolConfig.java
@@ -16,6 +16,7 @@
*/
package org.apache.dubbo.config;
+import org.apache.dubbo.common.serialization.PreferSerializationProvider;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.common.utils.StringUtils;
import org.apache.dubbo.config.support.Parameter;
@@ -30,7 +31,6 @@ import static org.apache.dubbo.common.constants.CommonConstants.JSON_CHECK_LEVEL
import static org.apache.dubbo.common.constants.CommonConstants.SSL_ENABLED_KEY;
import static org.apache.dubbo.common.constants.CommonConstants.THREAD_POOL_EXHAUSTED_LISTENERS_KEY;
import static org.apache.dubbo.common.constants.LoggerCodeConstants.COMMON_UNEXPECTED_EXCEPTION;
-import static org.apache.dubbo.common.constants.ProviderConstants.DEFAULT_PREFER_SERIALIZATION;
/**
* Configuration for the protocol.
@@ -270,7 +270,12 @@ public class ProtocolConfig extends AbstractConfig {
}
if (StringUtils.isBlank(preferSerialization)) {
- preferSerialization = serialization != null ? serialization : DEFAULT_PREFER_SERIALIZATION;
+ preferSerialization = serialization != null
+ ? serialization
+ : getScopeModel()
+ .getBeanFactory()
+ .getBean(PreferSerializationProvider.class)
+ .getPreferSerialization();
}
}
diff --git a/dubbo-common/src/test/java/org/apache/dubbo/config/context/ConfigManagerTest.java b/dubbo-common/src/test/java/org/apache/dubbo/config/context/ConfigManagerTest.java
index ae74fc11a4..bcccd7e133 100644
--- a/dubbo-common/src/test/java/org/apache/dubbo/config/context/ConfigManagerTest.java
+++ b/dubbo-common/src/test/java/org/apache/dubbo/config/context/ConfigManagerTest.java
@@ -16,6 +16,7 @@
*/
package org.apache.dubbo.config.context;
+import org.apache.dubbo.common.serialization.PreferSerializationProvider;
import org.apache.dubbo.common.utils.CollectionUtils;
import org.apache.dubbo.config.ApplicationConfig;
import org.apache.dubbo.config.ConfigCenterConfig;
@@ -27,6 +28,7 @@ import org.apache.dubbo.config.ProtocolConfig;
import org.apache.dubbo.config.ProviderConfig;
import org.apache.dubbo.config.RegistryConfig;
import org.apache.dubbo.rpc.model.ApplicationModel;
+import org.apache.dubbo.rpc.model.FrameworkModel;
import java.util.Collection;
import java.util.Optional;
@@ -64,6 +66,7 @@ class ConfigManagerTest {
ApplicationModel applicationModel = ApplicationModel.defaultModel();
configManager = applicationModel.getApplicationConfigManager();
moduleConfigManager = applicationModel.getDefaultModule().getConfigManager();
+ FrameworkModel.defaultModel().getBeanFactory().registerBean(TestPreferSerializationProvider.class);
}
@Test
@@ -474,4 +477,11 @@ class ConfigManagerTest {
Assertions.assertFalse(moduleConfigManager.getProviders().isEmpty());
Assertions.assertFalse(moduleConfigManager.getConsumers().isEmpty());
}
+
+ public static class TestPreferSerializationProvider implements PreferSerializationProvider {
+ @Override
+ public String getPreferSerialization() {
+ return "fastjson2,hessian2";
+ }
+ }
}
diff --git a/dubbo-compatible/src/test/java/org/apache/dubbo/generic/GenericServiceTest.java b/dubbo-compatible/src/test/java/org/apache/dubbo/generic/GenericServiceTest.java
index 26f99a6f2d..65200169ac 100644
--- a/dubbo-compatible/src/test/java/org/apache/dubbo/generic/GenericServiceTest.java
+++ b/dubbo-compatible/src/test/java/org/apache/dubbo/generic/GenericServiceTest.java
@@ -42,13 +42,13 @@ import java.util.Map;
import com.alibaba.dubbo.config.ReferenceConfig;
import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
class GenericServiceTest {
- @BeforeEach
- public void beforeEach() {
+ @BeforeAll
+ public static void beforeAll() {
DubboBootstrap.reset();
}
diff --git a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ProtocolConfigTest.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ProtocolConfigTest.java
index 686794ffa6..3c86651c6c 100644
--- a/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ProtocolConfigTest.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/ProtocolConfigTest.java
@@ -31,7 +31,6 @@ import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
-import static org.apache.dubbo.common.constants.ProviderConstants.DEFAULT_PREFER_SERIALIZATION;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.hasEntry;
@@ -43,6 +42,7 @@ class ProtocolConfigTest {
@BeforeEach
public void setUp() {
DubboBootstrap.reset();
+ // FrameworkModel.defaultModel().getBeanFactory().registerBean(TestPreferSerializationProvider.class);
}
@AfterEach
@@ -389,7 +389,7 @@ class ProtocolConfigTest {
assertNull(protocolConfig.getPreferSerialization());
protocolConfig.checkDefault();
- assertThat(protocolConfig.getPreferSerialization(), equalTo(DEFAULT_PREFER_SERIALIZATION));
+ assertThat(protocolConfig.getPreferSerialization(), equalTo("fastjson2,hessian2"));
protocolConfig = new ProtocolConfig();
protocolConfig.setSerialization("x-serialization");
@@ -405,7 +405,7 @@ class ProtocolConfigTest {
assertNull(protocolConfig.getPreferSerialization());
protocolConfig.refresh();
- assertThat(protocolConfig.getPreferSerialization(), equalTo(DEFAULT_PREFER_SERIALIZATION));
+ assertThat(protocolConfig.getPreferSerialization(), equalTo("fastjson2,hessian2"));
protocolConfig = new ProtocolConfig();
protocolConfig.setSerialization("x-serialization");
diff --git a/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/XdsInitializationException.java b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/utils/TestPreferSerializationProvider.java
similarity index 73%
rename from dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/XdsInitializationException.java
rename to dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/utils/TestPreferSerializationProvider.java
index 9a9b9a35ca..dd2d1f119f 100644
--- a/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/XdsInitializationException.java
+++ b/dubbo-config/dubbo-config-api/src/test/java/org/apache/dubbo/config/utils/TestPreferSerializationProvider.java
@@ -14,15 +14,13 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.registry.xds;
+package org.apache.dubbo.config.utils;
-public final class XdsInitializationException extends Exception {
+import org.apache.dubbo.common.serialization.PreferSerializationProvider;
- public XdsInitializationException(String message) {
- super(message);
- }
-
- public XdsInitializationException(String message, Throwable cause) {
- super(message, cause);
+public class TestPreferSerializationProvider implements PreferSerializationProvider {
+ @Override
+ public String getPreferSerialization() {
+ return "fastjson2,hessian2";
}
}
diff --git a/dubbo-configcenter/dubbo-configcenter-apollo/pom.xml b/dubbo-configcenter/dubbo-configcenter-apollo/pom.xml
index d561592e9c..5a709b40e8 100644
--- a/dubbo-configcenter/dubbo-configcenter-apollo/pom.xml
+++ b/dubbo-configcenter/dubbo-configcenter-apollo/pom.xml
@@ -30,7 +30,7 @@
The Apollo implementation of the configcenter api
false
- 2.1.0
+ 2.2.0
diff --git a/dubbo-dependencies-bom/pom.xml b/dubbo-dependencies-bom/pom.xml
index fb79bd584a..4121138d8e 100644
--- a/dubbo-dependencies-bom/pom.xml
+++ b/dubbo-dependencies-bom/pom.xml
@@ -101,7 +101,7 @@
4.5.14
4.4.16
1.2.83
- 2.0.42
+ 2.0.43
3.7.2
5.1.0
2.12.0
@@ -110,7 +110,7 @@
2.2.1
1.5.3
1.4.3
- 3.5.5
+ 3.6.2
0.19.0
4.0.66
3.25.1
@@ -126,10 +126,10 @@
4.0.3
0.45
2.57
- 1.11.1
+ 1.11.3
2.1.0
2.2
- 3.12.0
+ 3.14.0
1.8.0
0.1.35
1.12.0
@@ -146,12 +146,12 @@
2.1.1
3.15.6.Final
1.9.13
- 8.5.87
+ 8.5.96
0.7.6
2.2.4
1.8.6
1.6.1
- 1.59.0
+ 1.60.0
0.8.1
1.2.2
0.9.10
@@ -200,8 +200,8 @@
6.1.26
2.0
1.5.0
- 1.23.0
- 2.41.0
+ 1.25.0
+ 2.41.1
check
1.0.0
2.38.0
diff --git a/dubbo-dependencies/dubbo-dependencies-zookeeper-curator5/pom.xml b/dubbo-dependencies/dubbo-dependencies-zookeeper-curator5/pom.xml
index dbe8e646ab..0cf95672d5 100644
--- a/dubbo-dependencies/dubbo-dependencies-zookeeper-curator5/pom.xml
+++ b/dubbo-dependencies/dubbo-dependencies-zookeeper-curator5/pom.xml
@@ -36,7 +36,7 @@
1.7.36
5.1.0
3.8.3
- 2.41.0
+ 2.41.1
check
1.0.0
2.38.0
diff --git a/dubbo-dependencies/dubbo-dependencies-zookeeper/pom.xml b/dubbo-dependencies/dubbo-dependencies-zookeeper/pom.xml
index 62a3340084..ea2e35d93b 100644
--- a/dubbo-dependencies/dubbo-dependencies-zookeeper/pom.xml
+++ b/dubbo-dependencies/dubbo-dependencies-zookeeper/pom.xml
@@ -36,7 +36,7 @@
1.7.36
4.3.0
3.4.14
- 2.41.0
+ 2.41.1
check
1.0.0
2.38.0
diff --git a/dubbo-dependencies/pom.xml b/dubbo-dependencies/pom.xml
index 735560b9de..937fdb8fa0 100644
--- a/dubbo-dependencies/pom.xml
+++ b/dubbo-dependencies/pom.xml
@@ -32,7 +32,7 @@
- 2.41.0
+ 2.41.1
check
1.0.0
2.38.0
diff --git a/dubbo-distribution/dubbo-all/pom.xml b/dubbo-distribution/dubbo-all/pom.xml
index eaf6db3737..1faf586154 100644
--- a/dubbo-distribution/dubbo-all/pom.xml
+++ b/dubbo-distribution/dubbo-all/pom.xml
@@ -120,15 +120,6 @@
true
-
-
- org.apache.dubbo
- dubbo-kubernetes
- ${project.version}
- compile
- true
-
-
org.apache.dubbo
@@ -591,15 +582,6 @@
true
-
-
- org.apache.dubbo
- dubbo-xds
- ${project.version}
- compile
- true
-
-
org.springframework
@@ -718,8 +700,6 @@
org.apache.dubbo:dubbo-serialization-hessian2
org.apache.dubbo:dubbo-serialization-fastjson2
org.apache.dubbo:dubbo-serialization-jdk
- org.apache.dubbo:dubbo-kubernetes
- org.apache.dubbo:dubbo-xds
@@ -911,9 +891,6 @@
META-INF/dubbo/internal/org.apache.dubbo.registry.integration.RegistryProtocolListener
-
- META-INF/dubbo/internal/org.apache.dubbo.registry.xds.XdsCertificateSigner
-
META-INF/dubbo/internal/org.apache.dubbo.rpc.protocol.rest.filter.RestResponseInterceptor
diff --git a/dubbo-distribution/dubbo-apache-release/pom.xml b/dubbo-distribution/dubbo-apache-release/pom.xml
index d48ee13382..e0a301d6db 100644
--- a/dubbo-distribution/dubbo-apache-release/pom.xml
+++ b/dubbo-distribution/dubbo-apache-release/pom.xml
@@ -52,7 +52,7 @@
maven-assembly-plugin
- 3.5.0
+ 3.6.0
bin
diff --git a/dubbo-distribution/dubbo-bom/pom.xml b/dubbo-distribution/dubbo-bom/pom.xml
index 32e40b9a9e..0ea7de708f 100644
--- a/dubbo-distribution/dubbo-bom/pom.xml
+++ b/dubbo-distribution/dubbo-bom/pom.xml
@@ -180,13 +180,6 @@
${project.version}
-
-
- org.apache.dubbo
- dubbo-kubernetes
- ${project.version}
-
-
org.apache.dubbo
@@ -741,12 +734,6 @@
${project.version}
-
-
- org.apache.dubbo
- dubbo-xds
- ${project.version}
-
diff --git a/dubbo-distribution/dubbo-core-spi/pom.xml b/dubbo-distribution/dubbo-core-spi/pom.xml
index f65aa0b258..a11d6ee556 100644
--- a/dubbo-distribution/dubbo-core-spi/pom.xml
+++ b/dubbo-distribution/dubbo-core-spi/pom.xml
@@ -510,12 +510,6 @@
META-INF/dubbo/internal/org.apache.dubbo.registry.integration.RegistryProtocolListener
-
-
- META-INF/dubbo/internal/org.apache.dubbo.registry.xds.XdsCertificateSigner
-
-
diff --git a/dubbo-distribution/pom.xml b/dubbo-distribution/pom.xml
index e22311c0e0..0faaa05506 100644
--- a/dubbo-distribution/pom.xml
+++ b/dubbo-distribution/pom.xml
@@ -28,7 +28,7 @@
pom
- 2.41.0
+ 2.41.1
check
1.0.0
2.38.0
diff --git a/dubbo-kubernetes/pom.xml b/dubbo-kubernetes/pom.xml
deleted file mode 100644
index c8a99a6c42..0000000000
--- a/dubbo-kubernetes/pom.xml
+++ /dev/null
@@ -1,78 +0,0 @@
-
-
-
- 4.0.0
-
- org.apache.dubbo
- dubbo-parent
- ${revision}
- ../pom.xml
-
-
- dubbo-kubernetes
- ${project.artifactId}
- The Kubernetes Integration
-
- false
-
-
-
-
- org.apache.dubbo
- dubbo-registry-api
- ${project.parent.version}
-
-
- org.apache.dubbo
- dubbo-common
- ${project.parent.version}
-
-
- org.apache.dubbo
- dubbo-metadata-api
- ${project.parent.version}
-
-
- org.apache.dubbo
- dubbo-plugin-router-mesh
- ${project.parent.version}
-
-
- io.fabric8
- kubernetes-client
-
-
- io.fabric8
- kubernetes-server-mock
- test
-
-
- org.mockito
- mockito-junit-jupiter
- 3.12.4
- test
-
-
- org.junit.jupiter
- junit-jupiter-api
-
-
-
-
-
-
diff --git a/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/KubernetesMeshEnvListener.java b/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/KubernetesMeshEnvListener.java
deleted file mode 100644
index 43e79862fe..0000000000
--- a/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/KubernetesMeshEnvListener.java
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.registry.kubernetes;
-
-import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
-import org.apache.dubbo.common.logger.LoggerFactory;
-import org.apache.dubbo.rpc.cluster.router.mesh.route.MeshAppRuleListener;
-import org.apache.dubbo.rpc.cluster.router.mesh.route.MeshEnvListener;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import io.fabric8.kubernetes.api.model.GenericKubernetesResource;
-import io.fabric8.kubernetes.client.KubernetesClient;
-import io.fabric8.kubernetes.client.Watch;
-import io.fabric8.kubernetes.client.Watcher;
-import io.fabric8.kubernetes.client.WatcherException;
-import org.yaml.snakeyaml.LoaderOptions;
-import org.yaml.snakeyaml.Yaml;
-import org.yaml.snakeyaml.constructor.SafeConstructor;
-
-import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_ERROR_LISTEN_KUBERNETES;
-
-public class KubernetesMeshEnvListener implements MeshEnvListener {
- public static final ErrorTypeAwareLogger logger =
- LoggerFactory.getErrorTypeAwareLogger(KubernetesMeshEnvListener.class);
- private static volatile boolean usingApiServer = false;
- private static volatile KubernetesClient kubernetesClient;
- private static volatile String namespace;
-
- private final Map appRuleListenerMap = new ConcurrentHashMap<>();
-
- private final Map vsAppWatch = new ConcurrentHashMap<>();
- private final Map drAppWatch = new ConcurrentHashMap<>();
-
- private final Map vsAppCache = new ConcurrentHashMap<>();
- private final Map drAppCache = new ConcurrentHashMap<>();
-
- public static void injectKubernetesEnv(KubernetesClient client, String configuredNamespace) {
- usingApiServer = true;
- kubernetesClient = client;
- namespace = configuredNamespace;
- }
-
- @Override
- public boolean isEnable() {
- return usingApiServer;
- }
-
- @Override
- public void onSubscribe(String appName, MeshAppRuleListener listener) {
- appRuleListenerMap.put(appName, listener);
- logger.info("Subscribe Mesh Rule in Kubernetes. AppName: " + appName);
-
- // subscribe VisualService
- subscribeVs(appName);
-
- // subscribe DestinationRule
- subscribeDr(appName);
-
- // notify for start
- notifyOnce(appName);
- }
-
- private void subscribeVs(String appName) {
- if (vsAppWatch.containsKey(appName)) {
- return;
- }
-
- try {
- Watch watch = kubernetesClient
- .genericKubernetesResources(MeshConstant.getVsDefinition())
- .inNamespace(namespace)
- .withName(appName)
- .watch(new Watcher() {
- @Override
- public void eventReceived(Action action, GenericKubernetesResource resource) {
- if (logger.isInfoEnabled()) {
- logger.info("Received VS Rule notification. AppName: " + appName + " Action:" + action
- + " Resource:" + resource);
- }
-
- if (action == Action.ADDED || action == Action.MODIFIED) {
- String vsRule = new Yaml(new SafeConstructor(new LoaderOptions())).dump(resource);
- vsAppCache.put(appName, vsRule);
- if (drAppCache.containsKey(appName)) {
- notifyListener(vsRule, appName, drAppCache.get(appName));
- }
- } else {
- appRuleListenerMap.get(appName).receiveConfigInfo("");
- }
- }
-
- @Override
- public void onClose(WatcherException cause) {
- // ignore
- }
- });
- vsAppWatch.put(appName, watch);
- try {
- GenericKubernetesResource vsRule = kubernetesClient
- .genericKubernetesResources(MeshConstant.getVsDefinition())
- .inNamespace(namespace)
- .withName(appName)
- .get();
- vsAppCache.put(appName, new Yaml(new SafeConstructor(new LoaderOptions())).dump(vsRule));
- } catch (Throwable ignore) {
-
- }
- } catch (Exception e) {
- logger.error(REGISTRY_ERROR_LISTEN_KUBERNETES, "", "", "Error occurred when listen kubernetes crd.", e);
- }
- }
-
- private void notifyListener(String vsRule, String appName, String drRule) {
- String rule = vsRule + "\n---\n" + drRule;
- logger.info("Notify App Rule Listener. AppName: " + appName + " Rule:" + rule);
-
- appRuleListenerMap.get(appName).receiveConfigInfo(rule);
- }
-
- private void subscribeDr(String appName) {
- if (drAppWatch.containsKey(appName)) {
- return;
- }
-
- try {
- Watch watch = kubernetesClient
- .genericKubernetesResources(MeshConstant.getDrDefinition())
- .inNamespace(namespace)
- .withName(appName)
- .watch(new Watcher() {
- @Override
- public void eventReceived(Action action, GenericKubernetesResource resource) {
- if (logger.isInfoEnabled()) {
- logger.info("Received VS Rule notification. AppName: " + appName + " Action:" + action
- + " Resource:" + resource);
- }
-
- if (action == Action.ADDED || action == Action.MODIFIED) {
- String drRule = new Yaml(new SafeConstructor(new LoaderOptions())).dump(resource);
-
- drAppCache.put(appName, drRule);
- if (vsAppCache.containsKey(appName)) {
- notifyListener(vsAppCache.get(appName), appName, drRule);
- }
- } else {
- appRuleListenerMap.get(appName).receiveConfigInfo("");
- }
- }
-
- @Override
- public void onClose(WatcherException cause) {
- // ignore
- }
- });
- drAppWatch.put(appName, watch);
- try {
- GenericKubernetesResource drRule = kubernetesClient
- .genericKubernetesResources(MeshConstant.getDrDefinition())
- .inNamespace(namespace)
- .withName(appName)
- .get();
- drAppCache.put(appName, new Yaml(new SafeConstructor(new LoaderOptions())).dump(drRule));
- } catch (Throwable ignore) {
-
- }
- } catch (Exception e) {
- logger.error(REGISTRY_ERROR_LISTEN_KUBERNETES, "", "", "Error occurred when listen kubernetes crd.", e);
- }
- }
-
- private void notifyOnce(String appName) {
- if (vsAppCache.containsKey(appName) && drAppCache.containsKey(appName)) {
- notifyListener(vsAppCache.get(appName), appName, drAppCache.get(appName));
- }
- }
-
- @Override
- public void onUnSubscribe(String appName) {
- appRuleListenerMap.remove(appName);
-
- if (vsAppWatch.containsKey(appName)) {
- vsAppWatch.remove(appName).close();
- }
- vsAppCache.remove(appName);
-
- if (drAppWatch.containsKey(appName)) {
- drAppWatch.remove(appName).close();
- }
- drAppCache.remove(appName);
- }
-}
diff --git a/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/KubernetesMeshEnvListenerFactory.java b/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/KubernetesMeshEnvListenerFactory.java
deleted file mode 100644
index 9d1c6d06cf..0000000000
--- a/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/KubernetesMeshEnvListenerFactory.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.registry.kubernetes;
-
-import org.apache.dubbo.common.logger.Logger;
-import org.apache.dubbo.common.logger.LoggerFactory;
-import org.apache.dubbo.rpc.cluster.router.mesh.route.MeshEnvListener;
-import org.apache.dubbo.rpc.cluster.router.mesh.route.MeshEnvListenerFactory;
-
-import java.util.concurrent.atomic.AtomicBoolean;
-
-public class KubernetesMeshEnvListenerFactory implements MeshEnvListenerFactory {
- public static final Logger logger = LoggerFactory.getLogger(KubernetesMeshEnvListenerFactory.class);
- private final AtomicBoolean initialized = new AtomicBoolean(false);
- private MeshEnvListener listener = null;
-
- @Override
- public MeshEnvListener getListener() {
- try {
- if (initialized.compareAndSet(false, true)) {
- listener = new NopKubernetesMeshEnvListener();
- }
- } catch (Throwable t) {
- logger.info("Current Env not support Kubernetes.");
- }
- return listener;
- }
-}
diff --git a/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/KubernetesRegistry.java b/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/KubernetesRegistry.java
deleted file mode 100644
index 2d51c1bfa2..0000000000
--- a/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/KubernetesRegistry.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.registry.kubernetes;
-
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.registry.NotifyListener;
-import org.apache.dubbo.registry.support.FailbackRegistry;
-
-/**
- * Empty implements for Kubernetes
- * Kubernetes only support `Service Discovery` mode register
- * Used to compat past version like 2.6.x, 2.7.x with interface level register
- * {@link KubernetesServiceDiscovery} is the real implementation of Kubernetes
- */
-public class KubernetesRegistry extends FailbackRegistry {
- public KubernetesRegistry(URL url) {
- super(url);
- }
-
- @Override
- public boolean isAvailable() {
- return true;
- }
-
- @Override
- public void doRegister(URL url) {}
-
- @Override
- public void doUnregister(URL url) {}
-
- @Override
- public void doSubscribe(URL url, NotifyListener listener) {}
-
- @Override
- public void doUnsubscribe(URL url, NotifyListener listener) {}
-}
diff --git a/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/KubernetesRegistryFactory.java b/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/KubernetesRegistryFactory.java
deleted file mode 100644
index fe0e0477d7..0000000000
--- a/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/KubernetesRegistryFactory.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.registry.kubernetes;
-
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.registry.Registry;
-import org.apache.dubbo.registry.support.AbstractRegistryFactory;
-
-public class KubernetesRegistryFactory extends AbstractRegistryFactory {
-
- @Override
- protected String createRegistryCacheKey(URL url) {
- return url.toFullString();
- }
-
- @Override
- protected Registry createRegistry(URL url) {
- return new KubernetesRegistry(url);
- }
-}
diff --git a/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/KubernetesServiceDiscovery.java b/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/KubernetesServiceDiscovery.java
deleted file mode 100644
index 7792abdd2b..0000000000
--- a/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/KubernetesServiceDiscovery.java
+++ /dev/null
@@ -1,451 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.registry.kubernetes;
-
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
-import org.apache.dubbo.common.logger.LoggerFactory;
-import org.apache.dubbo.common.utils.JsonUtils;
-import org.apache.dubbo.common.utils.StringUtils;
-import org.apache.dubbo.registry.client.AbstractServiceDiscovery;
-import org.apache.dubbo.registry.client.DefaultServiceInstance;
-import org.apache.dubbo.registry.client.ServiceInstance;
-import org.apache.dubbo.registry.client.event.ServiceInstancesChangedEvent;
-import org.apache.dubbo.registry.client.event.listener.ServiceInstancesChangedListener;
-import org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst;
-import org.apache.dubbo.registry.kubernetes.util.KubernetesConfigUtils;
-import org.apache.dubbo.rpc.model.ApplicationModel;
-import org.apache.dubbo.rpc.model.ScopeModelUtil;
-
-import java.util.HashSet;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicLong;
-import java.util.stream.Collectors;
-
-import io.fabric8.kubernetes.api.model.EndpointAddress;
-import io.fabric8.kubernetes.api.model.EndpointPort;
-import io.fabric8.kubernetes.api.model.EndpointSubset;
-import io.fabric8.kubernetes.api.model.Endpoints;
-import io.fabric8.kubernetes.api.model.Pod;
-import io.fabric8.kubernetes.api.model.PodBuilder;
-import io.fabric8.kubernetes.api.model.Service;
-import io.fabric8.kubernetes.client.Config;
-import io.fabric8.kubernetes.client.KubernetesClient;
-import io.fabric8.kubernetes.client.KubernetesClientBuilder;
-import io.fabric8.kubernetes.client.informers.ResourceEventHandler;
-import io.fabric8.kubernetes.client.informers.SharedIndexInformer;
-
-import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_UNABLE_ACCESS_KUBERNETES;
-import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_UNABLE_FIND_SERVICE_KUBERNETES;
-import static org.apache.dubbo.common.constants.LoggerCodeConstants.REGISTRY_UNABLE_MATCH_KUBERNETES;
-
-public class KubernetesServiceDiscovery extends AbstractServiceDiscovery {
- private final ErrorTypeAwareLogger logger = LoggerFactory.getErrorTypeAwareLogger(getClass());
-
- private KubernetesClient kubernetesClient;
-
- private String currentHostname;
-
- private final URL registryURL;
-
- private final String namespace;
-
- private final boolean enableRegister;
-
- public static final String KUBERNETES_PROPERTIES_KEY = "io.dubbo/metadata";
-
- private static final ConcurrentHashMap SERVICE_UPDATE_TIME = new ConcurrentHashMap<>(64);
-
- private static final ConcurrentHashMap> SERVICE_INFORMER =
- new ConcurrentHashMap<>(64);
-
- private static final ConcurrentHashMap> PODS_INFORMER =
- new ConcurrentHashMap<>(64);
-
- private static final ConcurrentHashMap> ENDPOINTS_INFORMER =
- new ConcurrentHashMap<>(64);
-
- public KubernetesServiceDiscovery(ApplicationModel applicationModel, URL registryURL) {
- super(applicationModel, registryURL);
- Config config = KubernetesConfigUtils.createKubernetesConfig(registryURL);
- this.kubernetesClient = new KubernetesClientBuilder().withConfig(config).build();
- this.currentHostname = System.getenv("HOSTNAME");
- this.registryURL = registryURL;
- this.namespace = config.getNamespace();
- this.enableRegister = registryURL.getParameter(KubernetesClientConst.ENABLE_REGISTER, true);
-
- boolean availableAccess;
- try {
- availableAccess = kubernetesClient.pods().withName(currentHostname).get() != null;
- } catch (Throwable e) {
- availableAccess = false;
- }
- if (!availableAccess) {
- String message = "Unable to access api server. " + "Please check your url config."
- + " Master URL: "
- + config.getMasterUrl() + " Hostname: "
- + currentHostname;
- logger.error(REGISTRY_UNABLE_ACCESS_KUBERNETES, "", "", message);
- } else {
- KubernetesMeshEnvListener.injectKubernetesEnv(kubernetesClient, namespace);
- }
- }
-
- @Override
- public void doDestroy() {
- SERVICE_INFORMER.forEach((k, v) -> v.close());
- SERVICE_INFORMER.clear();
-
- PODS_INFORMER.forEach((k, v) -> v.close());
- PODS_INFORMER.clear();
-
- ENDPOINTS_INFORMER.forEach((k, v) -> v.close());
- ENDPOINTS_INFORMER.clear();
-
- kubernetesClient.close();
- }
-
- @Override
- public void doRegister(ServiceInstance serviceInstance) throws RuntimeException {
- if (enableRegister) {
- kubernetesClient
- .pods()
- .inNamespace(namespace)
- .withName(currentHostname)
- .edit(pod -> new PodBuilder(pod)
- .editOrNewMetadata()
- .addToAnnotations(
- KUBERNETES_PROPERTIES_KEY, JsonUtils.toJson(serviceInstance.getMetadata()))
- .endMetadata()
- .build());
- if (logger.isInfoEnabled()) {
- logger.info("Write Current Service Instance Metadata to Kubernetes pod. " + "Current pod name: "
- + currentHostname);
- }
- }
- }
-
- /**
- * Comparing to {@link AbstractServiceDiscovery#doUpdate(ServiceInstance, ServiceInstance)}, unregister() is unnecessary here.
- */
- @Override
- public void doUpdate(ServiceInstance oldServiceInstance, ServiceInstance newServiceInstance)
- throws RuntimeException {
- reportMetadata(newServiceInstance.getServiceMetadata());
- this.doRegister(newServiceInstance);
- }
-
- @Override
- public void doUnregister(ServiceInstance serviceInstance) throws RuntimeException {
- if (enableRegister) {
- kubernetesClient
- .pods()
- .inNamespace(namespace)
- .withName(currentHostname)
- .edit(pod -> new PodBuilder(pod)
- .editOrNewMetadata()
- .removeFromAnnotations(KUBERNETES_PROPERTIES_KEY)
- .endMetadata()
- .build());
- if (logger.isInfoEnabled()) {
- logger.info(
- "Remove Current Service Instance from Kubernetes pod. Current pod name: " + currentHostname);
- }
- }
- }
-
- @Override
- public Set getServices() {
- return kubernetesClient.services().inNamespace(namespace).list().getItems().stream()
- .map(service -> service.getMetadata().getName())
- .collect(Collectors.toSet());
- }
-
- @Override
- public List getInstances(String serviceName) throws NullPointerException {
- Endpoints endpoints = null;
- SharedIndexInformer endInformer = ENDPOINTS_INFORMER.get(serviceName);
- if (endInformer != null) {
- // get endpoints directly from informer local store
- List endpointsList = endInformer.getStore().list();
- if (endpointsList.size() > 0) {
- endpoints = endpointsList.get(0);
- }
- }
- if (endpoints == null) {
- endpoints = kubernetesClient
- .endpoints()
- .inNamespace(namespace)
- .withName(serviceName)
- .get();
- }
-
- return toServiceInstance(endpoints, serviceName);
- }
-
- @Override
- public void addServiceInstancesChangedListener(ServiceInstancesChangedListener listener)
- throws NullPointerException, IllegalArgumentException {
- listener.getServiceNames().forEach(serviceName -> {
- SERVICE_UPDATE_TIME.put(serviceName, new AtomicLong(0L));
-
- // Watch Service Endpoint Modification
- watchEndpoints(listener, serviceName);
-
- // Watch Pods Modification, happens when ServiceInstance updated
- watchPods(listener, serviceName);
-
- // Watch Service Modification, happens when Service Selector updated, used to update pods watcher
- watchService(listener, serviceName);
- });
- }
-
- private void watchEndpoints(ServiceInstancesChangedListener listener, String serviceName) {
- SharedIndexInformer endInformer = kubernetesClient
- .endpoints()
- .inNamespace(namespace)
- .withName(serviceName)
- .inform(new ResourceEventHandler() {
- @Override
- public void onAdd(Endpoints endpoints) {
- if (logger.isDebugEnabled()) {
- logger.debug("Received Endpoint Event. Event type: added. Current pod name: "
- + currentHostname + ". Endpoints is: " + endpoints);
- }
- notifyServiceChanged(serviceName, listener, toServiceInstance(endpoints, serviceName));
- }
-
- @Override
- public void onUpdate(Endpoints oldEndpoints, Endpoints newEndpoints) {
- if (logger.isDebugEnabled()) {
- logger.debug("Received Endpoint Event. Event type: updated. Current pod name: "
- + currentHostname + ". The new Endpoints is: " + newEndpoints);
- }
- notifyServiceChanged(serviceName, listener, toServiceInstance(newEndpoints, serviceName));
- }
-
- @Override
- public void onDelete(Endpoints endpoints, boolean deletedFinalStateUnknown) {
- if (logger.isDebugEnabled()) {
- logger.debug("Received Endpoint Event. Event type: deleted. Current pod name: "
- + currentHostname + ". Endpoints is: " + endpoints);
- }
- notifyServiceChanged(serviceName, listener, toServiceInstance(endpoints, serviceName));
- }
- });
-
- ENDPOINTS_INFORMER.put(serviceName, endInformer);
- }
-
- private void watchPods(ServiceInstancesChangedListener listener, String serviceName) {
- Map serviceSelector = getServiceSelector(serviceName);
- if (serviceSelector == null) {
- return;
- }
-
- SharedIndexInformer podInformer = kubernetesClient
- .pods()
- .inNamespace(namespace)
- .withLabels(serviceSelector)
- .inform(new ResourceEventHandler() {
- @Override
- public void onAdd(Pod pod) {
- if (logger.isDebugEnabled()) {
- logger.debug("Received Pods Event. Event type: added. Current pod name: " + currentHostname
- + ". Pod is: " + pod);
- }
- }
-
- @Override
- public void onUpdate(Pod oldPod, Pod newPod) {
- if (logger.isDebugEnabled()) {
- logger.debug("Received Pods Event. Event type: updated. Current pod name: "
- + currentHostname + ". new Pod is: " + newPod);
- }
-
- notifyServiceChanged(serviceName, listener, getInstances(serviceName));
- }
-
- @Override
- public void onDelete(Pod pod, boolean deletedFinalStateUnknown) {
- if (logger.isDebugEnabled()) {
- logger.debug("Received Pods Event. Event type: deleted. Current pod name: "
- + currentHostname + ". Pod is: " + pod);
- }
- }
- });
-
- PODS_INFORMER.put(serviceName, podInformer);
- }
-
- private void watchService(ServiceInstancesChangedListener listener, String serviceName) {
- SharedIndexInformer serviceInformer = kubernetesClient
- .services()
- .inNamespace(namespace)
- .withName(serviceName)
- .inform(new ResourceEventHandler() {
- @Override
- public void onAdd(Service service) {
- if (logger.isDebugEnabled()) {
- logger.debug("Received Service Added Event. " + "Current pod name: " + currentHostname);
- }
- }
-
- @Override
- public void onUpdate(Service oldService, Service newService) {
- if (logger.isDebugEnabled()) {
- logger.debug("Received Service Update Event. Update Pods Watcher. Current pod name: "
- + currentHostname + ". The new Service is: " + newService);
- }
- if (PODS_INFORMER.containsKey(serviceName)) {
- PODS_INFORMER.get(serviceName).close();
- PODS_INFORMER.remove(serviceName);
- }
- watchPods(listener, serviceName);
- }
-
- @Override
- public void onDelete(Service service, boolean deletedFinalStateUnknown) {
- if (logger.isDebugEnabled()) {
- logger.debug("Received Service Delete Event. " + "Current pod name: " + currentHostname);
- }
- }
- });
-
- SERVICE_INFORMER.put(serviceName, serviceInformer);
- }
-
- private void notifyServiceChanged(
- String serviceName, ServiceInstancesChangedListener listener, List serviceInstanceList) {
- long receivedTime = System.nanoTime();
-
- ServiceInstancesChangedEvent event;
-
- event = new ServiceInstancesChangedEvent(serviceName, serviceInstanceList);
-
- AtomicLong updateTime = SERVICE_UPDATE_TIME.get(serviceName);
- long lastUpdateTime = updateTime.get();
-
- if (lastUpdateTime <= receivedTime) {
- if (updateTime.compareAndSet(lastUpdateTime, receivedTime)) {
- listener.onEvent(event);
- return;
- }
- }
-
- if (logger.isInfoEnabled()) {
- logger.info("Discard Service Instance Data. "
- + "Possible Cause: Newer message has been processed or Failed to update time record by CAS. "
- + "Current Data received time: "
- + receivedTime + ". " + "Newer Data received time: "
- + lastUpdateTime + ".");
- }
- }
-
- @Override
- public URL getUrl() {
- return registryURL;
- }
-
- private Map getServiceSelector(String serviceName) {
- Service service = kubernetesClient
- .services()
- .inNamespace(namespace)
- .withName(serviceName)
- .get();
- if (service == null) {
- return null;
- }
- return service.getSpec().getSelector();
- }
-
- private List toServiceInstance(Endpoints endpoints, String serviceName) {
- Map serviceSelector = getServiceSelector(serviceName);
- if (serviceSelector == null) {
- return new LinkedList<>();
- }
- Map pods =
- kubernetesClient.pods().inNamespace(namespace).withLabels(serviceSelector).list().getItems().stream()
- .collect(Collectors.toMap(pod -> pod.getMetadata().getName(), pod -> pod));
-
- List instances = new LinkedList<>();
- Set instancePorts = new HashSet<>();
-
- for (EndpointSubset endpointSubset : endpoints.getSubsets()) {
- instancePorts.addAll(endpointSubset.getPorts().stream()
- .map(EndpointPort::getPort)
- .collect(Collectors.toSet()));
- }
-
- for (EndpointSubset endpointSubset : endpoints.getSubsets()) {
- for (EndpointAddress address : endpointSubset.getAddresses()) {
- Pod pod = pods.get(address.getTargetRef().getName());
- String ip = address.getIp();
- if (pod == null) {
- logger.warn(
- REGISTRY_UNABLE_MATCH_KUBERNETES,
- "",
- "",
- "Unable to match Kubernetes Endpoint address with Pod. " + "EndpointAddress Hostname: "
- + address.getTargetRef().getName());
- continue;
- }
- instancePorts.forEach(port -> {
- ServiceInstance serviceInstance = new DefaultServiceInstance(
- serviceName, ip, port, ScopeModelUtil.getApplicationModel(getUrl().getScopeModel()));
-
- String properties = pod.getMetadata().getAnnotations().get(KUBERNETES_PROPERTIES_KEY);
- if (StringUtils.isNotEmpty(properties)) {
- serviceInstance.getMetadata().putAll(JsonUtils.toJavaObject(properties, Map.class));
- instances.add(serviceInstance);
- } else {
- logger.warn(
- REGISTRY_UNABLE_FIND_SERVICE_KUBERNETES,
- "",
- "",
- "Unable to find Service Instance metadata in Pod Annotations. "
- + "Possibly cause: provider has not been initialized successfully. "
- + "EndpointAddress Hostname: "
- + address.getTargetRef().getName());
- }
- });
- }
- }
-
- return instances;
- }
-
- /**
- * UT used only
- */
- @Deprecated
- public void setCurrentHostname(String currentHostname) {
- this.currentHostname = currentHostname;
- }
-
- /**
- * UT used only
- */
- @Deprecated
- public void setKubernetesClient(KubernetesClient kubernetesClient) {
- this.kubernetesClient = kubernetesClient;
- }
-}
diff --git a/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/KubernetesServiceDiscoveryFactory.java b/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/KubernetesServiceDiscoveryFactory.java
deleted file mode 100644
index 7d11dfaaa8..0000000000
--- a/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/KubernetesServiceDiscoveryFactory.java
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.registry.kubernetes;
-
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.registry.client.AbstractServiceDiscoveryFactory;
-import org.apache.dubbo.registry.client.ServiceDiscovery;
-
-public class KubernetesServiceDiscoveryFactory extends AbstractServiceDiscoveryFactory {
- @Override
- protected ServiceDiscovery createDiscovery(URL registryURL) {
- return new KubernetesServiceDiscovery(applicationModel, registryURL);
- }
-}
diff --git a/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/MeshConstant.java b/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/MeshConstant.java
deleted file mode 100644
index e8b8f8407f..0000000000
--- a/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/MeshConstant.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.registry.kubernetes;
-
-import io.fabric8.kubernetes.client.dsl.base.CustomResourceDefinitionContext;
-
-public class MeshConstant {
- public static CustomResourceDefinitionContext getVsDefinition() {
- // TODO cache
- return new CustomResourceDefinitionContext.Builder()
- .withGroup("service.dubbo.apache.org")
- .withVersion("v1alpha1")
- .withScope("Namespaced")
- .withName("virtualservices.service.dubbo.apache.org")
- .withPlural("virtualservices")
- .withKind("VirtualService")
- .build();
- }
-
- public static CustomResourceDefinitionContext getDrDefinition() {
- // TODO cache
- return new CustomResourceDefinitionContext.Builder()
- .withGroup("service.dubbo.apache.org")
- .withVersion("v1alpha1")
- .withScope("Namespaced")
- .withName("destinationrules.service.dubbo.apache.org")
- .withPlural("destinationrules")
- .withKind("DestinationRule")
- .build();
- }
-}
diff --git a/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/NopKubernetesMeshEnvListener.java b/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/NopKubernetesMeshEnvListener.java
deleted file mode 100644
index 818b8df64d..0000000000
--- a/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/NopKubernetesMeshEnvListener.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.registry.kubernetes;
-
-import org.apache.dubbo.rpc.cluster.router.mesh.route.MeshAppRuleListener;
-import org.apache.dubbo.rpc.cluster.router.mesh.route.MeshEnvListener;
-
-public class NopKubernetesMeshEnvListener implements MeshEnvListener {
-
- @Override
- public boolean isEnable() {
- return false;
- }
-
- @Override
- public void onSubscribe(String appName, MeshAppRuleListener listener) {}
-
- @Override
- public void onUnSubscribe(String appName) {}
-}
diff --git a/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/util/KubernetesClientConst.java b/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/util/KubernetesClientConst.java
deleted file mode 100644
index b7ace53894..0000000000
--- a/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/util/KubernetesClientConst.java
+++ /dev/null
@@ -1,78 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.registry.kubernetes.util;
-
-public class KubernetesClientConst {
- public static final String DEFAULT_MASTER_PLACEHOLDER = "DEFAULT_MASTER_HOST";
- public static final String DEFAULT_MASTER_URL = "https://kubernetes.default.svc";
-
- public static final String ENABLE_REGISTER = "enableRegister";
-
- public static final String TRUST_CERTS = "trustCerts";
-
- public static final String USE_HTTPS = "useHttps";
-
- public static final String HTTP2_DISABLE = "http2Disable";
-
- public static final String NAMESPACE = "namespace";
-
- public static final String API_VERSION = "apiVersion";
-
- public static final String CA_CERT_FILE = "caCertFile";
-
- public static final String CA_CERT_DATA = "caCertData";
-
- public static final String CLIENT_CERT_FILE = "clientCertFile";
-
- public static final String CLIENT_CERT_DATA = "clientCertData";
-
- public static final String CLIENT_KEY_FILE = "clientKeyFile";
-
- public static final String CLIENT_KEY_DATA = "clientKeyData";
-
- public static final String CLIENT_KEY_ALGO = "clientKeyAlgo";
-
- public static final String CLIENT_KEY_PASSPHRASE = "clientKeyPassphrase";
-
- public static final String OAUTH_TOKEN = "oauthToken";
-
- public static final String USERNAME = "username";
-
- public static final String PASSWORD = "password";
-
- public static final String WATCH_RECONNECT_INTERVAL = "watchReconnectInterval";
-
- public static final String WATCH_RECONNECT_LIMIT = "watchReconnectLimit";
-
- public static final String CONNECTION_TIMEOUT = "connectionTimeout";
-
- public static final String REQUEST_TIMEOUT = "requestTimeout";
-
- public static final String ROLLING_TIMEOUT = "rollingTimeout";
-
- public static final String LOGGING_INTERVAL = "loggingInterval";
-
- public static final String HTTP_PROXY = "httpProxy";
-
- public static final String HTTPS_PROXY = "httpsProxy";
-
- public static final String PROXY_USERNAME = "proxyUsername";
-
- public static final String PROXY_PASSWORD = "proxyPassword";
-
- public static final String NO_PROXY = "noProxy";
-}
diff --git a/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/util/KubernetesConfigUtils.java b/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/util/KubernetesConfigUtils.java
deleted file mode 100644
index 332bb6e733..0000000000
--- a/dubbo-kubernetes/src/main/java/org/apache/dubbo/registry/kubernetes/util/KubernetesConfigUtils.java
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.registry.kubernetes.util;
-
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.common.utils.StringUtils;
-
-import java.util.Base64;
-
-import io.fabric8.kubernetes.client.Config;
-import io.fabric8.kubernetes.client.ConfigBuilder;
-
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.API_VERSION;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.CA_CERT_DATA;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.CA_CERT_FILE;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.CLIENT_CERT_DATA;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.CLIENT_CERT_FILE;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.CLIENT_KEY_ALGO;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.CLIENT_KEY_DATA;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.CLIENT_KEY_FILE;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.CLIENT_KEY_PASSPHRASE;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.CONNECTION_TIMEOUT;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.DEFAULT_MASTER_PLACEHOLDER;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.DEFAULT_MASTER_URL;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.HTTP2_DISABLE;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.HTTPS_PROXY;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.HTTP_PROXY;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.LOGGING_INTERVAL;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.NAMESPACE;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.NO_PROXY;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.OAUTH_TOKEN;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.PASSWORD;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.PROXY_PASSWORD;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.PROXY_USERNAME;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.REQUEST_TIMEOUT;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.TRUST_CERTS;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.USERNAME;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.USE_HTTPS;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.WATCH_RECONNECT_INTERVAL;
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.WATCH_RECONNECT_LIMIT;
-
-public class KubernetesConfigUtils {
-
- public static Config createKubernetesConfig(URL url) {
- // Init default config
- Config base = Config.autoConfigure(null);
-
- // replace config with parameters if presents
- return new ConfigBuilder(base) //
- .withMasterUrl(buildMasterUrl(url)) //
- .withApiVersion(url.getParameter(API_VERSION, base.getApiVersion())) //
- .withNamespace(url.getParameter(NAMESPACE, base.getNamespace())) //
- .withUsername(url.getParameter(USERNAME, base.getUsername())) //
- .withPassword(url.getParameter(PASSWORD, base.getPassword())) //
- .withOauthToken(url.getParameter(OAUTH_TOKEN, base.getOauthToken())) //
- .withCaCertFile(url.getParameter(CA_CERT_FILE, base.getCaCertFile())) //
- .withCaCertData(url.getParameter(CA_CERT_DATA, decodeBase64(base.getCaCertData()))) //
- .withClientKeyFile(url.getParameter(CLIENT_KEY_FILE, base.getClientKeyFile())) //
- .withClientKeyData(url.getParameter(CLIENT_KEY_DATA, decodeBase64(base.getClientKeyData()))) //
- .withClientCertFile(url.getParameter(CLIENT_CERT_FILE, base.getClientCertFile())) //
- .withClientCertData(url.getParameter(CLIENT_CERT_DATA, decodeBase64(base.getClientCertData()))) //
- .withClientKeyAlgo(url.getParameter(CLIENT_KEY_ALGO, base.getClientKeyAlgo())) //
- .withClientKeyPassphrase(url.getParameter(CLIENT_KEY_PASSPHRASE, base.getClientKeyPassphrase())) //
- .withConnectionTimeout(url.getParameter(CONNECTION_TIMEOUT, base.getConnectionTimeout())) //
- .withRequestTimeout(url.getParameter(REQUEST_TIMEOUT, base.getRequestTimeout())) //
- .withWatchReconnectInterval(
- url.getParameter(WATCH_RECONNECT_INTERVAL, base.getWatchReconnectInterval())) //
- .withWatchReconnectLimit(url.getParameter(WATCH_RECONNECT_LIMIT, base.getWatchReconnectLimit())) //
- .withLoggingInterval(url.getParameter(LOGGING_INTERVAL, base.getLoggingInterval())) //
- .withTrustCerts(url.getParameter(TRUST_CERTS, base.isTrustCerts())) //
- .withHttp2Disable(url.getParameter(HTTP2_DISABLE, base.isHttp2Disable())) //
- .withHttpProxy(url.getParameter(HTTP_PROXY, base.getHttpProxy())) //
- .withHttpsProxy(url.getParameter(HTTPS_PROXY, base.getHttpsProxy())) //
- .withProxyUsername(url.getParameter(PROXY_USERNAME, base.getProxyUsername())) //
- .withProxyPassword(url.getParameter(PROXY_PASSWORD, base.getProxyPassword())) //
- .withNoProxy(url.getParameter(NO_PROXY, base.getNoProxy())) //
- .build();
- }
-
- private static String buildMasterUrl(URL url) {
- if (DEFAULT_MASTER_PLACEHOLDER.equalsIgnoreCase(url.getHost())) {
- return DEFAULT_MASTER_URL;
- }
- return (url.getParameter(USE_HTTPS, true) ? "https://" : "http://") + url.getHost() + ":" + url.getPort();
- }
-
- private static String decodeBase64(String str) {
- return StringUtils.isNotEmpty(str) ? new String(Base64.getDecoder().decode(str)) : null;
- }
-}
diff --git a/dubbo-kubernetes/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.RegistryFactory b/dubbo-kubernetes/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.RegistryFactory
deleted file mode 100644
index 94177d81ea..0000000000
--- a/dubbo-kubernetes/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.RegistryFactory
+++ /dev/null
@@ -1 +0,0 @@
-kubernetes=org.apache.dubbo.registry.kubernetes.KubernetesRegistryFactory
\ No newline at end of file
diff --git a/dubbo-kubernetes/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.client.ServiceDiscoveryFactory b/dubbo-kubernetes/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.client.ServiceDiscoveryFactory
deleted file mode 100644
index 4301ab8b4b..0000000000
--- a/dubbo-kubernetes/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.registry.client.ServiceDiscoveryFactory
+++ /dev/null
@@ -1 +0,0 @@
-kubernetes=org.apache.dubbo.registry.kubernetes.KubernetesServiceDiscoveryFactory
\ No newline at end of file
diff --git a/dubbo-kubernetes/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.cluster.router.mesh.route.MeshEnvListenerFactory b/dubbo-kubernetes/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.cluster.router.mesh.route.MeshEnvListenerFactory
deleted file mode 100644
index 4dfae84b80..0000000000
--- a/dubbo-kubernetes/src/main/resources/META-INF/dubbo/internal/org.apache.dubbo.rpc.cluster.router.mesh.route.MeshEnvListenerFactory
+++ /dev/null
@@ -1 +0,0 @@
-kubernetes=org.apache.dubbo.registry.kubernetes.KubernetesMeshEnvListenerFactory
diff --git a/dubbo-kubernetes/src/test/java/org/apache/dubbo/registry/kubernetes/KubernetesServiceDiscoveryTest.java b/dubbo-kubernetes/src/test/java/org/apache/dubbo/registry/kubernetes/KubernetesServiceDiscoveryTest.java
deleted file mode 100644
index 6f47be6015..0000000000
--- a/dubbo-kubernetes/src/test/java/org/apache/dubbo/registry/kubernetes/KubernetesServiceDiscoveryTest.java
+++ /dev/null
@@ -1,289 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements. See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-package org.apache.dubbo.registry.kubernetes;
-
-import org.apache.dubbo.common.URL;
-import org.apache.dubbo.config.ApplicationConfig;
-import org.apache.dubbo.registry.client.DefaultServiceInstance;
-import org.apache.dubbo.registry.client.ServiceInstance;
-import org.apache.dubbo.registry.client.event.ServiceInstancesChangedEvent;
-import org.apache.dubbo.registry.client.event.listener.ServiceInstancesChangedListener;
-import org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst;
-import org.apache.dubbo.rpc.model.ApplicationModel;
-import org.apache.dubbo.rpc.model.ScopeModelUtil;
-
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-
-import io.fabric8.kubernetes.api.model.Endpoints;
-import io.fabric8.kubernetes.api.model.EndpointsBuilder;
-import io.fabric8.kubernetes.api.model.Pod;
-import io.fabric8.kubernetes.api.model.PodBuilder;
-import io.fabric8.kubernetes.api.model.Service;
-import io.fabric8.kubernetes.api.model.ServiceBuilder;
-import io.fabric8.kubernetes.client.Config;
-import io.fabric8.kubernetes.client.NamespacedKubernetesClient;
-import io.fabric8.kubernetes.client.server.mock.KubernetesServer;
-import org.junit.jupiter.api.AfterEach;
-import org.junit.jupiter.api.Assertions;
-import org.junit.jupiter.api.BeforeEach;
-import org.junit.jupiter.api.Test;
-import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.ArgumentCaptor;
-import org.mockito.Mockito;
-import org.mockito.junit.jupiter.MockitoExtension;
-
-import static org.apache.dubbo.registry.kubernetes.util.KubernetesClientConst.NAMESPACE;
-import static org.awaitility.Awaitility.await;
-
-@ExtendWith({MockitoExtension.class})
-class KubernetesServiceDiscoveryTest {
-
- private static final String SERVICE_NAME = "TestService";
-
- private static final String POD_NAME = "TestServer";
-
- public KubernetesServer mockServer = new KubernetesServer(false, true);
-
- private NamespacedKubernetesClient mockClient;
-
- private ServiceInstancesChangedListener mockListener = Mockito.mock(ServiceInstancesChangedListener.class);
-
- private URL serverUrl;
-
- private Map selector;
-
- private KubernetesServiceDiscovery serviceDiscovery;
-
- @BeforeEach
- public void setUp() {
- mockServer.before();
- mockClient = mockServer.getClient().inNamespace("dubbo-demo");
-
- ApplicationModel applicationModel = ApplicationModel.defaultModel();
- applicationModel.getApplicationConfigManager().setApplication(new ApplicationConfig());
-
- serverUrl = URL.valueOf(mockClient.getConfiguration().getMasterUrl())
- .setProtocol("kubernetes")
- .addParameter(NAMESPACE, "dubbo-demo")
- .addParameter(KubernetesClientConst.USE_HTTPS, "false")
- .addParameter(KubernetesClientConst.HTTP2_DISABLE, "true");
- serverUrl.setScopeModel(applicationModel);
-
- this.serviceDiscovery = new KubernetesServiceDiscovery(applicationModel, serverUrl);
-
- System.setProperty(Config.KUBERNETES_AUTH_TRYKUBECONFIG_SYSTEM_PROPERTY, "false");
- System.setProperty(Config.KUBERNETES_AUTH_TRYSERVICEACCOUNT_SYSTEM_PROPERTY, "false");
-
- selector = new HashMap<>(4);
- selector.put("l", "v");
- Pod pod = new PodBuilder()
- .withNewMetadata()
- .withName(POD_NAME)
- .withLabels(selector)
- .endMetadata()
- .build();
-
- Service service = new ServiceBuilder()
- .withNewMetadata()
- .withName(SERVICE_NAME)
- .endMetadata()
- .withNewSpec()
- .withSelector(selector)
- .endSpec()
- .build();
-
- Endpoints endPoints = new EndpointsBuilder()
- .withNewMetadata()
- .withName(SERVICE_NAME)
- .endMetadata()
- .addNewSubset()
- .addNewAddress()
- .withIp("ip1")
- .withNewTargetRef()
- .withUid("uid1")
- .withName(POD_NAME)
- .endTargetRef()
- .endAddress()
- .addNewPort("Test", "Test", 12345, "TCP")
- .endSubset()
- .build();
-
- mockClient.pods().resource(pod).create();
- mockClient.services().resource(service).create();
- mockClient.endpoints().resource(endPoints).create();
- }
-
- @AfterEach
- public void destroy() throws Exception {
- serviceDiscovery.destroy();
- mockClient.close();
- mockServer.after();
- }
-
- @Test
- void testEndpointsUpdate() {
- serviceDiscovery.setCurrentHostname(POD_NAME);
- serviceDiscovery.setKubernetesClient(mockClient);
-
- ServiceInstance serviceInstance = new DefaultServiceInstance(
- SERVICE_NAME,
- "Test",
- 12345,
- ScopeModelUtil.getApplicationModel(serviceDiscovery.getUrl().getScopeModel()));
-
- serviceDiscovery.doRegister(serviceInstance);
-
- HashSet serviceList = new HashSet<>(4);
- serviceList.add(SERVICE_NAME);
- Mockito.when(mockListener.getServiceNames()).thenReturn(serviceList);
- Mockito.doNothing().when(mockListener).onEvent(Mockito.any());
-
- serviceDiscovery.addServiceInstancesChangedListener(mockListener);
- mockClient.endpoints().withName(SERVICE_NAME).edit(endpoints -> new EndpointsBuilder(endpoints)
- .editFirstSubset()
- .addNewAddress()
- .withIp("ip2")
- .withNewTargetRef()
- .withUid("uid2")
- .withName(POD_NAME)
- .endTargetRef()
- .endAddress()
- .endSubset()
- .build());
-
- await().until(() -> {
- ArgumentCaptor captor =
- ArgumentCaptor.forClass(ServiceInstancesChangedEvent.class);
- Mockito.verify(mockListener, Mockito.atLeast(0)).onEvent(captor.capture());
- return captor.getValue().getServiceInstances().size() == 2;
- });
- ArgumentCaptor eventArgumentCaptor =
- ArgumentCaptor.forClass(ServiceInstancesChangedEvent.class);
- Mockito.verify(mockListener, Mockito.times(2)).onEvent(eventArgumentCaptor.capture());
- Assertions.assertEquals(
- 2, eventArgumentCaptor.getValue().getServiceInstances().size());
-
- serviceDiscovery.doUnregister(serviceInstance);
- }
-
- @Test
- void testPodsUpdate() throws Exception {
- serviceDiscovery.setCurrentHostname(POD_NAME);
- serviceDiscovery.setKubernetesClient(mockClient);
-
- ServiceInstance serviceInstance = new DefaultServiceInstance(
- SERVICE_NAME,
- "Test",
- 12345,
- ScopeModelUtil.getApplicationModel(serviceDiscovery.getUrl().getScopeModel()));
-
- serviceDiscovery.doRegister(serviceInstance);
-
- HashSet serviceList = new HashSet<>(4);
- serviceList.add(SERVICE_NAME);
- Mockito.when(mockListener.getServiceNames()).thenReturn(serviceList);
- Mockito.doNothing().when(mockListener).onEvent(Mockito.any());
-
- serviceDiscovery.addServiceInstancesChangedListener(mockListener);
-
- serviceInstance = new DefaultServiceInstance(
- SERVICE_NAME,
- "Test12345",
- 12345,
- ScopeModelUtil.getApplicationModel(serviceDiscovery.getUrl().getScopeModel()));
- serviceDiscovery.doUpdate(serviceInstance, serviceInstance);
-
- await().until(() -> {
- ArgumentCaptor captor =
- ArgumentCaptor.forClass(ServiceInstancesChangedEvent.class);
- Mockito.verify(mockListener, Mockito.atLeast(0)).onEvent(captor.capture());
- return captor.getValue().getServiceInstances().size() == 1;
- });
- ArgumentCaptor eventArgumentCaptor =
- ArgumentCaptor.forClass(ServiceInstancesChangedEvent.class);
- Mockito.verify(mockListener, Mockito.times(1)).onEvent(eventArgumentCaptor.capture());
- Assertions.assertEquals(
- 1, eventArgumentCaptor.getValue().getServiceInstances().size());
-
- serviceDiscovery.doUnregister(serviceInstance);
- }
-
- @Test
- void testServiceUpdate() {
- serviceDiscovery.setCurrentHostname(POD_NAME);
- serviceDiscovery.setKubernetesClient(mockClient);
-
- ServiceInstance serviceInstance = new DefaultServiceInstance(
- SERVICE_NAME,
- "Test",
- 12345,
- ScopeModelUtil.getApplicationModel(serviceDiscovery.getUrl().getScopeModel()));
-
- serviceDiscovery.doRegister(serviceInstance);
-
- HashSet serviceList = new HashSet<>(4);
- serviceList.add(SERVICE_NAME);
- Mockito.when(mockListener.getServiceNames()).thenReturn(serviceList);
- Mockito.doNothing().when(mockListener).onEvent(Mockito.any());
-
- serviceDiscovery.addServiceInstancesChangedListener(mockListener);
-
- selector.put("app", "test");
- mockClient.services().withName(SERVICE_NAME).edit(service -> new ServiceBuilder(service)
- .editSpec()
- .addToSelector(selector)
- .endSpec()
- .build());
-
- await().until(() -> {
- ArgumentCaptor captor =
- ArgumentCaptor.forClass(ServiceInstancesChangedEvent.class);
- Mockito.verify(mockListener, Mockito.atLeast(0)).onEvent(captor.capture());
- return captor.getValue().getServiceInstances().size() == 1;
- });
- ArgumentCaptor eventArgumentCaptor =
- ArgumentCaptor.forClass(ServiceInstancesChangedEvent.class);
- Mockito.verify(mockListener, Mockito.times(1)).onEvent(eventArgumentCaptor.capture());
- Assertions.assertEquals(
- 1, eventArgumentCaptor.getValue().getServiceInstances().size());
-
- serviceDiscovery.doUnregister(serviceInstance);
- }
-
- @Test
- void testGetInstance() {
- serviceDiscovery.setCurrentHostname(POD_NAME);
- serviceDiscovery.setKubernetesClient(mockClient);
-
- ServiceInstance serviceInstance = new DefaultServiceInstance(
- SERVICE_NAME,
- "Test",
- 12345,
- ScopeModelUtil.getApplicationModel(serviceDiscovery.getUrl().getScopeModel()));
-
- serviceDiscovery.doRegister(serviceInstance);
-
- serviceDiscovery.doUpdate(serviceInstance, serviceInstance);
-
- Assertions.assertEquals(1, serviceDiscovery.getServices().size());
- Assertions.assertEquals(1, serviceDiscovery.getInstances(SERVICE_NAME).size());
-
- serviceDiscovery.doUnregister(serviceInstance);
- }
-}
diff --git a/dubbo-kubernetes/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker b/dubbo-kubernetes/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
deleted file mode 100644
index ca6ee9cea8..0000000000
--- a/dubbo-kubernetes/src/test/resources/mockito-extensions/org.mockito.plugins.MockMaker
+++ /dev/null
@@ -1 +0,0 @@
-mock-maker-inline
\ No newline at end of file
diff --git a/dubbo-maven-plugin/pom.xml b/dubbo-maven-plugin/pom.xml
index 24dec2d1ac..bdb1e4a64a 100644
--- a/dubbo-maven-plugin/pom.xml
+++ b/dubbo-maven-plugin/pom.xml
@@ -42,14 +42,14 @@
org.apache.maven
maven-core
- 3.9.1
+ 3.9.6
provided
org.apache.maven.plugin-tools
maven-plugin-annotations
- 3.8.1
+ 3.10.2
provided
@@ -103,7 +103,7 @@
maven-plugin-plugin
- 3.8.1
+ 3.10.2
default-addPluginArtifactMetadata
diff --git a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/ssl/SslServerTlsHandler.java b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/ssl/SslServerTlsHandler.java
index 408b8915a6..519c45c6de 100644
--- a/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/ssl/SslServerTlsHandler.java
+++ b/dubbo-remoting/dubbo-remoting-netty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/ssl/SslServerTlsHandler.java
@@ -105,8 +105,7 @@ public class SslServerTlsHandler extends ByteToMessageDecoder {
url, channelHandlerContext.channel().remoteAddress());
if (providerConnectionConfig == null) {
- ChannelPipeline p = channelHandlerContext.pipeline();
- p.remove(this);
+ channelHandlerContext.pipeline().remove(this);
return;
}
@@ -117,8 +116,8 @@ public class SslServerTlsHandler extends ByteToMessageDecoder {
}
if (providerConnectionConfig.getAuthPolicy() == AuthPolicy.NONE) {
- ChannelPipeline p = channelHandlerContext.pipeline();
- p.remove(this);
+ channelHandlerContext.pipeline().remove(this);
+ return;
}
logger.error(INTERNAL_ERROR, "", "", "TLS negotiation failed when trying to accept new connection.");
diff --git a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/ReflectionPackableMethod.java b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/ReflectionPackableMethod.java
index d90eba24db..22d3ff956f 100644
--- a/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/ReflectionPackableMethod.java
+++ b/dubbo-rpc/dubbo-rpc-triple/src/main/java/org/apache/dubbo/rpc/protocol/tri/ReflectionPackableMethod.java
@@ -33,6 +33,7 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
import java.util.Collection;
import java.util.Iterator;
import java.util.stream.Stream;
@@ -73,18 +74,18 @@ public class ReflectionPackableMethod implements PackableMethod {
case CLIENT_STREAM:
case BI_STREAM:
actualRequestTypes = new Class>[] {
- (Class>)
- ((ParameterizedType) method.getMethod().getGenericReturnType()).getActualTypeArguments()[0]
+ obtainActualTypeInStreamObserver(
+ ((ParameterizedType) method.getMethod().getGenericReturnType()).getActualTypeArguments()[0])
};
- actualResponseType =
- (Class>) ((ParameterizedType) method.getMethod().getGenericParameterTypes()[0])
- .getActualTypeArguments()[0];
+ actualResponseType = obtainActualTypeInStreamObserver(
+ ((ParameterizedType) method.getMethod().getGenericParameterTypes()[0])
+ .getActualTypeArguments()[0]);
break;
case SERVER_STREAM:
actualRequestTypes = method.getMethod().getParameterTypes();
- actualResponseType =
- (Class>) ((ParameterizedType) method.getMethod().getGenericParameterTypes()[1])
- .getActualTypeArguments()[0];
+ actualResponseType = obtainActualTypeInStreamObserver(
+ ((ParameterizedType) method.getMethod().getGenericParameterTypes()[1])
+ .getActualTypeArguments()[0]);
break;
case UNARY:
actualRequestTypes = method.getParameterClasses();
@@ -291,6 +292,13 @@ public class ReflectionPackableMethod implements PackableMethod {
return serializeType;
}
+ static Class> obtainActualTypeInStreamObserver(Type typeInStreamObserver) {
+ return (Class>)
+ (typeInStreamObserver instanceof ParameterizedType
+ ? ((ParameterizedType) typeInStreamObserver).getRawType()
+ : typeInStreamObserver);
+ }
+
@Override
public Pack getRequestPack() {
return requestPack;
diff --git a/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/XdsEnv.java b/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/DataWrapper.java
similarity index 89%
rename from dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/XdsEnv.java
rename to dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/DataWrapper.java
index c09ea80877..0157cfb4ec 100644
--- a/dubbo-xds/src/main/java/org/apache/dubbo/registry/xds/XdsEnv.java
+++ b/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/DataWrapper.java
@@ -14,9 +14,8 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.registry.xds;
+package org.apache.dubbo.rpc.protocol.tri;
-public interface XdsEnv {
-
- String getCluster();
+public class DataWrapper {
+ public T data;
}
diff --git a/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/DescriptorService.java b/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/DescriptorService.java
index 7d93565c33..9457a951fa 100644
--- a/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/DescriptorService.java
+++ b/dubbo-rpc/dubbo-rpc-triple/src/test/java/org/apache/dubbo/rpc/protocol/tri/DescriptorService.java
@@ -68,6 +68,17 @@ public interface DescriptorService {
void sayHelloServerStream2(Object request, StreamObserver