You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by al...@apache.org on 2021/07/16 04:57:00 UTC
[dubbo-samples] branch master updated: Add Configuration Override
Support Check for 3.0 (#345)
This is an automated email from the ASF dual-hosted git repository.
albumenj pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/dubbo-samples.git
The following commit(s) were added to refs/heads/master by this push:
new 8193343 Add Configuration Override Support Check for 3.0 (#345)
8193343 is described below
commit 8193343b5f3adbcd7add36c6cd4b0f4651ea01ba
Author: Albumen Kevin <jh...@gmail.com>
AuthorDate: Fri Jul 16 12:56:49 2021 +0800
Add Configuration Override Support Check for 3.0 (#345)
---
.../case-versions.conf | 2 +-
.../dubbo-samples-applevel-override/pom.xml | 2 +-
.../dubbo/samples/governance/UpgradeUtil.java | 52 ++++++++++++++++++++++
.../src/main/resources/dubbo.properties | 4 +-
.../dubbo/samples/governance/DemoServiceIT.java | 44 +++++++++++++++++-
.../governance/FrameworkStatusReporterImpl.java | 44 ++++++++++++++++++
....common.status.reporter.FrameworkStatusReporter | 1 +
.../case-versions.conf | 2 +-
.../dubbo-samples-servicelevel-override/pom.xml | 2 +-
.../dubbo/samples/governance/UpgradeUtil.java | 52 ++++++++++++++++++++++
.../src/main/resources/dubbo.properties | 3 +-
...eIT.java => DemoServiceApplicationLevelIT.java} | 29 +++++++++---
...iceIT.java => DemoServiceInterfaceLevelIT.java} | 29 +++++++++---
.../governance/FrameworkStatusReporterImpl.java | 44 ++++++++++++++++++
....common.status.reporter.FrameworkStatusReporter | 1 +
15 files changed, 289 insertions(+), 22 deletions(-)
diff --git a/dubbo-samples-governance/dubbo-samples-applevel-override/case-versions.conf b/dubbo-samples-governance/dubbo-samples-applevel-override/case-versions.conf
index 0e26c8b..d718a9f 100644
--- a/dubbo-samples-governance/dubbo-samples-applevel-override/case-versions.conf
+++ b/dubbo-samples-governance/dubbo-samples-applevel-override/case-versions.conf
@@ -20,5 +20,5 @@
# Supported component versions of the test case
# Spring app
-dubbo.version=2.7*, 3.*
+dubbo.version=3.*
spring.version=4.*, 5.*
diff --git a/dubbo-samples-governance/dubbo-samples-applevel-override/pom.xml b/dubbo-samples-governance/dubbo-samples-applevel-override/pom.xml
index 6046b46..01ca7d4 100644
--- a/dubbo-samples-governance/dubbo-samples-applevel-override/pom.xml
+++ b/dubbo-samples-governance/dubbo-samples-applevel-override/pom.xml
@@ -31,7 +31,7 @@
<properties>
<source.level>1.8</source.level>
<target.level>1.8</target.level>
- <dubbo.version>2.7.7</dubbo.version>
+ <dubbo.version>3.0.1</dubbo.version>
<spring.version>4.3.16.RELEASE</spring.version>
<junit.version>4.12</junit.version>
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
diff --git a/dubbo-samples-governance/dubbo-samples-applevel-override/src/main/java/org/apache/dubbo/samples/governance/UpgradeUtil.java b/dubbo-samples-governance/dubbo-samples-applevel-override/src/main/java/org/apache/dubbo/samples/governance/UpgradeUtil.java
new file mode 100644
index 0000000..03b1379
--- /dev/null
+++ b/dubbo-samples-governance/dubbo-samples-applevel-override/src/main/java/org/apache/dubbo/samples/governance/UpgradeUtil.java
@@ -0,0 +1,52 @@
+/*
+ * 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.samples.governance;
+
+import org.apache.dubbo.common.config.configcenter.DynamicConfiguration;
+import org.apache.dubbo.rpc.model.ApplicationModel;
+
+public class UpgradeUtil {
+ private static final String DUBBO_SERVICEDISCOVERY_MIGRATION = "DUBBO_SERVICEDISCOVERY_MIGRATION";
+
+ public static void writeApplicationFirstRule(int proportion) {
+ String content = "step: APPLICATION_FIRST\r\n" +
+ "proportion: " + proportion;
+
+ String RULE_KEY = ApplicationModel.getName() + ".migration";
+ DynamicConfiguration configuration = ApplicationModel.getEnvironment().getDynamicConfiguration().get();
+ configuration.publishConfig(RULE_KEY, DUBBO_SERVICEDISCOVERY_MIGRATION, content);
+ }
+
+ public static void writeForceInterfaceRule() {
+ String content = "step: FORCE_INTERFACE\r\n" +
+ "force: true";
+
+ String RULE_KEY = ApplicationModel.getName() + ".migration";
+ DynamicConfiguration configuration = ApplicationModel.getEnvironment().getDynamicConfiguration().get();
+ configuration.publishConfig(RULE_KEY, DUBBO_SERVICEDISCOVERY_MIGRATION, content);
+ }
+
+ public static void writeForceApplicationRule() {
+ String content = "step: FORCE_APPLICATION\r\n" +
+ "force: true";
+
+ String RULE_KEY = ApplicationModel.getName() + ".migration";
+ DynamicConfiguration configuration = ApplicationModel.getEnvironment().getDynamicConfiguration().get();
+ configuration.publishConfig(RULE_KEY, DUBBO_SERVICEDISCOVERY_MIGRATION, content);
+ }
+
+}
diff --git a/dubbo-samples-governance/dubbo-samples-applevel-override/src/main/resources/dubbo.properties b/dubbo-samples-governance/dubbo-samples-applevel-override/src/main/resources/dubbo.properties
index 9e0c362..694674d 100644
--- a/dubbo-samples-governance/dubbo-samples-applevel-override/src/main/resources/dubbo.properties
+++ b/dubbo-samples-governance/dubbo-samples-applevel-override/src/main/resources/dubbo.properties
@@ -1,2 +1,2 @@
-dubbo.application.register-mode=interface
-dubbo.application.service-discovery.migration=FORCE_INTERFACE
\ No newline at end of file
+dubbo.application.register-mode=all
+dubbo.application.metadata.delay=10
\ No newline at end of file
diff --git a/dubbo-samples-governance/dubbo-samples-applevel-override/src/test/java/org/apache/dubbo/samples/governance/DemoServiceIT.java b/dubbo-samples-governance/dubbo-samples-applevel-override/src/test/java/org/apache/dubbo/samples/governance/DemoServiceIT.java
index 2e00cd0..cd05b04 100644
--- a/dubbo-samples-governance/dubbo-samples-applevel-override/src/test/java/org/apache/dubbo/samples/governance/DemoServiceIT.java
+++ b/dubbo-samples-governance/dubbo-samples-applevel-override/src/test/java/org/apache/dubbo/samples/governance/DemoServiceIT.java
@@ -42,7 +42,9 @@ public class DemoServiceIT {
}
@Test
- public void test20880() throws Exception {
+ public void test20880_interface() throws Exception {
+ UpgradeUtil.writeForceInterfaceRule();
+ checkIfNotified();
ZKTools.generateAppLevelOverride(100, 0);
Thread.sleep(5000);
for (int i = 0; i < 10; i++) {
@@ -53,7 +55,22 @@ public class DemoServiceIT {
}
@Test
- public void test20881() throws Exception {
+ public void test20880_application() throws Exception {
+ UpgradeUtil.writeForceApplicationRule();
+ checkIfNotified();
+ ZKTools.generateAppLevelOverride(100, 0);
+ Thread.sleep(5000);
+ for (int i = 0; i < 10; i++) {
+ String result = demoService.sayHello("world");
+ System.out.println(result);
+ Assert.assertTrue(result.contains("20880"));
+ }
+ }
+
+ @Test
+ public void test20881_interface() throws Exception {
+ UpgradeUtil.writeForceInterfaceRule();
+ checkIfNotified();
ZKTools.generateAppLevelOverride(0, 100);
Thread.sleep(5000);
for (int i = 0; i < 10; i++) {
@@ -62,4 +79,27 @@ public class DemoServiceIT {
Assert.assertTrue(result.contains("20881"));
}
}
+
+ @Test
+ public void test20881_application() throws Exception {
+ UpgradeUtil.writeForceApplicationRule();
+ checkIfNotified();
+ ZKTools.generateAppLevelOverride(0, 100);
+ Thread.sleep(5000);
+ for (int i = 0; i < 10; i++) {
+ String result = demoService.sayHello("world");
+ System.out.println(result);
+ Assert.assertTrue(result.contains("20881"));
+ }
+ }
+
+ private void checkIfNotified() throws InterruptedException {
+ for (int i = 0; i < 50; i++) {
+ if (FrameworkStatusReporterImpl.getReport().size() == 1) {
+ FrameworkStatusReporterImpl.clearReport();
+ return;
+ }
+ Thread.sleep(100);
+ }
+ }
}
diff --git a/dubbo-samples-governance/dubbo-samples-applevel-override/src/test/java/org/apache/dubbo/samples/governance/FrameworkStatusReporterImpl.java b/dubbo-samples-governance/dubbo-samples-applevel-override/src/test/java/org/apache/dubbo/samples/governance/FrameworkStatusReporterImpl.java
new file mode 100644
index 0000000..fd57ef9
--- /dev/null
+++ b/dubbo-samples-governance/dubbo-samples-applevel-override/src/test/java/org/apache/dubbo/samples/governance/FrameworkStatusReporterImpl.java
@@ -0,0 +1,44 @@
+/*
+ * 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.samples.governance;
+
+import org.apache.dubbo.common.status.reporter.FrameworkStatusReporter;
+
+import com.google.gson.Gson;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class FrameworkStatusReporterImpl implements FrameworkStatusReporter {
+ private static final Map<String, String> report = new HashMap<>();
+
+ @Override
+ public void report(String type, Object obj) {
+ if (obj instanceof String) {
+ Object group = new Gson().fromJson((String) obj, Map.class).get("group");
+ report.put((String) group, (String) obj);
+ }
+ }
+
+ public static Map<String, String> getReport() {
+ return report;
+ }
+
+ public static void clearReport() {
+ report.clear();
+ }
+}
diff --git a/dubbo-samples-governance/dubbo-samples-applevel-override/src/test/resources/META-INF.dubbo.internal/org.apache.dubbo.common.status.reporter.FrameworkStatusReporter b/dubbo-samples-governance/dubbo-samples-applevel-override/src/test/resources/META-INF.dubbo.internal/org.apache.dubbo.common.status.reporter.FrameworkStatusReporter
new file mode 100644
index 0000000..98a8d9f
--- /dev/null
+++ b/dubbo-samples-governance/dubbo-samples-applevel-override/src/test/resources/META-INF.dubbo.internal/org.apache.dubbo.common.status.reporter.FrameworkStatusReporter
@@ -0,0 +1 @@
+test = org.apache.dubbo.demo.consumer.FrameworkStatusReporterImpl
\ No newline at end of file
diff --git a/dubbo-samples-governance/dubbo-samples-servicelevel-override/case-versions.conf b/dubbo-samples-governance/dubbo-samples-servicelevel-override/case-versions.conf
index 0e26c8b..d718a9f 100644
--- a/dubbo-samples-governance/dubbo-samples-servicelevel-override/case-versions.conf
+++ b/dubbo-samples-governance/dubbo-samples-servicelevel-override/case-versions.conf
@@ -20,5 +20,5 @@
# Supported component versions of the test case
# Spring app
-dubbo.version=2.7*, 3.*
+dubbo.version=3.*
spring.version=4.*, 5.*
diff --git a/dubbo-samples-governance/dubbo-samples-servicelevel-override/pom.xml b/dubbo-samples-governance/dubbo-samples-servicelevel-override/pom.xml
index fc9dc57..c7acb56 100644
--- a/dubbo-samples-governance/dubbo-samples-servicelevel-override/pom.xml
+++ b/dubbo-samples-governance/dubbo-samples-servicelevel-override/pom.xml
@@ -31,7 +31,7 @@
<properties>
<source.level>1.8</source.level>
<target.level>1.8</target.level>
- <dubbo.version>2.7.7</dubbo.version>
+ <dubbo.version>3.0.1</dubbo.version>
<spring.version>4.3.16.RELEASE</spring.version>
<junit.version>4.12</junit.version>
<maven-compiler-plugin.version>3.7.0</maven-compiler-plugin.version>
diff --git a/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/main/java/org/apache/dubbo/samples/governance/UpgradeUtil.java b/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/main/java/org/apache/dubbo/samples/governance/UpgradeUtil.java
new file mode 100644
index 0000000..03b1379
--- /dev/null
+++ b/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/main/java/org/apache/dubbo/samples/governance/UpgradeUtil.java
@@ -0,0 +1,52 @@
+/*
+ * 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.samples.governance;
+
+import org.apache.dubbo.common.config.configcenter.DynamicConfiguration;
+import org.apache.dubbo.rpc.model.ApplicationModel;
+
+public class UpgradeUtil {
+ private static final String DUBBO_SERVICEDISCOVERY_MIGRATION = "DUBBO_SERVICEDISCOVERY_MIGRATION";
+
+ public static void writeApplicationFirstRule(int proportion) {
+ String content = "step: APPLICATION_FIRST\r\n" +
+ "proportion: " + proportion;
+
+ String RULE_KEY = ApplicationModel.getName() + ".migration";
+ DynamicConfiguration configuration = ApplicationModel.getEnvironment().getDynamicConfiguration().get();
+ configuration.publishConfig(RULE_KEY, DUBBO_SERVICEDISCOVERY_MIGRATION, content);
+ }
+
+ public static void writeForceInterfaceRule() {
+ String content = "step: FORCE_INTERFACE\r\n" +
+ "force: true";
+
+ String RULE_KEY = ApplicationModel.getName() + ".migration";
+ DynamicConfiguration configuration = ApplicationModel.getEnvironment().getDynamicConfiguration().get();
+ configuration.publishConfig(RULE_KEY, DUBBO_SERVICEDISCOVERY_MIGRATION, content);
+ }
+
+ public static void writeForceApplicationRule() {
+ String content = "step: FORCE_APPLICATION\r\n" +
+ "force: true";
+
+ String RULE_KEY = ApplicationModel.getName() + ".migration";
+ DynamicConfiguration configuration = ApplicationModel.getEnvironment().getDynamicConfiguration().get();
+ configuration.publishConfig(RULE_KEY, DUBBO_SERVICEDISCOVERY_MIGRATION, content);
+ }
+
+}
diff --git a/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/main/resources/dubbo.properties b/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/main/resources/dubbo.properties
index 9e0c362..339a589 100644
--- a/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/main/resources/dubbo.properties
+++ b/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/main/resources/dubbo.properties
@@ -1,2 +1 @@
-dubbo.application.register-mode=interface
-dubbo.application.service-discovery.migration=FORCE_INTERFACE
\ No newline at end of file
+dubbo.application.register-mode=all
diff --git a/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/test/java/org/apache/dubbo/samples/governance/DemoServiceIT.java b/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/test/java/org/apache/dubbo/samples/governance/DemoServiceApplicationLevelIT.java
similarity index 76%
copy from dubbo-samples-governance/dubbo-samples-servicelevel-override/src/test/java/org/apache/dubbo/samples/governance/DemoServiceIT.java
copy to dubbo-samples-governance/dubbo-samples-servicelevel-override/src/test/java/org/apache/dubbo/samples/governance/DemoServiceApplicationLevelIT.java
index 699425e..6df2261 100644
--- a/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/test/java/org/apache/dubbo/samples/governance/DemoServiceIT.java
+++ b/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/test/java/org/apache/dubbo/samples/governance/DemoServiceApplicationLevelIT.java
@@ -32,7 +32,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:/spring/dubbo-demo-consumer.xml"})
-public class DemoServiceIT {
+public class DemoServiceApplicationLevelIT {
@Autowired
private DemoService demoService;
@@ -41,42 +41,59 @@ public class DemoServiceIT {
ZKTools.initClient();
}
+ private static boolean init = false;
+
@Before
public void cleanAllRules() throws Exception {
+ if(!init) {
+ UpgradeUtil.writeForceApplicationRule();
+ checkIfNotified();
+ init = true;
+ }
ZKTools.cleanup();
}
@Test(expected = RpcException.class)
public void testWithoutRule() throws Exception {
Thread.sleep(2000);
- demoService.sayHello("world", 3000);
+ demoService.sayHello("world", 1500);
}
@Test(expected = RpcException.class)
public void testWithServiceRuleWithInsufficientTimeout() throws Exception {
ZKTools.generateServiceLevelOverride(600);
Thread.sleep(2000);
- demoService.sayHello("world", 1000);
+ demoService.sayHello("world", 800);
}
@Test
public void testWithServiceRuleWithSufficientTimeout() throws Exception {
ZKTools.generateServiceLevelOverride(6000);
Thread.sleep(2000);
- Assert.assertTrue(demoService.sayHello("world", 1000).startsWith("Hello world"));
+ Assert.assertTrue(demoService.sayHello("world", 1200).startsWith("Hello world"));
}
@Test(expected = RpcException.class)
public void testWithAppRuleWithInsufficientTimeout() throws Exception {
ZKTools.generateApplicationLevelOverride(600);
Thread.sleep(2000);
- demoService.sayHello("world", 1000);
+ demoService.sayHello("world", 800);
}
@Test
public void testWithAppRuleWithSufficientTimeout() throws Exception {
ZKTools.generateApplicationLevelOverride(6000);
Thread.sleep(2000);
- Assert.assertTrue(demoService.sayHello("world", 1000).startsWith("Hello world"));
+ Assert.assertTrue(demoService.sayHello("world", 1200).startsWith("Hello world"));
+ }
+
+ private static void checkIfNotified() throws InterruptedException {
+ for (int i = 0; i < 50; i++) {
+ if (FrameworkStatusReporterImpl.getReport().size() == 1) {
+ FrameworkStatusReporterImpl.clearReport();
+ return;
+ }
+ Thread.sleep(100);
+ }
}
}
diff --git a/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/test/java/org/apache/dubbo/samples/governance/DemoServiceIT.java b/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/test/java/org/apache/dubbo/samples/governance/DemoServiceInterfaceLevelIT.java
similarity index 76%
rename from dubbo-samples-governance/dubbo-samples-servicelevel-override/src/test/java/org/apache/dubbo/samples/governance/DemoServiceIT.java
rename to dubbo-samples-governance/dubbo-samples-servicelevel-override/src/test/java/org/apache/dubbo/samples/governance/DemoServiceInterfaceLevelIT.java
index 699425e..7be3e1a 100644
--- a/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/test/java/org/apache/dubbo/samples/governance/DemoServiceIT.java
+++ b/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/test/java/org/apache/dubbo/samples/governance/DemoServiceInterfaceLevelIT.java
@@ -32,7 +32,7 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = {"classpath:/spring/dubbo-demo-consumer.xml"})
-public class DemoServiceIT {
+public class DemoServiceInterfaceLevelIT {
@Autowired
private DemoService demoService;
@@ -41,42 +41,59 @@ public class DemoServiceIT {
ZKTools.initClient();
}
+ private static boolean init = false;
+
@Before
public void cleanAllRules() throws Exception {
+ if(!init) {
+ UpgradeUtil.writeForceInterfaceRule();
+ checkIfNotified();
+ init = true;
+ }
ZKTools.cleanup();
}
@Test(expected = RpcException.class)
public void testWithoutRule() throws Exception {
Thread.sleep(2000);
- demoService.sayHello("world", 3000);
+ demoService.sayHello("world", 1200);
}
@Test(expected = RpcException.class)
public void testWithServiceRuleWithInsufficientTimeout() throws Exception {
ZKTools.generateServiceLevelOverride(600);
Thread.sleep(2000);
- demoService.sayHello("world", 1000);
+ demoService.sayHello("world", 800);
}
@Test
public void testWithServiceRuleWithSufficientTimeout() throws Exception {
ZKTools.generateServiceLevelOverride(6000);
Thread.sleep(2000);
- Assert.assertTrue(demoService.sayHello("world", 1000).startsWith("Hello world"));
+ Assert.assertTrue(demoService.sayHello("world", 1200).startsWith("Hello world"));
}
@Test(expected = RpcException.class)
public void testWithAppRuleWithInsufficientTimeout() throws Exception {
ZKTools.generateApplicationLevelOverride(600);
Thread.sleep(2000);
- demoService.sayHello("world", 1000);
+ demoService.sayHello("world", 800);
}
@Test
public void testWithAppRuleWithSufficientTimeout() throws Exception {
ZKTools.generateApplicationLevelOverride(6000);
Thread.sleep(2000);
- Assert.assertTrue(demoService.sayHello("world", 1000).startsWith("Hello world"));
+ Assert.assertTrue(demoService.sayHello("world", 1200).startsWith("Hello world"));
+ }
+
+ private static void checkIfNotified() throws InterruptedException {
+ for (int i = 0; i < 50; i++) {
+ if (FrameworkStatusReporterImpl.getReport().size() == 1) {
+ FrameworkStatusReporterImpl.clearReport();
+ return;
+ }
+ Thread.sleep(100);
+ }
}
}
diff --git a/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/test/java/org/apache/dubbo/samples/governance/FrameworkStatusReporterImpl.java b/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/test/java/org/apache/dubbo/samples/governance/FrameworkStatusReporterImpl.java
new file mode 100644
index 0000000..fd57ef9
--- /dev/null
+++ b/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/test/java/org/apache/dubbo/samples/governance/FrameworkStatusReporterImpl.java
@@ -0,0 +1,44 @@
+/*
+ * 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.samples.governance;
+
+import org.apache.dubbo.common.status.reporter.FrameworkStatusReporter;
+
+import com.google.gson.Gson;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class FrameworkStatusReporterImpl implements FrameworkStatusReporter {
+ private static final Map<String, String> report = new HashMap<>();
+
+ @Override
+ public void report(String type, Object obj) {
+ if (obj instanceof String) {
+ Object group = new Gson().fromJson((String) obj, Map.class).get("group");
+ report.put((String) group, (String) obj);
+ }
+ }
+
+ public static Map<String, String> getReport() {
+ return report;
+ }
+
+ public static void clearReport() {
+ report.clear();
+ }
+}
diff --git a/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/test/resources/META-INF.dubbo.internal/org.apache.dubbo.common.status.reporter.FrameworkStatusReporter b/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/test/resources/META-INF.dubbo.internal/org.apache.dubbo.common.status.reporter.FrameworkStatusReporter
new file mode 100644
index 0000000..98a8d9f
--- /dev/null
+++ b/dubbo-samples-governance/dubbo-samples-servicelevel-override/src/test/resources/META-INF.dubbo.internal/org.apache.dubbo.common.status.reporter.FrameworkStatusReporter
@@ -0,0 +1 @@
+test = org.apache.dubbo.demo.consumer.FrameworkStatusReporterImpl
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org