Skip to content

Commit

Permalink
mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
deipss committed Feb 20, 2024
1 parent 641baf0 commit 91cbca6
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 13 deletions.
2 changes: 1 addition & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ aux_links:
mermaid:
# Version of mermaid library
# Pick an available version from https://cdn.jsdelivr.net/npm/mermaid/
version: "10.8.1"
version: "10.5.1"


# For copy button on code
Expand Down
3 changes: 1 addition & 2 deletions docs/Database/mysql.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@ WHERE age > 25;
* **id**: 查询的标识符。
* **select_type**: 查询的类型(例如 SIMPLE, SUBQUERY, DERIVED 等)。
* **table**: 输出的表名。
* **type**: 访问类型(例如 ALL, index, range, ref, eq_ref, const, system, NULL)。
https://www.cnblogs.com/xxoome/p/14434061.html **务必浏览此文档**
* **type**: 访问类型(例如 ALL, index, range, ref, eq_ref, const, system, NULL)。https://www.cnblogs.com/xxoome/p/14434061.html
* **possible_keys**: 可能使用的索引。
* **key**: 实际使用的索引。
* **key_len**: 使用的索引的长度。
Expand Down
6 changes: 6 additions & 0 deletions docs/Java/Atomic.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
layout: default
title: Atomic
parent: Java
---

6 changes: 5 additions & 1 deletion docs/Java/Lock.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ parent: Java
# 1. synchronized的实现

`synchronized` 是 Java 中实现同步的一种机制,它的底层实现完全依赖于 JVM(Java 虚拟机)的支持。在 JVM 中,
[synchronized 实现原理]( https://pdai.tech/md/db/sql-mysql/sql-mysql-b-tree.html)
`synchronized` 的实现涉及到对象头(Object Header)和 Monitor 机制。


- 对象头(Object Header)

在 JVM 中,每个对象都有一个对象头(Object Header),它包含了关于对象自身运行时的数据,
Expand Down Expand Up @@ -127,9 +129,11 @@ parent: Java

`synchronized``ReentrantLock` 都是 Java 中用于实现同步的机制,
但它们在实现方式、功能和性能上有一些区别。

## 3.1. synchronized



`synchronized` 是 Java 语言内置的关键字,用于控制多个线程对共享资源的访问。它可以用来修饰方法或代码块。

**特点:**
Expand Down
19 changes: 10 additions & 9 deletions docs/Java/SPI.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ parent: Java
使用这个库,加上注解的类,编译后,在META-INFO目录下,生成配置文件

```xml

<dependency>
<groupId>org.kohsuke.metainf-services</groupId>
<artifactId>metainf-services</artifactId>
Expand All @@ -20,7 +21,6 @@ parent: Java

> @MetaInfServices(InspectorPlugin.class)

# 2. java加载SPI

Java的SPI机制就是指:针对一个接口,我们需要加载外部对该接口的实现,
Expand All @@ -29,8 +29,8 @@ Java的SPI机制就是指:针对一个接口,我们需要加载外部对该
SPI中三个重要的角色:

- 接口
```java

```java
public interface InspectorPlugin {

String identify();
Expand All @@ -39,29 +39,32 @@ public interface InspectorPlugin {

boolean entrance();

int watch(ModuleEventWatcher watcher,InvocationSendService service);
int watch(ModuleEventWatcher watcher, InvocationSendService service);

}
```

- 配置文件

```java

@MetaInfServices(InspectorPlugin.class)
public class DubboProviderPlugin extends BasePlugin {
public DubboProviderPlugin( InvocationSendService invocationSendService) {
super(Constant.DUBBO_PROVIDER,true,invocationSendService);
public DubboProviderPlugin(InvocationSendService invocationSendService) {
super(Constant.DUBBO_PROVIDER, true, invocationSendService);
}



@Override
public void watch(ModuleEventWatcher watcher) {
new EventWatchBuilder(watcher)
.onClass("org.apache.dubbo.rpc.filter.ContextFilter").includeBootstrap()
.onBehavior("invoke")
.onWatch(new DubboProviderEventListener(entrance, protocol,invocationSendService), Event.Type.BEFORE, Event.Type.RETURN, Event.Type.THROWS);
.onWatch(new DubboProviderEventListener(entrance, protocol, invocationSendService), Event.Type.BEFORE, Event.Type.RETURN, Event.Type.THROWS);
}
}
```

- ServiceLoader反射获取

``` java
Expand All @@ -78,6 +81,4 @@ private List<InspectorPlugin> loadInspectorPluginBySPI( ClassLoader classLoader)
}
return target;
}


```

0 comments on commit 91cbca6

Please sign in to comment.