rename arthas-demo to math-game. #1738

pull/1744/head
hengyunabc 4 years ago
parent f19bd33805
commit 9c936db7b3

@ -152,7 +152,7 @@ chmod +x /tmp/sphinx.osx-x86_64
比如下载地址: https://maven.aliyun.com/repository/public/com/taobao/arthas/arthas-packaging/3.x.x/arthas-packaging-3.x.x-bin.zip
* 打上tagpush tag到仓库上
* 需要更新 gh-pages 分支下面的 arthas-boot.jar/arthas-demo.jar/as.sh ,下载 doc.zip解压覆盖掉文档的更新
* 需要更新 gh-pages 分支下面的 arthas-boot.jar/math-game.jar/as.sh ,下载 doc.zip解压覆盖掉文档的更新
* 需要更新docker镜像push新的taghttps://hub.docker.com/r/hengyunabc/arthas/tags?page=1&ordering=last_updated
以 3.1.0 版本为例:

@ -451,7 +451,7 @@ EXAMPLES:
./as.sh --use-version 3.5.0
./as.sh --session-timeout 3600
./as.sh --attach-only
./as.sh --select arthas-demo
./as.sh --select math-game
./as.sh --repo-mirror aliyun --use-http
WIKI:
https://arthas.aliyun.com/doc

@ -55,7 +55,7 @@ import static com.taobao.arthas.boot.ProcessUtils.STATUS_EXEC_TIMEOUT;
+ " java -jar arthas-boot.jar -f batch.as <pid>\n"
+ " java -jar arthas-boot.jar --use-version 3.5.0\n"
+ " java -jar arthas-boot.jar --versions\n"
+ " java -jar arthas-boot.jar --select arthas-demo\n"
+ " java -jar arthas-boot.jar --select math-game\n"
+ " java -jar arthas-boot.jar --session-timeout 3600\n" + " java -jar arthas-boot.jar --attach-only\n"
+ " java -jar arthas-boot.jar --repo-mirror aliyun --use-http\n" + "WIKI:\n"
+ " https://arthas.aliyun.com/doc\n")

@ -225,7 +225,7 @@
</dependency>
<dependency>
<groupId>com.taobao.arthas</groupId>
<artifactId>arthas-demo</artifactId>
<artifactId>math-game</artifactId>
<version>${project.version}</version>
<scope>test</scope>
</dependency>

@ -7,11 +7,11 @@
<version>${revision}</version>
<relativePath>../pom.xml</relativePath>
</parent>
<artifactId>arthas-demo</artifactId>
<name>arthas-demo</name>
<artifactId>math-game</artifactId>
<name>math-game</name>
<build>
<finalName>arthas-demo</finalName>
<finalName>math-game</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>

@ -38,8 +38,8 @@
<destName>arthas-boot.jar</destName>
</file>
<file>
<source>../demo/target/arthas-demo.jar</source>
<destName>arthas-demo.jar</destName>
<source>../math-game/target/math-game.jar</source>
<destName>math-game.jar</destName>
</file>
<file>

@ -56,6 +56,7 @@
<url>https://github.com/alibaba/arthas</url>
<modules>
<module>math-game</module>
<module>spy</module>
<module>common</module>
<module>tunnel-common</module>
@ -67,7 +68,6 @@
<module>boot</module>
<module>arthas-agent-attach</module>
<module>arthas-spring-boot-starter</module>
<module>demo</module>
<module>testcase</module>
<module>site</module>
<module>packaging</module>

@ -111,18 +111,18 @@ Arthas支持使用管道对上述命令的结果进行进一步的处理如`s
正常情况下,每次执行`as.sh`/`arthas-boot.jar`需要选择或者指定PID。这样会比较麻烦因为每次启动应用它的PID会变化。
比如,已经启动了`arthas-demo.jar`,使用`jps`命令查看:
比如,已经启动了`math-game.jar`,使用`jps`命令查看:
```bash
$ jps
58883 arthas-demo.jar
58883 math-game.jar
58884 Jps
```
通过`select`参数可以指定进程名字,非常方便。
```bash
$ ./as.sh --select arthas-demo
$ ./as.sh --select math-game
Arthas script version: 3.3.6
[INFO] JAVA_HOME: /tmp/java/8.0.222-zulu
Arthas home: /Users/admin/.arthas/lib/3.3.6/arthas

