mirror of
https://gitee.com/mirrors/Spring-Cloud-Alibaba.git
synced 2021-06-26 13:25:11 +08:00
commit
5bb5375bef
@ -48,7 +48,7 @@ Example 列表:
|
|||||||
|
|
||||||
[Nacos Discovery Example](https://github.com/spring-cloud-incubator/spring-cloud-alibaba/blob/master/spring-cloud-alibaba-examples/nacos-example/nacos-discovery-example/readme-zh.md)
|
[Nacos Discovery Example](https://github.com/spring-cloud-incubator/spring-cloud-alibaba/blob/master/spring-cloud-alibaba-examples/nacos-example/nacos-discovery-example/readme-zh.md)
|
||||||
|
|
||||||
[AliCloud OSS Example](https://github.com/spring-cloud-incubator/spring-cloud-alibaba/blob/master/spring-cloud-alibaba-examples/storage-example/readme-zh.md)
|
[AliCloud OSS Example](https://github.com/spring-cloud-incubator/spring-cloud-alibaba/blob/master/spring-cloud-alibaba-examples/oss-example/readme-zh.md)
|
||||||
|
|
||||||
## 版本管理规范
|
## 版本管理规范
|
||||||
项目的版本号格式为 x.x.x 的形式,其中 x 的数值类型为数字,从0开始取值,且不限于 0~9 这个范围。项目处于孵化器阶段时,第一位版本号固定使用0,即版本号为 0.x.x 的格式。
|
项目的版本号格式为 x.x.x 的形式,其中 x 的数值类型为数字,从0开始取值,且不限于 0~9 这个范围。项目处于孵化器阶段时,第一位版本号固定使用0,即版本号为 0.x.x 的格式。
|
||||||
|
@ -47,7 +47,7 @@ Examples:
|
|||||||
|
|
||||||
[Nacos Discovery Example](https://github.com/spring-cloud-incubator/spring-cloud-alibaba/blob/master/spring-cloud-alibaba-examples/nacos-example/nacos-discovery-example/readme.md)
|
[Nacos Discovery Example](https://github.com/spring-cloud-incubator/spring-cloud-alibaba/blob/master/spring-cloud-alibaba-examples/nacos-example/nacos-discovery-example/readme.md)
|
||||||
|
|
||||||
[AliCloud OSS Example](https://github.com/spring-cloud-incubator/spring-cloud-alibaba/blob/master/spring-cloud-alibaba-examples/storage-example/readme.md)
|
[AliCloud OSS Example](https://github.com/spring-cloud-incubator/spring-cloud-alibaba/blob/master/spring-cloud-alibaba-examples/oss-example/readme.md)
|
||||||
|
|
||||||
## Version control guidelines
|
## Version control guidelines
|
||||||
The version number of the project is in the form of x.x.x, where x is a number, starting from 0, and is not limited to the range 0~9. When the project is in the incubator phase, the first version number is fixed to 0, that is, the version number is 0.x.x.
|
The version number of the project is in the form of x.x.x, where x is a number, starting from 0, and is not limited to the range 0~9. When the project is in the incubator phase, the first version number is fixed to 0, that is, the version number is 0.x.x.
|
||||||
|
8
pom.xml
8
pom.xml
@ -8,13 +8,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-build</artifactId>
|
<artifactId>spring-cloud-build</artifactId>
|
||||||
<version>1.3.8.RELEASE</version>
|
<version>1.3.10.RELEASE</version>
|
||||||
<relativePath/>
|
<relativePath/>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba</artifactId>
|
<artifactId>spring-cloud-alibaba</artifactId>
|
||||||
<version>0.1.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>Spring Cloud Alibaba</name>
|
<name>Spring Cloud Alibaba</name>
|
||||||
|
|
||||||
@ -73,12 +73,14 @@
|
|||||||
<modules>
|
<modules>
|
||||||
<module>spring-cloud-alibaba-dependencies</module>
|
<module>spring-cloud-alibaba-dependencies</module>
|
||||||
<module>spring-cloud-alibaba-sentinel</module>
|
<module>spring-cloud-alibaba-sentinel</module>
|
||||||
<module>spring-cloud-alibaba-storage</module>
|
|
||||||
<module>spring-cloud-alibaba-nacos-config</module>
|
<module>spring-cloud-alibaba-nacos-config</module>
|
||||||
<module>spring-cloud-alibaba-nacos-discovery</module>
|
<module>spring-cloud-alibaba-nacos-discovery</module>
|
||||||
<module>spring-cloud-alibaba-examples</module>
|
<module>spring-cloud-alibaba-examples</module>
|
||||||
<module>spring-cloud-alibaba-test</module>
|
<module>spring-cloud-alibaba-test</module>
|
||||||
<module>spring-cloud-starter-alibaba</module>
|
<module>spring-cloud-starter-alibaba</module>
|
||||||
|
<module>spring-cloud-starter-alicloud</module>
|
||||||
|
<module>spring-cloud-alicloud-oss</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
|
@ -6,19 +6,19 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<artifactId>spring-cloud-dependencies-parent</artifactId>
|
<artifactId>spring-cloud-dependencies-parent</artifactId>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<version>1.3.3.BUILD-SNAPSHOT</version>
|
<version>1.3.10.RELEASE</version>
|
||||||
<relativePath/>
|
<relativePath/>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
<artifactId>spring-cloud-alibaba-dependencies</artifactId>
|
||||||
<version>0.1.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0</version>
|
||||||
<packaging>pom</packaging>
|
<packaging>pom</packaging>
|
||||||
<name>Spring Cloud Alibaba Dependencies</name>
|
<name>Spring Cloud Alibaba Dependencies</name>
|
||||||
<description>Spring Cloud Alibaba Dependencies</description>
|
<description>Spring Cloud Alibaba Dependencies</description>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<sentinel.version>0.1.1</sentinel.version>
|
<sentinel.version>0.2.0</sentinel.version>
|
||||||
<oss.version>3.1.0</oss.version>
|
<oss.version>3.1.0</oss.version>
|
||||||
<nacos.version>0.2.1-RC1</nacos.version>
|
<nacos.version>0.2.1</nacos.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<dependencyManagement>
|
<dependencyManagement>
|
||||||
@ -98,7 +98,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba-storage</artifactId>
|
<artifactId>spring-cloud-alicloud-oss</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -120,7 +120,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-alibaba-storage</artifactId>
|
<artifactId>spring-cloud-starter-alicloud-oss</artifactId>
|
||||||
<version>${project.version}</version>
|
<version>${project.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba-examples</artifactId>
|
<artifactId>spring-cloud-alibaba-examples</artifactId>
|
||||||
<version>0.1.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>nacos-discovery-example</artifactId>
|
<artifactId>nacos-discovery-example</artifactId>
|
||||||
<version>0.1.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>nacos-discovery-example</artifactId>
|
<artifactId>nacos-discovery-example</artifactId>
|
||||||
<version>0.1.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba-examples</artifactId>
|
<artifactId>spring-cloud-alibaba-examples</artifactId>
|
||||||
<version>0.1.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,14 +5,14 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba-examples</artifactId>
|
<artifactId>spring-cloud-alibaba-examples</artifactId>
|
||||||
<version>0.1.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
|
||||||
<artifactId>storage-example</artifactId>
|
<artifactId>oss-example</artifactId>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<description>Example demonstrating how to use storage</description>
|
<description>Example demonstrating how to use alicloud oss</description>
|
||||||
|
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
@ -22,7 +22,7 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-alibaba-storage</artifactId>
|
<artifactId>spring-cloud-starter-alicloud-oss</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
@ -13,11 +13,11 @@
|
|||||||
|
|
||||||
**注意:本节只是为了便于您理解接入方式,本示例代码中已经完成接入工作,您只需修改 accessKeyId、secretAccessKey、region 即可。**
|
**注意:本节只是为了便于您理解接入方式,本示例代码中已经完成接入工作,您只需修改 accessKeyId、secretAccessKey、region 即可。**
|
||||||
|
|
||||||
1. 修改 pom.xml 文件,引入 Storage starter。
|
1. 修改 pom.xml 文件,引入 OSS starter。
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-alibaba-storage</artifactId>
|
<artifactId>spring-cloud-starter-alicloud-oss</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
2. 在配置文件中配置 OSS 服务对应的 accessKeyId、secretAccessKey 和 region。
|
2. 在配置文件中配置 OSS 服务对应的 accessKeyId、secretAccessKey 和 region。
|
@ -1,4 +1,4 @@
|
|||||||
# Storage Example
|
# OSS Example
|
||||||
## Introduction
|
## Introduction
|
||||||
|
|
||||||
If your applications are Spring Cloud applications and you need to use Alibaba Cloud's OSS service for file storage (for example, storing commodity image for your e-commerce business), you can use OSS starter. This topic provides an example to illustrate how to use OSS starter to implement object storage for Spring Cloud applications.
|
If your applications are Spring Cloud applications and you need to use Alibaba Cloud's OSS service for file storage (for example, storing commodity image for your e-commerce business), you can use OSS starter. This topic provides an example to illustrate how to use OSS starter to implement object storage for Spring Cloud applications.
|
||||||
@ -13,11 +13,11 @@ If your applications are Spring Cloud applications and you need to use Alibaba C
|
|||||||
Before we start the demo, let's learn how to connect OSS to a Spring Cloud application.
|
Before we start the demo, let's learn how to connect OSS to a Spring Cloud application.
|
||||||
**Note: This section is to show you how to connect to oss. The actual configurations have been completed in the following example, and you only need to specify your accessKeyId, secretAccessKey and region.**
|
**Note: This section is to show you how to connect to oss. The actual configurations have been completed in the following example, and you only need to specify your accessKeyId, secretAccessKey and region.**
|
||||||
|
|
||||||
1. Add dependency spring-cloud-starter-alibaba-storage in the pom.xml file in your Spring Cloud project.
|
1. Add dependency spring-cloud-starter-alicloud-oss in the pom.xml file in your Spring Cloud project.
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-alibaba-storage</artifactId>
|
<artifactId>spring-cloud-starter-alicloud-oss</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
2. Configure accessKeyId, secretAccessKey and region in application.properties.
|
2. Configure accessKeyId, secretAccessKey and region in application.properties.
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba</artifactId>
|
<artifactId>spring-cloud-alibaba</artifactId>
|
||||||
<version>0.1.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
@ -22,7 +22,7 @@
|
|||||||
<module>sentinel-example/sentinel-dubbo-example/sentinel-dubbo-api</module>
|
<module>sentinel-example/sentinel-dubbo-example/sentinel-dubbo-api</module>
|
||||||
<module>nacos-example/nacos-discovery-example</module>
|
<module>nacos-example/nacos-discovery-example</module>
|
||||||
<module>nacos-example/nacos-config-example</module>
|
<module>nacos-example/nacos-config-example</module>
|
||||||
<module>storage-example</module>
|
<module>oss-example</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba-examples</artifactId>
|
<artifactId>spring-cloud-alibaba-examples</artifactId>
|
||||||
<version>0.1.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0</version>
|
||||||
<relativePath>../../pom.xml</relativePath>
|
<relativePath>../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -78,7 +78,7 @@
|
|||||||
```
|
```
|
||||||
spring.application.name=sentinel-example
|
spring.application.name=sentinel-example
|
||||||
server.port=18083
|
server.port=18083
|
||||||
spring.cloud.sentinel.dashboard=localhost:8080
|
spring.cloud.sentinel.transport.dashboard=localhost:8080
|
||||||
```
|
```
|
||||||
|
|
||||||
2. 启动应用,支持 IDE 直接启动和编译打包后启动。
|
2. 启动应用,支持 IDE 直接启动和编译打包后启动。
|
||||||
@ -204,7 +204,7 @@ Sentinel starter 整合了目前存在的几类 DataSource。只需要在配置
|
|||||||
spring.cloud.sentinel.datasource.recommendRefreshMs=2000
|
spring.cloud.sentinel.datasource.recommendRefreshMs=2000
|
||||||
spring.cloud.sentinel.datasource.bufSize=2048
|
spring.cloud.sentinel.datasource.bufSize=2048
|
||||||
spring.cloud.sentinel.datasource.charset=utf-8
|
spring.cloud.sentinel.datasource.charset=utf-8
|
||||||
spring.cloud.sentinel.datasource.configParser=myParser
|
spring.cloud.sentinel.datasource.converter=myParser
|
||||||
spring.cloud.sentinel.datasource.file=/Users/you/rule.json
|
spring.cloud.sentinel.datasource.file=/Users/you/rule.json
|
||||||
|
|
||||||
然后使用`@SentinelDataSource` 注解修饰 DataSource 即可注入:
|
然后使用`@SentinelDataSource` 注解修饰 DataSource 即可注入:
|
||||||
@ -220,7 +220,7 @@ Sentinel starter 整合了目前存在的几类 DataSource。只需要在配置
|
|||||||
|
|
||||||
`spring.cloud.sentinel.datasource.recommendRefreshMs` 里的 `recommendRefreshMs` 对应相关 DataSource 的属性。
|
`spring.cloud.sentinel.datasource.recommendRefreshMs` 里的 `recommendRefreshMs` 对应相关 DataSource 的属性。
|
||||||
|
|
||||||
`spring.cloud.sentinel.datasource.configParser`代表 `ConfigParser` 在 Spring 容器里的 name。如果没找到,会抛出异常。
|
`spring.cloud.sentinel.datasource.converter`代表 `Converter` 在 Spring 容器里的 name。如果没找到,会抛出异常。
|
||||||
|
|
||||||
type目前支持file, nacos, zk, apollo。
|
type目前支持file, nacos, zk, apollo。
|
||||||
|
|
||||||
@ -260,7 +260,7 @@ type目前支持file, nacos, zk, apollo。
|
|||||||
spring.cloud.sentinel.datasource.fieldA = valueA
|
spring.cloud.sentinel.datasource.fieldA = valueA
|
||||||
spring.cloud.sentinel.datasource.fieldB = valueB
|
spring.cloud.sentinel.datasource.fieldB = valueB
|
||||||
|
|
||||||
注意:由于目前Sentinel的AbstractDataSource需要有个ConfigParser作为构造函数中的参数,并且它的子类的构造都是通过多个参数的构造函数构造的。
|
注意:由于目前Sentinel的AbstractDataSource需要有个Converter作为构造函数中的参数,并且它的子类的构造都是通过多个参数的构造函数构造的。
|
||||||
所以目前所有的Sentinel starter中的DataSource都是基于FactoryBean并且通过设置属性构造的。如果有这方面的需求,需要再多加一个registerFactoryBean过程。
|
所以目前所有的Sentinel starter中的DataSource都是基于FactoryBean并且通过设置属性构造的。如果有这方面的需求,需要再多加一个registerFactoryBean过程。
|
||||||
|
|
||||||
SentinelDataSourceRegistry.registerFactoryBean("custeom", CustomDataSourceFactoryBean.class);
|
SentinelDataSourceRegistry.registerFactoryBean("custeom", CustomDataSourceFactoryBean.class);
|
||||||
|
@ -66,7 +66,7 @@ Before we start the demo, let's learn how to connect Sentinel to a Spring Cloud
|
|||||||
|
|
||||||
spring.application.name=sentinel-example
|
spring.application.name=sentinel-example
|
||||||
server.port=18083
|
server.port=18083
|
||||||
spring.cloud.sentinel.dashboard=localhost:8080
|
spring.cloud.sentinel.transport.dashboard=localhost:8080
|
||||||
|
|
||||||
2. Start the application in IDE or by building a fatjar.
|
2. Start the application in IDE or by building a fatjar.
|
||||||
|
|
||||||
@ -177,7 +177,7 @@ If you want to define FileRefreshableDataSource:
|
|||||||
spring.cloud.sentinel.datasource.recommendRefreshMs=2000
|
spring.cloud.sentinel.datasource.recommendRefreshMs=2000
|
||||||
spring.cloud.sentinel.datasource.bufSize=2048
|
spring.cloud.sentinel.datasource.bufSize=2048
|
||||||
spring.cloud.sentinel.datasource.charset=utf-8
|
spring.cloud.sentinel.datasource.charset=utf-8
|
||||||
spring.cloud.sentinel.datasource.configParser=myParser
|
spring.cloud.sentinel.datasource.converter=myParser
|
||||||
spring.cloud.sentinel.datasource.file=/Users/you/rule.json
|
spring.cloud.sentinel.datasource.file=/Users/you/rule.json
|
||||||
|
|
||||||
then use `@SentinelDataSource` to annotate DataSource:
|
then use `@SentinelDataSource` to annotate DataSource:
|
||||||
@ -191,7 +191,7 @@ spring.cloud.sentinel.datasource.type means the type of DataSource.
|
|||||||
|
|
||||||
spring.cloud.sentinel.datasource.recommendRefreshMs means the recommendRefreshMs property of specified DataSource.
|
spring.cloud.sentinel.datasource.recommendRefreshMs means the recommendRefreshMs property of specified DataSource.
|
||||||
|
|
||||||
spring.cloud.sentinel.datasource.configParser means the name of spring bean that type is ConfigParser. If the bean is not exists, will throw exception.
|
spring.cloud.sentinel.datasource.converter means the name of spring bean that type is Converter. If the bean is not exists, will throw exception.
|
||||||
|
|
||||||
Now datasource type support 4 categories: file, nacos, zk, apollo.
|
Now datasource type support 4 categories: file, nacos, zk, apollo.
|
||||||
|
|
||||||
@ -230,7 +230,7 @@ User-defined DataSource need 2 steps.
|
|||||||
spring.cloud.sentinel.datasource.fieldA = valueA
|
spring.cloud.sentinel.datasource.fieldA = valueA
|
||||||
spring.cloud.sentinel.datasource.fieldB = valueB
|
spring.cloud.sentinel.datasource.fieldB = valueB
|
||||||
|
|
||||||
Note: The AbstractDataSource of Sentinel need a ConfigParser as a constructor param and the subclass of AbstractDataSource was construct by multi-param constructor.
|
Note: The AbstractDataSource of Sentinel need a Converter as a constructor param and the subclass of AbstractDataSource was construct by multi-param constructor.
|
||||||
Now All DataSources in starter was construct by FactoryBean. If you want to do it in this way, you should register FactoryBean by SentinelDataSourceRegistry.
|
Now All DataSources in starter was construct by FactoryBean. If you want to do it in this way, you should register FactoryBean by SentinelDataSourceRegistry.
|
||||||
|
|
||||||
SentinelDataSourceRegistry.registerFactoryBean("custeom", CustomDataSourceFactoryBean.class);
|
SentinelDataSourceRegistry.registerFactoryBean("custeom", CustomDataSourceFactoryBean.class);
|
||||||
|
@ -2,7 +2,7 @@ package org.springframework.cloud.alibaba.cloud.examples;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.alibaba.csp.sentinel.datasource.ConfigParser;
|
import com.alibaba.csp.sentinel.datasource.Converter;
|
||||||
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
|
import com.alibaba.csp.sentinel.slots.block.flow.FlowRule;
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.alibaba.fastjson.TypeReference;
|
import com.alibaba.fastjson.TypeReference;
|
||||||
@ -10,9 +10,10 @@ import com.alibaba.fastjson.TypeReference;
|
|||||||
/**
|
/**
|
||||||
* @author fangjian
|
* @author fangjian
|
||||||
*/
|
*/
|
||||||
public class JsonFlowRuleListParser implements ConfigParser<String, List<FlowRule>> {
|
public class JsonFlowRuleListParser implements Converter<String, List<FlowRule>> {
|
||||||
@Override
|
@Override
|
||||||
public List<FlowRule> parse(String source) {
|
public List<FlowRule> convert(String source) {
|
||||||
return JSON.parseObject(source, new TypeReference<List<FlowRule>>() {});
|
return JSON.parseObject(source, new TypeReference<List<FlowRule>>() {
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import org.springframework.cloud.alibaba.sentinel.annotation.SentinelProtect;
|
|||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.web.client.RestTemplate;
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
import com.alibaba.csp.sentinel.datasource.ConfigParser;
|
import com.alibaba.csp.sentinel.datasource.Converter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xiaojing
|
* @author xiaojing
|
||||||
@ -26,7 +26,7 @@ public class ServiceApplication {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public ConfigParser myParser() {
|
public Converter myParser() {
|
||||||
return new JsonFlowRuleListParser();
|
return new JsonFlowRuleListParser();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
spring.application.name=sentinel-example
|
spring.application.name=sentinel-example
|
||||||
server.port=18083
|
server.port=18083
|
||||||
management.security.enabled=false
|
management.security.enabled=false
|
||||||
spring.cloud.sentinel.port=8721
|
spring.cloud.sentinel.transport.port=8721
|
||||||
spring.cloud.sentinel.dashboard=localhost:8080
|
spring.cloud.sentinel.transport.dashboard=localhost:8080
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba-examples</artifactId>
|
<artifactId>spring-cloud-alibaba-examples</artifactId>
|
||||||
<version>0.1.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba-examples</artifactId>
|
<artifactId>spring-cloud-alibaba-examples</artifactId>
|
||||||
<version>0.1.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba-examples</artifactId>
|
<artifactId>spring-cloud-alibaba-examples</artifactId>
|
||||||
<version>0.1.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0</version>
|
||||||
<relativePath>../../../pom.xml</relativePath>
|
<relativePath>../../../pom.xml</relativePath>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba</artifactId>
|
<artifactId>spring-cloud-alibaba</artifactId>
|
||||||
<version>0.1.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -28,6 +28,8 @@ import com.alibaba.nacos.api.exception.NacosException;
|
|||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
import org.springframework.beans.factory.config.YamlPropertiesFactoryBean;
|
||||||
|
import org.springframework.core.io.ByteArrayResource;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -83,11 +85,22 @@ public class NacosPropertySourceBuilder {
|
|||||||
data = configService.getConfig(dataId, group, timeout);
|
data = configService.getConfig(dataId, group, timeout);
|
||||||
// todo add file extension yaml support
|
// todo add file extension yaml support
|
||||||
if (!StringUtils.isEmpty(data)) {
|
if (!StringUtils.isEmpty(data)) {
|
||||||
Properties properties = new Properties();
|
|
||||||
logger.info(String.format("Loading nacos data, dataId: '%s', group: '%s'",
|
logger.info(String.format("Loading nacos data, dataId: '%s', group: '%s'",
|
||||||
dataId, group));
|
dataId, group));
|
||||||
properties.load(new StringReader(data));
|
|
||||||
return properties;
|
if (fileExtension.equalsIgnoreCase("properties")) {
|
||||||
|
Properties properties = new Properties();
|
||||||
|
|
||||||
|
properties.load(new StringReader(data));
|
||||||
|
return properties;
|
||||||
|
}
|
||||||
|
else if (fileExtension.equalsIgnoreCase("yaml")
|
||||||
|
|| fileExtension.equalsIgnoreCase("yml")) {
|
||||||
|
YamlPropertiesFactoryBean yamlFactory = new YamlPropertiesFactoryBean();
|
||||||
|
yamlFactory.setResources(new ByteArrayResource(data.getBytes()));
|
||||||
|
return yamlFactory.getObject();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (NacosException e) {
|
catch (NacosException e) {
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba</artifactId>
|
<artifactId>spring-cloud-alibaba</artifactId>
|
||||||
<version>0.1.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package org.springframework.cloud.alibaba.nacos;
|
package org.springframework.cloud.alibaba.nacos;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
|
||||||
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
@ -48,12 +47,6 @@ public class NacosDiscoveryAutoConfiguration {
|
|||||||
return new NacosServiceRegistry();
|
return new NacosServiceRegistry();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
|
||||||
@ConditionalOnMissingBean
|
|
||||||
public NacosDiscoveryProperties nacosProperties() {
|
|
||||||
return new NacosDiscoveryProperties();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
@ConditionalOnBean(AutoServiceRegistrationProperties.class)
|
@ConditionalOnBean(AutoServiceRegistrationProperties.class)
|
||||||
public NacosRegistration nacosRegistration() {
|
public NacosRegistration nacosRegistration() {
|
||||||
|
@ -19,13 +19,15 @@ package org.springframework.cloud.alibaba.nacos;
|
|||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cloud.alibaba.nacos.registry.NacosRegistration;
|
import org.springframework.cloud.client.DefaultServiceInstance;
|
||||||
import org.springframework.cloud.client.ServiceInstance;
|
import org.springframework.cloud.client.ServiceInstance;
|
||||||
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||||
|
import org.springframework.core.env.Environment;
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
import com.alibaba.nacos.api.naming.NamingService;
|
import com.alibaba.nacos.api.naming.NamingService;
|
||||||
import com.alibaba.nacos.api.naming.pojo.Instance;
|
import com.alibaba.nacos.api.naming.pojo.Instance;
|
||||||
import com.alibaba.nacos.api.naming.pojo.ListView;
|
import com.alibaba.nacos.api.naming.pojo.ListView;
|
||||||
@ -40,53 +42,38 @@ public class NacosDiscoveryClient implements DiscoveryClient {
|
|||||||
public static final String DESCRIPTION = "Spring Cloud Nacos Discovery Client";
|
public static final String DESCRIPTION = "Spring Cloud Nacos Discovery Client";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private NacosRegistration nacosRegistration;
|
private NacosDiscoveryProperties discoveryProperties;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private Environment environment;
|
||||||
|
|
||||||
|
private NamingService namingService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String description() {
|
public String description() {
|
||||||
return DESCRIPTION;
|
return DESCRIPTION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostConstruct
|
||||||
|
public void init() {
|
||||||
|
discoveryProperties.overrideFromEnv(environment);
|
||||||
|
namingService = discoveryProperties.getNamingService();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ServiceInstance getLocalServiceInstance() {
|
public ServiceInstance getLocalServiceInstance() {
|
||||||
return new ServiceInstance() {
|
String serviceId = discoveryProperties.getService();
|
||||||
@Override
|
String host = discoveryProperties.getIp();
|
||||||
public String getServiceId() {
|
int port = discoveryProperties.getPort();
|
||||||
return nacosRegistration.getServiceId();
|
boolean secure = discoveryProperties.isSecure();
|
||||||
}
|
Map<String, String> metadata = discoveryProperties.getMetadata();
|
||||||
|
return new DefaultServiceInstance(serviceId, host, port, secure, metadata);
|
||||||
@Override
|
|
||||||
public String getHost() {
|
|
||||||
return nacosRegistration.getHost();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public int getPort() {
|
|
||||||
return nacosRegistration.getPort();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isSecure() {
|
|
||||||
return nacosRegistration.isSecure();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public URI getUri() {
|
|
||||||
return nacosRegistration.getUri();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, String> getMetadata() {
|
|
||||||
return nacosRegistration.getMetadata();
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<ServiceInstance> getInstances(String serviceId) {
|
public List<ServiceInstance> getInstances(String serviceId) {
|
||||||
try {
|
try {
|
||||||
NamingService namingService = nacosRegistration.getNacosNamingService();
|
List<Instance> instances = namingService.getAllInstances(serviceId);
|
||||||
List<Instance> instances = namingService.selectInstances(serviceId, true);
|
|
||||||
return hostToServiceInstanceList(instances, serviceId);
|
return hostToServiceInstanceList(instances, serviceId);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
@ -115,7 +102,9 @@ public class NacosDiscoveryClient implements DiscoveryClient {
|
|||||||
List<Instance> instances, String serviceId) {
|
List<Instance> instances, String serviceId) {
|
||||||
List<ServiceInstance> result = new ArrayList<ServiceInstance>(instances.size());
|
List<ServiceInstance> result = new ArrayList<ServiceInstance>(instances.size());
|
||||||
for (Instance instance : instances) {
|
for (Instance instance : instances) {
|
||||||
result.add(hostToServiceInstance(instance, serviceId));
|
if (instance.isHealthy()) {
|
||||||
|
result.add(hostToServiceInstance(instance, serviceId));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -124,7 +113,6 @@ public class NacosDiscoveryClient implements DiscoveryClient {
|
|||||||
public List<String> getServices() {
|
public List<String> getServices() {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
NamingService namingService = nacosRegistration.getNacosNamingService();
|
|
||||||
ListView<String> services = namingService.getServicesOfServer(1,
|
ListView<String> services = namingService.getServicesOfServer(1,
|
||||||
Integer.MAX_VALUE);
|
Integer.MAX_VALUE);
|
||||||
return services.getData();
|
return services.getData();
|
||||||
@ -135,4 +123,7 @@ public class NacosDiscoveryClient implements DiscoveryClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NamingService getNamingService() {
|
||||||
|
return namingService;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,4 +36,10 @@ public class NacosDiscoveryClientAutoConfiguration {
|
|||||||
return new NacosDiscoveryClient();
|
return new NacosDiscoveryClient();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
@ConditionalOnMissingBean
|
||||||
|
public NacosDiscoveryProperties nacosProperties() {
|
||||||
|
return new NacosDiscoveryProperties();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
|
|
||||||
package org.springframework.cloud.alibaba.nacos;
|
package org.springframework.cloud.alibaba.nacos;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.context.properties.ConfigurationProperties;
|
import org.springframework.boot.context.properties.ConfigurationProperties;
|
||||||
@ -33,6 +35,18 @@ import java.util.Enumeration;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
import com.alibaba.nacos.api.NacosFactory;
|
||||||
|
import com.alibaba.nacos.api.naming.NamingService;
|
||||||
|
import com.alibaba.nacos.client.naming.utils.UtilAndComs;
|
||||||
|
|
||||||
|
import static com.alibaba.nacos.api.PropertyKeyConst.ACCESS_KEY;
|
||||||
|
import static com.alibaba.nacos.api.PropertyKeyConst.CLUSTER_NAME;
|
||||||
|
import static com.alibaba.nacos.api.PropertyKeyConst.ENDPOINT;
|
||||||
|
import static com.alibaba.nacos.api.PropertyKeyConst.NAMESPACE;
|
||||||
|
import static com.alibaba.nacos.api.PropertyKeyConst.SECRET_KEY;
|
||||||
|
import static com.alibaba.nacos.api.PropertyKeyConst.SERVER_ADDR;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author dungu.zpf
|
* @author dungu.zpf
|
||||||
@ -42,6 +56,9 @@ import java.util.Objects;
|
|||||||
@ConfigurationProperties("spring.cloud.nacos.discovery")
|
@ConfigurationProperties("spring.cloud.nacos.discovery")
|
||||||
public class NacosDiscoveryProperties {
|
public class NacosDiscoveryProperties {
|
||||||
|
|
||||||
|
private static final Logger LOGGER = LoggerFactory
|
||||||
|
.getLogger(NacosDiscoveryProperties.class);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* nacos discovery server address
|
* nacos discovery server address
|
||||||
*/
|
*/
|
||||||
@ -333,4 +350,22 @@ public class NacosDiscoveryProperties {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public NamingService getNamingService() {
|
||||||
|
Properties properties = new Properties();
|
||||||
|
properties.put(SERVER_ADDR, serverAddr);
|
||||||
|
properties.put(NAMESPACE, namespace);
|
||||||
|
properties.put(UtilAndComs.NACOS_NAMING_LOG_NAME, logName);
|
||||||
|
properties.put(ENDPOINT, endpoint);
|
||||||
|
properties.put(ACCESS_KEY, accessKey);
|
||||||
|
properties.put(SECRET_KEY, secretKey);
|
||||||
|
properties.put(CLUSTER_NAME, clusterName);
|
||||||
|
try {
|
||||||
|
return NacosFactory.createNamingService(properties);
|
||||||
|
}
|
||||||
|
catch (Exception e) {
|
||||||
|
LOGGER.error("create naming service error!properties={},e=,", this, e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -28,8 +28,8 @@ import org.slf4j.Logger;
|
|||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.actuate.endpoint.AbstractEndpoint;
|
import org.springframework.boot.actuate.endpoint.AbstractEndpoint;
|
||||||
|
import org.springframework.cloud.alibaba.nacos.NacosDiscoveryClient;
|
||||||
import org.springframework.cloud.alibaba.nacos.NacosDiscoveryProperties;
|
import org.springframework.cloud.alibaba.nacos.NacosDiscoveryProperties;
|
||||||
import org.springframework.cloud.alibaba.nacos.registry.NacosRegistration;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Endpoint for nacos discovery, get nacos properties and subscribed services
|
* Endpoint for nacos discovery, get nacos properties and subscribed services
|
||||||
@ -44,7 +44,7 @@ public class NacosDiscoveryEndpoint extends AbstractEndpoint<Map<String, Object>
|
|||||||
private NacosDiscoveryProperties nacosDiscoveryProperties;
|
private NacosDiscoveryProperties nacosDiscoveryProperties;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private NacosRegistration nacosRegistration;
|
private NacosDiscoveryClient discoveryClient;
|
||||||
|
|
||||||
public NacosDiscoveryEndpoint() {
|
public NacosDiscoveryEndpoint() {
|
||||||
super("nacos_discovery", false);
|
super("nacos_discovery", false);
|
||||||
@ -58,7 +58,7 @@ public class NacosDiscoveryEndpoint extends AbstractEndpoint<Map<String, Object>
|
|||||||
Map<String, Object> result = new HashMap<>();
|
Map<String, Object> result = new HashMap<>();
|
||||||
result.put("NacosDiscoveryProperties", nacosDiscoveryProperties);
|
result.put("NacosDiscoveryProperties", nacosDiscoveryProperties);
|
||||||
|
|
||||||
NamingService namingService = nacosRegistration.getNacosNamingService();
|
NamingService namingService = discoveryClient.getNamingService();
|
||||||
List<ServiceInfo> subscribe = Collections.emptyList();
|
List<ServiceInfo> subscribe = Collections.emptyList();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -26,7 +26,6 @@ import org.springframework.context.annotation.Configuration;
|
|||||||
* @author xiaojing
|
* @author xiaojing
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
@ConditionalOnProperty(value = "spring.cloud.service-registry.auto-registration.enabled", matchIfMissing = true)
|
|
||||||
@ConditionalOnClass(name = "org.springframework.boot.actuate.endpoint.AbstractEndpoint")
|
@ConditionalOnClass(name = "org.springframework.boot.actuate.endpoint.AbstractEndpoint")
|
||||||
public class NacosDiscoveryEndpointAutoConfiguration {
|
public class NacosDiscoveryEndpointAutoConfiguration {
|
||||||
|
|
||||||
|
@ -20,52 +20,55 @@ import org.springframework.cloud.alibaba.nacos.NacosDiscoveryProperties;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cloud.client.DefaultServiceInstance;
|
import org.springframework.cloud.client.DefaultServiceInstance;
|
||||||
import org.springframework.cloud.client.ServiceInstance;
|
import org.springframework.cloud.client.ServiceInstance;
|
||||||
|
import org.springframework.cloud.client.discovery.ManagementServerPortUtils;
|
||||||
import org.springframework.cloud.client.serviceregistry.Registration;
|
import org.springframework.cloud.client.serviceregistry.Registration;
|
||||||
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.core.env.Environment;
|
import org.springframework.core.env.Environment;
|
||||||
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Properties;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
import com.alibaba.nacos.api.NacosFactory;
|
|
||||||
import com.alibaba.nacos.api.naming.NamingService;
|
import com.alibaba.nacos.api.naming.NamingService;
|
||||||
import com.alibaba.nacos.client.naming.utils.UtilAndComs;
|
|
||||||
|
|
||||||
import static com.alibaba.nacos.api.PropertyKeyConst.*;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xiaojing
|
* @author xiaojing
|
||||||
*/
|
*/
|
||||||
public class NacosRegistration implements Registration, ServiceInstance {
|
public class NacosRegistration implements Registration, ServiceInstance {
|
||||||
|
|
||||||
|
private static final String MANAGEMENT_PORT = "management.port";
|
||||||
|
private static final String MANAGEMENT_CONTEXT_PATH = "management.context-path";
|
||||||
|
private static final String MANAGEMENT_ADDRESS = "management.address";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private NacosDiscoveryProperties nacosDiscoveryProperties;
|
private NacosDiscoveryProperties nacosDiscoveryProperties;
|
||||||
|
|
||||||
private NamingService nacosNamingService;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private Environment environment;
|
private ApplicationContext context;
|
||||||
|
|
||||||
|
private NamingService nacosNamingService;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
public void init() {
|
public void init() {
|
||||||
nacosDiscoveryProperties.overrideFromEnv(environment);
|
|
||||||
|
|
||||||
Properties properties = new Properties();
|
Environment env = context.getEnvironment();
|
||||||
properties.put(SERVER_ADDR, nacosDiscoveryProperties.getServerAddr());
|
nacosDiscoveryProperties.overrideFromEnv(context.getEnvironment());
|
||||||
properties.put(NAMESPACE, nacosDiscoveryProperties.getNamespace());
|
nacosNamingService = nacosDiscoveryProperties.getNamingService();
|
||||||
properties.put(UtilAndComs.NACOS_NAMING_LOG_NAME,
|
|
||||||
nacosDiscoveryProperties.getLogName());
|
|
||||||
properties.put(ENDPOINT, nacosDiscoveryProperties.getEndpoint());
|
|
||||||
properties.put(ACCESS_KEY, nacosDiscoveryProperties.getAccessKey());
|
|
||||||
properties.put(SECRET_KEY, nacosDiscoveryProperties.getSecretKey());
|
|
||||||
properties.put(CLUSTER_NAME, nacosDiscoveryProperties.getClusterName());
|
|
||||||
try {
|
|
||||||
nacosNamingService = NacosFactory.createNamingService(properties);
|
|
||||||
}
|
|
||||||
catch (Exception e) {
|
|
||||||
|
|
||||||
|
Integer managementPort = ManagementServerPortUtils.getPort(context);
|
||||||
|
if (null != managementPort) {
|
||||||
|
Map<String, String> metadata = nacosDiscoveryProperties.getMetadata();
|
||||||
|
metadata.put(MANAGEMENT_PORT, managementPort.toString());
|
||||||
|
String contextPath = env.getProperty("management.context-path");
|
||||||
|
String address = env.getProperty("management.address");
|
||||||
|
if (!StringUtils.isEmpty(contextPath)) {
|
||||||
|
metadata.put(MANAGEMENT_CONTEXT_PATH, contextPath);
|
||||||
|
}
|
||||||
|
if (!StringUtils.isEmpty(address)) {
|
||||||
|
metadata.put(MANAGEMENT_ADDRESS, address);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,9 +88,7 @@ public class NacosRegistration implements Registration, ServiceInstance {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setPort(int port) {
|
public void setPort(int port) {
|
||||||
if (nacosDiscoveryProperties.getPort() < 0) {
|
this.nacosDiscoveryProperties.setPort(port);
|
||||||
this.nacosDiscoveryProperties.setPort(port);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -19,7 +19,9 @@ package org.springframework.cloud.alibaba.nacos.ribbon;
|
|||||||
import com.netflix.client.config.IClientConfig;
|
import com.netflix.client.config.IClientConfig;
|
||||||
import com.netflix.loadbalancer.AbstractServerList;
|
import com.netflix.loadbalancer.AbstractServerList;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.cloud.alibaba.nacos.NacosDiscoveryClient;
|
||||||
import org.springframework.cloud.alibaba.nacos.registry.NacosRegistration;
|
import org.springframework.cloud.alibaba.nacos.registry.NacosRegistration;
|
||||||
|
import org.springframework.cloud.client.discovery.DiscoveryClient;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -32,7 +34,7 @@ import com.alibaba.nacos.api.naming.pojo.Instance;
|
|||||||
public class NacosServerList extends AbstractServerList<NacosServer> {
|
public class NacosServerList extends AbstractServerList<NacosServer> {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private NacosRegistration registration;
|
private NacosDiscoveryClient discoveryClient;
|
||||||
|
|
||||||
private String serviceId;
|
private String serviceId;
|
||||||
|
|
||||||
@ -55,7 +57,7 @@ public class NacosServerList extends AbstractServerList<NacosServer> {
|
|||||||
|
|
||||||
private List<NacosServer> getServers() {
|
private List<NacosServer> getServers() {
|
||||||
try {
|
try {
|
||||||
List<Instance> instances = registration.getNacosNamingService()
|
List<Instance> instances = discoveryClient.getNamingService()
|
||||||
.getAllInstances(serviceId);
|
.getAllInstances(serviceId);
|
||||||
return instancesToServerList(instances);
|
return instancesToServerList(instances);
|
||||||
}
|
}
|
||||||
|
@ -42,6 +42,7 @@ public class NacosDiscoveryAutoConfigurationTests {
|
|||||||
@Before
|
@Before
|
||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
this.context = new SpringApplicationBuilder(NacosDiscoveryTestConfiguration.class,
|
this.context = new SpringApplicationBuilder(NacosDiscoveryTestConfiguration.class,
|
||||||
|
NacosDiscoveryClientAutoConfiguration.class,
|
||||||
NacosDiscoveryAutoConfiguration.class).web(false).run(
|
NacosDiscoveryAutoConfiguration.class).web(false).run(
|
||||||
"--spring.cloud.nacos.discovery.server-addr=127.0.0.1:8080",
|
"--spring.cloud.nacos.discovery.server-addr=127.0.0.1:8080",
|
||||||
"--spring.cloud.nacos.discovery.port=18080",
|
"--spring.cloud.nacos.discovery.port=18080",
|
||||||
|
@ -9,6 +9,7 @@ import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
|||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.builder.SpringApplicationBuilder;
|
import org.springframework.boot.builder.SpringApplicationBuilder;
|
||||||
import org.springframework.cloud.alibaba.nacos.NacosDiscoveryAutoConfiguration;
|
import org.springframework.cloud.alibaba.nacos.NacosDiscoveryAutoConfiguration;
|
||||||
|
import org.springframework.cloud.alibaba.nacos.NacosDiscoveryClientAutoConfiguration;
|
||||||
import org.springframework.cloud.alibaba.nacos.NacosDiscoveryProperties;
|
import org.springframework.cloud.alibaba.nacos.NacosDiscoveryProperties;
|
||||||
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
|
||||||
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
|
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
|
||||||
@ -33,6 +34,7 @@ public class NacosRibbonClientConfigurationTests {
|
|||||||
public void setUp() throws Exception {
|
public void setUp() throws Exception {
|
||||||
this.context = new SpringApplicationBuilder(NacosRibbonTestConfiguration.class,
|
this.context = new SpringApplicationBuilder(NacosRibbonTestConfiguration.class,
|
||||||
NacosDiscoveryAutoConfiguration.class,
|
NacosDiscoveryAutoConfiguration.class,
|
||||||
|
NacosDiscoveryClientAutoConfiguration.class,
|
||||||
NacosRibbonClientConfiguration.class, RibbonNacosAutoConfiguration.class)
|
NacosRibbonClientConfiguration.class, RibbonNacosAutoConfiguration.class)
|
||||||
.web(false).run("--server.port=18080",
|
.web(false).run("--server.port=18080",
|
||||||
"--spring.cloud.nacos.discovery.server-addr=127.0.0.1:8080",
|
"--spring.cloud.nacos.discovery.server-addr=127.0.0.1:8080",
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba</artifactId>
|
<artifactId>spring-cloud-alibaba</artifactId>
|
||||||
<version>0.1.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -29,82 +29,244 @@ import org.springframework.core.Ordered;
|
|||||||
@ConfigurationProperties(prefix = SentinelConstants.PROPERTY_PREFIX)
|
@ConfigurationProperties(prefix = SentinelConstants.PROPERTY_PREFIX)
|
||||||
public class SentinelProperties {
|
public class SentinelProperties {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enable sentinel auto configure, the default value is true
|
* 是否提前初始化心跳连接
|
||||||
*/
|
*/
|
||||||
private boolean enabled = true;
|
private boolean eager = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* sentinel api port,default value is 8721
|
* Enable sentinel auto configure, the default value is true
|
||||||
*/
|
*/
|
||||||
private String port = "8721";
|
private boolean enabled = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sentinel dashboard address, won't try to connect dashboard when address is empty
|
* 字符编码集
|
||||||
*/
|
*/
|
||||||
private String dashboard = "";
|
private String charset = "UTF-8";
|
||||||
|
|
||||||
@NestedConfigurationProperty
|
/**
|
||||||
private Filter filter;
|
* 通信相关配置
|
||||||
|
*/
|
||||||
|
@NestedConfigurationProperty
|
||||||
|
private Transport transport = new Transport();
|
||||||
|
|
||||||
public boolean isEnabled() {
|
/**
|
||||||
return enabled;
|
* 监控数据相关配置
|
||||||
}
|
*/
|
||||||
|
@NestedConfigurationProperty
|
||||||
|
private Metric metric = new Metric();
|
||||||
|
|
||||||
public void setEnabled(boolean enabled) {
|
/**
|
||||||
this.enabled = enabled;
|
* web 相关配置
|
||||||
}
|
*/
|
||||||
|
@NestedConfigurationProperty
|
||||||
|
private Servlet servlet = new Servlet();
|
||||||
|
|
||||||
public String getPort() {
|
/**
|
||||||
return port;
|
* 限流相关
|
||||||
}
|
*/
|
||||||
|
@NestedConfigurationProperty
|
||||||
|
private Filter filter = new Filter();
|
||||||
|
|
||||||
public void setPort(String port) {
|
@NestedConfigurationProperty
|
||||||
this.port = port;
|
private Flow flow = new Flow();
|
||||||
}
|
|
||||||
|
|
||||||
public String getDashboard() {
|
public boolean isEager() {
|
||||||
return dashboard;
|
return eager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDashboard(String dashboard) {
|
public void setEager(boolean eager) {
|
||||||
this.dashboard = dashboard;
|
this.eager = eager;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Filter getFilter() {
|
public Flow getFlow() {
|
||||||
return filter;
|
return flow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFilter(Filter filter) {
|
public void setFlow(Flow flow) {
|
||||||
this.filter = filter;
|
this.flow = flow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Filter {
|
public String getCharset() {
|
||||||
|
return charset;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
public void setCharset(String charset) {
|
||||||
* Sentinel filter chain order.
|
this.charset = charset;
|
||||||
*/
|
}
|
||||||
private int order = Ordered.HIGHEST_PRECEDENCE;
|
|
||||||
|
|
||||||
/**
|
public Transport getTransport() {
|
||||||
* URL pattern for sentinel filter,default is /*
|
return transport;
|
||||||
*/
|
}
|
||||||
private List<String> urlPatterns;
|
|
||||||
|
|
||||||
public int getOrder() {
|
public void setTransport(Transport transport) {
|
||||||
return this.order;
|
this.transport = transport;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOrder(int order) {
|
public Metric getMetric() {
|
||||||
this.order = order;
|
return metric;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getUrlPatterns() {
|
public void setMetric(Metric metric) {
|
||||||
return urlPatterns;
|
this.metric = metric;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUrlPatterns(List<String> urlPatterns) {
|
public Servlet getServlet() {
|
||||||
this.urlPatterns = urlPatterns;
|
return servlet;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public void setServlet(Servlet servlet) {
|
||||||
|
this.servlet = servlet;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled() {
|
||||||
|
return enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEnabled(boolean enabled) {
|
||||||
|
this.enabled = enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Filter getFilter() {
|
||||||
|
return filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFilter(Filter filter) {
|
||||||
|
this.filter = filter;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Flow {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 限流冷启动因子
|
||||||
|
*/
|
||||||
|
private String coldFactor = "3";
|
||||||
|
|
||||||
|
public String getColdFactor() {
|
||||||
|
return coldFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColdFactor(String coldFactor) {
|
||||||
|
this.coldFactor = coldFactor;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Servlet {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* url 限流后的处理页面
|
||||||
|
*/
|
||||||
|
private String blockPage;
|
||||||
|
|
||||||
|
public String getBlockPage() {
|
||||||
|
return blockPage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBlockPage(String blockPage) {
|
||||||
|
this.blockPage = blockPage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Metric {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监控数据写磁盘时单个文件的大小
|
||||||
|
*/
|
||||||
|
private String fileSingleSize;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 监控数据在磁盘上的总数量
|
||||||
|
*/
|
||||||
|
private String fileTotalCount;
|
||||||
|
|
||||||
|
public String getFileSingleSize() {
|
||||||
|
return fileSingleSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileSingleSize(String fileSingleSize) {
|
||||||
|
this.fileSingleSize = fileSingleSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileTotalCount() {
|
||||||
|
return fileTotalCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileTotalCount(String fileTotalCount) {
|
||||||
|
this.fileTotalCount = fileTotalCount;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Transport {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sentinel api port,default value is 8721
|
||||||
|
*/
|
||||||
|
private String port = "8721";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sentinel dashboard address, won't try to connect dashboard when address is
|
||||||
|
* empty
|
||||||
|
*/
|
||||||
|
private String dashboard = "";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 客户端和DashBord心跳发送时间
|
||||||
|
*/
|
||||||
|
private String heartbeatIntervalMs;
|
||||||
|
|
||||||
|
public String getHeartbeatIntervalMs() {
|
||||||
|
return heartbeatIntervalMs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeartbeatIntervalMs(String heartbeatIntervalMs) {
|
||||||
|
this.heartbeatIntervalMs = heartbeatIntervalMs;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPort() {
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPort(String port) {
|
||||||
|
this.port = port;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDashboard() {
|
||||||
|
return dashboard;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDashboard(String dashboard) {
|
||||||
|
this.dashboard = dashboard;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Filter {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sentinel filter chain order.
|
||||||
|
*/
|
||||||
|
private int order = Ordered.HIGHEST_PRECEDENCE;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* URL pattern for sentinel filter,default is /*
|
||||||
|
*/
|
||||||
|
private List<String> urlPatterns;
|
||||||
|
|
||||||
|
public int getOrder() {
|
||||||
|
return this.order;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setOrder(int order) {
|
||||||
|
this.order = order;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getUrlPatterns() {
|
||||||
|
return urlPatterns;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrlPatterns(List<String> urlPatterns) {
|
||||||
|
this.urlPatterns = urlPatterns;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,8 @@ import java.util.List;
|
|||||||
|
|
||||||
import javax.servlet.Filter;
|
import javax.servlet.Filter;
|
||||||
|
|
||||||
|
import com.alibaba.csp.sentinel.adapter.servlet.CommonFilter;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
@ -31,8 +33,6 @@ import org.springframework.boot.web.servlet.FilterRegistrationBean;
|
|||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
import com.alibaba.csp.sentinel.adapter.servlet.CommonFilter;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xiaojing
|
* @author xiaojing
|
||||||
*/
|
*/
|
||||||
@ -41,37 +41,39 @@ import com.alibaba.csp.sentinel.adapter.servlet.CommonFilter;
|
|||||||
@ConditionalOnProperty(name = "spring.cloud.sentinel.enabled", matchIfMissing = true)
|
@ConditionalOnProperty(name = "spring.cloud.sentinel.enabled", matchIfMissing = true)
|
||||||
@EnableConfigurationProperties(SentinelProperties.class)
|
@EnableConfigurationProperties(SentinelProperties.class)
|
||||||
public class SentinelWebAutoConfiguration {
|
public class SentinelWebAutoConfiguration {
|
||||||
private static final Logger logger = LoggerFactory
|
|
||||||
.getLogger(SentinelWebAutoConfiguration.class);
|
|
||||||
|
|
||||||
@Autowired
|
private static final Logger logger = LoggerFactory
|
||||||
private SentinelProperties properties;
|
.getLogger(SentinelWebAutoConfiguration.class);
|
||||||
|
|
||||||
@Bean
|
@Autowired
|
||||||
public FilterRegistrationBean servletRequestListener() {
|
private SentinelProperties properties;
|
||||||
FilterRegistrationBean registration = new FilterRegistrationBean();
|
|
||||||
|
|
||||||
SentinelProperties.Filter filterConfig = properties.getFilter();
|
@Bean
|
||||||
|
public FilterRegistrationBean servletRequestListener() {
|
||||||
|
FilterRegistrationBean registration = new FilterRegistrationBean();
|
||||||
|
|
||||||
if (null == filterConfig) {
|
SentinelProperties.Filter filterConfig = properties.getFilter();
|
||||||
filterConfig = new SentinelProperties.Filter();
|
|
||||||
properties.setFilter(filterConfig);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (filterConfig.getUrlPatterns() == null
|
if (null == filterConfig) {
|
||||||
|| filterConfig.getUrlPatterns().isEmpty()) {
|
filterConfig = new SentinelProperties.Filter();
|
||||||
List<String> defaultPatterns = new ArrayList<>();
|
properties.setFilter(filterConfig);
|
||||||
defaultPatterns.add("/*");
|
}
|
||||||
filterConfig.setUrlPatterns(defaultPatterns);
|
|
||||||
}
|
|
||||||
|
|
||||||
registration.addUrlPatterns(filterConfig.getUrlPatterns().toArray(new String[0]));
|
if (filterConfig.getUrlPatterns() == null
|
||||||
Filter filter = new CommonFilter();
|
|| filterConfig.getUrlPatterns().isEmpty()) {
|
||||||
registration.setFilter(filter);
|
List<String> defaultPatterns = new ArrayList<>();
|
||||||
registration.setOrder(filterConfig.getOrder());
|
defaultPatterns.add("/*");
|
||||||
logger.info("[Sentinel Starter] register Sentinel with urlPatterns: {}.",
|
filterConfig.setUrlPatterns(defaultPatterns);
|
||||||
filterConfig.getUrlPatterns());
|
}
|
||||||
return registration;
|
|
||||||
|
registration.addUrlPatterns(filterConfig.getUrlPatterns().toArray(new String[0]));
|
||||||
|
Filter filter = new CommonFilter();
|
||||||
|
registration.setFilter(filter);
|
||||||
|
registration.setOrder(filterConfig.getOrder());
|
||||||
|
logger.info("[Sentinel Starter] register Sentinel with urlPatterns: {}.",
|
||||||
|
filterConfig.getUrlPatterns());
|
||||||
|
return registration;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
@ -16,19 +16,25 @@
|
|||||||
|
|
||||||
package org.springframework.cloud.alibaba.sentinel.annotation;
|
package org.springframework.cloud.alibaba.sentinel.annotation;
|
||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.Documented;
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
import com.alibaba.csp.sentinel.datasource.ReadableDataSource;
|
||||||
|
|
||||||
import org.springframework.core.annotation.AliasFor;
|
import org.springframework.core.annotation.AliasFor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An annotation to inject {@link com.alibaba.csp.sentinel.datasource.DataSource} instance
|
* An annotation to inject {@link ReadableDataSource} instance
|
||||||
* into a Spring Bean. The Properties of DataSource bean get from config files with
|
* into a Spring Bean. The Properties of DataSource bean get from config files with
|
||||||
* specific prefix.
|
* specific prefix.
|
||||||
*
|
*
|
||||||
* @author fangjian
|
* @author fangjian
|
||||||
* @see com.alibaba.csp.sentinel.datasource.DataSource
|
* @see ReadableDataSource
|
||||||
*/
|
*/
|
||||||
@Target({ ElementType.FIELD })
|
@Target({ElementType.FIELD})
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
@Documented
|
@Documented
|
||||||
public @interface SentinelDataSource {
|
public @interface SentinelDataSource {
|
||||||
|
@ -16,8 +16,18 @@
|
|||||||
|
|
||||||
package org.springframework.cloud.alibaba.sentinel.custom;
|
package org.springframework.cloud.alibaba.sentinel.custom;
|
||||||
|
|
||||||
|
import javax.annotation.PostConstruct;
|
||||||
|
|
||||||
|
import com.alibaba.csp.sentinel.adapter.servlet.callback.UrlBlockHandler;
|
||||||
|
import com.alibaba.csp.sentinel.adapter.servlet.callback.UrlCleaner;
|
||||||
|
import com.alibaba.csp.sentinel.adapter.servlet.callback.WebCallbackManager;
|
||||||
|
import com.alibaba.csp.sentinel.adapter.servlet.config.WebServletConfig;
|
||||||
|
import com.alibaba.csp.sentinel.annotation.aspectj.SentinelResourceAspect;
|
||||||
|
import com.alibaba.csp.sentinel.config.SentinelConfig;
|
||||||
|
import com.alibaba.csp.sentinel.init.InitExecutor;
|
||||||
import com.alibaba.csp.sentinel.transport.config.TransportConfig;
|
import com.alibaba.csp.sentinel.transport.config.TransportConfig;
|
||||||
import com.alibaba.csp.sentinel.util.AppNameUtil;
|
import com.alibaba.csp.sentinel.util.AppNameUtil;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Value;
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
@ -29,11 +39,6 @@ import org.springframework.cloud.alibaba.sentinel.datasource.SentinelDataSourceP
|
|||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
import org.springframework.web.client.RestTemplate;
|
|
||||||
|
|
||||||
import com.alibaba.csp.sentinel.annotation.aspectj.SentinelResourceAspect;
|
|
||||||
|
|
||||||
import javax.annotation.PostConstruct;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author xiaojing
|
* @author xiaojing
|
||||||
@ -49,16 +54,69 @@ public class SentinelAutoConfiguration {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private SentinelProperties properties;
|
private SentinelProperties properties;
|
||||||
|
|
||||||
|
@Autowired(required = false)
|
||||||
|
private UrlCleaner urlCleaner;
|
||||||
|
|
||||||
|
@Autowired(required = false)
|
||||||
|
private UrlBlockHandler urlBlockHandler;
|
||||||
|
|
||||||
@PostConstruct
|
@PostConstruct
|
||||||
private void init() {
|
private void init() {
|
||||||
if (StringUtils.isEmpty(System.getProperty(AppNameUtil.APP_NAME))) {
|
if (StringUtils.isEmpty(System.getProperty(AppNameUtil.APP_NAME))
|
||||||
|
&& StringUtils.hasText(projectName)) {
|
||||||
System.setProperty(AppNameUtil.APP_NAME, projectName);
|
System.setProperty(AppNameUtil.APP_NAME, projectName);
|
||||||
}
|
}
|
||||||
if (StringUtils.isEmpty(System.getProperty(TransportConfig.SERVER_PORT))) {
|
if (StringUtils.isEmpty(System.getProperty(TransportConfig.SERVER_PORT))
|
||||||
System.setProperty(TransportConfig.SERVER_PORT, properties.getPort());
|
&& StringUtils.hasText(properties.getTransport().getPort())) {
|
||||||
|
System.setProperty(TransportConfig.SERVER_PORT,
|
||||||
|
properties.getTransport().getPort());
|
||||||
}
|
}
|
||||||
if (StringUtils.isEmpty(System.getProperty(TransportConfig.CONSOLE_SERVER))) {
|
if (StringUtils.isEmpty(System.getProperty(TransportConfig.CONSOLE_SERVER))
|
||||||
System.setProperty(TransportConfig.CONSOLE_SERVER, properties.getDashboard());
|
&& StringUtils.hasText(properties.getTransport().getDashboard())) {
|
||||||
|
System.setProperty(TransportConfig.CONSOLE_SERVER,
|
||||||
|
properties.getTransport().getDashboard());
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(System.getProperty(TransportConfig.HEARTBEAT_INTERVAL_MS))
|
||||||
|
&& StringUtils
|
||||||
|
.hasText(properties.getTransport().getHeartbeatIntervalMs())) {
|
||||||
|
System.setProperty(TransportConfig.HEARTBEAT_INTERVAL_MS,
|
||||||
|
properties.getTransport().getHeartbeatIntervalMs());
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(System.getProperty(SentinelConfig.CHARSET))
|
||||||
|
&& StringUtils.hasText(properties.getCharset())) {
|
||||||
|
System.setProperty(SentinelConfig.CHARSET, properties.getCharset());
|
||||||
|
}
|
||||||
|
if (StringUtils
|
||||||
|
.isEmpty(System.getProperty(SentinelConfig.SINGLE_METRIC_FILE_SIZE))
|
||||||
|
&& StringUtils.hasText(properties.getMetric().getFileSingleSize())) {
|
||||||
|
System.setProperty(SentinelConfig.SINGLE_METRIC_FILE_SIZE,
|
||||||
|
properties.getMetric().getFileSingleSize());
|
||||||
|
}
|
||||||
|
if (StringUtils
|
||||||
|
.isEmpty(System.getProperty(SentinelConfig.TOTAL_METRIC_FILE_COUNT))
|
||||||
|
&& StringUtils.hasText(properties.getMetric().getFileTotalCount())) {
|
||||||
|
System.setProperty(SentinelConfig.TOTAL_METRIC_FILE_COUNT,
|
||||||
|
properties.getMetric().getFileTotalCount());
|
||||||
|
}
|
||||||
|
if (StringUtils.isEmpty(System.getProperty(SentinelConfig.COLD_FACTOR))
|
||||||
|
&& StringUtils.hasText(properties.getFlow().getColdFactor())) {
|
||||||
|
System.setProperty(SentinelConfig.COLD_FACTOR,
|
||||||
|
properties.getFlow().getColdFactor());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.hasText(properties.getServlet().getBlockPage())) {
|
||||||
|
WebServletConfig.setBlockPage(properties.getServlet().getBlockPage());
|
||||||
|
}
|
||||||
|
if (urlBlockHandler != null) {
|
||||||
|
WebCallbackManager.setUrlBlockHandler(urlBlockHandler);
|
||||||
|
}
|
||||||
|
if (urlCleaner != null) {
|
||||||
|
WebCallbackManager.setUrlCleaner(urlCleaner);
|
||||||
|
}
|
||||||
|
|
||||||
|
// earlier initialize
|
||||||
|
if (properties.isEager()) {
|
||||||
|
InitExecutor.doInit();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,118 +34,119 @@ import org.springframework.core.io.support.ResourcePatternResolver;
|
|||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
import org.springframework.util.ClassUtils;
|
import org.springframework.util.ClassUtils;
|
||||||
|
|
||||||
import com.alibaba.csp.sentinel.datasource.DataSource;
|
import com.alibaba.csp.sentinel.datasource.ReadableDataSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link DataSource} Loader
|
* {@link ReadableDataSource} Loader
|
||||||
*
|
*
|
||||||
* @author fangjian
|
* @author fangjian
|
||||||
*/
|
*/
|
||||||
public class DataSourceLoader {
|
public class DataSourceLoader {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory.getLogger(DataSourceLoader.class);
|
private static final Logger logger = LoggerFactory.getLogger(DataSourceLoader.class);
|
||||||
|
|
||||||
private final static String PROPERTIES_RESOURCE_LOCATION = "META-INF/sentinel-datasource.properties";
|
private final static String PROPERTIES_RESOURCE_LOCATION = "META-INF/sentinel-datasource.properties";
|
||||||
|
|
||||||
private final static String ALL_PROPERTIES_RESOURCES_LOCATION = CLASSPATH_ALL_URL_PREFIX
|
private final static String ALL_PROPERTIES_RESOURCES_LOCATION = CLASSPATH_ALL_URL_PREFIX
|
||||||
+ PROPERTIES_RESOURCE_LOCATION;
|
+ PROPERTIES_RESOURCE_LOCATION;
|
||||||
|
|
||||||
private final static ConcurrentMap<String, Class<? extends DataSource>> dataSourceClassesCache = new ConcurrentHashMap<String, Class<? extends DataSource>>(
|
private final static ConcurrentMap<String, Class<? extends ReadableDataSource>> dataSourceClassesCache = new ConcurrentHashMap<String, Class<? extends ReadableDataSource>>(
|
||||||
4);
|
4);
|
||||||
|
|
||||||
static void loadAllDataSourceClassesCache() {
|
static void loadAllDataSourceClassesCache() {
|
||||||
Map<String, Class<? extends DataSource>> dataSourceClassesMap = loadAllDataSourceClassesCache(
|
Map<String, Class<? extends ReadableDataSource>> dataSourceClassesMap = loadAllDataSourceClassesCache(
|
||||||
ALL_PROPERTIES_RESOURCES_LOCATION);
|
ALL_PROPERTIES_RESOURCES_LOCATION);
|
||||||
|
|
||||||
dataSourceClassesCache.putAll(dataSourceClassesMap);
|
dataSourceClassesCache.putAll(dataSourceClassesMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
static Map<String, Class<? extends DataSource>> loadAllDataSourceClassesCache(
|
static Map<String, Class<? extends ReadableDataSource>> loadAllDataSourceClassesCache(
|
||||||
String resourcesLocation) {
|
String resourcesLocation) {
|
||||||
|
|
||||||
Map<String, Class<? extends DataSource>> dataSourcesMap = new HashMap<String, Class<? extends DataSource>>(
|
Map<String, Class<? extends ReadableDataSource>> dataSourcesMap = new HashMap<String, Class<? extends ReadableDataSource>>(
|
||||||
4);
|
4);
|
||||||
|
|
||||||
ClassLoader classLoader = DataSourceLoader.class.getClassLoader();
|
ClassLoader classLoader = DataSourceLoader.class.getClassLoader();
|
||||||
|
|
||||||
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
ResourcePatternResolver resolver = new PathMatchingResourcePatternResolver();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Resource[] resources = resolver.getResources(resourcesLocation);
|
Resource[] resources = resolver.getResources(resourcesLocation);
|
||||||
|
|
||||||
for (Resource resource : resources) {
|
for (Resource resource : resources) {
|
||||||
if (resource.exists()) {
|
if (resource.exists()) {
|
||||||
Properties properties = PropertiesLoaderUtils
|
Properties properties = PropertiesLoaderUtils
|
||||||
.loadProperties(resource);
|
.loadProperties(resource);
|
||||||
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
|
for (Map.Entry<Object, Object> entry : properties.entrySet()) {
|
||||||
|
|
||||||
String type = (String) entry.getKey();
|
String type = (String) entry.getKey();
|
||||||
String className = (String) entry.getValue();
|
String className = (String) entry.getValue();
|
||||||
|
|
||||||
if (!ClassUtils.isPresent(className, classLoader)) {
|
if (!ClassUtils.isPresent(className, classLoader)) {
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug(
|
logger.debug(
|
||||||
"Sentinel DataSource implementation [ type : "
|
"Sentinel DataSource implementation [ type : "
|
||||||
+ type + ": , class : " + className
|
+ type + ": , class : " + className
|
||||||
+ " , url : " + resource.getURL()
|
+ " , url : " + resource.getURL()
|
||||||
+ "] was not present in current classpath , "
|
+ "] was not present in current classpath , "
|
||||||
+ "thus loading will be ignored , please add dependency if required !");
|
+ "thus loading will be ignored , please add dependency if required !");
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
Assert.isTrue(!dataSourcesMap.containsKey(type),
|
Assert.isTrue(!dataSourcesMap.containsKey(type),
|
||||||
"The duplicated type[" + type
|
"The duplicated type[" + type
|
||||||
+ "] of SentinelDataSource were found in "
|
+ "] of SentinelDataSource were found in "
|
||||||
+ "resource [" + resource.getURL() + "]");
|
+ "resource [" + resource.getURL() + "]");
|
||||||
|
|
||||||
Class<?> dataSourceClass = ClassUtils.resolveClassName(className,
|
Class<?> dataSourceClass = ClassUtils.resolveClassName(className,
|
||||||
classLoader);
|
classLoader);
|
||||||
Assert.isAssignable(DataSource.class, dataSourceClass);
|
Assert.isAssignable(ReadableDataSource.class, dataSourceClass);
|
||||||
|
|
||||||
dataSourcesMap.put(type,
|
dataSourcesMap.put(type,
|
||||||
(Class<? extends DataSource>) dataSourceClass);
|
(Class<? extends ReadableDataSource>) dataSourceClass);
|
||||||
|
|
||||||
if (logger.isDebugEnabled()) {
|
if (logger.isDebugEnabled()) {
|
||||||
logger.debug("Sentinel DataSource implementation [ type : "
|
logger.debug("Sentinel DataSource implementation [ type : "
|
||||||
+ type + ": , class : " + className
|
+ type + ": , class : " + className
|
||||||
+ "] was loaded.");
|
+ "] was loaded.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
catch (IOException e) {
|
||||||
if (logger.isErrorEnabled()) {
|
if (logger.isErrorEnabled()) {
|
||||||
logger.error(e.getMessage(), e);
|
logger.error(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return dataSourcesMap;
|
return dataSourcesMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Class<? extends DataSource> loadClass(String type)
|
public static Class<? extends ReadableDataSource> loadClass(String type)
|
||||||
throws IllegalArgumentException {
|
throws IllegalArgumentException {
|
||||||
|
|
||||||
Class<? extends DataSource> dataSourceClass = dataSourceClassesCache.get(type);
|
Class<? extends ReadableDataSource> dataSourceClass = dataSourceClassesCache
|
||||||
|
.get(type);
|
||||||
|
|
||||||
if (dataSourceClass == null) {
|
if (dataSourceClass == null) {
|
||||||
if (dataSourceClassesCache.isEmpty()) {
|
if (dataSourceClassesCache.isEmpty()) {
|
||||||
loadAllDataSourceClassesCache();
|
loadAllDataSourceClassesCache();
|
||||||
dataSourceClass = dataSourceClassesCache.get(type);
|
dataSourceClass = dataSourceClassesCache.get(type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (dataSourceClass == null) {
|
if (dataSourceClass == null) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
"Sentinel DataSource implementation [ type : " + type
|
"Sentinel DataSource implementation [ type : " + type
|
||||||
+ " ] can't be found!");
|
+ " ] can't be found!");
|
||||||
}
|
}
|
||||||
|
|
||||||
return dataSourceClass;
|
return dataSourceClass;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -44,174 +44,174 @@ import org.springframework.core.env.ConfigurableEnvironment;
|
|||||||
import org.springframework.util.ReflectionUtils;
|
import org.springframework.util.ReflectionUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import com.alibaba.csp.sentinel.datasource.ConfigParser;
|
import com.alibaba.csp.sentinel.datasource.Converter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* {@link SentinelDataSource @SentinelDataSource} Post Processor
|
* {@link SentinelDataSource @SentinelDataSource} Post Processor
|
||||||
*
|
*
|
||||||
* @author fangjian
|
* @author fangjian
|
||||||
* @see com.alibaba.csp.sentinel.datasource.DataSource
|
* @see com.alibaba.csp.sentinel.datasource.ReadableDataSource
|
||||||
* @see SentinelDataSource
|
* @see SentinelDataSource
|
||||||
*/
|
*/
|
||||||
public class SentinelDataSourcePostProcessor
|
public class SentinelDataSourcePostProcessor
|
||||||
extends InstantiationAwareBeanPostProcessorAdapter
|
extends InstantiationAwareBeanPostProcessorAdapter
|
||||||
implements MergedBeanDefinitionPostProcessor {
|
implements MergedBeanDefinitionPostProcessor {
|
||||||
|
|
||||||
private static final Logger logger = LoggerFactory
|
private static final Logger logger = LoggerFactory
|
||||||
.getLogger(SentinelDataSourcePostProcessor.class);
|
.getLogger(SentinelDataSourcePostProcessor.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationContext applicationContext;
|
private ApplicationContext applicationContext;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ConfigurableEnvironment environment;
|
private ConfigurableEnvironment environment;
|
||||||
|
|
||||||
private final Map<String, List<SentinelDataSourceField>> dataSourceFieldCache = new ConcurrentHashMap<>(
|
private final Map<String, List<SentinelDataSourceField>> dataSourceFieldCache = new ConcurrentHashMap<>(
|
||||||
64);
|
64);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition,
|
public void postProcessMergedBeanDefinition(RootBeanDefinition beanDefinition,
|
||||||
Class<?> beanType, final String beanName) {
|
Class<?> beanType, final String beanName) {
|
||||||
// find all fields using by @SentinelDataSource annotation
|
// find all fields using by @SentinelDataSource annotation
|
||||||
ReflectionUtils.doWithFields(beanType, new ReflectionUtils.FieldCallback() {
|
ReflectionUtils.doWithFields(beanType, new ReflectionUtils.FieldCallback() {
|
||||||
@Override
|
@Override
|
||||||
public void doWith(Field field)
|
public void doWith(Field field)
|
||||||
throws IllegalArgumentException, IllegalAccessException {
|
throws IllegalArgumentException, IllegalAccessException {
|
||||||
SentinelDataSource annotation = getAnnotation(field,
|
SentinelDataSource annotation = getAnnotation(field,
|
||||||
SentinelDataSource.class);
|
SentinelDataSource.class);
|
||||||
if (annotation != null) {
|
if (annotation != null) {
|
||||||
if (Modifier.isStatic(field.getModifiers())) {
|
if (Modifier.isStatic(field.getModifiers())) {
|
||||||
if (logger.isWarnEnabled()) {
|
if (logger.isWarnEnabled()) {
|
||||||
logger.warn(
|
logger.warn(
|
||||||
"@SentinelDataSource annotation is not supported on static fields: "
|
"@SentinelDataSource annotation is not supported on static fields: "
|
||||||
+ field);
|
+ field);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (dataSourceFieldCache.containsKey(beanName)) {
|
if (dataSourceFieldCache.containsKey(beanName)) {
|
||||||
dataSourceFieldCache.get(beanName)
|
dataSourceFieldCache.get(beanName)
|
||||||
.add(new SentinelDataSourceField(annotation, field));
|
.add(new SentinelDataSourceField(annotation, field));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
List<SentinelDataSourceField> list = new ArrayList<>();
|
List<SentinelDataSourceField> list = new ArrayList<>();
|
||||||
list.add(new SentinelDataSourceField(annotation, field));
|
list.add(new SentinelDataSourceField(annotation, field));
|
||||||
dataSourceFieldCache.put(beanName, list);
|
dataSourceFieldCache.put(beanName, list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PropertyValues postProcessPropertyValues(PropertyValues pvs,
|
public PropertyValues postProcessPropertyValues(PropertyValues pvs,
|
||||||
PropertyDescriptor[] pds, Object bean, String beanName)
|
PropertyDescriptor[] pds, Object bean, String beanName)
|
||||||
throws BeanCreationException {
|
throws BeanCreationException {
|
||||||
if (dataSourceFieldCache.containsKey(beanName)) {
|
if (dataSourceFieldCache.containsKey(beanName)) {
|
||||||
List<SentinelDataSourceField> sentinelDataSourceFields = dataSourceFieldCache
|
List<SentinelDataSourceField> sentinelDataSourceFields = dataSourceFieldCache
|
||||||
.get(beanName);
|
.get(beanName);
|
||||||
for(SentinelDataSourceField sentinelDataSourceField : sentinelDataSourceFields) {
|
for (SentinelDataSourceField sentinelDataSourceField : sentinelDataSourceFields) {
|
||||||
try {
|
try {
|
||||||
// construct DataSource field annotated by @SentinelDataSource
|
// construct DataSource field annotated by @SentinelDataSource
|
||||||
Field field = sentinelDataSourceField.getField();
|
Field field = sentinelDataSourceField.getField();
|
||||||
ReflectionUtils.makeAccessible(field);
|
ReflectionUtils.makeAccessible(field);
|
||||||
String dataSourceBeanName = constructDataSource(
|
String dataSourceBeanName = constructDataSource(
|
||||||
sentinelDataSourceField.getSentinelDataSource());
|
sentinelDataSourceField.getSentinelDataSource());
|
||||||
field.set(bean, applicationContext.getBean(dataSourceBeanName));
|
field.set(bean, applicationContext.getBean(dataSourceBeanName));
|
||||||
}
|
}
|
||||||
catch (IllegalAccessException e) {
|
catch (IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return pvs;
|
return pvs;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String constructDataSource(SentinelDataSource annotation) {
|
private String constructDataSource(SentinelDataSource annotation) {
|
||||||
String prefix = annotation.value();
|
String prefix = annotation.value();
|
||||||
if (StringUtils.isEmpty(prefix)) {
|
if (StringUtils.isEmpty(prefix)) {
|
||||||
prefix = SentinelConstants.PROPERTY_DATASOURCE_PREFIX;
|
prefix = SentinelConstants.PROPERTY_DATASOURCE_PREFIX;
|
||||||
}
|
}
|
||||||
Map<String, Object> propertyMap = PropertySourcesUtils
|
Map<String, Object> propertyMap = PropertySourcesUtils
|
||||||
.getSubProperties(environment.getPropertySources(), prefix);
|
.getSubProperties(environment.getPropertySources(), prefix);
|
||||||
String alias = propertyMap.get("type").toString();
|
String alias = propertyMap.get("type").toString();
|
||||||
Class dataSourceClass = DataSourceLoader.loadClass(alias);
|
Class dataSourceClass = DataSourceLoader.loadClass(alias);
|
||||||
|
|
||||||
String beanName = StringUtils.isEmpty(annotation.name())
|
String beanName = StringUtils.isEmpty(annotation.name())
|
||||||
? StringUtils.uncapitalize(dataSourceClass.getSimpleName()) + "_" + prefix
|
? StringUtils.uncapitalize(dataSourceClass.getSimpleName()) + "_" + prefix
|
||||||
: annotation.name();
|
: annotation.name();
|
||||||
if (applicationContext.containsBean(beanName)) {
|
if (applicationContext.containsBean(beanName)) {
|
||||||
return beanName;
|
return beanName;
|
||||||
}
|
}
|
||||||
|
|
||||||
Class targetClass = null;
|
Class targetClass = null;
|
||||||
// if alias exists in SentinelDataSourceRegistry, wired properties into
|
// if alias exists in SentinelDataSourceRegistry, wired properties into
|
||||||
// FactoryBean
|
// FactoryBean
|
||||||
if (SentinelDataSourceRegistry.checkFactoryBean(alias)) {
|
if (SentinelDataSourceRegistry.checkFactoryBean(alias)) {
|
||||||
targetClass = SentinelDataSourceRegistry.getFactoryBean(alias);
|
targetClass = SentinelDataSourceRegistry.getFactoryBean(alias);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// if alias not exists in SentinelDataSourceRegistry, wired properties into
|
// if alias not exists in SentinelDataSourceRegistry, wired properties into
|
||||||
// raw class
|
// raw class
|
||||||
targetClass = dataSourceClass;
|
targetClass = dataSourceClass;
|
||||||
}
|
}
|
||||||
|
|
||||||
registerDataSource(beanName, targetClass, propertyMap);
|
registerDataSource(beanName, targetClass, propertyMap);
|
||||||
|
|
||||||
return beanName;
|
return beanName;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerDataSource(String beanName, Class targetClass,
|
private void registerDataSource(String beanName, Class targetClass,
|
||||||
Map<String, Object> propertyMap) {
|
Map<String, Object> propertyMap) {
|
||||||
BeanDefinitionBuilder builder = BeanDefinitionBuilder
|
BeanDefinitionBuilder builder = BeanDefinitionBuilder
|
||||||
.genericBeanDefinition(targetClass);
|
.genericBeanDefinition(targetClass);
|
||||||
for (String propertyName : propertyMap.keySet()) {
|
for (String propertyName : propertyMap.keySet()) {
|
||||||
Field field = ReflectionUtils.findField(targetClass, propertyName);
|
Field field = ReflectionUtils.findField(targetClass, propertyName);
|
||||||
if (field != null) {
|
if (field != null) {
|
||||||
if (field.getType().isAssignableFrom(ConfigParser.class)) {
|
if (field.getType().isAssignableFrom(Converter.class)) {
|
||||||
// ConfigParser get from ApplicationContext
|
// Converter get from ApplicationContext
|
||||||
builder.addPropertyReference(propertyName,
|
builder.addPropertyReference(propertyName,
|
||||||
propertyMap.get(propertyName).toString());
|
propertyMap.get(propertyName).toString());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// wired properties
|
// wired properties
|
||||||
builder.addPropertyValue(propertyName, propertyMap.get(propertyName));
|
builder.addPropertyValue(propertyName, propertyMap.get(propertyName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) applicationContext
|
DefaultListableBeanFactory beanFactory = (DefaultListableBeanFactory) applicationContext
|
||||||
.getAutowireCapableBeanFactory();
|
.getAutowireCapableBeanFactory();
|
||||||
beanFactory.registerBeanDefinition(beanName, builder.getBeanDefinition());
|
beanFactory.registerBeanDefinition(beanName, builder.getBeanDefinition());
|
||||||
}
|
}
|
||||||
|
|
||||||
class SentinelDataSourceField {
|
class SentinelDataSourceField {
|
||||||
private SentinelDataSource sentinelDataSource;
|
private SentinelDataSource sentinelDataSource;
|
||||||
private Field field;
|
private Field field;
|
||||||
|
|
||||||
public SentinelDataSourceField(SentinelDataSource sentinelDataSource,
|
public SentinelDataSourceField(SentinelDataSource sentinelDataSource,
|
||||||
Field field) {
|
Field field) {
|
||||||
this.sentinelDataSource = sentinelDataSource;
|
this.sentinelDataSource = sentinelDataSource;
|
||||||
this.field = field;
|
this.field = field;
|
||||||
}
|
}
|
||||||
|
|
||||||
public SentinelDataSource getSentinelDataSource() {
|
public SentinelDataSource getSentinelDataSource() {
|
||||||
return sentinelDataSource;
|
return sentinelDataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSentinelDataSource(SentinelDataSource sentinelDataSource) {
|
public void setSentinelDataSource(SentinelDataSource sentinelDataSource) {
|
||||||
this.sentinelDataSource = sentinelDataSource;
|
this.sentinelDataSource = sentinelDataSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Field getField() {
|
public Field getField() {
|
||||||
return field;
|
return field;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setField(Field field) {
|
public void setField(Field field) {
|
||||||
this.field = field;
|
this.field = field;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,8 @@ package org.springframework.cloud.alibaba.sentinel.datasource;
|
|||||||
|
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
import com.alibaba.csp.sentinel.datasource.ReadableDataSource;
|
||||||
|
|
||||||
import org.springframework.beans.factory.FactoryBean;
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
import org.springframework.cloud.alibaba.sentinel.datasource.factorybean.ApolloDataSourceFactoryBean;
|
import org.springframework.cloud.alibaba.sentinel.datasource.factorybean.ApolloDataSourceFactoryBean;
|
||||||
import org.springframework.cloud.alibaba.sentinel.datasource.factorybean.FileRefreshableDataSourceFactoryBean;
|
import org.springframework.cloud.alibaba.sentinel.datasource.factorybean.FileRefreshableDataSourceFactoryBean;
|
||||||
@ -28,7 +30,7 @@ import org.springframework.cloud.alibaba.sentinel.datasource.factorybean.Zookeep
|
|||||||
* Registry to save DataSource FactoryBean
|
* Registry to save DataSource FactoryBean
|
||||||
*
|
*
|
||||||
* @author fangjian
|
* @author fangjian
|
||||||
* @see com.alibaba.csp.sentinel.datasource.DataSource
|
* @see ReadableDataSource
|
||||||
* @see FileRefreshableDataSourceFactoryBean
|
* @see FileRefreshableDataSourceFactoryBean
|
||||||
* @see ZookeeperDataSourceFactoryBean
|
* @see ZookeeperDataSourceFactoryBean
|
||||||
* @see NacosDataSourceFactoryBean
|
* @see NacosDataSourceFactoryBean
|
||||||
@ -37,17 +39,17 @@ import org.springframework.cloud.alibaba.sentinel.datasource.factorybean.Zookeep
|
|||||||
public class SentinelDataSourceRegistry {
|
public class SentinelDataSourceRegistry {
|
||||||
|
|
||||||
private static ConcurrentHashMap<String, Class<? extends FactoryBean>> cache = new ConcurrentHashMap<>(
|
private static ConcurrentHashMap<String, Class<? extends FactoryBean>> cache = new ConcurrentHashMap<>(
|
||||||
32);
|
32);
|
||||||
|
|
||||||
static {
|
static {
|
||||||
SentinelDataSourceRegistry.registerFactoryBean("file",
|
SentinelDataSourceRegistry.registerFactoryBean("file",
|
||||||
FileRefreshableDataSourceFactoryBean.class);
|
FileRefreshableDataSourceFactoryBean.class);
|
||||||
SentinelDataSourceRegistry.registerFactoryBean("zk",
|
SentinelDataSourceRegistry.registerFactoryBean("zk",
|
||||||
ZookeeperDataSourceFactoryBean.class);
|
ZookeeperDataSourceFactoryBean.class);
|
||||||
SentinelDataSourceRegistry.registerFactoryBean("nacos",
|
SentinelDataSourceRegistry.registerFactoryBean("nacos",
|
||||||
NacosDataSourceFactoryBean.class);
|
NacosDataSourceFactoryBean.class);
|
||||||
SentinelDataSourceRegistry.registerFactoryBean("apollo",
|
SentinelDataSourceRegistry.registerFactoryBean("apollo",
|
||||||
ApolloDataSourceFactoryBean.class);
|
ApolloDataSourceFactoryBean.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static synchronized void registerFactoryBean(String alias,
|
public static synchronized void registerFactoryBean(String alias,
|
||||||
|
@ -2,7 +2,7 @@ package org.springframework.cloud.alibaba.sentinel.datasource.factorybean;
|
|||||||
|
|
||||||
import org.springframework.beans.factory.FactoryBean;
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
|
|
||||||
import com.alibaba.csp.sentinel.datasource.ConfigParser;
|
import com.alibaba.csp.sentinel.datasource.Converter;
|
||||||
import com.alibaba.csp.sentinel.datasource.apollo.ApolloDataSource;
|
import com.alibaba.csp.sentinel.datasource.apollo.ApolloDataSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,12 +14,12 @@ public class ApolloDataSourceFactoryBean implements FactoryBean<ApolloDataSource
|
|||||||
private String namespaceName;
|
private String namespaceName;
|
||||||
private String flowRulesKey;
|
private String flowRulesKey;
|
||||||
private String defaultFlowRuleValue;
|
private String defaultFlowRuleValue;
|
||||||
private ConfigParser configParser;
|
private Converter converter;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ApolloDataSource getObject() throws Exception {
|
public ApolloDataSource getObject() throws Exception {
|
||||||
return new ApolloDataSource(namespaceName, flowRulesKey, defaultFlowRuleValue,
|
return new ApolloDataSource(namespaceName, flowRulesKey, defaultFlowRuleValue,
|
||||||
configParser);
|
converter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -56,11 +56,11 @@ public class ApolloDataSourceFactoryBean implements FactoryBean<ApolloDataSource
|
|||||||
this.defaultFlowRuleValue = defaultFlowRuleValue;
|
this.defaultFlowRuleValue = defaultFlowRuleValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigParser getConfigParser() {
|
public Converter getConverter() {
|
||||||
return configParser;
|
return converter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConfigParser(ConfigParser configParser) {
|
public void setConverter(Converter converter) {
|
||||||
this.configParser = configParser;
|
this.converter = converter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ import java.nio.charset.Charset;
|
|||||||
|
|
||||||
import org.springframework.beans.factory.FactoryBean;
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
|
|
||||||
import com.alibaba.csp.sentinel.datasource.ConfigParser;
|
import com.alibaba.csp.sentinel.datasource.Converter;
|
||||||
import com.alibaba.csp.sentinel.datasource.FileRefreshableDataSource;
|
import com.alibaba.csp.sentinel.datasource.FileRefreshableDataSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -18,11 +18,11 @@ public class FileRefreshableDataSourceFactoryBean implements FactoryBean<FileRef
|
|||||||
private String charset;
|
private String charset;
|
||||||
private long recommendRefreshMs;
|
private long recommendRefreshMs;
|
||||||
private int bufSize;
|
private int bufSize;
|
||||||
private ConfigParser configParser;
|
private Converter converter;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FileRefreshableDataSource getObject() throws Exception {
|
public FileRefreshableDataSource getObject() throws Exception {
|
||||||
return new FileRefreshableDataSource(new File(file), configParser,
|
return new FileRefreshableDataSource(new File(file), converter,
|
||||||
recommendRefreshMs, bufSize, Charset.forName(charset));
|
recommendRefreshMs, bufSize, Charset.forName(charset));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -68,11 +68,11 @@ public class FileRefreshableDataSourceFactoryBean implements FactoryBean<FileRef
|
|||||||
this.bufSize = bufSize;
|
this.bufSize = bufSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigParser getConfigParser() {
|
public Converter getConverter() {
|
||||||
return configParser;
|
return converter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConfigParser(ConfigParser configParser) {
|
public void setConverter(Converter converter) {
|
||||||
this.configParser = configParser;
|
this.converter = converter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package org.springframework.cloud.alibaba.sentinel.datasource.factorybean;
|
|||||||
|
|
||||||
import org.springframework.beans.factory.FactoryBean;
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
|
|
||||||
import com.alibaba.csp.sentinel.datasource.ConfigParser;
|
import com.alibaba.csp.sentinel.datasource.Converter;
|
||||||
import com.alibaba.csp.sentinel.datasource.nacos.NacosDataSource;
|
import com.alibaba.csp.sentinel.datasource.nacos.NacosDataSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,11 +14,11 @@ public class NacosDataSourceFactoryBean implements FactoryBean<NacosDataSource>
|
|||||||
private String serverAddr;
|
private String serverAddr;
|
||||||
private String groupId;
|
private String groupId;
|
||||||
private String dataId;
|
private String dataId;
|
||||||
private ConfigParser configParser;
|
private Converter converter;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NacosDataSource getObject() throws Exception {
|
public NacosDataSource getObject() throws Exception {
|
||||||
return new NacosDataSource(serverAddr, groupId, dataId, configParser);
|
return new NacosDataSource(serverAddr, groupId, dataId, converter);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -55,11 +55,11 @@ public class NacosDataSourceFactoryBean implements FactoryBean<NacosDataSource>
|
|||||||
this.dataId = dataId;
|
this.dataId = dataId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigParser getConfigParser() {
|
public Converter getConverter() {
|
||||||
return configParser;
|
return converter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConfigParser(ConfigParser configParser) {
|
public void setConverter(Converter converter) {
|
||||||
this.configParser = configParser;
|
this.converter = converter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package org.springframework.cloud.alibaba.sentinel.datasource.factorybean;
|
|||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.beans.factory.FactoryBean;
|
import org.springframework.beans.factory.FactoryBean;
|
||||||
|
|
||||||
import com.alibaba.csp.sentinel.datasource.ConfigParser;
|
import com.alibaba.csp.sentinel.datasource.Converter;
|
||||||
import com.alibaba.csp.sentinel.datasource.zookeeper.ZookeeperDataSource;
|
import com.alibaba.csp.sentinel.datasource.zookeeper.ZookeeperDataSource;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -12,74 +12,74 @@ import com.alibaba.csp.sentinel.datasource.zookeeper.ZookeeperDataSource;
|
|||||||
*/
|
*/
|
||||||
public class ZookeeperDataSourceFactoryBean implements FactoryBean<ZookeeperDataSource> {
|
public class ZookeeperDataSourceFactoryBean implements FactoryBean<ZookeeperDataSource> {
|
||||||
|
|
||||||
private String serverAddr;
|
private String serverAddr;
|
||||||
|
|
||||||
private String path;
|
private String path;
|
||||||
|
|
||||||
private String groupId;
|
private String groupId;
|
||||||
private String dataId;
|
private String dataId;
|
||||||
|
|
||||||
private ConfigParser configParser;
|
private Converter converter;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ZookeeperDataSource getObject() throws Exception {
|
public ZookeeperDataSource getObject() throws Exception {
|
||||||
if (StringUtils.isNotEmpty(groupId) && StringUtils.isNotEmpty(dataId)) {
|
if (StringUtils.isNotEmpty(groupId) && StringUtils.isNotEmpty(dataId)) {
|
||||||
// the path will be /{groupId}/{dataId}
|
// the path will be /{groupId}/{dataId}
|
||||||
return new ZookeeperDataSource(serverAddr, groupId, dataId, configParser);
|
return new ZookeeperDataSource(serverAddr, groupId, dataId, converter);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// using path directly
|
// using path directly
|
||||||
return new ZookeeperDataSource(serverAddr, path, configParser);
|
return new ZookeeperDataSource(serverAddr, path, converter);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Class<?> getObjectType() {
|
public Class<?> getObjectType() {
|
||||||
return ZookeeperDataSource.class;
|
return ZookeeperDataSource.class;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isSingleton() {
|
public boolean isSingleton() {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getServerAddr() {
|
public String getServerAddr() {
|
||||||
return serverAddr;
|
return serverAddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setServerAddr(String serverAddr) {
|
public void setServerAddr(String serverAddr) {
|
||||||
this.serverAddr = serverAddr;
|
this.serverAddr = serverAddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPath() {
|
public String getPath() {
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPath(String path) {
|
public void setPath(String path) {
|
||||||
this.path = path;
|
this.path = path;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getGroupId() {
|
public String getGroupId() {
|
||||||
return groupId;
|
return groupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGroupId(String groupId) {
|
public void setGroupId(String groupId) {
|
||||||
this.groupId = groupId;
|
this.groupId = groupId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getDataId() {
|
public String getDataId() {
|
||||||
return dataId;
|
return dataId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDataId(String dataId) {
|
public void setDataId(String dataId) {
|
||||||
this.dataId = dataId;
|
this.dataId = dataId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConfigParser getConfigParser() {
|
public Converter getConverter() {
|
||||||
return configParser;
|
return converter;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConfigParser(ConfigParser configParser) {
|
public void setConverter(Converter converter) {
|
||||||
this.configParser = configParser;
|
this.converter = converter;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,26 +7,59 @@
|
|||||||
"description": "enable or disable sentinel auto configure."
|
"description": "enable or disable sentinel auto configure."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "spring.cloud.sentinel.port",
|
"name": "spring.cloud.sentinel.eager",
|
||||||
|
"type": "java.lang.Boolean",
|
||||||
|
"defaultValue": false,
|
||||||
|
"description": "earlier initialize heart-beat when the spring container starts when the transport dependency is on classpath, the configuration is effective."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "spring.cloud.sentinel.charset",
|
||||||
|
"type": "java.lang.String",
|
||||||
|
"defaultValue": "UTF-8",
|
||||||
|
"description": "charset when sentinel write or search metric file."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "spring.cloud.sentinel.transport.port",
|
||||||
"type": "java.lang.String",
|
"type": "java.lang.String",
|
||||||
"defaultValue": "8721",
|
"defaultValue": "8721",
|
||||||
"description": "sentinel api port."
|
"description": "sentinel api port."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "spring.cloud.sentinel.dashboard",
|
"name": "spring.cloud.sentinel.transport.dashboard",
|
||||||
"type": "java.lang.String",
|
"type": "java.lang.String",
|
||||||
"description": "sentinel dashboard address, won't try to connect dashboard when address is empty."
|
"description": "sentinel dashboard address, won't try to connect dashboard when address is empty."
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"name": "spring.cloud.sentinel.transport.heartbeatIntervalMs",
|
||||||
|
"type": "java.lang.String",
|
||||||
|
"description": "send heartbeat interval millisecond."
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "spring.cloud.sentinel.filter.order",
|
"name": "spring.cloud.sentinel.filter.order",
|
||||||
"type": "java.lang.Integer",
|
"type": "java.lang.Integer",
|
||||||
"defaultValue": "Integer.MIN_VALUE",
|
"defaultValue": "Integer.MIN_VALUE",
|
||||||
"description": "Sentinel filter chain order, will be set to FilterRegistrationBean."
|
"description": "sentinel filter chain order, will be set to FilterRegistrationBean."
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "spring.cloud.sentinel.filter.urlPatterns",
|
"name": "spring.cloud.sentinel.metric.fileSingleSize",
|
||||||
"type": "java.util.List",
|
"type": "java.lang.String",
|
||||||
"description": "URL pattern for Sentinel filter, default contains '/*'."
|
"description": "the metric file size."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "spring.cloud.sentinel.metric.fileTotalCount",
|
||||||
|
"type": "java.lang.String",
|
||||||
|
"description": "the total metric file count."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "spring.cloud.sentinel.servlet.blockPage",
|
||||||
|
"type": "java.lang.String",
|
||||||
|
"description": "the process page when the flow control is triggered."
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "spring.cloud.sentinel.flow.coldFactor",
|
||||||
|
"type": "java.lang.String",
|
||||||
|
"defaultValue": "3",
|
||||||
|
"description": "sentinel the cold factor."
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
package org.springframework.cloud.alibaba.sentinel;
|
package org.springframework.cloud.alibaba.sentinel;
|
||||||
|
|
||||||
import com.alibaba.csp.sentinel.slots.block.BlockException;
|
import com.alibaba.csp.sentinel.slots.block.BlockException;
|
||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
@ -33,7 +34,6 @@ import org.springframework.web.context.support.AnnotationConfigWebApplicationCon
|
|||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author fangjian
|
* @author fangjian
|
||||||
*/
|
*/
|
||||||
@ -43,9 +43,10 @@ public class SentinelAutoConfigurationTests {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void init() {
|
public void init() {
|
||||||
context.register(SentinelAutoConfiguration.class, SentinelWebAutoConfiguration.class, SentinelTestConfiguration.class);
|
context.register(SentinelAutoConfiguration.class, SentinelWebAutoConfiguration.class,
|
||||||
|
SentinelTestConfiguration.class);
|
||||||
EnvironmentTestUtils.addEnvironment(this.context,
|
EnvironmentTestUtils.addEnvironment(this.context,
|
||||||
"spring.cloud.sentinel.port=8888",
|
"spring.cloud.sentinel.transport.port=8888",
|
||||||
"spring.cloud.sentinel.filter.order=123",
|
"spring.cloud.sentinel.filter.order=123",
|
||||||
"spring.cloud.sentinel.filter.urlPatterns=/*,/test");
|
"spring.cloud.sentinel.filter.urlPatterns=/*,/test");
|
||||||
this.context.refresh();
|
this.context.refresh();
|
||||||
@ -65,14 +66,14 @@ public class SentinelAutoConfigurationTests {
|
|||||||
@Test
|
@Test
|
||||||
public void testBeanPostProcessor() {
|
public void testBeanPostProcessor() {
|
||||||
assertThat(context.getBean("sentinelBeanPostProcessor")
|
assertThat(context.getBean("sentinelBeanPostProcessor")
|
||||||
.getClass() == SentinelBeanPostProcessor.class).isTrue();
|
.getClass() == SentinelBeanPostProcessor.class).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testProperties() {
|
public void testProperties() {
|
||||||
SentinelProperties sentinelProperties = context.getBean(SentinelProperties.class);
|
SentinelProperties sentinelProperties = context.getBean(SentinelProperties.class);
|
||||||
assertThat(sentinelProperties).isNotNull();
|
assertThat(sentinelProperties).isNotNull();
|
||||||
assertThat(sentinelProperties.getPort()).isEqualTo("8888");
|
assertThat(sentinelProperties.getTransport().getPort()).isEqualTo("8888");
|
||||||
assertThat(sentinelProperties.getFilter().getUrlPatterns().size()).isEqualTo(2);
|
assertThat(sentinelProperties.getFilter().getUrlPatterns().size()).isEqualTo(2);
|
||||||
assertThat(sentinelProperties.getFilter().getUrlPatterns().get(0)).isEqualTo("/*");
|
assertThat(sentinelProperties.getFilter().getUrlPatterns().get(0)).isEqualTo("/*");
|
||||||
assertThat(sentinelProperties.getFilter().getUrlPatterns().get(1)).isEqualTo("/test");
|
assertThat(sentinelProperties.getFilter().getUrlPatterns().get(1)).isEqualTo("/test");
|
||||||
@ -82,10 +83,10 @@ public class SentinelAutoConfigurationTests {
|
|||||||
public void testRestTemplate() {
|
public void testRestTemplate() {
|
||||||
assertThat(context.getBeansOfType(RestTemplate.class).size()).isEqualTo(2);
|
assertThat(context.getBeansOfType(RestTemplate.class).size()).isEqualTo(2);
|
||||||
RestTemplate restTemplate = context.getBean("restTemplateWithBlockClass",
|
RestTemplate restTemplate = context.getBean("restTemplateWithBlockClass",
|
||||||
RestTemplate.class);
|
RestTemplate.class);
|
||||||
assertThat(restTemplate.getInterceptors().size()).isEqualTo(1);
|
assertThat(restTemplate.getInterceptors().size()).isEqualTo(1);
|
||||||
assertThat(restTemplate.getInterceptors().get(0).getClass())
|
assertThat(restTemplate.getInterceptors().get(0).getClass())
|
||||||
.isEqualTo(SentinelProtectInterceptor.class);
|
.isEqualTo(SentinelProtectInterceptor.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Configuration
|
@Configuration
|
||||||
@ -111,5 +112,4 @@ public class SentinelAutoConfigurationTests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +0,0 @@
|
|||||||
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
|
||||||
org.springframework.cloud.alibaba.storage.OSSAutoConfiguration,\
|
|
||||||
org.springframework.cloud.alibaba.storage.endpoint.OSSEndpointAutoConfiguration
|
|
||||||
org.springframework.context.ApplicationListener=\
|
|
||||||
org.springframework.cloud.alibaba.storage.OSSApplicationListener
|
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba-test</artifactId>
|
<artifactId>spring-cloud-alibaba-test</artifactId>
|
||||||
<version>0.1.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba</artifactId>
|
<artifactId>spring-cloud-alibaba</artifactId>
|
||||||
<version>0.1.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba-test</artifactId>
|
<artifactId>spring-cloud-alibaba-test</artifactId>
|
||||||
<version>0.1.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
@ -5,13 +5,13 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba</artifactId>
|
<artifactId>spring-cloud-alibaba</artifactId>
|
||||||
<version>0.1.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba-storage</artifactId>
|
<artifactId>spring-cloud-alicloud-oss</artifactId>
|
||||||
<name>Spring Cloud Alibaba Storage Autoconfigure</name>
|
<name>Spring Cloud Alibaba Cloud OSS Autoconfigure</name>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.cloud.alibaba.storage;
|
package org.springframework.cloud.alibaba.oss;
|
||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.cloud.alibaba.storage;
|
package org.springframework.cloud.alibaba.oss;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
@ -22,7 +22,7 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
|||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.cloud.alibaba.storage.resource.OSSStorageProtocolResolver;
|
import org.springframework.cloud.alibaba.oss.resource.OSSStorageProtocolResolver;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.cloud.alibaba.storage;
|
package org.springframework.cloud.alibaba.oss;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* OSS constants
|
* OSS constants
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.cloud.alibaba.storage;
|
package org.springframework.cloud.alibaba.oss;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.cloud.alibaba.storage.endpoint;
|
package org.springframework.cloud.alibaba.oss.endpoint;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
@ -14,14 +14,14 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.cloud.alibaba.storage.endpoint;
|
package org.springframework.cloud.alibaba.oss.endpoint;
|
||||||
|
|
||||||
import org.springframework.boot.actuate.condition.ConditionalOnEnabledEndpoint;
|
import org.springframework.boot.actuate.condition.ConditionalOnEnabledEndpoint;
|
||||||
import org.springframework.boot.actuate.endpoint.Endpoint;
|
import org.springframework.boot.actuate.endpoint.Endpoint;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
|
||||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||||
import org.springframework.cloud.alibaba.storage.OSSProperties;
|
import org.springframework.cloud.alibaba.oss.OSSProperties;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.cloud.alibaba.storage.resource;
|
package org.springframework.cloud.alibaba.oss.resource;
|
||||||
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.cloud.alibaba.storage.resource;
|
package org.springframework.cloud.alibaba.oss.resource;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
@ -0,0 +1,5 @@
|
|||||||
|
org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
|
||||||
|
org.springframework.cloud.alibaba.oss.OSSAutoConfiguration,\
|
||||||
|
org.springframework.cloud.alibaba.oss.endpoint.OSSEndpointAutoConfiguration
|
||||||
|
org.springframework.context.ApplicationListener=\
|
||||||
|
org.springframework.cloud.alibaba.oss.OSSApplicationListener
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.cloud.alibaba.storage;
|
package org.springframework.cloud.alibaba.oss;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.springframework.cloud.alibaba.storage;
|
package org.springframework.cloud.alibaba.oss;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
|
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba</artifactId>
|
<artifactId>spring-cloud-alibaba</artifactId>
|
||||||
<version>0.1.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
|
|
||||||
@ -17,21 +17,6 @@
|
|||||||
<module>spring-cloud-starter-alibaba-nacos-config</module>
|
<module>spring-cloud-starter-alibaba-nacos-config</module>
|
||||||
<module>spring-cloud-starter-alibaba-nacos-discovery</module>
|
<module>spring-cloud-starter-alibaba-nacos-discovery</module>
|
||||||
<module>spring-cloud-starter-alibaba-sentinel</module>
|
<module>spring-cloud-starter-alibaba-sentinel</module>
|
||||||
<module>spring-cloud-starter-alibaba-storage</module>
|
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-deploy-plugin</artifactId>
|
|
||||||
<version>${maven-deploy-plugin.version}</version>
|
|
||||||
<configuration>
|
|
||||||
<skip>true</skip>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-alibaba</artifactId>
|
<artifactId>spring-cloud-starter-alibaba</artifactId>
|
||||||
<version>0.1.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
<artifactId>spring-cloud-starter-alibaba-nacos-config</artifactId>
|
||||||
<name>Spring Cloud Starter Alibaba Nacos Config</name>
|
<name>Spring Cloud Starter Alibaba Nacos Config</name>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-alibaba</artifactId>
|
<artifactId>spring-cloud-starter-alibaba</artifactId>
|
||||||
<version>0.1.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
<artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId>
|
||||||
<name>Spring Cloud Starter Alibaba Nacos Discovery</name>
|
<name>Spring Cloud Starter Alibaba Nacos Discovery</name>
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-alibaba</artifactId>
|
<artifactId>spring-cloud-starter-alibaba</artifactId>
|
||||||
<version>0.1.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
<artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
|
||||||
<name>Spring Cloud Starter Alibaba Sentinel</name>
|
<name>Spring Cloud Starter Alibaba Sentinel</name>
|
||||||
|
20
spring-cloud-starter-alicloud/pom.xml
Normal file
20
spring-cloud-starter-alicloud/pom.xml
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
<?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">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<parent>
|
||||||
|
<groupId>org.springframework.cloud</groupId>
|
||||||
|
<artifactId>spring-cloud-alibaba</artifactId>
|
||||||
|
<version>0.1.0</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<artifactId>spring-cloud-starter-alicloud</artifactId>
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
<name>Spring Cloud Alibaba Cloud Starters</name>
|
||||||
|
<description>Spring Cloud Alibaba Cloud Starters</description>
|
||||||
|
<modules>
|
||||||
|
<module>spring-cloud-starter-alicloud-oss</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
|
||||||
|
</project>
|
@ -4,16 +4,16 @@
|
|||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-starter-alibaba</artifactId>
|
<artifactId>spring-cloud-starter-alicloud</artifactId>
|
||||||
<version>0.1.0.BUILD-SNAPSHOT</version>
|
<version>0.1.0</version>
|
||||||
</parent>
|
</parent>
|
||||||
<artifactId>spring-cloud-starter-alibaba-storage</artifactId>
|
<artifactId>spring-cloud-starter-alicloud-oss</artifactId>
|
||||||
<name>Spring Cloud Starter Alibaba Storage</name>
|
<name>Spring Cloud Starter Alibaba Cloud OSS</name>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.springframework.cloud</groupId>
|
<groupId>org.springframework.cloud</groupId>
|
||||||
<artifactId>spring-cloud-alibaba-storage</artifactId>
|
<artifactId>spring-cloud-alicloud-oss</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.aliyun.oss</groupId>
|
<groupId>com.aliyun.oss</groupId>
|
Loading…
x
Reference in New Issue
Block a user