This is an automated email from the ASF dual-hosted git repository.
liujun 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 0b58483f feat: Support extensibility router task (#739)
0b58483f is described below
commit 0b58483f814f806690650ce0bc289189417c5236
Author: Pin Xiong <[email protected]>
AuthorDate: Fri Feb 17 21:36:31 2023 +0800
feat: Support extensibility router task (#739)
refer to issue #716
---
10-task/dubbo-samples-extensibility/deploy/All.yml | 55 ++++++++++-
.../deploy/router/Deployment.yml | 65 +++++++++++++
.../pom.xml | 21 ++--
.../router/api/ExtensibilityRouterService.java | 22 +++++
.../pom.xml | 108 +++++++++++++++++++++
.../ExtensibilityRouterConsumerApplication.java | 27 ++++++
.../consumer/ExtensibilityRouterConsumerTask.java | 33 +++++++
.../consumer/router/StickFirstStateRouter.java | 81 ++++++++++++++++
.../router/StickFirstStateRouterFactory.java | 28 ++++++
...bbo.rpc.cluster.router.state.StateRouterFactory | 1 +
.../src/main/resources/application.properties | 26 +++++
.../pom.xml | 107 ++++++++++++++++++++
.../ExtensibilityRouterProviderApplication.java | 29 ++++++
.../provider/ExtensibilityRouterServiceImpl.java | 29 ++++++
.../src/main/resources/application.properties | 27 ++++++
10-task/dubbo-samples-extensibility/pom.xml | 3 +
16 files changed, 649 insertions(+), 13 deletions(-)
diff --git a/10-task/dubbo-samples-extensibility/deploy/All.yml
b/10-task/dubbo-samples-extensibility/deploy/All.yml
index d49c8b92..b58643a3 100644
--- a/10-task/dubbo-samples-extensibility/deploy/All.yml
+++ b/10-task/dubbo-samples-extensibility/deploy/All.yml
@@ -85,7 +85,7 @@ spec:
targetPort: 9848
---
-# Provider
+# Filter Provider
apiVersion: apps/v1
kind: Deployment
metadata:
@@ -111,7 +111,7 @@ spec:
protocol: TCP
---
-# Consumer
+# Filter Consumer
apiVersion: apps/v1
kind: Deployment
metadata:
@@ -131,6 +131,57 @@ spec:
- name: consumer
image:
apache/dubbo-demo:dubbo-samples-extensibility-filter-consumer_0.0.1
imagePullPolicy: Always
+ ports:
+ - name: dubbo
+ containerPort: 20880
+ protocol: TCP
+---
+# Router Provider
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: dubbo-samples-extensibility-router-provider
+ namespace: dubbo-demo
+spec:
+ replicas: 2
+ selector:
+ matchLabels:
+ app: dubbo-samples-extensibility-router-provider
+ template:
+ metadata:
+ labels:
+ app: dubbo-samples-extensibility-router-provider
+ spec:
+ containers:
+ - name: consumer
+ image:
apache/dubbo-demo:dubbo-samples-extensibility-router-provider_0.0.1
+ imagePullPolicy: Always
+ ports:
+ - name: dubbo
+ containerPort: 20880
+ protocol: TCP
+---
+
+# Router Consumer
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: dubbo-samples-extensibility-router-consumer
+ namespace: dubbo-demo
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: dubbo-samples-extensibility-router-consumer
+ template:
+ metadata:
+ labels:
+ app: dubbo-samples-extensibility-router-consumer
+ spec:
+ containers:
+ - name: consumer
+ image:
apache/dubbo-demo:dubbo-samples-extensibility-router-consumer_0.0.1
+ imagePullPolicy: Always
ports:
- name: dubbo
containerPort: 20880
diff --git a/10-task/dubbo-samples-extensibility/deploy/router/Deployment.yml
b/10-task/dubbo-samples-extensibility/deploy/router/Deployment.yml
new file mode 100644
index 00000000..097d5fbb
--- /dev/null
+++ b/10-task/dubbo-samples-extensibility/deploy/router/Deployment.yml
@@ -0,0 +1,65 @@
+# 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.
+
+# Provider
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: dubbo-samples-extensibility-router-provider
+ namespace: dubbo-demo
+spec:
+ replicas: 2
+ selector:
+ matchLabels:
+ app: dubbo-samples-extensibility-router-provider
+ template:
+ metadata:
+ labels:
+ app: dubbo-samples-extensibility-router-provider
+ spec:
+ containers:
+ - name: consumer
+ image:
apache/dubbo-demo:dubbo-samples-extensibility-router-provider_0.0.1
+ imagePullPolicy: Always
+ ports:
+ - name: dubbo
+ containerPort: 20880
+ protocol: TCP
+---
+
+# Consumer
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: dubbo-samples-extensibility-router-consumer
+ namespace: dubbo-demo
+spec:
+ replicas: 1
+ selector:
+ matchLabels:
+ app: dubbo-samples-extensibility-router-consumer
+ template:
+ metadata:
+ labels:
+ app: dubbo-samples-extensibility-router-consumer
+ spec:
+ containers:
+ - name: consumer
+ image:
apache/dubbo-demo:dubbo-samples-extensibility-router-consumer_0.0.1
+ imagePullPolicy: Always
+ ports:
+ - name: dubbo
+ containerPort: 20880
+ protocol: TCP
\ No newline at end of file
diff --git a/10-task/dubbo-samples-extensibility/pom.xml
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-api/pom.xml
similarity index 71%
copy from 10-task/dubbo-samples-extensibility/pom.xml
copy to
10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-api/pom.xml
index 02617715..6cc7399e 100644
--- a/10-task/dubbo-samples-extensibility/pom.xml
+++
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-api/pom.xml
@@ -18,20 +18,19 @@
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <parent>
+ <groupId>org.apache</groupId>
+ <artifactId>apache</artifactId>
+ <version>23</version>
+ <relativePath/>
+ </parent>
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.dubbo.samples</groupId>
- <artifactId>dubbo-samples-extensibility</artifactId>
- <packaging>pom</packaging>
- <version>1.0-SNAPSHOT</version>
+ <artifactId>dubbo-samples-extensibility-router-api</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
- <name>Extensibility Task</name>
- <description>Dubbo Samples Extensibility Task</description>
-
- <modules>
- <module>dubbo-samples-extensibility-filter-api</module>
- <module>dubbo-samples-extensibility-filter-provider</module>
- <module>dubbo-samples-extensibility-filter-consumer</module>
- </modules>
+ <name>Dubbo Extensibility Router Task - API</name>
+ <description>Dubbo Extensibility Router Task - API</description>
</project>
\ No newline at end of file
diff --git
a/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-api/src/main/java/org/apache/dubbo/samples/extensibility/router/api/ExtensibilityRouterService.java
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-api/src/main/java/org/apache/dubbo/samples/extensibility/router/api/ExtensibilityRouterService.java
new file mode 100644
index 00000000..842e422a
--- /dev/null
+++
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-api/src/main/java/org/apache/dubbo/samples/extensibility/router/api/ExtensibilityRouterService.java
@@ -0,0 +1,22 @@
+/*
+ * 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.extensibility.router.api;
+
+public interface ExtensibilityRouterService {
+
+ String sayHello(String name);
+}
\ No newline at end of file
diff --git
a/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-consumer/pom.xml
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-consumer/pom.xml
new file mode 100644
index 00000000..82e2c0e9
--- /dev/null
+++
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-consumer/pom.xml
@@ -0,0 +1,108 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-parent</artifactId>
+ <version>3.0.0</version>
+ <relativePath/> <!-- lookup parent from repository -->
+ </parent>
+
+ <groupId>org.apache.dubbo.samples</groupId>
+ <artifactId>dubbo-samples-extensibility-router-consumer</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+
+ <name>Dubbo Extensibility Router Task - Consumer</name>
+ <description>Dubbo Extensibility Router Task - Consumer</description>
+
+ <properties>
+ <java.version>17</java.version>
+ <dubbo.version>3.2.0-beta.4</dubbo.version>
+ <nacos.version>2.2.0</nacos.version>
+ </properties>
+
+ <dependencies>
+ <!-- common api -->
+ <dependency>
+ <groupId>org.apache.dubbo.samples</groupId>
+ <artifactId>dubbo-samples-extensibility-router-api</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+
+ <!-- registry dependency -->
+ <dependency>
+ <groupId>com.alibaba.nacos</groupId>
+ <artifactId>nacos-client</artifactId>
+ <version>${nacos.version}</version>
+ </dependency>
+
+ <!-- dubbo dependency-->
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-spring-boot-starter</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.graalvm.buildtools</groupId>
+ <artifactId>native-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>com.google.cloud.tools</groupId>
+ <artifactId>jib-maven-plugin</artifactId>
+ <version>3.2.1</version>
+ <configuration>
+ <to>
+
<image>apache/dubbo-demo:dubbo-samples-extensibility-router-consumer_0.0.1</image>
+ </to>
+ <container>
+ <jvmFlags>
+
<jvmFlag>-Dnacos.address=nacos.dubbo-system.svc</jvmFlag>
+ </jvmFlags>
+ <ports>
+ <port>20881</port>
+ <port>20991</port>
+ </ports>
+ </container>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+
+</project>
\ No newline at end of file
diff --git
a/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-consumer/src/main/java/org/apache/dubbo/samples/extensibility/router/consumer/ExtensibilityRouterConsumerApplication.java
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-consumer/src/main/java/org/apache/dubbo/samples/extensibility/router/consumer/ExtensibilityRouterConsumerApplication.java
new file mode 100644
index 00000000..3223cd4c
--- /dev/null
+++
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-consumer/src/main/java/org/apache/dubbo/samples/extensibility/router/consumer/ExtensibilityRouterConsumerApplication.java
@@ -0,0 +1,27 @@
+/*
+ * 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.extensibility.router.consumer;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@SpringBootApplication
+public class ExtensibilityRouterConsumerApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(ExtensibilityRouterConsumerApplication.class,
args);
+ }
+}
\ No newline at end of file
diff --git
a/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-consumer/src/main/java/org/apache/dubbo/samples/extensibility/router/consumer/ExtensibilityRouterConsumerTask.java
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-consumer/src/main/java/org/apache/dubbo/samples/extensibility/router/consumer/ExtensibilityRouterConsumerTask.java
new file mode 100644
index 00000000..785bb569
--- /dev/null
+++
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-consumer/src/main/java/org/apache/dubbo/samples/extensibility/router/consumer/ExtensibilityRouterConsumerTask.java
@@ -0,0 +1,33 @@
+/*
+ * 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.extensibility.router.consumer;
+
+import org.apache.dubbo.config.annotation.DubboReference;
+import
org.apache.dubbo.samples.extensibility.router.api.ExtensibilityRouterService;
+import org.springframework.boot.CommandLineRunner;
+import org.springframework.stereotype.Component;
+
+@Component
+public class ExtensibilityRouterConsumerTask implements CommandLineRunner {
+ @DubboReference
+ private ExtensibilityRouterService extensibilityRouterService;
+
+ @Override
+ public void run(String... args) {
+ System.out.println("Dubbo Remote Return ======> " +
this.extensibilityRouterService.sayHello("dubbo"));
+ }
+}
diff --git
a/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-consumer/src/main/java/org/apache/dubbo/samples/extensibility/router/consumer/router/StickFirstStateRouter.java
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-consumer/src/main/java/org/apache/dubbo/samples/extensibility/router/consumer/router/StickFirstStateRouter.java
new file mode 100644
index 00000000..632d9fd0
--- /dev/null
+++
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-consumer/src/main/java/org/apache/dubbo/samples/extensibility/router/consumer/router/StickFirstStateRouter.java
@@ -0,0 +1,81 @@
+/*
+ * 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.extensibility.router.consumer.router;
+
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.common.config.configcenter.ConfigChangeType;
+import org.apache.dubbo.common.config.configcenter.ConfigChangedEvent;
+import org.apache.dubbo.common.config.configcenter.ConfigurationListener;
+import org.apache.dubbo.common.logger.ErrorTypeAwareLogger;
+import org.apache.dubbo.common.logger.LoggerFactory;
+import org.apache.dubbo.common.utils.CollectionUtils;
+import org.apache.dubbo.common.utils.Holder;
+import org.apache.dubbo.rpc.Invocation;
+import org.apache.dubbo.rpc.Invoker;
+import org.apache.dubbo.rpc.RpcException;
+import org.apache.dubbo.rpc.cluster.router.RouterSnapshotNode;
+import org.apache.dubbo.rpc.cluster.router.state.AbstractStateRouter;
+import org.apache.dubbo.rpc.cluster.router.state.BitList;
+
+public class StickFirstStateRouter<T> extends AbstractStateRouter<T>
implements ConfigurationListener {
+ public StickFirstStateRouter(URL url) {
+ super(url);
+ }
+
+ public static final String NAME = "STICK_FIRST_ROUTER";
+ private static final ErrorTypeAwareLogger logger =
LoggerFactory.getErrorTypeAwareLogger(StickFirstStateRouter.class);
+ private volatile BitList<Invoker<T>> firstInvokers;
+
+ @Override
+ protected BitList<Invoker<T>> doRoute(BitList<Invoker<T>> invokers, URL
url, Invocation invocation, boolean needToPrintMessage,
Holder<RouterSnapshotNode<T>> routerSnapshotNodeHolder, Holder<String>
messageHolder) throws RpcException {
+ if (CollectionUtils.isEmpty(invokers)) {
+ if (needToPrintMessage) {
+ messageHolder.set("Directly Return. Reason: Invokers from
previous router is empty.");
+ }
+ return invokers;
+ }
+ BitList<Invoker<T>> copy = invokers.clone();
+ if (CollectionUtils.isEmpty(copy)) {
+ this.firstInvokers = new BitList<>(BitList.emptyList());
+ this.firstInvokers.add(copy.get(0));
+ } else {
+ this.firstInvokers = copy.and(invokers);
+ if(CollectionUtils.isEmpty(this.firstInvokers)){
+ this.firstInvokers.add(copy.get(0));
+ }
+ }
+ return this.firstInvokers;
+ }
+
+ @Override
+ public void process(ConfigChangedEvent event) {
+ if (logger.isDebugEnabled()) {
+ logger.debug("Notification of tag rule, change type is: " +
event.getChangeType() + ", raw rule is:\n " +
+ event.getContent());
+ }
+ // Reset
+ if (event.getChangeType().equals(ConfigChangeType.DELETED)) {
+ this.firstInvokers = null;
+ }
+ }
+
+ @Override
+ public void stop() {
+ super.stop();
+ this.firstInvokers = null;
+ }
+}
diff --git
a/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-consumer/src/main/java/org/apache/dubbo/samples/extensibility/router/consumer/router/StickFirstStateRouterFactory.java
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-consumer/src/main/java/org/apache/dubbo/samples/extensibility/router/consumer/router/StickFirstStateRouterFactory.java
new file mode 100644
index 00000000..5b9553eb
--- /dev/null
+++
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-consumer/src/main/java/org/apache/dubbo/samples/extensibility/router/consumer/router/StickFirstStateRouterFactory.java
@@ -0,0 +1,28 @@
+/*
+ * 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.extensibility.router.consumer.router;
+
+import org.apache.dubbo.common.URL;
+import org.apache.dubbo.rpc.cluster.router.state.StateRouter;
+import org.apache.dubbo.rpc.cluster.router.state.StateRouterFactory;
+
+public class StickFirstStateRouterFactory implements StateRouterFactory {
+ @Override
+ public <T> StateRouter<T> getRouter(Class<T> interfaceClass, URL url) {
+ return new StickFirstStateRouter<>(url);
+ }
+}
diff --git
a/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-consumer/src/main/resources/META-INF/dubbo/org.apache.dubbo.rpc.cluster.router.state.StateRouterFactory
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-consumer/src/main/resources/META-INF/dubbo/org.apache.dubbo.rpc.cluster.router.state.StateRouterFactory
new file mode 100644
index 00000000..fd9ad9f6
--- /dev/null
+++
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-consumer/src/main/resources/META-INF/dubbo/org.apache.dubbo.rpc.cluster.router.state.StateRouterFactory
@@ -0,0 +1 @@
+stickfirst=org.apache.dubbo.samples.extensibility.router.consumer.router.StickFirstStateRouterFactory
\ No newline at end of file
diff --git
a/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-consumer/src/main/resources/application.properties
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-consumer/src/main/resources/application.properties
new file mode 100644
index 00000000..702c2bbc
--- /dev/null
+++
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-consumer/src/main/resources/application.properties
@@ -0,0 +1,26 @@
+# 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.
+
+# Specify the application name of Dubbo
+dubbo.application.name=extensibility-filter-consumer
+
+# Enable token verification for each invocation
+dubbo.provider.token=true
+
+# Specify the registry address
+dubbo.registry.address=nacos://localhost:8848?username=nacos&password=nacos
+#
dubbo.registry.address=nacos://${nacos.address:localhost}:8848?username=nacos&password=nacos
+
+dubbo.consumer.router=stickfirst
\ No newline at end of file
diff --git
a/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-provider/pom.xml
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-provider/pom.xml
new file mode 100644
index 00000000..28c9f387
--- /dev/null
+++
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-provider/pom.xml
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ 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.
+ -->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/xsd/maven-4.0.0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-parent</artifactId>
+ <version>3.0.0</version>
+ <relativePath/> <!-- lookup parent from repository -->
+ </parent>
+
+ <groupId>org.apache.dubbo.samples</groupId>
+ <artifactId>dubbo-samples-extensibility-router-provider</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+
+ <name>Dubbo Extensibility Router Task - Provider</name>
+ <description>Dubbo Extensibility Router Task - Provider</description>
+
+ <properties>
+ <java.version>17</java.version>
+ <dubbo.version>3.2.0-beta.4</dubbo.version>
+ <nacos.version>2.2.0</nacos.version>
+ </properties>
+
+ <dependencies>
+ <!-- common api -->
+ <dependency>
+ <groupId>org.apache.dubbo.samples</groupId>
+ <artifactId>dubbo-samples-extensibility-router-api</artifactId>
+ <version>0.0.1-SNAPSHOT</version>
+ </dependency>
+
+ <!-- registry dependency -->
+ <dependency>
+ <groupId>com.alibaba.nacos</groupId>
+ <artifactId>nacos-client</artifactId>
+ <version>${nacos.version}</version>
+ </dependency>
+
+ <!-- dubbo dependency-->
+ <dependency>
+ <groupId>org.apache.dubbo</groupId>
+ <artifactId>dubbo-spring-boot-starter</artifactId>
+ <version>${dubbo.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-test</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.graalvm.buildtools</groupId>
+ <artifactId>native-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-maven-plugin</artifactId>
+ </plugin>
+ <plugin>
+ <groupId>com.google.cloud.tools</groupId>
+ <artifactId>jib-maven-plugin</artifactId>
+ <version>3.2.1</version>
+ <configuration>
+ <to>
+
<image>apache/dubbo-demo:dubbo-samples-extensibility-router-provider_0.0.1</image>
+ </to>
+ <container>
+ <jvmFlags>
+
<jvmFlag>-Dnacos.address=nacos.dubbo-system.svc</jvmFlag>
+ </jvmFlags>
+ <ports>
+ <port>20881</port>
+ <port>20991</port>
+ </ports>
+ </container>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
\ No newline at end of file
diff --git
a/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-provider/src/main/java/org/apache/dubbo/samples/extensibility/router/provider/ExtensibilityRouterProviderApplication.java
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-provider/src/main/java/org/apache/dubbo/samples/extensibility/router/provider/ExtensibilityRouterProviderApplication.java
new file mode 100644
index 00000000..c83b2d1e
--- /dev/null
+++
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-provider/src/main/java/org/apache/dubbo/samples/extensibility/router/provider/ExtensibilityRouterProviderApplication.java
@@ -0,0 +1,29 @@
+/*
+ * 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.extensibility.router.provider;
+
+import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+
+@EnableDubbo
+@SpringBootApplication
+public class ExtensibilityRouterProviderApplication {
+ public static void main(String[] args) {
+ SpringApplication.run(ExtensibilityRouterProviderApplication.class,
args);
+ }
+}
\ No newline at end of file
diff --git
a/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-provider/src/main/java/org/apache/dubbo/samples/extensibility/router/provider/ExtensibilityRouterServiceImpl.java
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-provider/src/main/java/org/apache/dubbo/samples/extensibility/router/provider/ExtensibilityRouterServiceImpl.java
new file mode 100644
index 00000000..fd9111b3
--- /dev/null
+++
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-provider/src/main/java/org/apache/dubbo/samples/extensibility/router/provider/ExtensibilityRouterServiceImpl.java
@@ -0,0 +1,29 @@
+/*
+ * 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.extensibility.router.provider;
+
+import org.apache.dubbo.config.annotation.DubboService;
+import
org.apache.dubbo.samples.extensibility.router.api.ExtensibilityRouterService;
+
+@DubboService
+public class ExtensibilityRouterServiceImpl implements
ExtensibilityRouterService {
+
+ @Override
+ public String sayHello(String name) {
+ return "Hello, " + name;
+ }
+}
diff --git
a/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-provider/src/main/resources/application.properties
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-provider/src/main/resources/application.properties
new file mode 100644
index 00000000..630d6438
--- /dev/null
+++
b/10-task/dubbo-samples-extensibility/dubbo-samples-extensibility-router-provider/src/main/resources/application.properties
@@ -0,0 +1,27 @@
+# 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.
+
+# Specify the application name of Dubbo
+dubbo.application.name=extensibility-router-provider
+
+# Enable token verification for each invocation
+dubbo.provider.token=true
+
+# Specify the registry address
+dubbo.registry.address=nacos://localhost:8848?username=nacos&password=nacos
+#
dubbo.registry.address=nacos://${nacos.address:localhost}:8848?username=nacos&password=nacos
+
+# Specify the port of Dubbo protocol
+dubbo.protocol.port=20881
\ No newline at end of file
diff --git a/10-task/dubbo-samples-extensibility/pom.xml
b/10-task/dubbo-samples-extensibility/pom.xml
index 02617715..c24b6ca8 100644
--- a/10-task/dubbo-samples-extensibility/pom.xml
+++ b/10-task/dubbo-samples-extensibility/pom.xml
@@ -32,6 +32,9 @@
<module>dubbo-samples-extensibility-filter-api</module>
<module>dubbo-samples-extensibility-filter-provider</module>
<module>dubbo-samples-extensibility-filter-consumer</module>
+ <module>dubbo-samples-extensibility-router-api</module>
+ <module>dubbo-samples-extensibility-router-provider</module>
+ <module>dubbo-samples-extensibility-router-consumer</module>
</modules>
</project>
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]