@ -6,7 +6,7 @@
比如下载全量的arthas zip包解压之后以 `-javaagent` 的参数指定`arthas-agent.jar`来启动:
```
java -javaagent:/tmp/test/arthas-agent.jar -jar arthas-demo.jar
java -javaagent:/tmp/test/arthas-agent.jar -jar math-game.jar
```
默认的配置项在解压目录里的`arthas.properties`文件里。参考:[Arthas Properties](arthas-properties.md)

@ -64,7 +64,7 @@ Affect(row-cnt:4) cost in 3 ms.
```bash
$ classloader -c 3d4eac69
file:/private/tmp/arthas-demo.jar
file:/private/tmp/math-game.jar
file:/Users/hengyunabc/.arthas/lib/3.0.5/arthas/arthas-agent.jar
Affect(row-cnt:9) cost in 3 ms.
@ -76,7 +76,7 @@ Affect(row-cnt:9) cost in 3 ms.
```bash
$ classloader --classLoaderClass sun.misc.Launcher$AppClassLoader
file:/private/tmp/arthas-demo.jar
file:/private/tmp/math-game.jar
file:/Users/hengyunabc/.arthas/lib/3.0.5/arthas/arthas-agent.jar
Affect(row-cnt:9) cost in 3 ms.
@ -87,7 +87,7 @@ Affect(row-cnt:9) cost in 3 ms.
```bash
$ classloader -c 3d4eac69 -r META-INF/MANIFEST.MF
jar:file:/System/Library/Java/Extensions/MRJToolkit.jar!/META-INF/MANIFEST.MF
jar:file:/private/tmp/arthas-demo.jar!/META-INF/MANIFEST.MF
jar:file:/private/tmp/math-game.jar!/META-INF/MANIFEST.MF
jar:file:/Users/hengyunabc/.arthas/lib/3.0.5/arthas/arthas-agent.jar!/META-INF/MANIFEST.MF
```
@ -104,7 +104,7 @@ $ classloader -c 1b6d3586 -r java/lang/String.class
$ classloader -c 3d4eac69 --load demo.MathGame
load class success.
class-info demo.MathGame
code-source /private/tmp/arthas-demo.jar
code-source /private/tmp/math-game.jar
name demo.MathGame
isInterface false
isAnnotation false

@ -56,22 +56,22 @@ RUN export JAVA_HOME
## 通过Docker快速入门
1. 删除本地已有的`arthas-demo` docker container非必要
1. 删除本地已有的`math-game` docker container非必要
```sh
$ docker stop arthas-demo || true && docker rm arthas-demo || true
$ docker stop math-game || true && docker rm math-game || true
```
1. 启动`arthas-demo`
1. 启动`math-game`
```sh
$ docker run --name arthas-demo -it hengyunabc/arthas:latest /bin/sh -c "java -jar /opt/arthas/arthas-demo.jar"
$ docker run --name math-game -it hengyunabc/arthas:latest /bin/sh -c "java -jar /opt/arthas/math-game.jar"
```
1. 启动`arthas-boot`来进行诊断
```sh
$ docker exec -it arthas-demo /bin/sh -c "java -jar /opt/arthas/arthas-boot.jar"
$ docker exec -it math-game /bin/sh -c "java -jar /opt/arthas/arthas-boot.jar"
* [1]: 9 jar
[INFO] arthas home: /opt/arthas

@ -107,18 +107,18 @@ Arthas supports living inside a browser. The communication between arthas and br
Normally, `as.sh`/`arthas-boot.jar` needs to a pid, bacause the pid will change.
For example, with `arthas-demo.jar` already started, use the `jps` command to see.
For example, with `math-game.jar` already started, use the `jps` command to see.
```bash
$ jps
58883 arthas-demo.jar
58883 math-game.jar
58884 Jps
```
The `select` option allows you to specify a process name, which is very convenient.
```bash
$ ./as.sh --select arthas-demo
$ ./as.sh --select math-game
Arthas script version: 3.3.6
[INFO] JAVA_HOME: /tmp/java/8.0.222-zulu
Arthas home: /Users/admin/.arthas/lib/3.3.6/arthas

