mirror of
https://github.com/doocs/advanced-java.git
synced 2024-12-24 03:50:08 +08:00
docs: update articles
This commit is contained in:
parent
0a52be9d0d
commit
5bf02395e7
@ -272,7 +272,7 @@ public class ZooKeeperDistributedLock implements Watcher {
|
||||
// 如果不是最小的节点,找到比自己小1的节点
|
||||
int previousLockIndex = -1;
|
||||
for (int i = 0; i < locks.size(); i++) {
|
||||
if (lockNode.equals(locksRoot + “ /”+locks.get(i))){
|
||||
if (lockNode.equals(locksRoot + "/" +locks.get(i))){
|
||||
previousLockIndex = i - 1;
|
||||
break;
|
||||
}
|
||||
|
@ -32,7 +32,6 @@ Hystrix 出现以下四种情况,都会去调用 fallback 降级机制:
|
||||
* 品牌名称本地缓存
|
||||
*
|
||||
*/
|
||||
|
||||
public class BrandCache {
|
||||
|
||||
private static Map<Long, String> brandMap = new HashMap<>();
|
||||
|
@ -46,6 +46,6 @@ Hystrix 可以对其进行资源隔离,比如限制服务 B 只有 40 个线
|
||||
- 避免请求排队和积压,采用限流和 `fail fast` 来控制故障。
|
||||
- 提供 fallback 降级机制来应对故障。
|
||||
- 使用资源隔离技术,比如 `bulkhead`(舱壁隔离技术)、`swimlane`(泳道技术)、`circuit breaker`(断路技术)来限制任何一个依赖服务的故障的影响。
|
||||
- 通过近实时的统计/监控/报警功能,来提高故障发现的速度。
|
||||
- 通过近实时的统计、监控、报警功能,来提高故障发现的速度。
|
||||
- 通过近实时的属性和配置**热修改**功能,来提高故障处理和恢复的速度。
|
||||
- 保护依赖服务调用的所有故障情况,而不仅仅只是网络故障情况。
|
||||
|
@ -165,5 +165,5 @@ ProductInfo(id=null, name=降级商品, price=null, pictureList=null, specificat
|
||||
ProductInfo(id=null, name=降级商品, price=null, pictureList=null, specification=null, service=null, color=null, size=null, shopId=null, modifiedTime=null, cityId=null, cityName=null, brandId=null, brandName=null)
|
||||
{"id": -2, "name": "iphone7手机", "price": 5599, "pictureList":"a.jpg,b.jpg", "specification": "iphone7的规格", "service": "iphone7的售后服务", "color": "红色,白色,黑色", "size": "5.5", "shopId": 1, "modifiedTime": "2017-01-01 12:00:00", "cityId": 1, "brandId": 1}
|
||||
// 后面都是一些正常的商品信息,就不贴出来了
|
||||
//...
|
||||
// ...
|
||||
```
|
||||
|
@ -288,25 +288,25 @@ public class TokenBucket {
|
||||
|
||||
```yaml
|
||||
spring:
|
||||
cloud:
|
||||
gateway:
|
||||
routes:
|
||||
- id: requestratelimiter_route
|
||||
cloud:
|
||||
gateway:
|
||||
routes:
|
||||
- id: requestratelimiter_route
|
||||
|
||||
uri: lb://pigx-upms
|
||||
order: 10000
|
||||
predicates:
|
||||
- Path=/admin/**
|
||||
|
||||
filters:
|
||||
- name: RequestRateLimiter
|
||||
|
||||
args:
|
||||
redis-rate-limiter.replenishRate: 1 # 令牌桶的容积
|
||||
redis-rate-limiter.burstCapacity: 3 # 流速 每秒
|
||||
key-resolver: '#{@remoteAddrKeyResolver}' #SPEL表达式去的对应的bean
|
||||
|
||||
uri: lb://pigx-upms
|
||||
order: 10000
|
||||
predicates:
|
||||
- Path=/admin/**
|
||||
|
||||
filters:
|
||||
- name: RequestRateLimiter
|
||||
|
||||
args:
|
||||
redis-rate-limiter.replenishRate: 1 # 令牌桶的容积
|
||||
redis-rate-limiter.burstCapacity: 3 # 流速 每秒
|
||||
key-resolver: '#{@remoteAddrKeyResolver}' #SPEL表达式去的对应的bean
|
||||
|
||||
- StripPrefix=1
|
||||
- StripPrefix=1
|
||||
```
|
||||
|
||||
```java
|
||||
@ -329,22 +329,22 @@ KeyResolver remoteAddrKeyResolver() {
|
||||
|
||||
```yaml
|
||||
spring:
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: localhost:8848
|
||||
sentinel:
|
||||
transport:
|
||||
dashboard: localhost:8080
|
||||
port: 8720
|
||||
datasource:
|
||||
ds:
|
||||
nacos:
|
||||
server-addr: localhost:8848
|
||||
dataId: spring-cloud-sentinel-nacos
|
||||
groupId: DEFAULT_GROUP
|
||||
rule-type: flow
|
||||
namespace: xxxxxxxx
|
||||
cloud:
|
||||
nacos:
|
||||
discovery:
|
||||
server-addr: localhost:8848
|
||||
sentinel:
|
||||
transport:
|
||||
dashboard: localhost:8080
|
||||
port: 8720
|
||||
datasource:
|
||||
ds:
|
||||
nacos:
|
||||
server-addr: localhost:8848
|
||||
dataId: spring-cloud-sentinel-nacos
|
||||
groupId: DEFAULT_GROUP
|
||||
rule-type: flow
|
||||
namespace: xxxxxxxx
|
||||
```
|
||||
|
||||
- 配置内容在 nacos 上进行编辑
|
||||
@ -352,12 +352,12 @@ spring:
|
||||
```json
|
||||
[
|
||||
{
|
||||
"resource": "/hello",
|
||||
"limitApp": "default",
|
||||
"grade": 1,
|
||||
"count": 1,
|
||||
"strategy": 0,
|
||||
"controlBehavior": 0,
|
||||
"resource": "/hello",
|
||||
"limitApp": "default",
|
||||
"grade": 1,
|
||||
"count": 1,
|
||||
"strategy": 0,
|
||||
"controlBehavior": 0,
|
||||
"clusterMode": false
|
||||
}
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user