Skip to content

Commit

Permalink
dara
Browse files Browse the repository at this point in the history
  • Loading branch information
deipss committed Nov 17, 2023
1 parent ee46b0a commit 7db0935
Show file tree
Hide file tree
Showing 6 changed files with 127 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/Database/Redission.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Redission
parent: Database
---

> 图片来源:https://www.bilibili.com/video/BV1cr4y1671t?p=160&vd_source=f52d9488d7d3c21ed33580e4dce1a022
- 图片来源:https://www.bilibili.com/video/BV1cr4y1671t?p=160&vd_source=f52d9488d7d3c21ed33580e4dce1a022

# 1. 分布式锁需要优化的问题

Expand Down
2 changes: 1 addition & 1 deletion docs/Database/Redis实践.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Redis实践
parent: Database
---

> 图片来源:https://www.bilibili.com/video/BV1cr4y1671t?p=160&vd_source=f52d9488d7d3c21ed33580e4dce1a022
- 图片来源:https://www.bilibili.com/video/BV1cr4y1671t?p=160&vd_source=f52d9488d7d3c21ed33580e4dce1a022

# 1. KEY设计

Expand Down
2 changes: 1 addition & 1 deletion docs/Database/Redis网络模型.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ title: Redis网络模型
parent: Database
---

> 图片来源:https://www.bilibili.com/video/BV1cr4y1671t?p=160&vd_source=f52d9488d7d3c21ed33580e4dce1a022
- 图片来源:https://www.bilibili.com/video/BV1cr4y1671t?p=160&vd_source=f52d9488d7d3c21ed33580e4dce1a022

# 1. 用户空间与内核空间

Expand Down
83 changes: 83 additions & 0 deletions docs/Sandbox/Repeater-Dubbo-插桩.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---
layout: default
title: Repeater-Dubbo-插桩
parent: Sandbox
---

# 1. Dubbo泛化调用traceId
## 1.1. consumer 端
只对repeater-receiver应用的Dubbo泛化调用的类
`org.apache.dubbo.rpc.filter.GenericImplFilter`
进行插桩,代码如下:

```css
{
// EnhanceModel onResponse = EnhanceModel.builder().classPattern("org.apache.dubbo.rpc.filter.ConsumerContextFilter$ConsumerContextListener")
// .methodPatterns(EnhanceModel.MethodPattern.transform("onResponse"))
// .watchTypes(Event.Type.BEFORE, Event.Type.RETURN, Event.Type.THROWS)
// .build();
EnhanceModel invoke = EnhanceModel.builder().classPattern("org.apache.dubbo.rpc.filter.ConsumerContextFilter")
.methodPatterns(EnhanceModel.MethodPattern.transform("invoke"))
.watchTypes(Event.Type.BEFORE, Event.Type.RETURN, Event.Type.THROWS)
.build();

EnhanceModel geneticInvoke = EnhanceModel.builder().classPattern("org.apache.dubbo.rpc.filter.GenericImplFilter")
.methodPatterns(EnhanceModel.MethodPattern.transform("invoke"))
.watchTypes(Event.Type.BEFORE, Event.Type.RETURN, Event.Type.THROWS)
.build();
// EnhanceModel onResponseV3 = EnhanceModel.builder().classPattern("org.apache.dubbo.rpc.cluster.filter.support.ConsumerContextFilter")
// .methodPatterns(EnhanceModel.MethodPattern.transform("onResponse"))
// .watchTypes(Event.Type.BEFORE, Event.Type.RETURN, Event.Type.THROWS)
// .build();
EnhanceModel invokeV3 = EnhanceModel.builder().classPattern("org.apache.dubbo.rpc.cluster.filter.support.ConsumerContextFilter")
.methodPatterns(EnhanceModel.MethodPattern.transform("invoke"))
.watchTypes(Event.Type.BEFORE, Event.Type.RETURN, Event.Type.THROWS)
.build();
return ApplicationModel.instance().isRepeater()?Lists.newArrayList(geneticInvoke):Lists.newArrayList(invoke,invokeV3);
}
```