@ -6,7 +6,7 @@ Usually Arthas dynamic attach the applications on the fly, but from version `3.2
For example, download the full arthas zip package, decompress it and start it by specifying `arthas-agent.jar` with the parameter `-javaagent`.
````
java -javaagent:/tmp/test/arthas-agent.jar -jar arthas-demo.jar
java -javaagent:/tmp/test/arthas-agent.jar -jar math-game.jar
````
The default configuration is in the `arthas.properties` file in the decompression directory. Reference: [Arthas Properties](arthas-properties.md)

@ -61,7 +61,7 @@ Affect(row-cnt:4) cost in 3 ms.
```bash
$ classloader -c 3d4eac69
file:/private/tmp/arthas-demo.jar
file:/private/tmp/math-game.jar
file:/Users/hengyunabc/.arthas/lib/3.0.5/arthas/arthas-agent.jar
Affect(row-cnt:9) cost in 3 ms.
@ -73,7 +73,7 @@ For ClassLoader with only unique instance, it can be specified by class name, wh
```bash
$ classloader --classLoaderClass sun.misc.Launcher$AppClassLoader
file:/private/tmp/arthas-demo.jar
file:/private/tmp/math-game.jar
file:/Users/hengyunabc/.arthas/lib/3.0.5/arthas/arthas-agent.jar
Affect(row-cnt:9) cost in 3 ms.
@ -84,7 +84,7 @@ Affect(row-cnt:9) cost in 3 ms.
```bash
$ classloader -c 3d4eac69 -r META-INF/MANIFEST.MF
jar:file:/System/Library/Java/Extensions/MRJToolkit.jar!/META-INF/MANIFEST.MF
jar:file:/private/tmp/arthas-demo.jar!/META-INF/MANIFEST.MF
jar:file:/private/tmp/math-game.jar!/META-INF/MANIFEST.MF
jar:file:/Users/hengyunabc/.arthas/lib/3.0.5/arthas/arthas-agent.jar!/META-INF/MANIFEST.MF
```
@ -101,7 +101,7 @@ $ classloader -c 1b6d3586 -r java/lang/String.class
$ classloader -c 3d4eac69 --load demo.MathGame
load class success.
class-info demo.MathGame
code-source /private/tmp/arthas-demo.jar
code-source /private/tmp/math-game.jar
name demo.MathGame
isInterface false
isAnnotation false

@ -58,22 +58,22 @@ RUN export JAVA_HOME
## Quick start with Docker
1. Delete the existing `arthas-demo` docker container (not necessary)
1. Delete the existing `math-game` docker container (not necessary)
```sh
$ docker stop arthas-demo || true && docker rm arthas-demo || true
$ docker stop math-game || true && docker rm math-game || true
```
1. Start `arthas-demo`
1. Start `math-game`
```sh
$ docker run --name arthas-demo -it hengyunabc/arthas:latest /bin/sh -c "java -jar /opt/arthas/arthas-demo.jar"
$ docker run --name math-game -it hengyunabc/arthas:latest /bin/sh -c "java -jar /opt/arthas/math-game.jar"
```
1. Start `arthas-boot` for diagnosis
```sh
$ docker exec -it arthas-demo /bin/sh -c "java -jar /opt/arthas/arthas-boot.jar"
$ docker exec -it math-game /bin/sh -c "java -jar /opt/arthas/arthas-boot.jar"
* [1]: 9 jar
[INFO] arthas home: /opt/arthas

