You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@dubbo.apache.org by li...@apache.org on 2023/02/15 07:06:33 UTC
[dubbo-samples] branch master updated: Traffic management task improvement (#732)
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 1142f24a Traffic management task improvement (#732)
1142f24a is described below
commit 1142f24a7696aab0d4923eca560f2ac4bd5d869a
Author: Ken Liu <ke...@gmail.com>
AuthorDate: Wed Feb 15 15:06:27 2023 +0800
Traffic management task improvement (#732)
---
.licenserc.yaml | 2 +
.../.images/ide_runnable_task.png | Bin 0 -> 299229 bytes
.../.images/ide_runnable_task_configuration.png | Bin 0 -> 487437 bytes
.../dubbo-samples-shop/.images/shop-arc-deploy.png | Bin 0 -> 112879 bytes
.../.images/shop-arc-deploy2.png | Bin 0 -> 131625 bytes
10-task/dubbo-samples-shop/.images/shop-arc.png | Bin 0 -> 46312 bytes
.../.run/CommentApplication1.run.xml | 15 ++
.../.run/CommentApplication2.run.xml | 15 ++
.../.run/CommentApplicationGray.run.xml | 12 ++
.../.run/DetailApplication1.run.xml | 21 +++
.../.run/DetailApplication2.run.xml | 21 +++
.../.run/DetailApplicationGray.run.xml | 12 ++
.../.run/FrontEndApplication.run.xml | 11 ++
.../.run/OrderApplication1.run.xml | 12 ++
.../.run/OrderApplication2.run.xml | 12 ++
.../.run/OrderApplicationGray.run.xml | 12 ++
.../.run/UserApplication.run.xml | 11 ++
.../.run/UserApplicationGray.run.xml | 11 ++
10-task/dubbo-samples-shop/README.md | 50 ++++++
10-task/dubbo-samples-shop/deploy/All.yml | 198 +++++++++++++++++++--
10-task/dubbo-samples-shop/deploy/App.yml | 194 +++++++++++++++++++-
.../deploy/{App.yml => Gray.yml} | 137 +++++---------
.../{order-v2 => comment-v1-gray}/Deployment.yml | 20 ++-
.../deploy/{order-v2 => comment-v1}/Deployment.yml | 20 ++-
.../deploy/{order-v2 => comment-v2}/Deployment.yml | 20 ++-
.../{detail => detail-v1-gray}/Deployment.yml | 12 +-
.../deploy/{detail => detail-v1}/Deployment.yml | 6 +-
.../deploy/{detail => detail-v2}/Deployment.yml | 12 +-
.../{order-v1 => order-v1-gray}/Deployment.yml | 16 +-
.../deploy/order-v1/Deployment.yml | 8 +-
.../deploy/order-v2/Deployment.yml | 8 +-
.../deploy/traffic-rules/accesslog.yaml | 25 +++
.../deploy/traffic-rules/arguments.yaml | 25 +++
.../deploy/traffic-rules/isolation-env.yaml | 44 +++++
.../deploy/traffic-rules/region-affinity.yaml | 25 +++
.../deploy/traffic-rules/retry.yaml | 30 ++++
.../deploy/traffic-rules/timeout.yaml | 25 +++
.../deploy/traffic-rules/traffic-split.yaml | 14 ++
.../deploy/traffic-rules/weight.yaml | 30 ++++
.../deploy/{order-v2 => user-gray}/Deployment.yml | 18 +-
.../pom.xml | 6 +-
.../org/apache/dubbo/samples/CommentService.java} | 5 +-
.../pom.xml | 18 +-
.../samples/comment/CommentApplicationGray.java} | 6 +-
.../samples/comment/CommentServiceImplGray.java} | 14 +-
.../src/main/resources/application.properties | 11 +-
.../pom.xml | 18 +-
.../dubbo/samples/comment/CommentApplication.java} | 6 +-
.../dubbo/samples/comment/CommentServiceImpl.java} | 14 +-
.../src/main/resources/application.properties | 11 +-
.../pom.xml | 18 +-
.../samples/comment/CommentApplication2.java} | 6 +-
.../samples/comment/CommentServiceImpl2.java} | 14 +-
.../src/main/resources/application.properties | 11 +-
.../org/apache/dubbo/samples/DetailService.java | 2 +-
.../main/java/org/apache/dubbo/samples/Item.java | 18 ++
.../pom.xml | 19 +-
.../samples/detail/DetailApplicationGray.java} | 4 +-
.../samples/detail/DetailServiceImplGray.java} | 35 ++--
.../src/main/resources/application.properties | 4 +-
.../pom.xml | 19 +-
.../dubbo/samples/detail/DetailApplication.java | 0
.../dubbo/samples/detail/DetailServiceImpl.java | 31 ++--
.../src/main/resources/application.properties | 5 -
.../pom.xml | 19 +-
.../dubbo/samples/detail/DetailApplication2.java} | 4 +-
.../dubbo/samples/detail/DetailServiceImpl2.java} | 55 ++++--
.../src/main/resources/application.properties | 9 +-
.../dubbo-samples-shop-frontend-api/pom.xml | 17 ++
.../java/org/apache/dubbo/samples/ShopService.java | 10 +-
.../dubbo-samples-shop-frontend/pom.xml | 11 +-
.../dubbo/samples/frontend/BenchmarkClient.java | 3 +-
.../samples/frontend/FrontEndApplication.java | 2 +-
.../dubbo/samples/frontend/ShopServiceImpl.java | 37 ++--
.../samples/frontend/pages/WebController.java | 105 +++++++++++
.../src/main/resources/application.properties | 10 +-
.../src/main/resources/static/architecture.png | Bin 0 -> 131625 bytes
.../src/main/resources/static/goods.png | Bin 0 -> 1850937 bytes
.../src/main/resources/static/jquery-3.6.3.min.js | 2 +
.../src/main/resources/templates/detail.ftl | 113 ++++++++++++
.../src/main/resources/templates/index.ftl | 107 +++++++++++
.../org/apache/dubbo/samples/OrderDetail.java} | 51 +++---
.../org/apache/dubbo/samples/OrderService.java | 2 +-
.../pom.xml | 14 +-
.../dubbo/samples/order/OrderApplicationGray.java} | 6 +-
.../dubbo/samples/order/OrderServiceImplGray.java} | 21 +--
.../src/main/resources/application.properties | 11 +-
.../dubbo-samples-shop-order-v1/pom.xml | 2 +-
.../dubbo/samples/order/OrderServiceImpl.java | 15 +-
.../dubbo-samples-shop-order-v2/pom.xml | 2 +-
...rderServiceImpl.java => OrderServiceImpl2.java} | 24 +--
.../main/java/org/apache/dubbo/samples/User.java | 9 +
.../java/org/apache/dubbo/samples/UserService.java | 4 +
.../pom.xml | 16 +-
.../dubbo/samples/user/UserApplicationGray.java} | 6 +-
.../dubbo/samples/user/UserServiceImplGray.java} | 53 ++++--
.../src/main/resources/application.properties | 11 +-
.../dubbo-samples-shop-user/pom.xml | 2 +-
.../apache/dubbo/samples/user/UserServiceImpl.java | 51 ++++--
10-task/dubbo-samples-shop/pom.xml | 16 +-
.../pom.xml | 2 +-
101 files changed, 1737 insertions(+), 484 deletions(-)
diff --git a/.licenserc.yaml b/.licenserc.yaml
index ea2b4b91..fe597fb9 100644
--- a/.licenserc.yaml
+++ b/.licenserc.yaml
@@ -73,6 +73,8 @@ header:
- '**/*.MD'
- '**/src/main/resources/certs/**'
- '**/dubbo-samples-tengine/dubbo-samples-tengine-provider/src/main/resources/docker/sources.list'
+ - '**/.run/**'
+ - '**/*.js'
comment: on-failure
diff --git a/10-task/dubbo-samples-shop/.images/ide_runnable_task.png b/10-task/dubbo-samples-shop/.images/ide_runnable_task.png
new file mode 100644
index 00000000..70e3f11a
Binary files /dev/null and b/10-task/dubbo-samples-shop/.images/ide_runnable_task.png differ
diff --git a/10-task/dubbo-samples-shop/.images/ide_runnable_task_configuration.png b/10-task/dubbo-samples-shop/.images/ide_runnable_task_configuration.png
new file mode 100644
index 00000000..4dfefd24
Binary files /dev/null and b/10-task/dubbo-samples-shop/.images/ide_runnable_task_configuration.png differ
diff --git a/10-task/dubbo-samples-shop/.images/shop-arc-deploy.png b/10-task/dubbo-samples-shop/.images/shop-arc-deploy.png
new file mode 100644
index 00000000..c977eb7d
Binary files /dev/null and b/10-task/dubbo-samples-shop/.images/shop-arc-deploy.png differ
diff --git a/10-task/dubbo-samples-shop/.images/shop-arc-deploy2.png b/10-task/dubbo-samples-shop/.images/shop-arc-deploy2.png
new file mode 100644
index 00000000..515efaa9
Binary files /dev/null and b/10-task/dubbo-samples-shop/.images/shop-arc-deploy2.png differ
diff --git a/10-task/dubbo-samples-shop/.images/shop-arc.png b/10-task/dubbo-samples-shop/.images/shop-arc.png
new file mode 100644
index 00000000..bd9ea23c
Binary files /dev/null and b/10-task/dubbo-samples-shop/.images/shop-arc.png differ
diff --git a/10-task/dubbo-samples-shop/.run/CommentApplication1.run.xml b/10-task/dubbo-samples-shop/.run/CommentApplication1.run.xml
new file mode 100644
index 00000000..1fcd9efb
--- /dev/null
+++ b/10-task/dubbo-samples-shop/.run/CommentApplication1.run.xml
@@ -0,0 +1,15 @@
+<component name="ProjectRunConfigurationManager">
+ <configuration default="false" name="CommentApplication1" type="SpringBootApplicationConfigurationType"
+ factoryName="Spring Boot">
+ <module name="dubbo-samples-shop-comment-v1"/>
+ <selectedOptions>
+ <option name="environmentVariables"/>
+ </selectedOptions>
+ <option name="SPRING_BOOT_MAIN_CLASS" value="org.apache.dubbo.samples.comment.CommentApplication"/>
+ <option name="VM_PARAMETERS" value="-Ddubbo.labels="commentVersion=v1;region=beijing""/>
+ <option name="ALTERNATIVE_JRE_PATH"/>
+ <method v="2">
+ <option name="Make" enabled="true"/>
+ </method>
+ </configuration>
+</component>
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/.run/CommentApplication2.run.xml b/10-task/dubbo-samples-shop/.run/CommentApplication2.run.xml
new file mode 100644
index 00000000..afab6064
--- /dev/null
+++ b/10-task/dubbo-samples-shop/.run/CommentApplication2.run.xml
@@ -0,0 +1,15 @@
+<component name="ProjectRunConfigurationManager">
+ <configuration default="false" name="CommentApplication2" type="SpringBootApplicationConfigurationType"
+ factoryName="Spring Boot">
+ <module name="dubbo-samples-shop-comment-v2"/>
+ <selectedOptions>
+ <option name="environmentVariables"/>
+ </selectedOptions>
+ <option name="SPRING_BOOT_MAIN_CLASS" value="org.apache.dubbo.samples.comment.CommentApplication2"/>
+ <option name="VM_PARAMETERS" value="-Ddubbo.labels="commentVersion=v2;region=hangzhou;type=vip""/>
+ <option name="ALTERNATIVE_JRE_PATH"/>
+ <method v="2">
+ <option name="Make" enabled="true"/>
+ </method>
+ </configuration>
+</component>
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/.run/CommentApplicationGray.run.xml b/10-task/dubbo-samples-shop/.run/CommentApplicationGray.run.xml
new file mode 100644
index 00000000..a3051ac2
--- /dev/null
+++ b/10-task/dubbo-samples-shop/.run/CommentApplicationGray.run.xml
@@ -0,0 +1,12 @@
+<component name="ProjectRunConfigurationManager">
+ <configuration default="false" name="CommentApplicationGray" type="SpringBootApplicationConfigurationType"
+ factoryName="Spring Boot">
+ <module name="dubbo-samples-shop-comment-gray"/>
+ <option name="SPRING_BOOT_MAIN_CLASS" value="org.apache.dubbo.samples.comment.CommentApplicationGray"/>
+ <option name="VM_PARAMETERS" value="-Ddubbo.labels="env=gray""/>
+ <option name="ALTERNATIVE_JRE_PATH"/>
+ <method v="2">
+ <option name="Make" enabled="true"/>
+ </method>
+ </configuration>
+</component>
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/.run/DetailApplication1.run.xml b/10-task/dubbo-samples-shop/.run/DetailApplication1.run.xml
new file mode 100644
index 00000000..5c7405b9
--- /dev/null
+++ b/10-task/dubbo-samples-shop/.run/DetailApplication1.run.xml
@@ -0,0 +1,21 @@
+<component name="ProjectRunConfigurationManager">
+ <configuration default="false" name="DetailApplication1" type="SpringBootApplicationConfigurationType"
+ factoryName="Spring Boot">
+ <module name="dubbo-samples-shop-detail-v1"/>
+ <selectedOptions>
+ <option name="environmentVariables"/>
+ </selectedOptions>
+ <extension name="coverage">
+ <pattern>
+ <option name="PATTERN" value="org.apache.dubbo.samples.detail.*"/>
+ <option name="ENABLED" value="true"/>
+ </pattern>
+ </extension>
+ <option name="SPRING_BOOT_MAIN_CLASS" value="org.apache.dubbo.samples.detail.DetailApplication"/>
+ <option name="VM_PARAMETERS" value="-Ddubbo.labels="detailVersion=v1;region=beijing""/>
+ <option name="ALTERNATIVE_JRE_PATH"/>
+ <method v="2">
+ <option name="Make" enabled="true"/>
+ </method>
+ </configuration>
+</component>
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/.run/DetailApplication2.run.xml b/10-task/dubbo-samples-shop/.run/DetailApplication2.run.xml
new file mode 100644
index 00000000..ef928da6
--- /dev/null
+++ b/10-task/dubbo-samples-shop/.run/DetailApplication2.run.xml
@@ -0,0 +1,21 @@
+<component name="ProjectRunConfigurationManager">
+ <configuration default="false" name="DetailApplication2" type="SpringBootApplicationConfigurationType"
+ factoryName="Spring Boot">
+ <module name="dubbo-samples-shop-detail-v2"/>
+ <selectedOptions>
+ <option name="environmentVariables"/>
+ </selectedOptions>
+ <extension name="coverage">
+ <pattern>
+ <option name="PATTERN" value="org.apache.dubbo.samples.detail.*"/>
+ <option name="ENABLED" value="true"/>
+ </pattern>
+ </extension>
+ <option name="SPRING_BOOT_MAIN_CLASS" value="org.apache.dubbo.samples.detail.DetailApplication2"/>
+ <option name="VM_PARAMETERS" value="-Ddubbo.labels="detailVersion=v2;region=hangzhou;type=vip""/>
+ <option name="ALTERNATIVE_JRE_PATH"/>
+ <method v="2">
+ <option name="Make" enabled="true"/>
+ </method>
+ </configuration>
+</component>
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/.run/DetailApplicationGray.run.xml b/10-task/dubbo-samples-shop/.run/DetailApplicationGray.run.xml
new file mode 100644
index 00000000..f9932aaf
--- /dev/null
+++ b/10-task/dubbo-samples-shop/.run/DetailApplicationGray.run.xml
@@ -0,0 +1,12 @@
+<component name="ProjectRunConfigurationManager">
+ <configuration default="false" name="DetailApplicationGray" type="SpringBootApplicationConfigurationType"
+ factoryName="Spring Boot">
+ <module name="dubbo-samples-shop-detail-gray"/>
+ <option name="SPRING_BOOT_MAIN_CLASS" value="org.apache.dubbo.samples.detail.DetailApplicationGray"/>
+ <option name="VM_PARAMETERS" value="-Ddubbo.labels="env=gray""/>
+ <option name="ALTERNATIVE_JRE_PATH"/>
+ <method v="2">
+ <option name="Make" enabled="true"/>
+ </method>
+ </configuration>
+</component>
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/.run/FrontEndApplication.run.xml b/10-task/dubbo-samples-shop/.run/FrontEndApplication.run.xml
new file mode 100644
index 00000000..5dc6406b
--- /dev/null
+++ b/10-task/dubbo-samples-shop/.run/FrontEndApplication.run.xml
@@ -0,0 +1,11 @@
+<component name="ProjectRunConfigurationManager">
+ <configuration default="false" name="FrontEndApplication" type="SpringBootApplicationConfigurationType"
+ factoryName="Spring Boot">
+ <module name="dubbo-samples-shop-frontend"/>
+ <option name="SPRING_BOOT_MAIN_CLASS" value="org.apache.dubbo.samples.frontend.FrontEndApplication"/>
+ <option name="ALTERNATIVE_JRE_PATH"/>
+ <method v="2">
+ <option name="Make" enabled="true"/>
+ </method>
+ </configuration>
+</component>
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/.run/OrderApplication1.run.xml b/10-task/dubbo-samples-shop/.run/OrderApplication1.run.xml
new file mode 100644
index 00000000..e2a27094
--- /dev/null
+++ b/10-task/dubbo-samples-shop/.run/OrderApplication1.run.xml
@@ -0,0 +1,12 @@
+<component name="ProjectRunConfigurationManager">
+ <configuration default="false" name="OrderApplication1" type="SpringBootApplicationConfigurationType"
+ factoryName="Spring Boot">
+ <module name="dubbo-samples-shop-order-v1"/>
+ <option name="SPRING_BOOT_MAIN_CLASS" value="org.apache.dubbo.samples.order.OrderApplicationV1"/>
+ <option name="VM_PARAMETERS" value="-Ddubbo.labels="orderVersion=v1""/>
+ <option name="ALTERNATIVE_JRE_PATH"/>
+ <method v="2">
+ <option name="Make" enabled="true"/>
+ </method>
+ </configuration>
+</component>
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/.run/OrderApplication2.run.xml b/10-task/dubbo-samples-shop/.run/OrderApplication2.run.xml
new file mode 100644
index 00000000..d0053356
--- /dev/null
+++ b/10-task/dubbo-samples-shop/.run/OrderApplication2.run.xml
@@ -0,0 +1,12 @@
+<component name="ProjectRunConfigurationManager">
+ <configuration default="false" name="OrderApplication2" type="SpringBootApplicationConfigurationType"
+ factoryName="Spring Boot">
+ <module name="dubbo-samples-shop-order-v2"/>
+ <option name="SPRING_BOOT_MAIN_CLASS" value="org.apache.dubbo.samples.order.OrderApplicationV2"/>
+ <option name="VM_PARAMETERS" value="-Ddubbo.labels="orderVersion=v2""/>
+ <option name="ALTERNATIVE_JRE_PATH"/>
+ <method v="2">
+ <option name="Make" enabled="true"/>
+ </method>
+ </configuration>
+</component>
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/.run/OrderApplicationGray.run.xml b/10-task/dubbo-samples-shop/.run/OrderApplicationGray.run.xml
new file mode 100644
index 00000000..ec7c9722
--- /dev/null
+++ b/10-task/dubbo-samples-shop/.run/OrderApplicationGray.run.xml
@@ -0,0 +1,12 @@
+<component name="ProjectRunConfigurationManager">
+ <configuration default="false" name="OrderApplicationGray" type="SpringBootApplicationConfigurationType"
+ factoryName="Spring Boot">
+ <module name="dubbo-samples-shop-order-gray"/>
+ <option name="SPRING_BOOT_MAIN_CLASS" value="org.apache.dubbo.samples.order.OrderApplicationGray"/>
+ <option name="VM_PARAMETERS" value="-Ddubbo.labels="env=gray""/>
+ <option name="ALTERNATIVE_JRE_PATH"/>
+ <method v="2">
+ <option name="Make" enabled="true"/>
+ </method>
+ </configuration>
+</component>
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/.run/UserApplication.run.xml b/10-task/dubbo-samples-shop/.run/UserApplication.run.xml
new file mode 100644
index 00000000..c8251188
--- /dev/null
+++ b/10-task/dubbo-samples-shop/.run/UserApplication.run.xml
@@ -0,0 +1,11 @@
+<component name="ProjectRunConfigurationManager">
+ <configuration default="false" name="UserApplication" type="SpringBootApplicationConfigurationType"
+ factoryName="Spring Boot">
+ <module name="dubbo-samples-shop-user"/>
+ <option name="SPRING_BOOT_MAIN_CLASS" value="org.apache.dubbo.samples.user.UserApplication"/>
+ <option name="ALTERNATIVE_JRE_PATH"/>
+ <method v="2">
+ <option name="Make" enabled="true"/>
+ </method>
+ </configuration>
+</component>
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/.run/UserApplicationGray.run.xml b/10-task/dubbo-samples-shop/.run/UserApplicationGray.run.xml
new file mode 100644
index 00000000..19655951
--- /dev/null
+++ b/10-task/dubbo-samples-shop/.run/UserApplicationGray.run.xml
@@ -0,0 +1,11 @@
+<component name="ProjectRunConfigurationManager">
+ <configuration default="false" name="UserApplicationGray" type="SpringBootApplicationConfigurationType"
+ factoryName="Spring Boot">
+ <module name="dubbo-samples-shop-user-gray"/>
+ <option name="SPRING_BOOT_MAIN_CLASS" value="org.apache.dubbo.samples.user.UserApplicationGray"/>
+ <option name="ALTERNATIVE_JRE_PATH"/>
+ <method v="2">
+ <option name="Make" enabled="true"/>
+ </method>
+ </configuration>
+</component>
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/README.md b/10-task/dubbo-samples-shop/README.md
new file mode 100644
index 00000000..b496a956
--- /dev/null
+++ b/10-task/dubbo-samples-shop/README.md
@@ -0,0 +1,50 @@
+此任务基于一个简单的线上商城微服务系统演示了 Dubbo 的流量管控能力。用于配合 【Dubbo 官网】-【文档】-【任务】-【流量管控】部分文档。
+
+## 架构
+线上商城的架构图如下:
+
+
+
+系统由 5 个微服务应用组成:
+* `Frontend 商城主页`,作为与用户交互的 web 界面,通过调用 `User`、`Detail`、`Order` 等提供用户登录、商品展示和订单管理等服务。
+* `User 用户服务`,负责用户数据管理、身份校验等。
+* `Order 订单服务`,提供订订单创建、订单查询等服务,依赖 `Detail` 服务校验商品库存等信息。
+* `Detail 商品详情服务`,展示商品详情信息,调用 `Comment` 服务展示用户对商品的评论记录。
+* `Comment 评论服务`,管理用户对商品的评论数据。
+
+## 部署商场系统
+有两种模式可以
+
+### 本地 IDE 部署
+把当前项目导入 IDEA 后,通过点击 IDEA 上方的可运行命令列表,可以看到一系列预先配置好的可运行 Shop 子任务示例,比如 `FrontEndApplication`、`UserApplication` 等。
+
+
+
+这些预先配置的可运行任务都已经被正确的打标,比如 `CommentApplicationGray` 的配置如下图所示,因此,如果直接运行
+`CommentApplicationGray`,则启动的进程将自动带有 `env=gray` 的标签。
+
+
+
+接下来,你就可以跟随 Dubbo 官网描述的任务,启动相应的任务示例,并运行查看效果。
+
+> 注意,要成功的在本地运行这里的示例,还需要先在本地启动 Nacos 注册中心、Dubbo Admin 等基础组件。
+
+### Kubernetes 部署
+
+为方便起见,推荐将整个系统部署在 Kubernetes 集群,执行以下命令即可完成商城项目部署,项目源码示例在 [dubbo-samples/task](https://github.com/apache/dubbo-samples/tree/master/10-task/dubbo-samples-shop)。
+
+```sh
+kubectl apply -f https://raw.githubusercontent.com/apache/dubbo-samples/master/10-task/dubbo-samples-shop/deploy/All.yml
+```
+
+完整的部署架构图如下:
+
+
+
+`Order 订单服务`有两个版本 `v1` 和 `v2`,`v2` 是订单服务优化后发布的新版本。
+* 版本 v1 只是简单的创建订单,不展示订单详情
+* 版本 v2 在订单创建成功后会展示订单的收货地址详情
+
+`Detail` 和 `Comment` 服务也分别有两个版本 `v1` 和 `v2`,我们通过多个版本来演示流量导流后的效果。
+* 版本 `v1` 默认为所有请求提供服务
+* 版本 `v2` 模拟被部署在特定的区域的服务,因此 `v2` 实例会带有特定的标签
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/deploy/All.yml b/10-task/dubbo-samples-shop/deploy/All.yml
index 08271977..62653aaf 100644
--- a/10-task/dubbo-samples-shop/deploy/All.yml
+++ b/10-task/dubbo-samples-shop/deploy/All.yml
@@ -216,9 +216,9 @@ spec:
selector:
app: skywalking-oap-dashboard
ports:
- - port: 8080
+ - port: 8082
name: http
- targetPort: 8080
+ targetPort: 8082
---
# App FrontEnd
@@ -273,7 +273,7 @@ spec:
value: "skywalking-oap-server.dubbo-system.svc:11800"
---
-# App Order V1
+# App Order V1-1
apiVersion: apps/v1
kind: Deployment
metadata:
@@ -283,11 +283,13 @@ spec:
replicas: 2
selector:
matchLabels:
- app: shop-order-v1
+ app: shop-order
+ orderVersion: v1
template:
metadata:
labels:
- app: shop-order-v1
+ app: shop-order
+ orderVersion: v1
spec:
volumes:
- name: skywalking-agent
@@ -323,6 +325,8 @@ spec:
value: shop::shop-order
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
value: "skywalking-oap-server.dubbo-system.svc:11800"
+ - name: DUBBO_LABELS
+ value: "orderVersion=v1"
---
# App Order V2
@@ -335,11 +339,13 @@ spec:
replicas: 3
selector:
matchLabels:
- app: shop-order-v2
+ app: shop-order
+ orderVersion: v2
template:
metadata:
labels:
- app: shop-order-v2
+ app: shop-order
+ orderVersion: v2
spec:
volumes:
- name: skywalking-agent
@@ -375,7 +381,8 @@ spec:
value: shop::shop-order
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
value: "skywalking-oap-server.dubbo-system.svc:11800"
-
+ - name: DUBBO_LABELS
+ value: "orderVersion=v2;"
---
# App User
@@ -430,21 +437,23 @@ spec:
value: "skywalking-oap-server.dubbo-system.svc:11800"
---
-# App Detail
+# App Detail-1
apiVersion: apps/v1
kind: Deployment
metadata:
- name: shop-detail
+ name: shop-detail-v1
namespace: dubbo-demo
spec:
replicas: 3
selector:
matchLabels:
app: shop-detail
+ detailVersion: v1
template:
metadata:
labels:
app: shop-detail
+ detailVersion: v1
spec:
volumes:
- name: skywalking-agent
@@ -480,5 +489,174 @@ spec:
value: shop::shop-detail
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
value: "skywalking-oap-server.dubbo-system.svc:11800"
+ - name: DUBBO_LABELS
+ value: "detailVersion=v1; region=beijing"
---
+# App Detail-2
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: shop-detail-v2
+ namespace: dubbo-demo
+spec:
+ replicas: 3
+ selector:
+ matchLabels:
+ app: shop-detail
+ detailVersion: v2
+ template:
+ metadata:
+ labels:
+ app: shop-detail
+ detailVersion: v2
+ spec:
+ volumes:
+ - name: skywalking-agent
+ emptyDir: { }
+
+ initContainers:
+ - name: agent-container
+ image: apache/skywalking-java-agent:8.13.0-java17
+ volumeMounts:
+ - name: skywalking-agent
+ mountPath: /agent
+ command: [ "/bin/sh" ]
+ args: [ "-c", "cp -R /skywalking/agent /agent/" ]
+
+ containers:
+ - name: shop-detail
+ image: apache/dubbo-demo:dubbo-samples-shop-detail_v2_0.0.1
+ imagePullPolicy: Always
+ ports:
+ - name: dubbo
+ containerPort: 20886
+ protocol: TCP
+ - name: dubbo-qos
+ containerPort: 20996
+ protocol: TCP
+ volumeMounts:
+ - name: skywalking-agent
+ mountPath: /skywalking
+ env:
+ - name: JAVA_TOOL_OPTIONS
+ value: "-javaagent:/skywalking/agent/skywalking-agent.jar"
+ - name: SW_AGENT_NAME
+ value: shop::shop-detail
+ - name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
+ value: "skywalking-oap-server.dubbo-system.svc:11800"
+ - name: DUBBO_LABELS
+ value: "detailVersion=v2; region=hangzhou;"
+---
+
+#App Comment v1
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: shop-comment-v1
+ namespace: dubbo-demo
+spec:
+ replicas: 3
+ selector:
+ matchLabels:
+ app: shop-comment
+ commentVersion: v1
+ template:
+ metadata:
+ labels:
+ app: shop-comment
+ commentVersion: v1
+ spec:
+ volumes:
+ - name: skywalking-agent
+ emptyDir: { }
+
+ initContainers:
+ - name: agent-container
+ image: apache/skywalking-java-agent:8.13.0-java17
+ volumeMounts:
+ - name: skywalking-agent
+ mountPath: /agent
+ command: [ "/bin/sh" ]
+ args: [ "-c", "cp -R /skywalking/agent /agent/" ]
+
+ containers:
+ - name: shop-comment
+ image: apache/dubbo-demo:dubbo-samples-shop-comment_0.0.1
+ imagePullPolicy: Always
+ ports:
+ - name: dubbo
+ containerPort: 20887
+ protocol: TCP
+ - name: dubbo-qos
+ containerPort: 20997
+ protocol: TCP
+ volumeMounts:
+ - name: skywalking-agent
+ mountPath: /skywalking
+ env:
+ - name: JAVA_TOOL_OPTIONS
+ value: "-javaagent:/skywalking/agent/skywalking-agent.jar"
+ - name: SW_AGENT_NAME
+ value: shop::shop-comment
+ - name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
+ value: "skywalking-oap-server.dubbo-system.svc:11800"
+ - name: DUBBO_LABELS
+ value: "commentVersion=v1; region=beijing"
+---
+
+#App Comment v2
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: shop-comment-v2
+ namespace: dubbo-demo
+spec:
+ replicas: 3
+ selector:
+ matchLabels:
+ app: shop-comment
+ commentVersion: v2
+ template:
+ metadata:
+ labels:
+ app: shop-comment
+ commentVersion: v2
+ spec:
+ volumes:
+ - name: skywalking-agent
+ emptyDir: { }
+
+ initContainers:
+ - name: agent-container
+ image: apache/skywalking-java-agent:8.13.0-java17
+ volumeMounts:
+ - name: skywalking-agent
+ mountPath: /agent
+ command: [ "/bin/sh" ]
+ args: [ "-c", "cp -R /skywalking/agent /agent/" ]
+
+ containers:
+ - name: shop-comment
+ image: apache/dubbo-demo:dubbo-samples-shop-comment_v2_0.0.1
+ imagePullPolicy: Always
+ ports:
+ - name: dubbo
+ containerPort: 20888
+ protocol: TCP
+ - name: dubbo-qos
+ containerPort: 20998
+ protocol: TCP
+ volumeMounts:
+ - name: skywalking-agent
+ mountPath: /skywalking
+ env:
+ - name: JAVA_TOOL_OPTIONS
+ value: "-javaagent:/skywalking/agent/skywalking-agent.jar"
+ - name: SW_AGENT_NAME
+ value: shop::shop-comment
+ - name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
+ value: "skywalking-oap-server.dubbo-system.svc:11800"
+ - name: DUBBO_LABELS
+ value: "commentVersion=v2; region=hangzhou;"
+
diff --git a/10-task/dubbo-samples-shop/deploy/App.yml b/10-task/dubbo-samples-shop/deploy/App.yml
index 09c75f0b..4e24824b 100644
--- a/10-task/dubbo-samples-shop/deploy/App.yml
+++ b/10-task/dubbo-samples-shop/deploy/App.yml
@@ -65,7 +65,7 @@ spec:
value: "skywalking-oap-server.dubbo-system.svc:11800"
---
-# App Order V1
+# App Order V1-1
apiVersion: apps/v1
kind: Deployment
metadata:
@@ -75,11 +75,13 @@ spec:
replicas: 2
selector:
matchLabels:
- app: shop-order-v1
+ app: shop-order
+ orderVersion: v1
template:
metadata:
labels:
- app: shop-order-v1
+ app: shop-order
+ orderVersion: v1
spec:
volumes:
- name: skywalking-agent
@@ -115,6 +117,8 @@ spec:
value: shop::shop-order
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
value: "skywalking-oap-server.dubbo-system.svc:11800"
+ - name: DUBBO_LABELS
+ value: "orderVersion=v1"
---
# App Order V2
@@ -127,11 +131,13 @@ spec:
replicas: 3
selector:
matchLabels:
- app: shop-order-v2
+ app: shop-order
+ orderVersion: v2
template:
metadata:
labels:
- app: shop-order-v2
+ app: shop-order
+ orderVersion: v2
spec:
volumes:
- name: skywalking-agent
@@ -167,7 +173,8 @@ spec:
value: shop::shop-order
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
value: "skywalking-oap-server.dubbo-system.svc:11800"
-
+ - name: DUBBO_LABELS
+ value: "orderVersion=v2;"
---
# App User
@@ -222,21 +229,23 @@ spec:
value: "skywalking-oap-server.dubbo-system.svc:11800"
---
-# App Detail
+# App Detail-1
apiVersion: apps/v1
kind: Deployment
metadata:
- name: shop-detail
+ name: shop-detail-v1
namespace: dubbo-demo
spec:
replicas: 3
selector:
matchLabels:
app: shop-detail
+ detailVersion: v1
template:
metadata:
labels:
app: shop-detail
+ detailVersion: v1
spec:
volumes:
- name: skywalking-agent
@@ -272,4 +281,173 @@ spec:
value: shop::shop-detail
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
value: "skywalking-oap-server.dubbo-system.svc:11800"
+ - name: DUBBO_LABELS
+ value: "detailVersion=v1; region=beijing"
---
+
+# App Detail-2
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: shop-detail-v2
+ namespace: dubbo-demo
+spec:
+ replicas: 3
+ selector:
+ matchLabels:
+ app: shop-detail
+ detailVersion: v2
+ template:
+ metadata:
+ labels:
+ app: shop-detail
+ detailVersion: v2
+ spec:
+ volumes:
+ - name: skywalking-agent
+ emptyDir: { }
+
+ initContainers:
+ - name: agent-container
+ image: apache/skywalking-java-agent:8.13.0-java17
+ volumeMounts:
+ - name: skywalking-agent
+ mountPath: /agent
+ command: [ "/bin/sh" ]
+ args: [ "-c", "cp -R /skywalking/agent /agent/" ]
+
+ containers:
+ - name: shop-detail
+ image: apache/dubbo-demo:dubbo-samples-shop-detail_v2_0.0.1
+ imagePullPolicy: Always
+ ports:
+ - name: dubbo
+ containerPort: 20886
+ protocol: TCP
+ - name: dubbo-qos
+ containerPort: 20996
+ protocol: TCP
+ volumeMounts:
+ - name: skywalking-agent
+ mountPath: /skywalking
+ env:
+ - name: JAVA_TOOL_OPTIONS
+ value: "-javaagent:/skywalking/agent/skywalking-agent.jar"
+ - name: SW_AGENT_NAME
+ value: shop::shop-detail
+ - name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
+ value: "skywalking-oap-server.dubbo-system.svc:11800"
+ - name: DUBBO_LABELS
+ value: "detailVersion=v2; region=hangzhou;"
+---
+
+#App Comment v1
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: shop-comment-v1
+ namespace: dubbo-demo
+spec:
+ replicas: 3
+ selector:
+ matchLabels:
+ app: shop-comment
+ commentVersion: v1
+ template:
+ metadata:
+ labels:
+ app: shop-comment
+ commentVersion: v1
+ spec:
+ volumes:
+ - name: skywalking-agent
+ emptyDir: { }
+
+ initContainers:
+ - name: agent-container
+ image: apache/skywalking-java-agent:8.13.0-java17
+ volumeMounts:
+ - name: skywalking-agent
+ mountPath: /agent
+ command: [ "/bin/sh" ]
+ args: [ "-c", "cp -R /skywalking/agent /agent/" ]
+
+ containers:
+ - name: shop-comment
+ image: apache/dubbo-demo:dubbo-samples-shop-comment_0.0.1
+ imagePullPolicy: Always
+ ports:
+ - name: dubbo
+ containerPort: 20887
+ protocol: TCP
+ - name: dubbo-qos
+ containerPort: 20997
+ protocol: TCP
+ volumeMounts:
+ - name: skywalking-agent
+ mountPath: /skywalking
+ env:
+ - name: JAVA_TOOL_OPTIONS
+ value: "-javaagent:/skywalking/agent/skywalking-agent.jar"
+ - name: SW_AGENT_NAME
+ value: shop::shop-comment
+ - name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
+ value: "skywalking-oap-server.dubbo-system.svc:11800"
+ - name: DUBBO_LABELS
+ value: "commentVersion=v1; region=beijing"
+---
+
+#App Comment v2
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: shop-comment-v2
+ namespace: dubbo-demo
+spec:
+ replicas: 3
+ selector:
+ matchLabels:
+ app: shop-comment
+ commentVersion: v2
+ template:
+ metadata:
+ labels:
+ app: shop-comment
+ commentVersion: v2
+ spec:
+ volumes:
+ - name: skywalking-agent
+ emptyDir: { }
+
+ initContainers:
+ - name: agent-container
+ image: apache/skywalking-java-agent:8.13.0-java17
+ volumeMounts:
+ - name: skywalking-agent
+ mountPath: /agent
+ command: [ "/bin/sh" ]
+ args: [ "-c", "cp -R /skywalking/agent /agent/" ]
+
+ containers:
+ - name: shop-comment
+ image: apache/dubbo-demo:dubbo-samples-shop-comment_v2_0.0.1
+ imagePullPolicy: Always
+ ports:
+ - name: dubbo
+ containerPort: 20888
+ protocol: TCP
+ - name: dubbo-qos
+ containerPort: 20998
+ protocol: TCP
+ volumeMounts:
+ - name: skywalking-agent
+ mountPath: /skywalking
+ env:
+ - name: JAVA_TOOL_OPTIONS
+ value: "-javaagent:/skywalking/agent/skywalking-agent.jar"
+ - name: SW_AGENT_NAME
+ value: shop::shop-comment
+ - name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
+ value: "skywalking-oap-server.dubbo-system.svc:11800"
+ - name: DUBBO_LABELS
+ value: "commentVersion=v2; region=hangzhou;"
diff --git a/10-task/dubbo-samples-shop/deploy/App.yml b/10-task/dubbo-samples-shop/deploy/Gray.yml
similarity index 70%
copy from 10-task/dubbo-samples-shop/deploy/App.yml
copy to 10-task/dubbo-samples-shop/deploy/Gray.yml
index 09c75f0b..5f97c156 100644
--- a/10-task/dubbo-samples-shop/deploy/App.yml
+++ b/10-task/dubbo-samples-shop/deploy/Gray.yml
@@ -13,21 +13,20 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-# App FrontEnd
apiVersion: apps/v1
kind: Deployment
metadata:
- name: shop-frontend
+ name: shop-user-gray
namespace: dubbo-demo
spec:
- replicas: 1
+ replicas: 3
selector:
matchLabels:
- app: shop-frontend
+ app: shop-user
template:
metadata:
labels:
- app: shop-frontend
+ app: shop-user
spec:
volumes:
- name: skywalking-agent
@@ -43,15 +42,15 @@ spec:
args: [ "-c", "cp -R /skywalking/agent /agent/" ]
containers:
- - name: shop-frontend
- image: apache/dubbo-demo:dubbo-samples-shop-frontend_0.0.1
+ - name: shop-user-gray
+ image: apache/dubbo-demo:dubbo-samples-shop-user_gray_0.0.1
imagePullPolicy: Always
ports:
- name: dubbo
- containerPort: 20881
+ containerPort: 20892
protocol: TCP
- name: dubbo-qos
- containerPort: 20991
+ containerPort: 21002
protocol: TCP
volumeMounts:
- name: skywalking-agent
@@ -60,78 +59,29 @@ spec:
- name: JAVA_TOOL_OPTIONS
value: "-javaagent:/skywalking/agent/skywalking-agent.jar"
- name: SW_AGENT_NAME
- value: shop::shop-frontend
+ value: shop::shop-user
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
value: "skywalking-oap-server.dubbo-system.svc:11800"
+ - name: DUBBO_LABELS
+ value: "env=gray"
---
-# App Order V1
apiVersion: apps/v1
kind: Deployment
metadata:
- name: shop-order-v1
+ name: shop-order-v1-gray
namespace: dubbo-demo
spec:
replicas: 2
selector:
matchLabels:
- app: shop-order-v1
- template:
- metadata:
- labels:
- app: shop-order-v1
- spec:
- volumes:
- - name: skywalking-agent
- emptyDir: { }
-
- initContainers:
- - name: agent-container
- image: apache/skywalking-java-agent:8.13.0-java17
- volumeMounts:
- - name: skywalking-agent
- mountPath: /agent
- command: [ "/bin/sh" ]
- args: [ "-c", "cp -R /skywalking/agent /agent/" ]
-
- containers:
- - name: shop-order
- image: apache/dubbo-demo:dubbo-samples-shop-order_v1_0.0.1
- imagePullPolicy: Always
- ports:
- - name: dubbo
- containerPort: 20882
- protocol: TCP
- - name: dubbo-qos
- containerPort: 20992
- protocol: TCP
- volumeMounts:
- - name: skywalking-agent
- mountPath: /skywalking
- env:
- - name: JAVA_TOOL_OPTIONS
- value: "-javaagent:/skywalking/agent/skywalking-agent.jar"
- - name: SW_AGENT_NAME
- value: shop::shop-order
- - name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
- value: "skywalking-oap-server.dubbo-system.svc:11800"
----
-
-# App Order V2
-apiVersion: apps/v1
-kind: Deployment
-metadata:
- name: shop-order-v2
- namespace: dubbo-demo
-spec:
- replicas: 3
- selector:
- matchLabels:
- app: shop-order-v2
+ app: shop-order
+ orderVersion: v1
template:
metadata:
labels:
- app: shop-order-v2
+ app: shop-order
+ orderVersion: v1
spec:
volumes:
- name: skywalking-agent
@@ -148,14 +98,14 @@ spec:
containers:
- name: shop-order
- image: apache/dubbo-demo:dubbo-samples-shop-order_v2_0.0.1
+ image: apache/dubbo-demo:dubbo-samples-shop-order_gray_0.0.1
imagePullPolicy: Always
ports:
- name: dubbo
- containerPort: 20883
+ containerPort: 20891
protocol: TCP
- name: dubbo-qos
- containerPort: 20993
+ containerPort: 21001
protocol: TCP
volumeMounts:
- name: skywalking-agent
@@ -167,24 +117,25 @@ spec:
value: shop::shop-order
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
value: "skywalking-oap-server.dubbo-system.svc:11800"
-
+ - name: DUBBO_LABELS
+ value: "env=gray"
---
-
-# App User
apiVersion: apps/v1
kind: Deployment
metadata:
- name: shop-user
+ name: shop-detail-v1-gray
namespace: dubbo-demo
spec:
replicas: 3
selector:
matchLabels:
- app: shop-user
+ app: shop-detail
+ detailVersion: v1
template:
metadata:
labels:
- app: shop-user
+ app: shop-detail
+ detailVersion: v1
spec:
volumes:
- name: skywalking-agent
@@ -200,15 +151,15 @@ spec:
args: [ "-c", "cp -R /skywalking/agent /agent/" ]
containers:
- - name: shop-user
- image: apache/dubbo-demo:dubbo-samples-shop-user_0.0.1
+ - name: shop-detail
+ image: apache/dubbo-demo:dubbo-samples-shop-detail_gray_0.0.1
imagePullPolicy: Always
ports:
- name: dubbo
- containerPort: 20884
+ containerPort: 20890
protocol: TCP
- name: dubbo-qos
- containerPort: 20994
+ containerPort: 21000
protocol: TCP
volumeMounts:
- name: skywalking-agent
@@ -217,26 +168,28 @@ spec:
- name: JAVA_TOOL_OPTIONS
value: "-javaagent:/skywalking/agent/skywalking-agent.jar"
- name: SW_AGENT_NAME
- value: shop::shop-user
+ value: shop::shop-detail
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
value: "skywalking-oap-server.dubbo-system.svc:11800"
+ - name: DUBBO_LABELS
+ value: "env=gray"
---
-
-# App Detail
apiVersion: apps/v1
kind: Deployment
metadata:
- name: shop-detail
+ name: shop-comment-v1-gray
namespace: dubbo-demo
spec:
replicas: 3
selector:
matchLabels:
- app: shop-detail
+ app: shop-comment
+ commentVersion: v1
template:
metadata:
labels:
- app: shop-detail
+ app: shop-comment
+ commentVersion: v1
spec:
volumes:
- name: skywalking-agent
@@ -252,15 +205,15 @@ spec:
args: [ "-c", "cp -R /skywalking/agent /agent/" ]
containers:
- - name: shop-detail
- image: apache/dubbo-demo:dubbo-samples-shop-detail_0.0.1
+ - name: shop-comment
+ image: apache/dubbo-demo:dubbo-samples-shop-comment_gray_0.0.1
imagePullPolicy: Always
ports:
- name: dubbo
- containerPort: 20885
+ containerPort: 20889
protocol: TCP
- name: dubbo-qos
- containerPort: 20995
+ containerPort: 20999
protocol: TCP
volumeMounts:
- name: skywalking-agent
@@ -269,7 +222,9 @@ spec:
- name: JAVA_TOOL_OPTIONS
value: "-javaagent:/skywalking/agent/skywalking-agent.jar"
- name: SW_AGENT_NAME
- value: shop::shop-detail
+ value: shop::shop-comment
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
value: "skywalking-oap-server.dubbo-system.svc:11800"
----
+ - name: DUBBO_LABELS
+ value: "env=gray"
+---
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/deploy/order-v2/Deployment.yml b/10-task/dubbo-samples-shop/deploy/comment-v1-gray/Deployment.yml
similarity index 82%
copy from 10-task/dubbo-samples-shop/deploy/order-v2/Deployment.yml
copy to 10-task/dubbo-samples-shop/deploy/comment-v1-gray/Deployment.yml
index cdde71bb..0e6425e8 100644
--- a/10-task/dubbo-samples-shop/deploy/order-v2/Deployment.yml
+++ b/10-task/dubbo-samples-shop/deploy/comment-v1-gray/Deployment.yml
@@ -16,17 +16,19 @@
apiVersion: apps/v1
kind: Deployment
metadata:
- name: shop-order-v2
+ name: shop-comment-v1-gray
namespace: dubbo-demo
spec:
replicas: 3
selector:
matchLabels:
- app: shop-order-v2
+ app: shop-comment
+ commentVersion: v1
template:
metadata:
labels:
- app: shop-order-v2
+ app: shop-comment
+ commentVersion: v1
spec:
volumes:
- name: skywalking-agent
@@ -42,15 +44,15 @@ spec:
args: [ "-c", "cp -R /skywalking/agent /agent/" ]
containers:
- - name: shop-order
- image: apache/dubbo-demo:dubbo-samples-shop-order_v2_0.0.1
+ - name: shop-comment
+ image: apache/dubbo-demo:dubbo-samples-shop-comment_gray_0.0.1
imagePullPolicy: Always
ports:
- name: dubbo
- containerPort: 20883
+ containerPort: 20889
protocol: TCP
- name: dubbo-qos
- containerPort: 20993
+ containerPort: 20999
protocol: TCP
volumeMounts:
- name: skywalking-agent
@@ -59,6 +61,8 @@ spec:
- name: JAVA_TOOL_OPTIONS
value: "-javaagent:/skywalking/agent/skywalking-agent.jar"
- name: SW_AGENT_NAME
- value: shop::shop-order
+ value: shop::shop-comment
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
value: "skywalking-oap-server.dubbo-system.svc:11800"
+ - name: DUBBO_LABELS
+ value: "env=gray"
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/deploy/order-v2/Deployment.yml b/10-task/dubbo-samples-shop/deploy/comment-v1/Deployment.yml
similarity index 81%
copy from 10-task/dubbo-samples-shop/deploy/order-v2/Deployment.yml
copy to 10-task/dubbo-samples-shop/deploy/comment-v1/Deployment.yml
index cdde71bb..54d551e8 100644
--- a/10-task/dubbo-samples-shop/deploy/order-v2/Deployment.yml
+++ b/10-task/dubbo-samples-shop/deploy/comment-v1/Deployment.yml
@@ -16,17 +16,19 @@
apiVersion: apps/v1
kind: Deployment
metadata:
- name: shop-order-v2
+ name: shop-comment-v1
namespace: dubbo-demo
spec:
replicas: 3
selector:
matchLabels:
- app: shop-order-v2
+ app: shop-comment
+ commentVersion: v1
template:
metadata:
labels:
- app: shop-order-v2
+ app: shop-comment
+ commentVersion: v1
spec:
volumes:
- name: skywalking-agent
@@ -42,15 +44,15 @@ spec:
args: [ "-c", "cp -R /skywalking/agent /agent/" ]
containers:
- - name: shop-order
- image: apache/dubbo-demo:dubbo-samples-shop-order_v2_0.0.1
+ - name: shop-comment
+ image: apache/dubbo-demo:dubbo-samples-shop-comment_0.0.1
imagePullPolicy: Always
ports:
- name: dubbo
- containerPort: 20883
+ containerPort: 20887
protocol: TCP
- name: dubbo-qos
- containerPort: 20993
+ containerPort: 20997
protocol: TCP
volumeMounts:
- name: skywalking-agent
@@ -59,6 +61,8 @@ spec:
- name: JAVA_TOOL_OPTIONS
value: "-javaagent:/skywalking/agent/skywalking-agent.jar"
- name: SW_AGENT_NAME
- value: shop::shop-order
+ value: shop::shop-comment
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
value: "skywalking-oap-server.dubbo-system.svc:11800"
+ - name: DUBBO_LABELS
+ value: "commentVersion=v1; region=beijing"
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/deploy/order-v2/Deployment.yml b/10-task/dubbo-samples-shop/deploy/comment-v2/Deployment.yml
similarity index 81%
copy from 10-task/dubbo-samples-shop/deploy/order-v2/Deployment.yml
copy to 10-task/dubbo-samples-shop/deploy/comment-v2/Deployment.yml
index cdde71bb..566a77b0 100644
--- a/10-task/dubbo-samples-shop/deploy/order-v2/Deployment.yml
+++ b/10-task/dubbo-samples-shop/deploy/comment-v2/Deployment.yml
@@ -16,17 +16,19 @@
apiVersion: apps/v1
kind: Deployment
metadata:
- name: shop-order-v2
+ name: shop-comment-v2
namespace: dubbo-demo
spec:
replicas: 3
selector:
matchLabels:
- app: shop-order-v2
+ app: shop-comment
+ commentVersion: v2
template:
metadata:
labels:
- app: shop-order-v2
+ app: shop-comment
+ commentVersion: v2
spec:
volumes:
- name: skywalking-agent
@@ -42,15 +44,15 @@ spec:
args: [ "-c", "cp -R /skywalking/agent /agent/" ]
containers:
- - name: shop-order
- image: apache/dubbo-demo:dubbo-samples-shop-order_v2_0.0.1
+ - name: shop-comment
+ image: apache/dubbo-demo:dubbo-samples-shop-comment_v2_0.0.1
imagePullPolicy: Always
ports:
- name: dubbo
- containerPort: 20883
+ containerPort: 20888
protocol: TCP
- name: dubbo-qos
- containerPort: 20993
+ containerPort: 20998
protocol: TCP
volumeMounts:
- name: skywalking-agent
@@ -59,6 +61,8 @@ spec:
- name: JAVA_TOOL_OPTIONS
value: "-javaagent:/skywalking/agent/skywalking-agent.jar"
- name: SW_AGENT_NAME
- value: shop::shop-order
+ value: shop::shop-comment
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
value: "skywalking-oap-server.dubbo-system.svc:11800"
+ - name: DUBBO_LABELS
+ value: "commentVersion=v2; region=hangzhou;"
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/deploy/detail/Deployment.yml b/10-task/dubbo-samples-shop/deploy/detail-v1-gray/Deployment.yml
similarity index 87%
copy from 10-task/dubbo-samples-shop/deploy/detail/Deployment.yml
copy to 10-task/dubbo-samples-shop/deploy/detail-v1-gray/Deployment.yml
index 301ff76c..6895a4b3 100644
--- a/10-task/dubbo-samples-shop/deploy/detail/Deployment.yml
+++ b/10-task/dubbo-samples-shop/deploy/detail-v1-gray/Deployment.yml
@@ -16,17 +16,19 @@
apiVersion: apps/v1
kind: Deployment
metadata:
- name: shop-detail
+ name: shop-detail-v1-gray
namespace: dubbo-demo
spec:
replicas: 3
selector:
matchLabels:
app: shop-detail
+ detailVersion: v1
template:
metadata:
labels:
app: shop-detail
+ detailVersion: v1
spec:
volumes:
- name: skywalking-agent
@@ -43,14 +45,14 @@ spec:
containers:
- name: shop-detail
- image: apache/dubbo-demo:dubbo-samples-shop-detail_0.0.1
+ image: apache/dubbo-demo:dubbo-samples-shop-detail_gray_0.0.1
imagePullPolicy: Always
ports:
- name: dubbo
- containerPort: 20885
+ containerPort: 20890
protocol: TCP
- name: dubbo-qos
- containerPort: 20995
+ containerPort: 21000
protocol: TCP
volumeMounts:
- name: skywalking-agent
@@ -62,3 +64,5 @@ spec:
value: shop::shop-detail
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
value: "skywalking-oap-server.dubbo-system.svc:11800"
+ - name: DUBBO_LABELS
+ value: "env=gray"
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/deploy/detail/Deployment.yml b/10-task/dubbo-samples-shop/deploy/detail-v1/Deployment.yml
similarity index 93%
copy from 10-task/dubbo-samples-shop/deploy/detail/Deployment.yml
copy to 10-task/dubbo-samples-shop/deploy/detail-v1/Deployment.yml
index 301ff76c..4efa357b 100644
--- a/10-task/dubbo-samples-shop/deploy/detail/Deployment.yml
+++ b/10-task/dubbo-samples-shop/deploy/detail-v1/Deployment.yml
@@ -16,17 +16,19 @@
apiVersion: apps/v1
kind: Deployment
metadata:
- name: shop-detail
+ name: shop-detail-v1
namespace: dubbo-demo
spec:
replicas: 3
selector:
matchLabels:
app: shop-detail
+ detailVersion: v1
template:
metadata:
labels:
app: shop-detail
+ detailVersion: v1
spec:
volumes:
- name: skywalking-agent
@@ -62,3 +64,5 @@ spec:
value: shop::shop-detail
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
value: "skywalking-oap-server.dubbo-system.svc:11800"
+ - name: DUBBO_LABELS
+ value: "detailVersion=v1; region=beijing"
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/deploy/detail/Deployment.yml b/10-task/dubbo-samples-shop/deploy/detail-v2/Deployment.yml
similarity index 86%
rename from 10-task/dubbo-samples-shop/deploy/detail/Deployment.yml
rename to 10-task/dubbo-samples-shop/deploy/detail-v2/Deployment.yml
index 301ff76c..ed7df3a1 100644
--- a/10-task/dubbo-samples-shop/deploy/detail/Deployment.yml
+++ b/10-task/dubbo-samples-shop/deploy/detail-v2/Deployment.yml
@@ -16,17 +16,19 @@
apiVersion: apps/v1
kind: Deployment
metadata:
- name: shop-detail
+ name: shop-detail-v2
namespace: dubbo-demo
spec:
replicas: 3
selector:
matchLabels:
app: shop-detail
+ detailVersion: v2
template:
metadata:
labels:
app: shop-detail
+ detailVersion: v2
spec:
volumes:
- name: skywalking-agent
@@ -43,14 +45,14 @@ spec:
containers:
- name: shop-detail
- image: apache/dubbo-demo:dubbo-samples-shop-detail_0.0.1
+ image: apache/dubbo-demo:dubbo-samples-shop-detail_v2_0.0.1
imagePullPolicy: Always
ports:
- name: dubbo
- containerPort: 20885
+ containerPort: 20886
protocol: TCP
- name: dubbo-qos
- containerPort: 20995
+ containerPort: 20996
protocol: TCP
volumeMounts:
- name: skywalking-agent
@@ -62,3 +64,5 @@ spec:
value: shop::shop-detail
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
value: "skywalking-oap-server.dubbo-system.svc:11800"
+ - name: DUBBO_LABELS
+ value: "detailVersion=v2; region=hangzhou;"
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/deploy/order-v1/Deployment.yml b/10-task/dubbo-samples-shop/deploy/order-v1-gray/Deployment.yml
similarity index 85%
copy from 10-task/dubbo-samples-shop/deploy/order-v1/Deployment.yml
copy to 10-task/dubbo-samples-shop/deploy/order-v1-gray/Deployment.yml
index 36e54d93..464e458b 100644
--- a/10-task/dubbo-samples-shop/deploy/order-v1/Deployment.yml
+++ b/10-task/dubbo-samples-shop/deploy/order-v1-gray/Deployment.yml
@@ -16,17 +16,19 @@
apiVersion: apps/v1
kind: Deployment
metadata:
- name: shop-order-v1
+ name: shop-order-v1-gray
namespace: dubbo-demo
spec:
replicas: 2
selector:
matchLabels:
- app: shop-order-v1
+ app: shop-order
+ orderVersion: v1
template:
metadata:
labels:
- app: shop-order-v1
+ app: shop-order
+ orderVersion: v1
spec:
volumes:
- name: skywalking-agent
@@ -43,14 +45,14 @@ spec:
containers:
- name: shop-order
- image: apache/dubbo-demo:dubbo-samples-shop-order_v1_0.0.1
+ image: apache/dubbo-demo:dubbo-samples-shop-order_gray_0.0.1
imagePullPolicy: Always
ports:
- name: dubbo
- containerPort: 20882
+ containerPort: 20891
protocol: TCP
- name: dubbo-qos
- containerPort: 20992
+ containerPort: 21001
protocol: TCP
volumeMounts:
- name: skywalking-agent
@@ -62,3 +64,5 @@ spec:
value: shop::shop-order
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
value: "skywalking-oap-server.dubbo-system.svc:11800"
+ - name: DUBBO_LABELS
+ value: "env=gray"
diff --git a/10-task/dubbo-samples-shop/deploy/order-v1/Deployment.yml b/10-task/dubbo-samples-shop/deploy/order-v1/Deployment.yml
index 36e54d93..c26e3990 100644
--- a/10-task/dubbo-samples-shop/deploy/order-v1/Deployment.yml
+++ b/10-task/dubbo-samples-shop/deploy/order-v1/Deployment.yml
@@ -22,11 +22,13 @@ spec:
replicas: 2
selector:
matchLabels:
- app: shop-order-v1
+ app: shop-order
+ orderVersion: v1
template:
metadata:
labels:
- app: shop-order-v1
+ app: shop-order
+ orderVersion: v1
spec:
volumes:
- name: skywalking-agent
@@ -62,3 +64,5 @@ spec:
value: shop::shop-order
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
value: "skywalking-oap-server.dubbo-system.svc:11800"
+ - name: DUBBO_LABELS
+ value: "orderVersion=v1"
diff --git a/10-task/dubbo-samples-shop/deploy/order-v2/Deployment.yml b/10-task/dubbo-samples-shop/deploy/order-v2/Deployment.yml
index cdde71bb..5c448d74 100644
--- a/10-task/dubbo-samples-shop/deploy/order-v2/Deployment.yml
+++ b/10-task/dubbo-samples-shop/deploy/order-v2/Deployment.yml
@@ -22,11 +22,13 @@ spec:
replicas: 3
selector:
matchLabels:
- app: shop-order-v2
+ app: shop-order
+ orderVersion: v2
template:
metadata:
labels:
- app: shop-order-v2
+ app: shop-order
+ orderVersion: v2
spec:
volumes:
- name: skywalking-agent
@@ -62,3 +64,5 @@ spec:
value: shop::shop-order
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
value: "skywalking-oap-server.dubbo-system.svc:11800"
+ - name: DUBBO_LABELS
+ value: "orderVersion=v2;"
diff --git a/10-task/dubbo-samples-shop/deploy/traffic-rules/accesslog.yaml b/10-task/dubbo-samples-shop/deploy/traffic-rules/accesslog.yaml
new file mode 100644
index 00000000..49668abf
--- /dev/null
+++ b/10-task/dubbo-samples-shop/deploy/traffic-rules/accesslog.yaml
@@ -0,0 +1,25 @@
+# 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.
+
+# This rule sets the timeout value of service 'UserService' to 5000ms
+---
+configVersion: v3.0
+scope: application
+key: shop-detail
+configs:
+ - side: provier
+ parameters:
+ accesslog: true
+...
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/deploy/traffic-rules/arguments.yaml b/10-task/dubbo-samples-shop/deploy/traffic-rules/arguments.yaml
new file mode 100644
index 00000000..b15f41e9
--- /dev/null
+++ b/10-task/dubbo-samples-shop/deploy/traffic-rules/arguments.yaml
@@ -0,0 +1,25 @@
+# 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.
+
+---
+scope: service
+force: false
+runtime: false
+enabled: true
+priority: 1
+key: org.apache.dubbo.samples.DetailService
+conditions:
+ - arguments[1]=dubbo => orderVersion=v2
+...
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/deploy/traffic-rules/isolation-env.yaml b/10-task/dubbo-samples-shop/deploy/traffic-rules/isolation-env.yaml
new file mode 100644
index 00000000..30eeb52b
--- /dev/null
+++ b/10-task/dubbo-samples-shop/deploy/traffic-rules/isolation-env.yaml
@@ -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.
+
+---
+configVersion: v3.0
+force: true
+runtime: false
+enabled: true
+priority: 1
+key: shop-comment
+tags:
+ - name: gray
+ match:
+ - key: env
+ value:
+ exact: gray
+...
+
+---
+configVersion: v3.0
+force: true
+runtime: false
+enabled: true
+priority: 1
+key: shop-detail
+tags:
+ - name: gray
+ match:
+ - key: env
+ value:
+ exact: gray
+...
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/deploy/traffic-rules/region-affinity.yaml b/10-task/dubbo-samples-shop/deploy/traffic-rules/region-affinity.yaml
new file mode 100644
index 00000000..3ce54160
--- /dev/null
+++ b/10-task/dubbo-samples-shop/deploy/traffic-rules/region-affinity.yaml
@@ -0,0 +1,25 @@
+# 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.
+
+---
+scope: service
+key: org.apache.dubbo.samples.CommentService
+force: false
+runtime: false
+enabled: true
+priority: 1
+conditions:
+ - => region=$region
+...
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/deploy/traffic-rules/retry.yaml b/10-task/dubbo-samples-shop/deploy/traffic-rules/retry.yaml
new file mode 100644
index 00000000..096c4ba5
--- /dev/null
+++ b/10-task/dubbo-samples-shop/deploy/traffic-rules/retry.yaml
@@ -0,0 +1,30 @@
+# 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.
+
+# This rule tells shop-frontend to retry 2 times when encounters failure calling UserService
+---
+configVersion: v3.0
+scope: service
+key: org.apache.dubbo.samples.UserService
+configs:
+ - match:
+ application:
+ oneof:
+ - shop-frontend
+ side: consumer
+ parameters:
+ retries: 4
+ cluster: failover
+...
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/deploy/traffic-rules/timeout.yaml b/10-task/dubbo-samples-shop/deploy/traffic-rules/timeout.yaml
new file mode 100644
index 00000000..e0ec618b
--- /dev/null
+++ b/10-task/dubbo-samples-shop/deploy/traffic-rules/timeout.yaml
@@ -0,0 +1,25 @@
+# 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.
+
+# This rule sets the timeout value of service 'UserService' to 5000ms
+---
+configVersion: v3.0
+scope: service
+key: org.apache.dubbo.samples.UserService
+configs:
+ - side: provider
+ parameters:
+ timeout: 2000
+...
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/deploy/traffic-rules/traffic-split.yaml b/10-task/dubbo-samples-shop/deploy/traffic-rules/traffic-split.yaml
new file mode 100644
index 00000000..ae1e83ee
--- /dev/null
+++ b/10-task/dubbo-samples-shop/deploy/traffic-rules/traffic-split.yaml
@@ -0,0 +1,14 @@
+# 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.
diff --git a/10-task/dubbo-samples-shop/deploy/traffic-rules/weight.yaml b/10-task/dubbo-samples-shop/deploy/traffic-rules/weight.yaml
new file mode 100644
index 00000000..619467c9
--- /dev/null
+++ b/10-task/dubbo-samples-shop/deploy/traffic-rules/weight.yaml
@@ -0,0 +1,30 @@
+# 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.
+
+# This rule sets the timeout value of service 'UserService' to 5000ms
+---
+configVersion: v3.0
+scope: service
+key: org.apache.dubbo.samples.OrderService
+configs:
+ - side: provider
+ match:
+ param:
+ - key: orderVersion
+ value:
+ exact: v2
+ parameters:
+ weight: 25
+...
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/deploy/order-v2/Deployment.yml b/10-task/dubbo-samples-shop/deploy/user-gray/Deployment.yml
similarity index 84%
copy from 10-task/dubbo-samples-shop/deploy/order-v2/Deployment.yml
copy to 10-task/dubbo-samples-shop/deploy/user-gray/Deployment.yml
index cdde71bb..5b074a2b 100644
--- a/10-task/dubbo-samples-shop/deploy/order-v2/Deployment.yml
+++ b/10-task/dubbo-samples-shop/deploy/user-gray/Deployment.yml
@@ -16,17 +16,17 @@
apiVersion: apps/v1
kind: Deployment
metadata:
- name: shop-order-v2
+ name: shop-user-gray
namespace: dubbo-demo
spec:
replicas: 3
selector:
matchLabels:
- app: shop-order-v2
+ app: shop-user
template:
metadata:
labels:
- app: shop-order-v2
+ app: shop-user
spec:
volumes:
- name: skywalking-agent
@@ -42,15 +42,15 @@ spec:
args: [ "-c", "cp -R /skywalking/agent /agent/" ]
containers:
- - name: shop-order
- image: apache/dubbo-demo:dubbo-samples-shop-order_v2_0.0.1
+ - name: shop-user-gray
+ image: apache/dubbo-demo:dubbo-samples-shop-user_gray_0.0.1
imagePullPolicy: Always
ports:
- name: dubbo
- containerPort: 20883
+ containerPort: 20892
protocol: TCP
- name: dubbo-qos
- containerPort: 20993
+ containerPort: 21002
protocol: TCP
volumeMounts:
- name: skywalking-agent
@@ -59,6 +59,8 @@ spec:
- name: JAVA_TOOL_OPTIONS
value: "-javaagent:/skywalking/agent/skywalking-agent.jar"
- name: SW_AGENT_NAME
- value: shop::shop-order
+ value: shop::shop-user
- name: SW_AGENT_COLLECTOR_BACKEND_SERVICES
value: "skywalking-oap-server.dubbo-system.svc:11800"
+ - name: DUBBO_LABELS
+ value: "env=gray"
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend-api/pom.xml b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-api/pom.xml
similarity index 87%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-frontend-api/pom.xml
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-comment-api/pom.xml
index 801b0466..d3eaa4db 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend-api/pom.xml
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-api/pom.xml
@@ -27,10 +27,10 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.apache.dubbo.samples</groupId>
- <artifactId>dubbo-samples-shop-frontend-api</artifactId>
+ <artifactId>dubbo-samples-shop-comment-api</artifactId>
<version>0.0.1-SNAPSHOT</version>
- <name>Dubbo Task - Shop - FrontEnd's API</name>
- <description>Dubbo Task - Shop - FrontEnd's API</description>
+ <name>Dubbo Task - Shop - Comment's API</name>
+ <description>Dubbo Task - Shop - Comment's API</description>
</project>
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-order-api/src/main/java/org/apache/dubbo/samples/OrderService.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-api/src/main/java/org/apache/dubbo/samples/CommentService.java
similarity index 91%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-order-api/src/main/java/org/apache/dubbo/samples/OrderService.java
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-comment-api/src/main/java/org/apache/dubbo/samples/CommentService.java
index f1a6eb91..f44dd39d 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-order-api/src/main/java/org/apache/dubbo/samples/OrderService.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-api/src/main/java/org/apache/dubbo/samples/CommentService.java
@@ -16,7 +16,6 @@
*/
package org.apache.dubbo.samples;
-public interface OrderService {
-
- boolean submitOrder(Order order);
+public interface CommentService {
+ String getComment(String itemName);
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-user/pom.xml b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-gray/pom.xml
similarity index 88%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-user/pom.xml
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-comment-gray/pom.xml
index e0c14f3a..5f8c9965 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-user/pom.xml
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-gray/pom.xml
@@ -26,23 +26,23 @@
</parent>
<groupId>org.apache.dubbo.samples</groupId>
- <artifactId>dubbo-samples-shop-user</artifactId>
+ <artifactId>dubbo-samples-shop-comment-gray</artifactId>
<version>0.0.1-SNAPSHOT</version>
- <name>Dubbo Task - Shop - User</name>
- <description>Dubbo Task - Shop - User</description>
+ <name>Dubbo Task - Shop - Comment Gray</name>
+ <description>Dubbo Task - Shop - Comment Gray</description>
<properties>
<java.version>17</java.version>
- <dubbo.version>3.2.0-beta.4</dubbo.version>
+ <dubbo.version>3.2.0-beta.5-SNAPSHOT</dubbo.version>
<nacos.version>2.2.0</nacos.version>
</properties>
<dependencies>
- <!-- common api -->
+ <!-- comment api -->
<dependency>
<groupId>org.apache.dubbo.samples</groupId>
- <artifactId>dubbo-samples-shop-user-api</artifactId>
+ <artifactId>dubbo-samples-shop-comment-api</artifactId>
<version>${project.version}</version>
</dependency>
@@ -88,15 +88,15 @@
<version>3.2.1</version>
<configuration>
<to>
- <image>apache/dubbo-demo:dubbo-samples-shop-user_0.0.1</image>
+ <image>apache/dubbo-demo:dubbo-samples-shop-comment_gray_0.0.1</image>
</to>
<container>
<jvmFlags>
<jvmFlag>-Dnacos.address=nacos.dubbo-system.svc</jvmFlag>
</jvmFlags>
<ports>
- <port>20884</port>
- <port>20994</port>
+ <port>20889</port>
+ <port>20999</port>
</ports>
</container>
</configuration>
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/java/org/apache/dubbo/samples/frontend/FrontEndApplication.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-gray/src/main/java/org/apache/dubbo/samples/comment/CommentApplicationGray.java
similarity index 88%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/java/org/apache/dubbo/samples/frontend/FrontEndApplication.java
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-comment-gray/src/main/java/org/apache/dubbo/samples/comment/CommentApplicationGray.java
index f6e80ec8..2e272be8 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/java/org/apache/dubbo/samples/frontend/FrontEndApplication.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-gray/src/main/java/org/apache/dubbo/samples/comment/CommentApplicationGray.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.samples.frontend;
+package org.apache.dubbo.samples.comment;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
@@ -23,10 +23,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@EnableDubbo
@SpringBootApplication
-public class FrontEndApplication {
+public class CommentApplicationGray {
public static void main(String[] args) {
- SpringApplication.run(FrontEndApplication.class, args);
+ SpringApplication.run(CommentApplicationGray.class, args);
}
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-api/src/main/java/org/apache/dubbo/samples/DetailService.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-gray/src/main/java/org/apache/dubbo/samples/comment/CommentServiceImplGray.java
similarity index 70%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-detail-api/src/main/java/org/apache/dubbo/samples/DetailService.java
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-comment-gray/src/main/java/org/apache/dubbo/samples/comment/CommentServiceImplGray.java
index 2b75902d..65f9ad3c 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-api/src/main/java/org/apache/dubbo/samples/DetailService.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-gray/src/main/java/org/apache/dubbo/samples/comment/CommentServiceImplGray.java
@@ -14,11 +14,17 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.samples;
+package org.apache.dubbo.samples.comment;
-public interface DetailService {
+import org.apache.dubbo.config.annotation.DubboService;
+import org.apache.dubbo.samples.CommentService;
- boolean createItem(Item item);
+@DubboService
+public class CommentServiceImplGray implements CommentService {
+
+ @Override
+ public String getComment(String itemName) {
+ return "Comment from Gray.";
+ }
- boolean deductStock(long sku, int count);
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/resources/application.properties b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-gray/src/main/resources/application.properties
similarity index 92%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/resources/application.properties
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-comment-gray/src/main/resources/application.properties
index c64a752d..7c58f1ce 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/resources/application.properties
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-gray/src/main/resources/application.properties
@@ -12,19 +12,14 @@
# 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=shop-detail
-
+dubbo.application.name=shop-comment
# Specify the QoS port
-dubbo.application.qos-port=20995
-
+dubbo.application.qos-port=20999
# 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=20885
\ No newline at end of file
+dubbo.protocol.port=20889
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-user/pom.xml b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-v1/pom.xml
similarity index 88%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-user/pom.xml
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-comment-v1/pom.xml
index e0c14f3a..516b0a94 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-user/pom.xml
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-v1/pom.xml
@@ -26,23 +26,23 @@
</parent>
<groupId>org.apache.dubbo.samples</groupId>
- <artifactId>dubbo-samples-shop-user</artifactId>
+ <artifactId>dubbo-samples-shop-comment-v1</artifactId>
<version>0.0.1-SNAPSHOT</version>
- <name>Dubbo Task - Shop - User</name>
- <description>Dubbo Task - Shop - User</description>
+ <name>Dubbo Task - Shop - Comment V1</name>
+ <description>Dubbo Task - Shop - Comment Version1</description>
<properties>
<java.version>17</java.version>
- <dubbo.version>3.2.0-beta.4</dubbo.version>
+ <dubbo.version>3.2.0-beta.5-SNAPSHOT</dubbo.version>
<nacos.version>2.2.0</nacos.version>
</properties>
<dependencies>
- <!-- common api -->
+ <!-- comment api -->
<dependency>
<groupId>org.apache.dubbo.samples</groupId>
- <artifactId>dubbo-samples-shop-user-api</artifactId>
+ <artifactId>dubbo-samples-shop-comment-api</artifactId>
<version>${project.version}</version>
</dependency>
@@ -88,15 +88,15 @@
<version>3.2.1</version>
<configuration>
<to>
- <image>apache/dubbo-demo:dubbo-samples-shop-user_0.0.1</image>
+ <image>apache/dubbo-demo:dubbo-samples-shop-comment_0.0.1</image>
</to>
<container>
<jvmFlags>
<jvmFlag>-Dnacos.address=nacos.dubbo-system.svc</jvmFlag>
</jvmFlags>
<ports>
- <port>20884</port>
- <port>20994</port>
+ <port>20887</port>
+ <port>20997</port>
</ports>
</container>
</configuration>
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailApplication.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-v1/src/main/java/org/apache/dubbo/samples/comment/CommentApplication.java
similarity index 88%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailApplication.java
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-comment-v1/src/main/java/org/apache/dubbo/samples/comment/CommentApplication.java
index c9fccda3..d296b273 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailApplication.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-v1/src/main/java/org/apache/dubbo/samples/comment/CommentApplication.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.samples.detail;
+package org.apache.dubbo.samples.comment;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
@@ -23,10 +23,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@EnableDubbo
@SpringBootApplication
-public class DetailApplication {
+public class CommentApplication {
public static void main(String[] args) {
- SpringApplication.run(DetailApplication.class, args);
+ SpringApplication.run(CommentApplication.class, args);
}
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-api/src/main/java/org/apache/dubbo/samples/DetailService.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-v1/src/main/java/org/apache/dubbo/samples/comment/CommentServiceImpl.java
similarity index 71%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-detail-api/src/main/java/org/apache/dubbo/samples/DetailService.java
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-comment-v1/src/main/java/org/apache/dubbo/samples/comment/CommentServiceImpl.java
index 2b75902d..f051e33a 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-api/src/main/java/org/apache/dubbo/samples/DetailService.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-v1/src/main/java/org/apache/dubbo/samples/comment/CommentServiceImpl.java
@@ -14,11 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.samples;
+package org.apache.dubbo.samples.comment;
-public interface DetailService {
+import org.apache.dubbo.config.annotation.DubboService;
+import org.apache.dubbo.samples.CommentService;
- boolean createItem(Item item);
-
- boolean deductStock(long sku, int count);
+@DubboService
+public class CommentServiceImpl implements CommentService {
+ @Override
+ public String getComment(String itemName) {
+ return "Comment from v1.";
+ }
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/resources/application.properties b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-v1/src/main/resources/application.properties
similarity index 92%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/resources/application.properties
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-comment-v1/src/main/resources/application.properties
index c64a752d..f2b0b533 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/resources/application.properties
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-v1/src/main/resources/application.properties
@@ -12,19 +12,14 @@
# 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=shop-detail
-
+dubbo.application.name=shop-comment
# Specify the QoS port
-dubbo.application.qos-port=20995
-
+dubbo.application.qos-port=20997
# 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=20885
\ No newline at end of file
+dubbo.protocol.port=20887
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-user/pom.xml b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-v2/pom.xml
similarity index 88%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-user/pom.xml
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-comment-v2/pom.xml
index e0c14f3a..801b2933 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-user/pom.xml
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-v2/pom.xml
@@ -26,23 +26,23 @@
</parent>
<groupId>org.apache.dubbo.samples</groupId>
- <artifactId>dubbo-samples-shop-user</artifactId>
+ <artifactId>dubbo-samples-shop-comment-v2</artifactId>
<version>0.0.1-SNAPSHOT</version>
- <name>Dubbo Task - Shop - User</name>
- <description>Dubbo Task - Shop - User</description>
+ <name>Dubbo Task - Shop - Comment V2</name>
+ <description>Dubbo Task - Shop - Comment Version2</description>
<properties>
<java.version>17</java.version>
- <dubbo.version>3.2.0-beta.4</dubbo.version>
+ <dubbo.version>3.2.0-beta.5-SNAPSHOT</dubbo.version>
<nacos.version>2.2.0</nacos.version>
</properties>
<dependencies>
- <!-- common api -->
+ <!-- comment api -->
<dependency>
<groupId>org.apache.dubbo.samples</groupId>
- <artifactId>dubbo-samples-shop-user-api</artifactId>
+ <artifactId>dubbo-samples-shop-comment-api</artifactId>
<version>${project.version}</version>
</dependency>
@@ -88,15 +88,15 @@
<version>3.2.1</version>
<configuration>
<to>
- <image>apache/dubbo-demo:dubbo-samples-shop-user_0.0.1</image>
+ <image>apache/dubbo-demo:dubbo-samples-shop-comment_v2_0.0.1</image>
</to>
<container>
<jvmFlags>
<jvmFlag>-Dnacos.address=nacos.dubbo-system.svc</jvmFlag>
</jvmFlags>
<ports>
- <port>20884</port>
- <port>20994</port>
+ <port>20888</port>
+ <port>20998</port>
</ports>
</container>
</configuration>
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailApplication.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-v2/src/main/java/org/apache/dubbo/samples/comment/CommentApplication2.java
similarity index 88%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailApplication.java
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-comment-v2/src/main/java/org/apache/dubbo/samples/comment/CommentApplication2.java
index c9fccda3..3e59bf58 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailApplication.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-v2/src/main/java/org/apache/dubbo/samples/comment/CommentApplication2.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.samples.detail;
+package org.apache.dubbo.samples.comment;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
@@ -23,10 +23,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@EnableDubbo
@SpringBootApplication
-public class DetailApplication {
+public class CommentApplication2 {
public static void main(String[] args) {
- SpringApplication.run(DetailApplication.class, args);
+ SpringApplication.run(CommentApplication2.class, args);
}
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-api/src/main/java/org/apache/dubbo/samples/DetailService.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-v2/src/main/java/org/apache/dubbo/samples/comment/CommentServiceImpl2.java
similarity index 71%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-detail-api/src/main/java/org/apache/dubbo/samples/DetailService.java
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-comment-v2/src/main/java/org/apache/dubbo/samples/comment/CommentServiceImpl2.java
index 2b75902d..cd4b6737 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-api/src/main/java/org/apache/dubbo/samples/DetailService.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-v2/src/main/java/org/apache/dubbo/samples/comment/CommentServiceImpl2.java
@@ -14,11 +14,15 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.samples;
+package org.apache.dubbo.samples.comment;
-public interface DetailService {
+import org.apache.dubbo.config.annotation.DubboService;
+import org.apache.dubbo.samples.CommentService;
- boolean createItem(Item item);
-
- boolean deductStock(long sku, int count);
+@DubboService
+public class CommentServiceImpl2 implements CommentService {
+ @Override
+ public String getComment(String itemName) {
+ return "Comment from v2.";
+ }
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/resources/application.properties b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-v2/src/main/resources/application.properties
similarity index 92%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/resources/application.properties
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-comment-v2/src/main/resources/application.properties
index c64a752d..1455b8d2 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/resources/application.properties
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-comment-v2/src/main/resources/application.properties
@@ -12,19 +12,14 @@
# 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=shop-detail
-
+dubbo.application.name=shop-comment
# Specify the QoS port
-dubbo.application.qos-port=20995
-
+dubbo.application.qos-port=20998
# 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=20885
\ No newline at end of file
+dubbo.protocol.port=20888
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-api/src/main/java/org/apache/dubbo/samples/DetailService.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-api/src/main/java/org/apache/dubbo/samples/DetailService.java
index 2b75902d..0c8b3696 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-api/src/main/java/org/apache/dubbo/samples/DetailService.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-api/src/main/java/org/apache/dubbo/samples/DetailService.java
@@ -18,7 +18,7 @@ package org.apache.dubbo.samples;
public interface DetailService {
- boolean createItem(Item item);
+ Item getItem(long sku, String username);
boolean deductStock(long sku, int count);
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-api/src/main/java/org/apache/dubbo/samples/Item.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-api/src/main/java/org/apache/dubbo/samples/Item.java
index 37153842..e7eb3375 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-api/src/main/java/org/apache/dubbo/samples/Item.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-api/src/main/java/org/apache/dubbo/samples/Item.java
@@ -23,6 +23,8 @@ public class Item implements Serializable {
private String itemName;
private String description;
private int stock;
+ private long price;
+ private String comment;
public long getSku() {
return sku;
@@ -55,4 +57,20 @@ public class Item implements Serializable {
public void setStock(int stock) {
this.stock = stock;
}
+
+ public long getPrice() {
+ return price;
+ }
+
+ public void setPrice(long price) {
+ this.price = price;
+ }
+
+ public String getComment() {
+ return comment;
+ }
+
+ public void setComment(String comment) {
+ this.comment = comment;
+ }
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v2/pom.xml b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-gray/pom.xml
similarity index 90%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-order-v2/pom.xml
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-detail-gray/pom.xml
index 039ae5b7..4792df2d 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v2/pom.xml
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-gray/pom.xml
@@ -26,15 +26,15 @@
</parent>
<groupId>org.apache.dubbo.samples</groupId>
- <artifactId>dubbo-samples-shop-order-v2</artifactId>
+ <artifactId>dubbo-samples-shop-detail-gray</artifactId>
<version>0.0.1-SNAPSHOT</version>
- <name>Dubbo Task - Shop - Order V2</name>
- <description>Dubbo Task - Shop - Order - Version 2</description>
+ <name>Dubbo Task - Shop - Detail Gray</name>
+ <description>Dubbo Task - Shop - Detail Gray</description>
<properties>
<java.version>17</java.version>
- <dubbo.version>3.2.0-beta.4</dubbo.version>
+ <dubbo.version>3.2.0-beta.5-SNAPSHOT</dubbo.version>
<nacos.version>2.2.0</nacos.version>
</properties>
@@ -42,15 +42,14 @@
<!-- common api -->
<dependency>
<groupId>org.apache.dubbo.samples</groupId>
- <artifactId>dubbo-samples-shop-order-api</artifactId>
+ <artifactId>dubbo-samples-shop-detail-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo.samples</groupId>
- <artifactId>dubbo-samples-shop-detail-api</artifactId>
+ <artifactId>dubbo-samples-shop-comment-api</artifactId>
<version>${project.version}</version>
</dependency>
-
<!-- registry dependency -->
<dependency>
<groupId>com.alibaba.nacos</groupId>
@@ -93,15 +92,15 @@
<version>3.2.1</version>
<configuration>
<to>
- <image>apache/dubbo-demo:dubbo-samples-shop-order_v2_0.0.1</image>
+ <image>apache/dubbo-demo:dubbo-samples-shop-detail_gray_0.0.1</image>
</to>
<container>
<jvmFlags>
<jvmFlag>-Dnacos.address=nacos.dubbo-system.svc</jvmFlag>
</jvmFlags>
<ports>
- <port>20883</port>
- <port>20993</port>
+ <port>20890</port>
+ <port>21000</port>
</ports>
</container>
</configuration>
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailApplication.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-gray/src/main/java/org/apache/dubbo/samples/detail/DetailApplicationGray.java
similarity index 91%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailApplication.java
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-detail-gray/src/main/java/org/apache/dubbo/samples/detail/DetailApplicationGray.java
index c9fccda3..6b3140cb 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailApplication.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-gray/src/main/java/org/apache/dubbo/samples/detail/DetailApplicationGray.java
@@ -23,10 +23,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@EnableDubbo
@SpringBootApplication
-public class DetailApplication {
+public class DetailApplicationGray {
public static void main(String[] args) {
- SpringApplication.run(DetailApplication.class, args);
+ SpringApplication.run(DetailApplicationGray.class, args);
}
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailServiceImpl.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-gray/src/main/java/org/apache/dubbo/samples/detail/DetailServiceImplGray.java
similarity index 66%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailServiceImpl.java
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-detail-gray/src/main/java/org/apache/dubbo/samples/detail/DetailServiceImplGray.java
index 57ae9033..81bd5576 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailServiceImpl.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-gray/src/main/java/org/apache/dubbo/samples/detail/DetailServiceImplGray.java
@@ -16,27 +16,26 @@
*/
package org.apache.dubbo.samples.detail;
+import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
+import org.apache.dubbo.rpc.RpcContext;
+import org.apache.dubbo.samples.CommentService;
import org.apache.dubbo.samples.DetailService;
import org.apache.dubbo.samples.Item;
+import java.math.BigInteger;
import java.util.concurrent.ThreadLocalRandom;
@DubboService
-public class DetailServiceImpl implements DetailService {
+public class DetailServiceImplGray implements DetailService {
+
+ @DubboReference(check = false)
+ private CommentService commentService;
@Override
- public boolean createItem(Item item) {
- try {
- // Do something that consumes resources
- for (int i = 0; i < 1000; i++) {
- Math.pow(ThreadLocalRandom.current().nextDouble(10), ThreadLocalRandom.current().nextDouble(5));
- }
- Thread.sleep(ThreadLocalRandom.current().nextInt(100));
- } catch (InterruptedException ignore) {
- Thread.currentThread().interrupt();
- }
- return true;
+ public Item getItem(long sku, String username) {
+ RpcContext.getClientAttachment().setAttachment("dubbo.tag", "gray");
+ return getItem(sku);
}
@Override
@@ -52,4 +51,16 @@ public class DetailServiceImpl implements DetailService {
}
return true;
}
+
+ private Item getItem(long sku) {
+ Item item = new Item();
+ item.setSku(sku);
+ item.setItemName("itemName");
+ item.setDescription("item from detail gray");
+ item.setStock(100);
+ item.setPrice(100);
+ item.setComment(commentService.getComment("itemName"));
+ return item;
+ }
+
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/resources/application.properties b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-gray/src/main/resources/application.properties
similarity index 95%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/resources/application.properties
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-detail-gray/src/main/resources/application.properties
index c64a752d..8be0f738 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/resources/application.properties
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-gray/src/main/resources/application.properties
@@ -17,7 +17,7 @@
dubbo.application.name=shop-detail
# Specify the QoS port
-dubbo.application.qos-port=20995
+dubbo.application.qos-port=21000
# Enable token verification for each invocation
dubbo.provider.token=true
@@ -27,4 +27,4 @@ dubbo.provider.token=true
dubbo.registry.address=nacos://${nacos.address:localhost}:8848?username=nacos&password=nacos
# Specify the port of Dubbo protocol
-dubbo.protocol.port=20885
\ No newline at end of file
+dubbo.protocol.port=20890
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v2/pom.xml b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-v1/pom.xml
similarity index 90%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-order-v2/pom.xml
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-detail-v1/pom.xml
index 039ae5b7..66c1aa70 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v2/pom.xml
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-v1/pom.xml
@@ -26,15 +26,15 @@
</parent>
<groupId>org.apache.dubbo.samples</groupId>
- <artifactId>dubbo-samples-shop-order-v2</artifactId>
+ <artifactId>dubbo-samples-shop-detail-v1</artifactId>
<version>0.0.1-SNAPSHOT</version>
- <name>Dubbo Task - Shop - Order V2</name>
- <description>Dubbo Task - Shop - Order - Version 2</description>
+ <name>Dubbo Task - Shop - Detail V1</name>
+ <description>Dubbo Task - Shop - Detail Version1</description>
<properties>
<java.version>17</java.version>
- <dubbo.version>3.2.0-beta.4</dubbo.version>
+ <dubbo.version>3.2.0-beta.5-SNAPSHOT</dubbo.version>
<nacos.version>2.2.0</nacos.version>
</properties>
@@ -42,15 +42,14 @@
<!-- common api -->
<dependency>
<groupId>org.apache.dubbo.samples</groupId>
- <artifactId>dubbo-samples-shop-order-api</artifactId>
+ <artifactId>dubbo-samples-shop-detail-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo.samples</groupId>
- <artifactId>dubbo-samples-shop-detail-api</artifactId>
+ <artifactId>dubbo-samples-shop-comment-api</artifactId>
<version>${project.version}</version>
</dependency>
-
<!-- registry dependency -->
<dependency>
<groupId>com.alibaba.nacos</groupId>
@@ -93,15 +92,15 @@
<version>3.2.1</version>
<configuration>
<to>
- <image>apache/dubbo-demo:dubbo-samples-shop-order_v2_0.0.1</image>
+ <image>apache/dubbo-demo:dubbo-samples-shop-detail_0.0.1</image>
</to>
<container>
<jvmFlags>
<jvmFlag>-Dnacos.address=nacos.dubbo-system.svc</jvmFlag>
</jvmFlags>
<ports>
- <port>20883</port>
- <port>20993</port>
+ <port>20885</port>
+ <port>20995</port>
</ports>
</container>
</configuration>
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailApplication.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-v1/src/main/java/org/apache/dubbo/samples/detail/DetailApplication.java
similarity index 100%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailApplication.java
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-detail-v1/src/main/java/org/apache/dubbo/samples/detail/DetailApplication.java
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailServiceImpl.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-v1/src/main/java/org/apache/dubbo/samples/detail/DetailServiceImpl.java
similarity index 71%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailServiceImpl.java
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-detail-v1/src/main/java/org/apache/dubbo/samples/detail/DetailServiceImpl.java
index 57ae9033..7aafa143 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailServiceImpl.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-v1/src/main/java/org/apache/dubbo/samples/detail/DetailServiceImpl.java
@@ -16,7 +16,10 @@
*/
package org.apache.dubbo.samples.detail;
+import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
+import org.apache.dubbo.rpc.RpcContext;
+import org.apache.dubbo.samples.CommentService;
import org.apache.dubbo.samples.DetailService;
import org.apache.dubbo.samples.Item;
@@ -25,18 +28,12 @@ import java.util.concurrent.ThreadLocalRandom;
@DubboService
public class DetailServiceImpl implements DetailService {
+ @DubboReference(check = false)
+ private CommentService commentService;
+
@Override
- public boolean createItem(Item item) {
- try {
- // Do something that consumes resources
- for (int i = 0; i < 1000; i++) {
- Math.pow(ThreadLocalRandom.current().nextDouble(10), ThreadLocalRandom.current().nextDouble(5));
- }
- Thread.sleep(ThreadLocalRandom.current().nextInt(100));
- } catch (InterruptedException ignore) {
- Thread.currentThread().interrupt();
- }
- return true;
+ public Item getItem(long sku, String username) {
+ return getItem(sku);
}
@Override
@@ -52,4 +49,16 @@ public class DetailServiceImpl implements DetailService {
}
return true;
}
+
+ private Item getItem(long sku) {
+ Item item = new Item();
+ item.setSku(sku);
+ item.setItemName("itemName");
+ item.setDescription("item from detail v1");
+ item.setStock(100);
+ item.setPrice(100);
+ item.setComment(commentService.getComment("itemName"));
+ return item;
+ }
+
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/resources/application.properties b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-v1/src/main/resources/application.properties
similarity index 97%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/resources/application.properties
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-detail-v1/src/main/resources/application.properties
index c64a752d..91821d2a 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/resources/application.properties
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-v1/src/main/resources/application.properties
@@ -12,19 +12,14 @@
# 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=shop-detail
-
# Specify the QoS port
dubbo.application.qos-port=20995
-
# 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=20885
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v2/pom.xml b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-v2/pom.xml
similarity index 90%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-order-v2/pom.xml
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-detail-v2/pom.xml
index 039ae5b7..9ba2c208 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v2/pom.xml
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-v2/pom.xml
@@ -26,15 +26,15 @@
</parent>
<groupId>org.apache.dubbo.samples</groupId>
- <artifactId>dubbo-samples-shop-order-v2</artifactId>
+ <artifactId>dubbo-samples-shop-detail-v2</artifactId>
<version>0.0.1-SNAPSHOT</version>
- <name>Dubbo Task - Shop - Order V2</name>
- <description>Dubbo Task - Shop - Order - Version 2</description>
+ <name>Dubbo Task - Shop - Detail V2</name>
+ <description>Dubbo Task - Shop - Detail Version2</description>
<properties>
<java.version>17</java.version>
- <dubbo.version>3.2.0-beta.4</dubbo.version>
+ <dubbo.version>3.2.0-beta.5-SNAPSHOT</dubbo.version>
<nacos.version>2.2.0</nacos.version>
</properties>
@@ -42,15 +42,14 @@
<!-- common api -->
<dependency>
<groupId>org.apache.dubbo.samples</groupId>
- <artifactId>dubbo-samples-shop-order-api</artifactId>
+ <artifactId>dubbo-samples-shop-detail-api</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>org.apache.dubbo.samples</groupId>
- <artifactId>dubbo-samples-shop-detail-api</artifactId>
+ <artifactId>dubbo-samples-shop-comment-api</artifactId>
<version>${project.version}</version>
</dependency>
-
<!-- registry dependency -->
<dependency>
<groupId>com.alibaba.nacos</groupId>
@@ -93,15 +92,15 @@
<version>3.2.1</version>
<configuration>
<to>
- <image>apache/dubbo-demo:dubbo-samples-shop-order_v2_0.0.1</image>
+ <image>apache/dubbo-demo:dubbo-samples-shop-detail_v2_0.0.1</image>
</to>
<container>
<jvmFlags>
<jvmFlag>-Dnacos.address=nacos.dubbo-system.svc</jvmFlag>
</jvmFlags>
<ports>
- <port>20883</port>
- <port>20993</port>
+ <port>20886</port>
+ <port>20996</port>
</ports>
</container>
</configuration>
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailApplication.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-v2/src/main/java/org/apache/dubbo/samples/detail/DetailApplication2.java
similarity index 92%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailApplication.java
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-detail-v2/src/main/java/org/apache/dubbo/samples/detail/DetailApplication2.java
index c9fccda3..a9831e6e 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailApplication.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-v2/src/main/java/org/apache/dubbo/samples/detail/DetailApplication2.java
@@ -23,10 +23,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@EnableDubbo
@SpringBootApplication
-public class DetailApplication {
+public class DetailApplication2 {
public static void main(String[] args) {
- SpringApplication.run(DetailApplication.class, args);
+ SpringApplication.run(DetailApplication2.class, args);
}
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailServiceImpl.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-v2/src/main/java/org/apache/dubbo/samples/detail/DetailServiceImpl2.java
similarity index 52%
rename from 10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailServiceImpl.java
rename to 10-task/dubbo-samples-shop/dubbo-samples-shop-detail-v2/src/main/java/org/apache/dubbo/samples/detail/DetailServiceImpl2.java
index 57ae9033..e475e509 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailServiceImpl.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-v2/src/main/java/org/apache/dubbo/samples/detail/DetailServiceImpl2.java
@@ -16,27 +16,27 @@
*/
package org.apache.dubbo.samples.detail;
+import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
+import org.apache.dubbo.rpc.RpcContext;
+import org.apache.dubbo.samples.CommentService;
import org.apache.dubbo.samples.DetailService;
import org.apache.dubbo.samples.Item;
import java.util.concurrent.ThreadLocalRandom;
@DubboService
-public class DetailServiceImpl implements DetailService {
+public class DetailServiceImpl2 implements DetailService {
+
+ @DubboReference(check = false)
+ private CommentService commentService;
@Override
- public boolean createItem(Item item) {
- try {
- // Do something that consumes resources
- for (int i = 0; i < 1000; i++) {
- Math.pow(ThreadLocalRandom.current().nextDouble(10), ThreadLocalRandom.current().nextDouble(5));
- }
- Thread.sleep(ThreadLocalRandom.current().nextInt(100));
- } catch (InterruptedException ignore) {
- Thread.currentThread().interrupt();
+ public Item getItem(long sku, String username) {
+ if (username.equals("dubbo")) {
+ return getItemForVip(sku);
}
- return true;
+ return getItem(sku);
}
@Override
@@ -52,4 +52,37 @@ public class DetailServiceImpl implements DetailService {
}
return true;
}
+
+ private Item getItem(long sku) {
+ Item item = new Item();
+ item.setSku(sku);
+ item.setItemName("itemName");
+ item.setDescription("item from detail v2");
+ item.setStock(100);
+ item.setPrice(100);
+ item.setComment(commentService.getComment("itemName"));
+ return item;
+ }
+
+ private Item getItemGray(long sku) {
+ Item item = new Item();
+ item.setSku(sku);
+ item.setItemName("itemName");
+ item.setDescription("item from gray environment");
+ item.setStock(100);
+ item.setPrice(100);
+ item.setComment(commentService.getComment("itemName"));
+ return item;
+ }
+
+ private Item getItemForVip(long sku) {
+ Item item = new Item();
+ item.setSku(sku);
+ item.setItemName("itemName");
+ item.setDescription("item for vip");
+ item.setStock(100);
+ item.setPrice(50);
+ item.setComment(commentService.getComment("itemName"));
+ return item;
+ }
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/resources/application.properties b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-v2/src/main/resources/application.properties
similarity index 95%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/resources/application.properties
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-detail-v2/src/main/resources/application.properties
index c64a752d..6d332a5f 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/resources/application.properties
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-detail-v2/src/main/resources/application.properties
@@ -12,19 +12,14 @@
# 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=shop-detail
-
# Specify the QoS port
-dubbo.application.qos-port=20995
-
+dubbo.application.qos-port=20996
# 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=20885
\ No newline at end of file
+dubbo.protocol.port=20886
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend-api/pom.xml b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend-api/pom.xml
index 801b0466..70212580 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend-api/pom.xml
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend-api/pom.xml
@@ -33,4 +33,21 @@
<name>Dubbo Task - Shop - FrontEnd's API</name>
<description>Dubbo Task - Shop - FrontEnd's API</description>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.dubbo.samples</groupId>
+ <artifactId>dubbo-samples-shop-detail-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo.samples</groupId>
+ <artifactId>dubbo-samples-shop-order-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.dubbo.samples</groupId>
+ <artifactId>dubbo-samples-shop-user-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
</project>
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend-api/src/main/java/org/apache/dubbo/samples/ShopService.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend-api/src/main/java/org/apache/dubbo/samples/ShopService.java
index 61c7386c..9ce36a5e 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend-api/src/main/java/org/apache/dubbo/samples/ShopService.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend-api/src/main/java/org/apache/dubbo/samples/ShopService.java
@@ -22,7 +22,13 @@ public interface ShopService {
boolean login(String username, String password);
- boolean createItem(long sku, String itemName, String description, int stock);
+ User getUserInfo(String username);
- boolean submitOrder(long sku, int count, String address, String phone, String receiver);
+ boolean timeoutLogin(String username, String password);
+
+ Item checkItem(long sku, String username);
+
+ Item checkItemGray(long sku, String username);
+
+ OrderDetail submitOrder(long sku, int count, String address, String phone, String receiver);
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/pom.xml b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/pom.xml
index e9ef5221..4db7cfc1 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/pom.xml
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/pom.xml
@@ -34,7 +34,7 @@
<properties>
<java.version>17</java.version>
- <dubbo.version>3.2.0-beta.4</dubbo.version>
+ <dubbo.version>3.2.0-beta.5-SNAPSHOT</dubbo.version>
<nacos.version>2.2.0</nacos.version>
</properties>
@@ -81,6 +81,15 @@
<artifactId>spring-boot-starter</artifactId>
</dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-web</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework.boot</groupId>
+ <artifactId>spring-boot-starter-freemarker</artifactId>
+ </dependency>
+
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/java/org/apache/dubbo/samples/frontend/BenchmarkClient.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/java/org/apache/dubbo/samples/frontend/BenchmarkClient.java
index 1b539f88..163428c2 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/java/org/apache/dubbo/samples/frontend/BenchmarkClient.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/java/org/apache/dubbo/samples/frontend/BenchmarkClient.java
@@ -30,7 +30,6 @@ import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadLocalRandom;
-@Component
public class BenchmarkClient implements CommandLineRunner {
private static final Logger logger = LoggerFactory.getLogger(BenchmarkClient.class);
@@ -85,7 +84,7 @@ public class BenchmarkClient implements CommandLineRunner {
while (true) {
try {
long sku = ThreadLocalRandom.current().nextLong();
- shopService.createItem(sku, "Test Item", "Desc", 100);
+ shopService.checkItem(sku, "dubbo");
} catch (Throwable t) {
logger.error("Running CreateItem Bench Failed.", t);
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/java/org/apache/dubbo/samples/frontend/FrontEndApplication.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/java/org/apache/dubbo/samples/frontend/FrontEndApplication.java
index f6e80ec8..18a05a58 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/java/org/apache/dubbo/samples/frontend/FrontEndApplication.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/java/org/apache/dubbo/samples/frontend/FrontEndApplication.java
@@ -21,7 +21,7 @@ import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
-@EnableDubbo
+
@SpringBootApplication
public class FrontEndApplication {
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/java/org/apache/dubbo/samples/frontend/ShopServiceImpl.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/java/org/apache/dubbo/samples/frontend/ShopServiceImpl.java
index b13f47b8..b5b0c318 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/java/org/apache/dubbo/samples/frontend/ShopServiceImpl.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/java/org/apache/dubbo/samples/frontend/ShopServiceImpl.java
@@ -18,23 +18,27 @@ package org.apache.dubbo.samples.frontend;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
+import org.apache.dubbo.rpc.RpcContext;
import org.apache.dubbo.samples.DetailService;
import org.apache.dubbo.samples.Item;
import org.apache.dubbo.samples.Order;
+import org.apache.dubbo.samples.OrderDetail;
import org.apache.dubbo.samples.OrderService;
import org.apache.dubbo.samples.ShopService;
import org.apache.dubbo.samples.User;
import org.apache.dubbo.samples.UserService;
-@DubboService
+import org.springframework.stereotype.Component;
+
+@Component
public class ShopServiceImpl implements ShopService {
- @DubboReference
+ @DubboReference(check = false, retries = 0)
private UserService userService;
- @DubboReference
+ @DubboReference(check = false)
private OrderService orderService;
- @DubboReference
+ @DubboReference(check = false)
private DetailService detailService;
@Override
@@ -54,17 +58,26 @@ public class ShopServiceImpl implements ShopService {
}
@Override
- public boolean createItem(long sku, String itemName, String description, int stock) {
- Item item = new Item();
- item.setSku(sku);
- item.setItemName(itemName);
- item.setDescription(description);
- item.setStock(stock);
- return detailService.createItem(item);
+ public User getUserInfo(String username) {
+ return userService.getInfo(username);
+ }
+
+ @Override
+ public boolean timeoutLogin(String username, String password) {
+ return userService.timeoutLogin(username, password) != null;
+ }
+
+ @Override
+ public Item checkItem(long sku, String username) {
+ return detailService.getItem(sku, username);
+ }
+
+ public Item checkItemGray(long sku, String username) {
+ return detailService.getItem(sku, username);
}
@Override
- public boolean submitOrder(long sku, int count, String address, String phone, String receiver) {
+ public OrderDetail submitOrder(long sku, int count, String address, String phone, String receiver) {
Order order = new Order();
order.setSku(sku);
order.setCount(count);
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/java/org/apache/dubbo/samples/frontend/pages/WebController.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/java/org/apache/dubbo/samples/frontend/pages/WebController.java
new file mode 100755
index 00000000..2931023d
--- /dev/null
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/java/org/apache/dubbo/samples/frontend/pages/WebController.java
@@ -0,0 +1,105 @@
+/*
+ * 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.frontend.pages;
+
+import org.apache.dubbo.rpc.RpcContext;
+import org.apache.dubbo.samples.Item;
+import org.apache.dubbo.samples.OrderDetail;
+import org.apache.dubbo.samples.ShopService;
+import org.apache.dubbo.samples.User;
+
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.servlet.ModelAndView;
+
+@RestController
+public class WebController {
+
+ @Autowired
+ private ShopService shopService;
+
+ // user GET to avoid resubmit warning on browser side.
+ @RequestMapping(value = "/login", method = RequestMethod.GET)
+ ModelAndView login(@RequestParam String username, @RequestParam String password) {
+ shopService.login(username, password);
+ // get user info
+
+ // get item detail
+ Item item = shopService.checkItem(1, username);
+
+ ModelAndView modelAndView = new ModelAndView("detail");
+ modelAndView.addObject("username", username);
+ modelAndView.addObject("item", item);
+ return modelAndView;
+ }
+
+ // user GET to avoid resubmit warning on browser side.
+ @RequestMapping(value = "/timeoutLogin", method = RequestMethod.GET)
+ ModelAndView timeoutLogin(@RequestParam String username, @RequestParam String password) {
+ ModelAndView modelAndView;
+
+ try {
+ shopService.timeoutLogin(username, password);
+ } catch (Exception e) {
+ modelAndView = new ModelAndView("index");
+ modelAndView.addObject("result", "Failed to login, request timeout, please add timeout policy and retry!");
+ return modelAndView;
+ }
+
+ modelAndView = new ModelAndView("detail");
+ modelAndView.addObject("username", username);
+ return modelAndView;
+ }
+
+ // user GET to avoid resubmit warning on browser side.
+ @RequestMapping(value = "/grayLogin", method = RequestMethod.GET)
+ ModelAndView grayLogin(@RequestParam String username, @RequestParam String password) {
+ ModelAndView modelAndView;
+ shopService.login(username, password);
+ // get item detail from gray environment
+ RpcContext.getClientAttachment().setAttachment("dubbo.tag", "gray");
+ Item item = shopService.checkItemGray(1, username);
+
+ modelAndView = new ModelAndView("detail");
+ modelAndView.addObject("username", username);
+ modelAndView.addObject("item", item);
+
+ return modelAndView;
+ }
+
+ @RequestMapping(value = "/userinfo", method = RequestMethod.GET)
+ @ResponseBody
+ User userInfo(@RequestParam String username) {
+ // retry
+ try {
+ return shopService.getUserInfo(username);
+ } catch (Exception e) {
+ return null;
+ }
+ }
+
+ @RequestMapping(value = "/order", method = RequestMethod.POST)
+ @ResponseBody
+ OrderDetail createOrder(@RequestParam String username, @RequestParam long sku) {
+ return shopService.submitOrder(sku, 1, "Hangzhou China", "18069807880", username);
+ }
+
+}
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/resources/application.properties b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/resources/application.properties
index e27205be..9ab948dd 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/resources/application.properties
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/resources/application.properties
@@ -18,13 +18,15 @@ dubbo.application.name=shop-frontend
# Specify the QoS port
dubbo.application.qos-port=20991
-
# 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
+dubbo.protocol.port=20881
+#spring.freemarker.template-loader-path: /templates
+spring.freemarker.suffix=.ftl
+server.servlet.encoding.force=true
+server.servlet.encoding.charset=utf-8
+server.servlet.encoding.enabled=true
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/resources/static/architecture.png b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/resources/static/architecture.png
new file mode 100644
index 00000000..515efaa9
Binary files /dev/null and b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/resources/static/architecture.png differ
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/resources/static/goods.png b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/resources/static/goods.png
new file mode 100644
index 00000000..93663adc
Binary files /dev/null and b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/resources/static/goods.png differ
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/resources/static/jquery-3.6.3.min.js b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/resources/static/jquery-3.6.3.min.js
new file mode 100644
index 00000000..b5329e9a
--- /dev/null
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/resources/static/jquery-3.6.3.min.js
@@ -0,0 +1,2 @@
+/*! jQuery v3.6.3 | (c) OpenJS Foundation and other contributors | jquery.org/license */
+!function(e,t){"use strict";"object"==typeof module&&"object"==typeof module.exports?module.exports=e.document?t(e,!0):function(e){if(!e.document)throw new Error("jQuery requires a window with a document");return t(e)}:t(e)}("undefined"!=typeof window?window:this,function(C,e){"use strict";var t=[],r=Object.getPrototypeOf,s=t.slice,g=t.flat?function(e){return t.flat.call(e)}:function(e){return t.concat.apply([],e)},u=t.push,i=t.indexOf,n={},o=n.toString,y=n.hasOwnProperty,a=y.toString,l= [...]
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/resources/templates/detail.ftl b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/resources/templates/detail.ftl
new file mode 100755
index 00000000..e50b1bb8
--- /dev/null
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/resources/templates/detail.ftl
@@ -0,0 +1,113 @@
+<html>
+
+<head>
+ <title>Dubbo Onling Shopping Demo</title>
+ <script src="jquery-3.6.3.min.js"></script>
+ <script type="text/javascript">
+ $(document).ready(function () {
+ $.ajax({
+ url: "/userinfo?username=" + "${username}",
+ success: function (result) {
+ if (result === "") {
+ $("#userinfo").html("<label id='retry'>Failed to get user info, please add retry policy and refresh!</label>");
+ } else {
+ $("#userinfo").html("User Info: " + result.username + ", " + result.realName + ", " + result.mail + ", " + result.phone);
+ }
+ },
+ error: function (xhr, status, error) {
+ $("#userinfo").innerHTML = "<label id='retry'>Failed to get user info in background, please add retry policy and refresh!</label>";
+ },
+ complete: function (xhr, status) {
+ }
+ });
+ });
+
+ function buyNow() {
+ console.log("${username}");
+ $.post("/order?username=", {username: "${username}", sku: 1},
+ function (result, status, xhr) {
+ if (result === "") {
+ $("#orderDetail").html("<label>Order created successfully!</label>");
+ } else {
+ $("#orderDetail").html("Order created successfully! <br/><br/> Here's the package delivery message " + result.receiver + ", " + result.phone + ", " + result.address);
+ }
+ });
+ }
+ </script>
+ <style>
+ #retry {
+ color: red;
+ font-size: 1.3rem;
+ }
+
+ .image {
+ width: 100%;
+ height: 510px;
+ border: 1px solid black;
+ }
+
+ #userinfo {
+ width: 100%;
+ height: 100px;
+ border: 1px solid black;
+ }
+
+ .image img {
+ margin: 5px;
+ padding-right: 5px;
+ width: 1000px;
+ height: 500px;
+ border: 1px solid black;
+ }
+
+ .detail {
+ margin: 5px;
+ float: right;
+ height: 500px;
+ border: 1px solid black;
+ }
+
+ #orderDetail {
+ margin: 5px;
+ border: 1px solid black;
+ }
+ </style>
+</head>
+
+<body>
+
+<p id="userinfo"></p>
+
+<div>
+ <div>
+ <div class="image">
+ <img src="goods.png"/>
+ <p style="width:100px;float:right;position:absolute;left:1115px;top:550px;">
+ <input style="width:100px;height:50px;" id=login onclick="buyNow()" type="button" value="Buy Now"/>
+ </p>
+ <div class="detail">
+
+ <ul>
+ <li>SKU: ${item.sku}</li>
+ <li>Name: ${item.itemName}</li>
+ <li>Description: ${item.description}</li>
+ <li><label>Comment: ${item.comment}</label></li>
+ <li><label>Price: ${item.price}</label></li>
+ </ul>
+
+ </div>
+ </div>
+
+
+ </div>
+
+ <div id="orderDetail">
+
+ </div>
+
+</div>
+
+
+</body>
+
+</html>
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/resources/templates/index.ftl b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/resources/templates/index.ftl
new file mode 100755
index 00000000..a56ca780
--- /dev/null
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-frontend/src/main/resources/templates/index.ftl
@@ -0,0 +1,107 @@
+<!DOCTYPE html>
+<html>
+<head>
+ <meta charset="UTF-8">
+ <script src="jquery-3.6.3.min.js"></script>
+ <title>Dubbo Onling Shopping Demo</title>
+ <style type="text/css">
+ form {
+ width: 100%;
+ height: 100%;
+ font-size: 1.2rem;
+ }
+
+ div {
+ display: inline-block;
+ padding-bottom: 255px;
+ padding-left: 1px;
+ padding-right: 1px;
+ }
+
+ h2 {
+ font-size: 40px;
+ color: black;
+ }
+
+ #log {
+ color: blue;
+ }
+
+ ul li {
+ text-align: left;
+ }
+
+ .image img {
+ width: 550px;
+ height: 300px;
+ margin: 5px;
+ border: 1px solid black;
+ }
+ </style>
+
+ <script type="text/javascript">
+ function normalLogin() {
+ var username = $("#username").val();
+ var password = $("#password").val();
+
+ window.location.href = "/login?username=" + username + "&password=" + password;
+ }
+
+ function timeoutLogin() {
+ var username = $("#username").val();
+ var password = $("#password").val();
+
+ window.location.href = "/timeoutLogin?username=" + username + "&password=" + password;
+ }
+
+ function grayLogin() {
+ var username = $("#username").val();
+ var password = $("#password").val();
+
+ window.location.href = "/grayLogin?username=" + username + "&password=" + password;
+ }
+ </script>
+</head>
+<body>
+<!--div class="div">
+ <img src="favicon.png" width="100%" height="200px" alt="" id="picture">
+</div-->
+<form id="loginForm" name="login" method="post">
+ <center>
+ <div>
+ <h2>
+ The Dubbo Online Shopping Mall Demo
+ </h2>
+ <p class="image">
+ <img src="architecture.png"/>
+ </p>
+ <#if result??>
+ <p style="color:red; font-size: 1.3rem">
+ ${result}
+ </p>
+ </#if>
+ <p>
+ <p>
+ Username: <input id="username" type="text" name="username"/>
+ </p>
+ <p>
+ Password: <input id="password" type="password" name="password"/>
+ </p>
+ </p>
+ <p>
+ <input id=login onclick="normalLogin()" type="button" value="Login"/>
+ <input id=timeout-login onclick="timeoutLogin()" type="button" value="Timeout Login"/>
+ <input id=gray-login onclick="grayLogin()" type="button" value="Login To Gray"/>
+ </p>
+
+ <p>
+ <ul style="list-style-position:inside;">
+ <li>Input any username and password to login.</li>
+ <li>Use username 'dubbo' to test features like traffic isolation, argument routing, etc.</li>
+ </ul>
+ </p>
+ </div>
+ </center>
+</form>
+</body>
+</html>
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-user-api/src/main/java/org/apache/dubbo/samples/User.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-order-api/src/main/java/org/apache/dubbo/samples/OrderDetail.java
similarity index 58%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-user-api/src/main/java/org/apache/dubbo/samples/User.java
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-order-api/src/main/java/org/apache/dubbo/samples/OrderDetail.java
index 500c84f3..8f078cea 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-user-api/src/main/java/org/apache/dubbo/samples/User.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-order-api/src/main/java/org/apache/dubbo/samples/OrderDetail.java
@@ -16,45 +16,26 @@
*/
package org.apache.dubbo.samples;
-import java.io.Serializable;
-
-public class User implements Serializable {
- private String username;
- private String password;
- private String realName;
- private String mail;
+public class OrderDetail {
+ private String env;
+ private String address;
private String phone;
+ private String receiver;
- public String getUsername() {
- return username;
- }
-
- public void setUsername(String username) {
- this.username = username;
- }
-
- public String getPassword() {
- return password;
- }
-
- public void setPassword(String password) {
- this.password = password;
+ public String getEnv() {
+ return env;
}
- public String getRealName() {
- return realName;
+ public void setEnv(String env) {
+ this.env = env;
}
- public void setRealName(String realName) {
- this.realName = realName;
+ public String getAddress() {
+ return address;
}
- public String getMail() {
- return mail;
- }
-
- public void setMail(String mail) {
- this.mail = mail;
+ public void setAddress(String address) {
+ this.address = address;
}
public String getPhone() {
@@ -64,4 +45,12 @@ public class User implements Serializable {
public void setPhone(String phone) {
this.phone = phone;
}
+
+ public String getReceiver() {
+ return receiver;
+ }
+
+ public void setReceiver(String receiver) {
+ this.receiver = receiver;
+ }
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-order-api/src/main/java/org/apache/dubbo/samples/OrderService.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-order-api/src/main/java/org/apache/dubbo/samples/OrderService.java
index f1a6eb91..260d7141 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-order-api/src/main/java/org/apache/dubbo/samples/OrderService.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-order-api/src/main/java/org/apache/dubbo/samples/OrderService.java
@@ -18,5 +18,5 @@ package org.apache.dubbo.samples;
public interface OrderService {
- boolean submitOrder(Order order);
+ OrderDetail submitOrder(Order order);
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v1/pom.xml b/10-task/dubbo-samples-shop/dubbo-samples-shop-order-gray/pom.xml
similarity index 91%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-order-v1/pom.xml
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-order-gray/pom.xml
index 09d0cf87..ddccb8ab 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v1/pom.xml
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-order-gray/pom.xml
@@ -26,15 +26,15 @@
</parent>
<groupId>org.apache.dubbo.samples</groupId>
- <artifactId>dubbo-samples-shop-order-v1</artifactId>
+ <artifactId>dubbo-samples-shop-order-gray</artifactId>
<version>0.0.1-SNAPSHOT</version>
- <name>Dubbo Task - Shop - Order V1</name>
- <description>Dubbo Task - Shop - Order - Version 1</description>
+ <name>Dubbo Task - Shop - Order Gray</name>
+ <description>Dubbo Task - Shop - Order - Gray</description>
<properties>
<java.version>17</java.version>
- <dubbo.version>3.2.0-beta.4</dubbo.version>
+ <dubbo.version>3.2.0-beta.5-SNAPSHOT</dubbo.version>
<nacos.version>2.2.0</nacos.version>
</properties>
@@ -88,15 +88,15 @@
<version>3.2.1</version>
<configuration>
<to>
- <image>apache/dubbo-demo:dubbo-samples-shop-order_v1_0.0.1</image>
+ <image>apache/dubbo-demo:dubbo-samples-shop-order_gray_0.0.1</image>
</to>
<container>
<jvmFlags>
<jvmFlag>-Dnacos.address=nacos.dubbo-system.svc</jvmFlag>
</jvmFlags>
<ports>
- <port>20882</port>
- <port>20992</port>
+ <port>20891</port>
+ <port>21001</port>
</ports>
</container>
</configuration>
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailApplication.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-order-gray/src/main/java/org/apache/dubbo/samples/order/OrderApplicationGray.java
similarity index 88%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailApplication.java
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-order-gray/src/main/java/org/apache/dubbo/samples/order/OrderApplicationGray.java
index c9fccda3..f3f80bde 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailApplication.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-order-gray/src/main/java/org/apache/dubbo/samples/order/OrderApplicationGray.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.samples.detail;
+package org.apache.dubbo.samples.order;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
@@ -23,10 +23,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@EnableDubbo
@SpringBootApplication
-public class DetailApplication {
+public class OrderApplicationGray {
public static void main(String[] args) {
- SpringApplication.run(DetailApplication.class, args);
+ SpringApplication.run(OrderApplicationGray.class, args);
}
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v1/src/main/java/org/apache/dubbo/samples/order/OrderServiceImpl.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-order-gray/src/main/java/org/apache/dubbo/samples/order/OrderServiceImplGray.java
similarity index 66%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-order-v1/src/main/java/org/apache/dubbo/samples/order/OrderServiceImpl.java
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-order-gray/src/main/java/org/apache/dubbo/samples/order/OrderServiceImplGray.java
index b363fe8c..73c48419 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v1/src/main/java/org/apache/dubbo/samples/order/OrderServiceImpl.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-order-gray/src/main/java/org/apache/dubbo/samples/order/OrderServiceImplGray.java
@@ -18,23 +18,20 @@ package org.apache.dubbo.samples.order;
import org.apache.dubbo.config.annotation.DubboService;
import org.apache.dubbo.samples.Order;
+import org.apache.dubbo.samples.OrderDetail;
import org.apache.dubbo.samples.OrderService;
import java.util.concurrent.ThreadLocalRandom;
@DubboService
-public class OrderServiceImpl implements OrderService {
+public class OrderServiceImplGray implements OrderService {
@Override
- public boolean submitOrder(Order order) {
- try {
- // Do something that consumes resources
- for (int i = 0; i < 1000; i++) {
- Math.pow(ThreadLocalRandom.current().nextDouble(10), ThreadLocalRandom.current().nextDouble(5));
- }
- Thread.sleep(ThreadLocalRandom.current().nextInt(200));
- } catch (InterruptedException ignore) {
- Thread.currentThread().interrupt();
- }
- return true;
+ public OrderDetail submitOrder(Order order) {
+ OrderDetail orderDetail = new OrderDetail();
+ orderDetail.setEnv("gray");
+ orderDetail.setAddress(order.getAddress());
+ orderDetail.setReceiver(order.getReceiver());
+ orderDetail.setPhone(order.getPhone());
+ return orderDetail;
}
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/resources/application.properties b/10-task/dubbo-samples-shop/dubbo-samples-shop-order-gray/src/main/resources/application.properties
similarity index 92%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/resources/application.properties
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-order-gray/src/main/resources/application.properties
index c64a752d..3041b260 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/resources/application.properties
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-order-gray/src/main/resources/application.properties
@@ -12,19 +12,14 @@
# 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=shop-detail
-
+dubbo.application.name=shop-order
# Specify the QoS port
-dubbo.application.qos-port=20995
-
+dubbo.application.qos-port=21001
# 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=20885
\ No newline at end of file
+dubbo.protocol.port=20891
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v1/pom.xml b/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v1/pom.xml
index 09d0cf87..54bcdcba 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v1/pom.xml
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v1/pom.xml
@@ -34,7 +34,7 @@
<properties>
<java.version>17</java.version>
- <dubbo.version>3.2.0-beta.4</dubbo.version>
+ <dubbo.version>3.2.0-beta.5-SNAPSHOT</dubbo.version>
<nacos.version>2.2.0</nacos.version>
</properties>
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v1/src/main/java/org/apache/dubbo/samples/order/OrderServiceImpl.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v1/src/main/java/org/apache/dubbo/samples/order/OrderServiceImpl.java
index b363fe8c..1ccfb9d9 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v1/src/main/java/org/apache/dubbo/samples/order/OrderServiceImpl.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v1/src/main/java/org/apache/dubbo/samples/order/OrderServiceImpl.java
@@ -18,6 +18,7 @@ package org.apache.dubbo.samples.order;
import org.apache.dubbo.config.annotation.DubboService;
import org.apache.dubbo.samples.Order;
+import org.apache.dubbo.samples.OrderDetail;
import org.apache.dubbo.samples.OrderService;
import java.util.concurrent.ThreadLocalRandom;
@@ -25,16 +26,8 @@ import java.util.concurrent.ThreadLocalRandom;
@DubboService
public class OrderServiceImpl implements OrderService {
@Override
- public boolean submitOrder(Order order) {
- try {
- // Do something that consumes resources
- for (int i = 0; i < 1000; i++) {
- Math.pow(ThreadLocalRandom.current().nextDouble(10), ThreadLocalRandom.current().nextDouble(5));
- }
- Thread.sleep(ThreadLocalRandom.current().nextInt(200));
- } catch (InterruptedException ignore) {
- Thread.currentThread().interrupt();
- }
- return true;
+ public OrderDetail submitOrder(Order order) {
+ // Do something that consumes resources
+ return null;
}
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v2/pom.xml b/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v2/pom.xml
index 039ae5b7..17bc9e74 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v2/pom.xml
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v2/pom.xml
@@ -34,7 +34,7 @@
<properties>
<java.version>17</java.version>
- <dubbo.version>3.2.0-beta.4</dubbo.version>
+ <dubbo.version>3.2.0-beta.5-SNAPSHOT</dubbo.version>
<nacos.version>2.2.0</nacos.version>
</properties>
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v2/src/main/java/org/apache/dubbo/samples/order/OrderServiceImpl.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v2/src/main/java/org/apache/dubbo/samples/order/OrderServiceImpl2.java
similarity index 67%
rename from 10-task/dubbo-samples-shop/dubbo-samples-shop-order-v2/src/main/java/org/apache/dubbo/samples/order/OrderServiceImpl.java
rename to 10-task/dubbo-samples-shop/dubbo-samples-shop-order-v2/src/main/java/org/apache/dubbo/samples/order/OrderServiceImpl2.java
index 24ca75a8..1a7bd67c 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v2/src/main/java/org/apache/dubbo/samples/order/OrderServiceImpl.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-order-v2/src/main/java/org/apache/dubbo/samples/order/OrderServiceImpl2.java
@@ -20,26 +20,26 @@ import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService;
import org.apache.dubbo.samples.DetailService;
import org.apache.dubbo.samples.Order;
+import org.apache.dubbo.samples.OrderDetail;
import org.apache.dubbo.samples.OrderService;
import java.util.concurrent.ThreadLocalRandom;
@DubboService
-public class OrderServiceImpl implements OrderService {
+public class OrderServiceImpl2 implements OrderService {
@DubboReference
private DetailService detailService;
@Override
- public boolean submitOrder(Order order) {
- try {
- // Do something that consumes resources
- for (int i = 0; i < 1000; i++) {
- Math.pow(ThreadLocalRandom.current().nextDouble(10), ThreadLocalRandom.current().nextDouble(5));
- }
- Thread.sleep(ThreadLocalRandom.current().nextInt(200));
- } catch (InterruptedException ignore) {
- Thread.currentThread().interrupt();
- }
- return detailService.deductStock(order.getSku(), order.getCount());
+ public OrderDetail submitOrder(Order order) {
+ // Do something that consumes resources
+ detailService.deductStock(order.getSku(), order.getCount());
+
+ OrderDetail orderDetail = new OrderDetail();
+ orderDetail.setEnv("v2");
+ orderDetail.setAddress(order.getAddress());
+ orderDetail.setReceiver(order.getReceiver());
+ orderDetail.setPhone(order.getPhone());
+ return orderDetail;
}
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-user-api/src/main/java/org/apache/dubbo/samples/User.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-user-api/src/main/java/org/apache/dubbo/samples/User.java
index 500c84f3..6aa4249b 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-user-api/src/main/java/org/apache/dubbo/samples/User.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-user-api/src/main/java/org/apache/dubbo/samples/User.java
@@ -24,6 +24,7 @@ public class User implements Serializable {
private String realName;
private String mail;
private String phone;
+ private String env;
public String getUsername() {
return username;
@@ -64,4 +65,12 @@ public class User implements Serializable {
public void setPhone(String phone) {
this.phone = phone;
}
+
+ public String getEnv() {
+ return env;
+ }
+
+ public void setEnv(String env) {
+ this.env = env;
+ }
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-user-api/src/main/java/org/apache/dubbo/samples/UserService.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-user-api/src/main/java/org/apache/dubbo/samples/UserService.java
index 489e6e44..d2d82646 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-user-api/src/main/java/org/apache/dubbo/samples/UserService.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-user-api/src/main/java/org/apache/dubbo/samples/UserService.java
@@ -21,4 +21,8 @@ public interface UserService {
boolean register(User user);
User login(String username, String password);
+
+ User timeoutLogin(String username, String password);
+
+ User getInfo(String username);
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/pom.xml b/10-task/dubbo-samples-shop/dubbo-samples-shop-user-gray/pom.xml
similarity index 89%
rename from 10-task/dubbo-samples-shop/dubbo-samples-shop-detail/pom.xml
rename to 10-task/dubbo-samples-shop/dubbo-samples-shop-user-gray/pom.xml
index 95c9395a..633e1ad0 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/pom.xml
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-user-gray/pom.xml
@@ -26,15 +26,15 @@
</parent>
<groupId>org.apache.dubbo.samples</groupId>
- <artifactId>dubbo-samples-shop-detail</artifactId>
+ <artifactId>dubbo-samples-shop-user-gray</artifactId>
<version>0.0.1-SNAPSHOT</version>
- <name>Dubbo Task - Shop - Detail</name>
- <description>Dubbo Task - Shop - Detail</description>
+ <name>Dubbo Task - Shop - User Gray</name>
+ <description>Dubbo Task - Shop - User Gray</description>
<properties>
<java.version>17</java.version>
- <dubbo.version>3.2.0-beta.4</dubbo.version>
+ <dubbo.version>3.2.0-beta.5-SNAPSHOT</dubbo.version>
<nacos.version>2.2.0</nacos.version>
</properties>
@@ -42,7 +42,7 @@
<!-- common api -->
<dependency>
<groupId>org.apache.dubbo.samples</groupId>
- <artifactId>dubbo-samples-shop-detail-api</artifactId>
+ <artifactId>dubbo-samples-shop-user-api</artifactId>
<version>${project.version}</version>
</dependency>
@@ -88,15 +88,15 @@
<version>3.2.1</version>
<configuration>
<to>
- <image>apache/dubbo-demo:dubbo-samples-shop-detail_0.0.1</image>
+ <image>apache/dubbo-demo:dubbo-samples-shop-user_gray_0.0.1</image>
</to>
<container>
<jvmFlags>
<jvmFlag>-Dnacos.address=nacos.dubbo-system.svc</jvmFlag>
</jvmFlags>
<ports>
- <port>20885</port>
- <port>20995</port>
+ <port>20892</port>
+ <port>21002</port>
</ports>
</container>
</configuration>
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailApplication.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-user-gray/src/main/java/org/apache/dubbo/samples/user/UserApplicationGray.java
similarity index 88%
rename from 10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailApplication.java
rename to 10-task/dubbo-samples-shop/dubbo-samples-shop-user-gray/src/main/java/org/apache/dubbo/samples/user/UserApplicationGray.java
index c9fccda3..6a846cca 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/java/org/apache/dubbo/samples/detail/DetailApplication.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-user-gray/src/main/java/org/apache/dubbo/samples/user/UserApplicationGray.java
@@ -14,7 +14,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package org.apache.dubbo.samples.detail;
+package org.apache.dubbo.samples.user;
import org.apache.dubbo.config.spring.context.annotation.EnableDubbo;
@@ -23,10 +23,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
@EnableDubbo
@SpringBootApplication
-public class DetailApplication {
+public class UserApplicationGray {
public static void main(String[] args) {
- SpringApplication.run(DetailApplication.class, args);
+ SpringApplication.run(UserApplicationGray.class, args);
}
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-user/src/main/java/org/apache/dubbo/samples/user/UserServiceImpl.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-user-gray/src/main/java/org/apache/dubbo/samples/user/UserServiceImplGray.java
similarity index 59%
copy from 10-task/dubbo-samples-shop/dubbo-samples-shop-user/src/main/java/org/apache/dubbo/samples/user/UserServiceImpl.java
copy to 10-task/dubbo-samples-shop/dubbo-samples-shop-user-gray/src/main/java/org/apache/dubbo/samples/user/UserServiceImplGray.java
index 9ff8c4e1..ff7691f8 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-user/src/main/java/org/apache/dubbo/samples/user/UserServiceImpl.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-user-gray/src/main/java/org/apache/dubbo/samples/user/UserServiceImplGray.java
@@ -22,39 +22,64 @@ import org.apache.dubbo.samples.UserService;
import java.util.concurrent.ThreadLocalRandom;
-@DubboService
-public class UserServiceImpl implements UserService {
+@DubboService(timeout = 1000)
+public class UserServiceImplGray implements UserService {
@Override
public boolean register(User user) {
+ // Do something that consumes resources
+ for (int i = 0; i < 100; i++) {
+ Math.pow(ThreadLocalRandom.current().nextDouble(10), ThreadLocalRandom.current().nextDouble(5));
+ }
+
+ return true;
+ }
+
+ @Override
+ public User login(String username, String password) {
+ // Do something that consumes resources
+ User user = new User();
+ user.setUsername(username);
+ user.setPassword(password);
+ user.setPhone("13912345678");
+ user.setMail("dev@dubbo.apache.org");
+ user.setRealName("Dubbo Test");
+ return user;
+ }
+
+ @Override
+ public User timeoutLogin(String username, String password) {
try {
- // Do something that consumes resources
- for (int i = 0; i < 1000; i++) {
- Math.pow(ThreadLocalRandom.current().nextDouble(10), ThreadLocalRandom.current().nextDouble(5));
- }
- Thread.sleep(ThreadLocalRandom.current().nextInt(100));
+ Thread.sleep(1100);
} catch (InterruptedException ignore) {
Thread.currentThread().interrupt();
}
- return true;
+ User user = new User();
+ user.setUsername(username);
+ user.setPassword(password);
+ user.setPhone("13912345678");
+ user.setMail("dev@dubbo.apache.org");
+ user.setRealName("Dubbo Test");
+ return user;
}
+ private int count = 1;
+
@Override
- public User login(String username, String password) {
+ public User getInfo(String username) {
try {
- // Do something that consumes resources
- for (int i = 0; i < 200; i++) {
- Math.pow(ThreadLocalRandom.current().nextDouble(10), ThreadLocalRandom.current().nextDouble(5));
+ if (++count % 3 != 0) {
+ Thread.sleep(3000);
}
- Thread.sleep(ThreadLocalRandom.current().nextInt(50));
} catch (InterruptedException ignore) {
Thread.currentThread().interrupt();
}
User user = new User();
user.setUsername(username);
- user.setPassword(password);
+ user.setPassword("password");
user.setPhone("13912345678");
user.setMail("dev@dubbo.apache.org");
user.setRealName("Dubbo Test");
+ user.setEnv("gray");
return user;
}
}
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/resources/application.properties b/10-task/dubbo-samples-shop/dubbo-samples-shop-user-gray/src/main/resources/application.properties
similarity index 92%
rename from 10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/resources/application.properties
rename to 10-task/dubbo-samples-shop/dubbo-samples-shop-user-gray/src/main/resources/application.properties
index c64a752d..1632740f 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-detail/src/main/resources/application.properties
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-user-gray/src/main/resources/application.properties
@@ -12,19 +12,14 @@
# 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=shop-detail
-
+dubbo.application.name=shop-user
# Specify the QoS port
-dubbo.application.qos-port=20995
-
+dubbo.application.qos-port=21002
# 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=20885
\ No newline at end of file
+dubbo.protocol.port=20892
\ No newline at end of file
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-user/pom.xml b/10-task/dubbo-samples-shop/dubbo-samples-shop-user/pom.xml
index e0c14f3a..0824fdbb 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-user/pom.xml
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-user/pom.xml
@@ -34,7 +34,7 @@
<properties>
<java.version>17</java.version>
- <dubbo.version>3.2.0-beta.4</dubbo.version>
+ <dubbo.version>3.2.0-beta.5-SNAPSHOT</dubbo.version>
<nacos.version>2.2.0</nacos.version>
</properties>
diff --git a/10-task/dubbo-samples-shop/dubbo-samples-shop-user/src/main/java/org/apache/dubbo/samples/user/UserServiceImpl.java b/10-task/dubbo-samples-shop/dubbo-samples-shop-user/src/main/java/org/apache/dubbo/samples/user/UserServiceImpl.java
index 9ff8c4e1..dc088d9f 100644
--- a/10-task/dubbo-samples-shop/dubbo-samples-shop-user/src/main/java/org/apache/dubbo/samples/user/UserServiceImpl.java
+++ b/10-task/dubbo-samples-shop/dubbo-samples-shop-user/src/main/java/org/apache/dubbo/samples/user/UserServiceImpl.java
@@ -22,36 +22,61 @@ import org.apache.dubbo.samples.UserService;
import java.util.concurrent.ThreadLocalRandom;
-@DubboService
+@DubboService(timeout = 1000)
public class UserServiceImpl implements UserService {
@Override
public boolean register(User user) {
+ // Do something that consumes resources
+ for (int i = 0; i < 100; i++) {
+ Math.pow(ThreadLocalRandom.current().nextDouble(10), ThreadLocalRandom.current().nextDouble(5));
+ }
+
+ return true;
+ }
+
+ @Override
+ public User login(String username, String password) {
+ // Do something that consumes resources
+ User user = new User();
+ user.setUsername(username);
+ user.setPassword(password);
+ user.setPhone("13912345678");
+ user.setMail("dev@dubbo.apache.org");
+ user.setRealName("Dubbo Test");
+ return user;
+ }
+
+ @Override
+ public User timeoutLogin(String username, String password) {
try {
- // Do something that consumes resources
- for (int i = 0; i < 1000; i++) {
- Math.pow(ThreadLocalRandom.current().nextDouble(10), ThreadLocalRandom.current().nextDouble(5));
- }
- Thread.sleep(ThreadLocalRandom.current().nextInt(100));
+ Thread.sleep(1100);
} catch (InterruptedException ignore) {
Thread.currentThread().interrupt();
}
- return true;
+ User user = new User();
+ user.setUsername(username);
+ user.setPassword(password);
+ user.setPhone("13912345678");
+ user.setMail("dev@dubbo.apache.org");
+ user.setRealName("Dubbo Test");
+ return user;
}
+ private int count = 1;
+
@Override
- public User login(String username, String password) {
+ public User getInfo(String username) {
+ System.out.println("Received getInfo request......");
try {
- // Do something that consumes resources
- for (int i = 0; i < 200; i++) {
- Math.pow(ThreadLocalRandom.current().nextDouble(10), ThreadLocalRandom.current().nextDouble(5));
+ if (++count % 3 != 0) {
+ Thread.sleep(3000);
}
- Thread.sleep(ThreadLocalRandom.current().nextInt(50));
} catch (InterruptedException ignore) {
Thread.currentThread().interrupt();
}
User user = new User();
user.setUsername(username);
- user.setPassword(password);
+ user.setPassword("password");
user.setPhone("13912345678");
user.setMail("dev@dubbo.apache.org");
user.setRealName("Dubbo Test");
diff --git a/10-task/dubbo-samples-shop/pom.xml b/10-task/dubbo-samples-shop/pom.xml
index e03045bd..b72e2391 100644
--- a/10-task/dubbo-samples-shop/pom.xml
+++ b/10-task/dubbo-samples-shop/pom.xml
@@ -29,14 +29,22 @@
<description>Dubbo Samples RPC Task - Shop</description>
<modules>
- <module>dubbo-samples-shop-detail</module>
- <module>dubbo-samples-shop-detail-api</module>
- <module>dubbo-samples-shop-frontend</module>
<module>dubbo-samples-shop-frontend-api</module>
+ <module>dubbo-samples-shop-frontend</module>
+ <module>dubbo-samples-shop-order-api</module>
<module>dubbo-samples-shop-order-v1</module>
<module>dubbo-samples-shop-order-v2</module>
- <module>dubbo-samples-shop-order-api</module>
+ <module>dubbo-samples-shop-order-gray</module>
+ <module>dubbo-samples-shop-comment-api</module>
+ <module>dubbo-samples-shop-comment-v1</module>
+ <module>dubbo-samples-shop-comment-v2</module>
+ <module>dubbo-samples-shop-comment-gray</module>
+ <module>dubbo-samples-shop-detail-api</module>
+ <module>dubbo-samples-shop-detail-v1</module>
+ <module>dubbo-samples-shop-detail-v2</module>
+ <module>dubbo-samples-shop-detail-gray</module>
<module>dubbo-samples-shop-user</module>
+ <module>dubbo-samples-shop-user-gray</module>
<module>dubbo-samples-shop-user-api</module>
</modules>
</project>
\ No newline at end of file
diff --git a/4-governance/dubbo-samples-spring-boot-tracing-skywalking/pom.xml b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/pom.xml
index 68186586..adb2c8d1 100644
--- a/4-governance/dubbo-samples-spring-boot-tracing-skywalking/pom.xml
+++ b/4-governance/dubbo-samples-spring-boot-tracing-skywalking/pom.xml
@@ -44,7 +44,7 @@
<maven.compiler.target>17</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<java.version>17</java.version>
- <dubbo.version>3.2.0-beta.4-SNAPSHOT</dubbo.version>
+ <dubbo.version>3.2.0-beta.4</dubbo.version>
<nacos.version>2.2.0</nacos.version>
<micrometer.version>1.10.3</micrometer.version>
<micrometer-tracing.version>1.0.1</micrometer-tracing.version>
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@dubbo.apache.org
For additional commands, e-mail: notifications-help@dubbo.apache.org