Skip to content

Commit 16895ee

Browse files
committed
update docs
1 parent edee1e8 commit 16895ee

File tree

19 files changed

+409
-0
lines changed

19 files changed

+409
-0
lines changed

assets/Java业务问题.xmind

230 KB
Binary file not shown.

assets/TroubleShooting.eddx

35.6 KB
Binary file not shown.

assets/TroubleShooting.xmind

218 KB
Binary file not shown.

codes/deadloop/pom.xml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
6+
<parent>
7+
<groupId>org.springframework.boot</groupId>
8+
<artifactId>spring-boot-starter-parent</artifactId>
9+
<version>2.2.1.RELEASE</version>
10+
</parent>
11+
12+
<groupId>io.github.dunwu.trouble</groupId>
13+
<artifactId>deadloop</artifactId>
14+
<packaging>war</packaging>
15+
<name>故障诊断2</name>
16+
<description>故障诊断示例源码2</description>
17+
18+
<dependencies>
19+
<dependency>
20+
<groupId>org.springframework.boot</groupId>
21+
<artifactId>spring-boot-starter-web</artifactId>
22+
</dependency>
23+
<dependency>
24+
<groupId>org.springframework.boot</groupId>
25+
<artifactId>spring-boot-starter-jdbc</artifactId>
26+
</dependency>
27+
<dependency>
28+
<groupId>org.springframework.boot</groupId>
29+
<artifactId>spring-boot-starter-test</artifactId>
30+
<scope>test</scope>
31+
</dependency>
32+
<dependency>
33+
<groupId>io.github.dunwu</groupId>
34+
<artifactId>dunwu-tool-core</artifactId>
35+
</dependency>
36+
<dependency>
37+
<groupId>org.assertj</groupId>
38+
<artifactId>assertj-core</artifactId>
39+
</dependency>
40+
<dependency>
41+
<groupId>org.projectlombok</groupId>
42+
<artifactId>lombok</artifactId>
43+
</dependency>
44+
<dependency>
45+
<groupId>mysql</groupId>
46+
<artifactId>mysql-connector-java</artifactId>
47+
</dependency>
48+
<dependency>
49+
<groupId>org.apache.httpcomponents</groupId>
50+
<artifactId>httpclient</artifactId>
51+
<version>4.5.9</version>
52+
</dependency>
53+
<dependency>
54+
<groupId>org.apache.httpcomponents</groupId>
55+
<artifactId>fluent-hc</artifactId>
56+
<version>4.5.9</version>
57+
</dependency>
58+
</dependencies>
59+
<dependencyManagement>
60+
<dependencies>
61+
<dependency>
62+
<groupId>io.github.dunwu</groupId>
63+
<artifactId>dunwu-dependencies</artifactId>
64+
<version>0.5.7</version>
65+
<type>pom</type>
66+
<scope>import</scope>
67+
</dependency>
68+
</dependencies>
69+
</dependencyManagement>
70+
71+
<build>
72+
<finalName>${project.artifactId}</finalName>
73+
<plugins>
74+
<plugin>
75+
<groupId>org.springframework.boot</groupId>
76+
<artifactId>spring-boot-maven-plugin</artifactId>
77+
</plugin>
78+
</plugins>
79+
</build>
80+
</project>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package io.github.dunwu.trouble;
2+
3+
import org.springframework.stereotype.Component;
4+
5+
import java.util.ArrayList;
6+
import java.util.List;
7+
import java.util.stream.Collectors;
8+
import java.util.stream.IntStream;
9+
10+
@Component
11+
public class FooService {
12+
13+
List<String> data = new ArrayList<>();
14+
15+
public void oom() {
16+
data.add(IntStream.rangeClosed(1, 100000)
17+
.mapToObj(__ -> "a")
18+
.collect(Collectors.joining("")));
19+
}
20+
21+
}
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
package io.github.dunwu.trouble;
2+
3+
import lombok.extern.slf4j.Slf4j;
4+
import org.springframework.boot.CommandLineRunner;
5+
import org.springframework.boot.SpringApplication;
6+
import org.springframework.boot.autoconfigure.SpringBootApplication;
7+
8+
import java.lang.management.ManagementFactory;
9+
import java.util.Arrays;
10+
import java.util.concurrent.TimeUnit;
11+
import java.util.stream.Collectors;
12+
13+
/**
14+
* 启动参数:
15+
* <p>
16+
* java -verbose:gc -Xms128M -Xmx256M -XX:+PrintGCDetails -XX:+PrintGCTimeStamps -XX:+PrintGCDateStamps
17+
* -XX:-OmitStackTraceInFastThrow -XX:+HeapDumpOnOutOfMemoryError -Dcom.sun.management.jmxremote=true
18+
* -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
19+
* -Djava.rmi.server.hostname=172.22.6.43 -Dcom.sun.management.jmxremote.port=18888 -Xdebug -Xnoagent
20+
* -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=28888,server=y,suspend=n -jar deadloop.war
21+
*/
22+
@Slf4j
23+
@SpringBootApplication
24+
public class OOMApplication implements CommandLineRunner {
25+
26+
private final FooService fooService;
27+
28+
public OOMApplication(FooService fooService) {
29+
this.fooService = fooService;
30+
}
31+
32+
public static void main(String[] args) {
33+
SpringApplication.run(OOMApplication.class, args);
34+
}
35+
36+
@Override
37+
public void run(String... args) throws Exception {
38+
log.info("VM options");
39+
log.info(ManagementFactory.getRuntimeMXBean()
40+
.getInputArguments()
41+
.stream()
42+
.collect(Collectors.joining(System.lineSeparator())));
43+
log.info("Program arguments");
44+
log.info(Arrays.stream(args).collect(Collectors.joining(System.lineSeparator())));
45+
46+
while (true) {
47+
fooService.oom();
48+
try {
49+
TimeUnit.SECONDS.sleep(3);
50+
} catch (InterruptedException e) {
51+
e.printStackTrace();
52+
}
53+
}
54+
}
55+
56+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
server.port = 8888
2+
#server.port = ${random.int[1024,65536]}
3+
spring.datasource.url = jdbc:mysql://172.22.6.9:3316/trouble_shooting?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8
4+
#spring.datasource.url = jdbc:mysql://172.22.6.9:3316/trouble_shooting?serverTimezone=UTC&useUnicode=true&characterEncoding=utf8&rewriteBatchedStatements=true
5+
spring.datasource.driver-class-name = com.mysql.cj.jdbc.Driver
6+
spring.datasource.username = root
7+
spring.datasource.password = 604330436
8+
# 强制每次启动使用 sql 初始化数据,本项目仅为了演示方便,真实环境应避免这种模式
9+
spring.datasource.initialization-mode = ALWAYS
10+
spring.datasource.schema = classpath:sql/schema.sql
11+
spring.datasource.data = classpath:sql/data.sql
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
${AnsiColor.BRIGHT_YELLOW}${AnsiStyle.BOLD}
2+
________ ___ ___ ________ ___ __ ___ ___
3+
|\ ___ \|\ \|\ \|\ ___ \|\ \ |\ \|\ \|\ \
4+
\ \ \_|\ \ \ \\\ \ \ \\ \ \ \ \ \ \ \ \ \\\ \
5+
\ \ \ \\ \ \ \\\ \ \ \\ \ \ \ \ __\ \ \ \ \\\ \
6+
\ \ \_\\ \ \ \\\ \ \ \\ \ \ \ \|\__\_\ \ \ \\\ \
7+
\ \_______\ \_______\ \__\\ \__\ \____________\ \_______\
8+
\|_______|\|_______|\|__| \|__|\|____________|\|_______|
9+
${AnsiColor.CYAN}${AnsiStyle.BOLD}
10+
:: Java :: (v${java.version})
11+
:: Spring Boot :: (v${spring-boot.version})
12+
${AnsiStyle.NORMAL}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?xml version="1.0" encoding="UTF-8" ?>
2+
<configuration scan="true" scanPeriod="60 seconds" debug="false">
3+
<appender name="CONSOLE" class="ch.qos.logback.core.ConsoleAppender">
4+
<encoder>
5+
<pattern>%d{HH:mm:ss.SSS} [%boldYellow(%thread)] [%highlight(%-5level)] %boldGreen(%c{36}.%M) - %boldBlue(%m%n)
6+
</pattern>
7+
</encoder>
8+
</appender>
9+
10+
<root level="INFO">
11+
<appender-ref ref="CONSOLE" />
12+
</root>
13+
</configuration>
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
-- -------------------------------------------------------------------
2+
-- 运行本项目的初始化 DML 脚本
3+
-- Mysql 知识点可以参考:
4+
-- https://dunwu.github.io/db-tutorial/#/sql/mysql/README
5+
-- -------------------------------------------------------------------
6+
7+
# INSERT INTO user (username, password, email)
8+
# VALUES ('admin', '$2a$10$Y9uV9YjFuNlATDGz5MeTZeuo8LbebbpP6jRgtZYQcgiCZRlf8rJYG', '[email protected]');
9+
#
10+
# INSERT INTO user (username, password, email)
11+
# VALUES ('user', '$2a$10$Y9uV9YjFuNlATDGz5MeTZeuo8LbebbpP6jRgtZYQcgiCZRlf8rJYG', '[email protected]');

0 commit comments

Comments
 (0)