@ -18,7 +18,7 @@ com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: ta
1. Check whether the current user and the target java process are consistent. If they are inconsistent, switch to the same user. JVM can only attach java processes under the same user.
2. Try to use `jstack -l $pid`. If the process does not respond, it means that the process may freeze and fail to respond to the JVM attach signal. So Arthas based on the attach mechanism cannot work. Try to use `jmap` heapdump to analyze.
3. Try to attach arthas-demo in [quick-start](quick-start.md).
3. Try to attach math-game in [quick-start](quick-start.md).
4. For more information: [https://github.com/alibaba/arthas/issues/347](https://github.com/alibaba/arthas/issues/347)
@ -57,7 +57,7 @@ You can used all variables in [fundamental fields in expressions](advice-class.m
You can use `-v` to view the condition express result [https://github.com/alibaba/arthas/issues/1348](https://github.com/alibaba/arthas/issues/1348)
example [arthas-demo](quick-start.md)
example [math-game](quick-start.md)
```bash
watch demo.MathGame primeFactors traceE '{params,returnObj,throwExp}' -v -n 5 -x 3 'params.length >0 && returnObj instanceof java.util.List'

@ -93,7 +93,7 @@ ClassLoader:
+-sun.misc.Launcher$ExtClassLoader@7f31245a
Location:
/private/tmp/arthas-demo.jar
/private/tmp/math-game.jar
public static void main(String[] args) throws InterruptedException {
MathGame game = new MathGame();
@ -116,7 +116,7 @@ ClassLoader:
+-sun.misc.Launcher$ExtClassLoader@7f31245a
Location:
/private/tmp/arthas-demo.jar
/private/tmp/math-game.jar
public static void main(String[] args) throws InterruptedException {
MathGame game = new MathGame();

@ -4,13 +4,13 @@ Quick Start
## 1. Start Demo Application
```bash
curl -O https://arthas.aliyun.com/arthas-demo.jar
java -jar arthas-demo.jar
curl -O https://arthas.aliyun.com/math-game.jar
java -jar math-game.jar
```
`arthas-demo` is a simple program that generates a random number every second, then it finds all prime factors of that number.
`math-game` is a simple program that generates a random number every second, then it finds all prime factors of that number.
The source code of `arthas-demo`: [View](https://github.com/alibaba/arthas/blob/master/demo/src/main/java/demo/MathGame.java)
The source code of `math-game`: [View](https://github.com/alibaba/arthas/blob/master/demo/src/main/java/demo/MathGame.java)
## 2. Start Arthas
@ -32,7 +32,7 @@ Select the target Java process to attach:
```bash
$ $ java -jar arthas-boot.jar
* [1]: 35542
[2]: 71560 arthas-demo.jar
[2]: 71560 math-game.jar
```
The 'Demo' process is the second as shown above, press '2' then 'Enter'. Arthas will attach to the target process, and start to output:
@ -94,7 +94,7 @@ java.home /Library/Java/JavaVir
e/jre
```
## 4. Get the Main Class of the `arthas-demo` process with the thread command
## 4. Get the Main Class of the `math-game` process with the thread command
`thread 1` will print the stack of the thread with ID 1, which usually the main function thread.
@ -113,7 +113,7 @@ ClassLoader:
+-sun.misc.Launcher$ExtClassLoader@66350f69
Location:
/tmp/arthas-demo.jar
/tmp/math-game.jar
/*
* Decompiled with CFR 0_132.

@ -39,7 +39,7 @@ sc
```bash
$ sc -d demo.MathGame
class-info demo.MathGame
code-source /private/tmp/arthas-demo.jar
code-source /private/tmp/math-game.jar
name demo.MathGame
isInterface false
isAnnotation false
@ -67,7 +67,7 @@ sc
```bash
$ sc -d -f demo.MathGame
class-info demo.MathGame
code-source /private/tmp/arthas-demo.jar
code-source /private/tmp/math-game.jar
name demo.MathGame
isInterface false
isAnnotation false

@ -29,7 +29,7 @@ Pls. refer to [core parameters in expression](advice-class.md) for more details.
#### Start Demo
Start `arthas-demo` in [Quick Start](quick-start.md).
Start `math-game` in [Quick Start](quick-start.md).
#### stack

@ -43,7 +43,7 @@ Many times what we are interested is the exact trace result when the method call
#### Start Demo
Start `arthas-demo` in [Quick Start](quick-start.md).
Start `math-game` in [Quick Start](quick-start.md).
#### Trace method

@ -16,7 +16,7 @@ With the help of `tt` (*TimeTunnel*), you can check the contexts of the methods
#### Start Demo
Start `arthas-demo` in [Quick Start](quick-start.md).
Start `math-game` in [Quick Start](quick-start.md).
#### Record method calls

@ -41,7 +41,7 @@ Advanced:
#### Start Demo
Start `arthas-demo` in [Quick Start](quick-start.md).
Start `math-game` in [Quick Start](quick-start.md).
#### Check the `out parameters` and `return value`

@ -19,7 +19,7 @@ com.sun.tools.attach.AttachNotSupportedException: Unable to open socket file: ta
1. 检查当前用户和目标java进程是否一致。如果不一致则切换到同一用户。JVM只能attach同样用户下的java 进程。
2. 尝试使用 `jstack -l $pid`如果进程没有反应则说明进程可能假死无法响应JVM attach信号。所以同样基于attach机制的Arthas无法工作。尝试使用`jmap` heapdump后分析。
3. 尝试按[quick-start](quick-start.md)里的方式attach arthas-demo
3. 尝试按[quick-start](quick-start.md)里的方式attach math-game
4. 更多情况参考: [https://github.com/alibaba/arthas/issues/347](https://github.com/alibaba/arthas/issues/347)
##### trace/watch等命令能否增强jdk里的类
@ -56,7 +56,7 @@ options json-format true
可以使用 `-v` 查看观察匹配表达式的执行结果 [https://github.com/alibaba/arthas/issues/1348](https://github.com/alibaba/arthas/issues/1348)
例子[arthas-demo](quick-start.md)
例子[math-game](quick-start.md)
```bash
watch demo.MathGame primeFactors traceE '{params,returnObj,throwExp}' -v -n 5 -x 3 'params.length >0 && returnObj instanceof java.util.List'

@ -93,7 +93,7 @@ ClassLoader:
+-sun.misc.Launcher$ExtClassLoader@7f31245a
Location:
/private/tmp/arthas-demo.jar
/private/tmp/math-game.jar
public static void main(String[] args) throws InterruptedException {
MathGame game = new MathGame();
@ -116,7 +116,7 @@ ClassLoader:
+-sun.misc.Launcher$ExtClassLoader@7f31245a
Location:
/private/tmp/arthas-demo.jar
/private/tmp/math-game.jar
public static void main(String[] args) throws InterruptedException {
MathGame game = new MathGame();

@ -4,13 +4,13 @@
## 1. 启动Demo
```bash
curl -O https://arthas.aliyun.com/arthas-demo.jar
java -jar arthas-demo.jar
curl -O https://arthas.aliyun.com/math-game.jar
java -jar math-game.jar
```
`arthas-demo`是一个简单的程序,每隔一秒生成一个随机数,再执行质因数分解,并打印出分解结果。
`math-game`是一个简单的程序,每隔一秒生成一个随机数,再执行质因数分解,并打印出分解结果。
`arthas-demo`源代码:[查看](https://github.com/alibaba/arthas/blob/master/demo/src/main/java/demo/MathGame.java)
`math-game`源代码:[查看](https://github.com/alibaba/arthas/blob/master/demo/src/main/java/demo/MathGame.java)
## 2. 启动arthas
@ -33,7 +33,7 @@ java -jar arthas-boot.jar
```bash
$ $ java -jar arthas-boot.jar
* [1]: 35542
[2]: 71560 arthas-demo.jar
[2]: 71560 math-game.jar
```
Demo进程是第2个则输入2再输入`回车/enter`。Arthas会attach到目标进程上并输出日志
@ -95,7 +95,7 @@ java.home /Library/Java/JavaVir
e/jre
```
## 4. 通过thread命令来获取到`arthas-demo`进程的Main Class
## 4. 通过thread命令来获取到`math-game`进程的Main Class
`thread 1`会打印线程ID 1的栈通常是main函数的线程。
@ -114,7 +114,7 @@ ClassLoader:
+-sun.misc.Launcher$ExtClassLoader@66350f69
Location:
/tmp/arthas-demo.jar
/tmp/math-game.jar
/*
* Decompiled with CFR 0_132.

@ -43,7 +43,7 @@ sc
```bash
$ sc -d demo.MathGame
class-info demo.MathGame
code-source /private/tmp/arthas-demo.jar
code-source /private/tmp/math-game.jar
name demo.MathGame
isInterface false
isAnnotation false
@ -71,7 +71,7 @@ sc
```bash
$ sc -d -f demo.MathGame
class-info demo.MathGame
code-source /private/tmp/arthas-demo.jar
code-source /private/tmp/math-game.jar
name demo.MathGame
isInterface false
isAnnotation false

@ -31,7 +31,7 @@ stack
#### 启动 Demo
启动[快速入门](quick-start.md)里的`arthas-demo`。
启动[快速入门](quick-start.md)里的`math-game`。
#### stack

@ -47,7 +47,7 @@ trace
#### 启动 Demo
启动[快速入门](quick-start.md)里的`arthas-demo`。
启动[快速入门](quick-start.md)里的`math-game`。
#### trace函数

@ -16,7 +16,7 @@ tt
#### 启动 Demo
启动[快速入门](quick-start.md)里的`arthas-demo`。
启动[快速入门](quick-start.md)里的`math-game`。
#### 记录调用

@ -42,7 +42,7 @@ watch 的参数比较多,主要是因为它能在 4 个不同的场景观察
#### 启动 Demo
启动[快速入门](quick-start.md)里的`arthas-demo`。
启动[快速入门](quick-start.md)里的`math-game`。
#### 观察方法出参和返回值

Loading…
Cancel
Save