Update documents
- Update document for Dubbo demo - Update document for extensions Signed-off-by: Eric Zhao <sczyh16@gmail.com>
This commit is contained in:
parent
35c5bad3e4
commit
0438d530d4
|
|
@ -1,3 +1,5 @@
|
||||||
|
<img src="https://user-images.githubusercontent.com/9434884/43697219-3cb4ef3a-9975-11e8-9a9c-73f4f537442d.png" alt="Sentinel Logo" height="50%" width="50%">
|
||||||
|
|
||||||
# Sentinel: Sentinel of Your Application
|
# Sentinel: Sentinel of Your Application
|
||||||
|
|
||||||
[](https://travis-ci.org/alibaba/Sentinel)
|
[](https://travis-ci.org/alibaba/Sentinel)
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ Sentinel 提供了与 Dubbo 整合的模块 - Sentinel Dubbo Adapter,主要包
|
||||||
```
|
```
|
||||||
|
|
||||||
引入此依赖后,Dubbo 的服务接口和方法(包括调用端和服务端)就会成为 Sentinel 中的资源,在配置了规则后就可以自动享受到 Sentinel 的防护能力。
|
引入此依赖后,Dubbo 的服务接口和方法(包括调用端和服务端)就会成为 Sentinel 中的资源,在配置了规则后就可以自动享受到 Sentinel 的防护能力。
|
||||||
|
|
||||||
若不希望开启 Sentinel Dubbo Adapter 中的某个 Filter,可以手动关闭对应的 Filter,比如:
|
若不希望开启 Sentinel Dubbo Adapter 中的某个 Filter,可以手动关闭对应的 Filter,比如:
|
||||||
|
|
||||||
```java
|
```java
|
||||||
|
|
@ -63,13 +64,30 @@ Demo 2 演示了此限流场景,我们看一下这种模式的效果。假设
|
||||||
|
|
||||||
## Sentinel Dashboard
|
## Sentinel Dashboard
|
||||||
|
|
||||||
Sentinel 还提供 API 用于获取实时的监控信息,对应文档见[此处](https://github.com/alibaba/Sentinel/wiki/%E5%AE%9E%E6%97%B6%E7%9B%91%E6%8E%A7)。为了便于使用,Sentinel 还提供了一个控制台(Dashboard)用于配置规则、查看监控、机器发现等功能。我们只需要按照 [Sentinel 控制台文档](https://github.com/alibaba/Sentinel/wiki/%E6%8E%A7%E5%88%B6%E5%8F%B0) 启动控制台,然后给对应的应用程序添加相应参数并启动即可。比如本文中 Service Provider 示例的启动参数:
|
Sentinel 还提供 API 用于获取实时的监控信息,对应文档见[此处](https://github.com/alibaba/Sentinel/wiki/%E5%AE%9E%E6%97%B6%E7%9B%91%E6%8E%A7)。为了便于使用,Sentinel 还提供了一个控制台(Dashboard)用于配置规则、查看监控、机器发现等功能。
|
||||||
|
|
||||||
|
接入 Dashboard 的步骤(**缺一不可**):
|
||||||
|
|
||||||
|
1. 按照 [Sentinel 控制台文档](https://github.com/alibaba/Sentinel/wiki/%E6%8E%A7%E5%88%B6%E5%8F%B0) 启动控制台
|
||||||
|
2. 应用引入 `sentinel-transport-simple-http` 依赖,以便控制台可以拉取对应应用的相关信息
|
||||||
|
3. 给应用添加相关的启动参数,启动应用。需要配置的参数有:
|
||||||
|
- `-Dcsp.sentinel.api.port`:客户端的 port,用于上报相关信息
|
||||||
|
- `-Dcsp.sentinel.dashboard.server`:控制台的地址
|
||||||
|
- `-Dproject.name`:应用名称,会在控制台中显示
|
||||||
|
|
||||||
|
注意某些环境下本地运行 Dubbo 服务还需要加上 `-Djava.net.preferIPv4Stack=true` 参数。比如 Service Provider 示例的启动参数:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
-Djava.net.preferIPv4Stack=true -Dcsp.sentinel.api.port=8720 -Dcsp.sentinel.dashboard.server=localhost:8080 -Dproject.name=dubbo-provider-demo
|
-Djava.net.preferIPv4Stack=true -Dcsp.sentinel.api.port=8720 -Dcsp.sentinel.dashboard.server=localhost:8080 -Dproject.name=dubbo-provider-demo
|
||||||
```
|
```
|
||||||
|
|
||||||
这样在启动 Service Provider 示例以后,就可以在 Sentinel 控制台中找到我们的服务了。可以很方便地在控制台中配置限流规则:
|
Service Consumer 示例的启动参数:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
-Djava.net.preferIPv4Stack=true -Dcsp.sentinel.api.port=8721 -Dcsp.sentinel.dashboard.server=localhost:8080 -Dproject.name=dubbo-consumer-demo
|
||||||
|
```
|
||||||
|
|
||||||
|
这样在启动 Service Provider 和 Service Consumer 示例以后,就可以在 Sentinel 控制台中找到我们的服务了。可以很方便地在控制台中配置限流规则:
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,6 @@
|
||||||
# Sentinel Extension
|
# Sentinel Extension
|
||||||
|
|
||||||
This is the parent of all extension points to Sentinel.
|
Sentinel extension modules provide additional extension points
|
||||||
|
and functions.
|
||||||
Examples of what makes sense as a extension submodule are:
|
|
||||||
|
|
||||||
* alternate implementations rules config
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
# Sentinel DataSource Nacos
|
||||||
|
|
||||||
|
Sentinel DataSource Nacos provides integration with [Nacos](http://nacos.io) so that Nacos
|
||||||
|
can be the dynamic rule data source of Sentinel.
|
||||||
|
|
||||||
|
To use Sentinel DataSource Nacos, you should add the following dependency:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.csp</groupId>
|
||||||
|
<artifactId>sentinel-datasource-nacos</artifactId>
|
||||||
|
<version>x.y.z</version>
|
||||||
|
</dependency>
|
||||||
|
```
|
||||||
|
|
||||||
|
Then you can create an `NacosDataSource` and register to rule managers.
|
||||||
|
For instance:
|
||||||
|
|
||||||
|
```java
|
||||||
|
// remoteAddress is the address of Nacos
|
||||||
|
// groupId and dataId are concepts of Nacos
|
||||||
|
DataSource<String, List<FlowRule>> flowRuleDataSource = new NacosDataSource<>(remoteAddress, groupId, dataId,
|
||||||
|
source -> JSON.parseObject(source, new TypeReference<List<FlowRule>>() {}));
|
||||||
|
FlowRuleManager.register2Property(flowRuleDataSource.getProperty());
|
||||||
|
```
|
||||||
|
|
||||||
|
We've also provided an example: [sentinel-demo-nacos-datasource](https://github.com/alibaba/Sentinel/tree/master/sentinel-demo/sentinel-demo-nacos-datasource).
|
||||||
|
|
@ -0,0 +1,27 @@
|
||||||
|
# Sentinel DataSource ZooKeeper
|
||||||
|
|
||||||
|
Sentinel DataSource ZooKeeper provides integration with ZooKeeper so that ZooKeeper
|
||||||
|
can be the dynamic rule data source of Sentinel. The data source uses push model (listener).
|
||||||
|
|
||||||
|
To use Sentinel DataSource ZooKeeper, you should add the following dependency:
|
||||||
|
|
||||||
|
```xml
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.alibaba.csp</groupId>
|
||||||
|
<artifactId>sentinel-datasource-zookeeper</artifactId>
|
||||||
|
<version>x.y.z</version>
|
||||||
|
</dependency>
|
||||||
|
```
|
||||||
|
|
||||||
|
Then you can create an `ZookeeperDataSource` and register to rule managers.
|
||||||
|
For instance:
|
||||||
|
|
||||||
|
```java
|
||||||
|
// `path` is the data path in ZooKeeper
|
||||||
|
DataSource<String, List<FlowRule>> flowRuleDataSource = new ZookeeperDataSource<>(remoteAddress, path, source -> JSON.parseObject(source, new TypeReference<List<FlowRule>>() {}));
|
||||||
|
FlowRuleManager.register2Property(flowRuleDataSource.getProperty());
|
||||||
|
```
|
||||||
|
|
||||||
|
> Note: It's not recommended to add a large amount of rules to a single path (has limitation, also leads to bad performance).
|
||||||
|
|
||||||
|
We've also provided an example: [sentinel-demo-zookeeper-datasource](https://github.com/alibaba/Sentinel/tree/master/sentinel-demo/sentinel-demo-zookeeper-datasource).
|
||||||
Loading…
Reference in New Issue