Skip to content

Commit

Permalink
Merge pull request #1334 from daizhenyu/tag-transmission-demo
Browse files Browse the repository at this point in the history
流量标签透传插件集成测试demo:dubbo demo、rpc-api demo、公共httpserver demo
  • Loading branch information
Sherlockhan authored Oct 19, 2023
2 parents 70c0b62 + 024a4fb commit ff43ef2
Show file tree
Hide file tree
Showing 29 changed files with 1,061 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.huaweicloud.sermant.tagtransmission</groupId>
<artifactId>tag-transmission-test</artifactId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>alibaba-dubbo-consumer-demo</artifactId>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<zkclient.version>0.10</zkclient.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
<version>${curator.version}</version>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>${curator.version}</version>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-x-discovery</artifactId>
<version>${curator.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>${alibaba.dubbo.version}</version>
</dependency>
<dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
<version>${zkclient.version}</version>
</dependency>
<dependency>
<groupId>com.huaweicloud.sermant.tagtransmission</groupId>
<artifactId>rpc-api-demo</artifactId>
</dependency>
</dependencies>

<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (C) 2023-2023 Huawei Technologies Co., Ltd. All rights reserved.
*
* Licensed 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 com.huaweicloud.demo.tagtransmission.alibabadubbo.consumer;

import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
* springboot 启动类
*
* @author daizhenyu
* @since 2023-09-07
**/
@EnableDubbo
@SpringBootApplication
public class AlibabaDubboConsumerApplication {
/**
* 启动类
*
* @param args 进程启动入参
*/
public static void main(String[] args) {
SpringApplication.run(AlibabaDubboConsumerApplication.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* Copyright (C) 2023-2023 Huawei Technologies Co., Ltd. All rights reserved.
*
* Licensed 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 com.huaweicloud.demo.tagtransmission.alibabadubbo.consumer.controller;

import com.huaweicloud.demo.tagtransmission.rpc.api.alibabadubbo.AlibabaTagTransmissionService;

import com.alibaba.dubbo.config.annotation.Reference;

import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

/**
* alibaba dubbo消费端
*
* @author daizhenyu
* @since 2023-09-08
**/
@RestController
@RequestMapping("alibabaDubbo")
public class AlibabaDubboController {
@Reference(loadbalance = "random")
private AlibabaTagTransmissionService tagTransmissionService;

/**
* 验证alibaba dubbo透传流量标签
*
* @return 流量标签值
*/
@RequestMapping(value = "testAlibabaDubbo", method = RequestMethod.GET, produces = MediaType.TEXT_PLAIN_VALUE)
@ResponseBody
public String testAlibabaDubbo() {
return tagTransmissionService.transmitTag();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Spring Boot应用程序配置
spring:
application:
name: alibaba-dubbo-consumer
main:
allow-bean-definition-overriding: true
server:
port: 9041

# Dubbo配置
dubbo:
application:
name: alibaba-dubbo-consumer
qos-port: 33335
registry:
address: zookeeper://127.0.0.1:2181
protocol:
name: dubbo
port: -1
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<groupId>com.huaweicloud.sermant.tagtransmission</groupId>
<artifactId>tag-transmission-test</artifactId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>alibaba-dubbo-provider-demo</artifactId>

<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<tag-transmission.version>1.0.0</tag-transmission.version>
<zkclient.version>0.10</zkclient.version>
</properties>

<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-recipes</artifactId>
<version>${curator.version}</version>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-framework</artifactId>
<version>${curator.version}</version>
</dependency>
<dependency>
<groupId>org.apache.curator</groupId>
<artifactId>curator-x-discovery</artifactId>
<version>${curator.version}</version>
</dependency>
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>dubbo</artifactId>
<version>${alibaba.dubbo.version}</version>
</dependency>
<dependency>
<groupId>com.101tec</groupId>
<artifactId>zkclient</artifactId>
<version>${zkclient.version}</version>
</dependency>
<dependency>
<groupId>com.huaweicloud.sermant.tagtransmission</groupId>
<artifactId>rpc-api-demo</artifactId>
</dependency>
<dependency>
<groupId>com.huaweicloud.sermant.tagtransmission</groupId>
<artifactId>tag-transmission-util-demo</artifactId>
</dependency>
</dependencies>

<build>
<finalName>${project.artifactId}</finalName>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (C) 2023-2023 Huawei Technologies Co., Ltd. All rights reserved.
*
* Licensed 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 com.huaweicloud.demo.tagtransmission.alibabadubbo.provider;

import com.alibaba.dubbo.config.spring.context.annotation.EnableDubbo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;

/**
* springboot 启动类
*
* @author daizhenyu
* @since 2023-09-07
**/
@SpringBootApplication
@EnableDubbo
public class AlibabaDubboProviderApplication {
/**
* 启动类
*
* @param args 进程启动入参
*/
public static void main(String[] args) {
SpringApplication.run(AlibabaDubboProviderApplication.class, args);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
* Copyright (C) 2023-2023 Huawei Technologies Co., Ltd. All rights reserved.
*
* Licensed 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 com.huaweicloud.demo.tagtransmission.alibabadubbo.provider.serviceimpl;

import com.huaweicloud.demo.tagtransmission.rpc.api.alibabadubbo.AlibabaTagTransmissionService;
import com.huaweicloud.demo.tagtransmission.util.HttpClientUtils;

import com.alibaba.dubbo.config.annotation.Service;

import org.springframework.beans.factory.annotation.Value;

/**
* alibaba dubbo服务实现类
*
* @author daizhenyu
* @since 2023-09-08
**/
@Service
public class AlibabaTagTransmissionServiceImpl implements AlibabaTagTransmissionService {
@Value("${common.server.url}")
private String commonServerUrl;

@Override
public String transmitTag() {
return HttpClientUtils.doHttpUrlConnectionGet(commonServerUrl);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
common.server.url=http://127.0.0.1:9040/common/httpServer
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Spring Boot应用程序配置
spring:
application:
name: alibaba-dubbo-provider
main:
allow-bean-definition-overriding: true
server:
port: 9042

# Dubbo配置
dubbo:
application:
name: alibaba-dubbo-provider
qos-port: 33336
registry:
address: zookeeper://127.0.0.1:2181
protocol:
name: dubbo
port: -1
Loading

0 comments on commit ff43ef2

Please sign in to comment.