## 1.2. provider 端
对Dubbo Provider端,如果是泛化调用,会先执行 org.apache.dubbo.rpc.filter.GenericFilter ,再执行 org.apache.dubbo.rpc.filter.ContextFilter

对Dubbo Provider端,如果非泛化调用,只执行org.apache.dubbo.rpc.filter.ContextFilter

原因是

@Activate(group = CommonConstants.PROVIDER, order = -20000)

注解中,order 越小,越早执行。

两个调用方式都会调用 org.apache.dubbo.rpc.filter.ContextFilter 这个类的invoke方法,所以privder端暂时可以不处理。



# 2. Sql语句获取
前端将返回sql字段

"sql": "SELECT id,taskName,taskGroup,bizId,bizColumn,bizType,saveDate,bizRequest,tmCreate,tmModify FROM t_generated_biz_id WHERE id=238098 ",


## 2.1. mysql 5.0+版本 可以获取
```xml
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.46</version>
</dependency>
```

## 2.2. mysql 8.0+版本 可以获取

```xml

<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>8.0.11</version>
</dependency>
```


## 2.3. 分表分库 sphere-sharding
可以获取到SQL,但是非常多,如果10库100表,可能为1000条
2 changes: 1 addition & 1 deletion docs/command/mvn.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ parent: Command
nav_order: 6
---

> 图片来源=https://www.bilibili.com/video/BV1Ah411S7ZE?p=13&vd_source=f52d9488d7d3c21ed33580e4dce1a022
- 图片来源=https://www.bilibili.com/video/BV1Ah411S7ZE?p=13&vd_source=f52d9488d7d3c21ed33580e4dce1a022

# 1. maven简介

Expand Down
40 changes: 40 additions & 0 deletions docs/spring/Autowired和Resource注解的区别.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
---
layout: default
title: Autowired和Resource注解的区别
parent: Spring
---

# 相同点
- 都用依赖注入,@Autowired是Spring的,@Resource`javax.annotation.Resource`

# 不同点
- @Autowired注解是按照类型(byType)装配依赖对象,默认情况下它要求依赖对象必须存在,如果允许null值,可以设置它的required属性为false。如果我们想使用按照名称(byName)来装配,可以结合@Qualifier注解一起使用。(通过类型匹配找到多个candidate,在没有@Qualifier@Primary注解的情况下,会使用对象名作为最后的fallback匹配)如下:
```css
@Autowired
@Qualifier("userDao")
private UserDao userDao;
```

- @Resource默认按照ByName自动注入,由J2EE提供,需要导入包javax.annotation.Resource。@Resource有两个重要的属性:name和type,而Spring将@Resource注解的name属性解析为bean的名字,而type属性则解析为bean的类型。所以,如果使用name属性,则使用byName的自动注入策略,而使用type属性时则使用byType自动注入策略。如果既不制定name也不制定type属性,这时将通过反射机制使用byName自动注入策
```css
// 下面两种@Resource只要使用一种即可
@Resource(name="userDao")
private UserDao userDao; // 用于字段上

@Resource(name="userDao")
public void setUserDao(UserDao userDao) { // 用于属性的setter方法上
this.userDao = userDao;
}
```

## @Resource装配顺序:

- 如果同时指定了name和type,则从Spring上下文中找到唯一匹配的bean进行装配,找不到则抛出异常。

- 如果指定了name,则从上下文中查找名称(id)匹配的bean进行装配,找不到则抛出异常。

- 如果指定了type,则从上下文中找到类似匹配的唯一bean进行装配,找不到或是找到多个,都会抛出异常。

- 如果既没有指定name,又没有指定type,则自动按照byName方式进行装配;如果没有匹配,则回退为一个原始类型进行匹配,如果匹配则自动装配。

- @Resource的作用相当于@Autowired,只不过@Autowired按照byType自动注入。

0 comments on commit 7db0935

Please sign in to comment.