From acbae91c731b3a8533b309220d432fcbfe965bac Mon Sep 17 00:00:00 2001 From: hengyunabc Date: Fri, 19 Mar 2021 20:25:46 +0800 Subject: [PATCH] add case-ognl-practise-en. #1743 --- .../_include_html/arthas-tutorials.html | 12 ++++++ .../katacoda/case-ognl-practise-cn/README.md | 25 ----------- .../katacoda/case-ognl-practise-cn/index.json | 7 +--- .../katacoda/case-ognl-practise-en/finish.md | 12 ++++++ .../katacoda/case-ognl-practise-en/index.json | 29 +++++++++++++ .../katacoda/case-ognl-practise-en/intro.md | 8 ++++ .../katacoda/case-ognl-practise-en/setup.sh | 1 + .../katacoda/case-ognl-practise-en/step1.md | 42 +++++++++++++++++++ 8 files changed, 106 insertions(+), 30 deletions(-) delete mode 100644 tutorials/katacoda/case-ognl-practise-cn/README.md create mode 100644 tutorials/katacoda/case-ognl-practise-en/finish.md create mode 100644 tutorials/katacoda/case-ognl-practise-en/index.json create mode 100644 tutorials/katacoda/case-ognl-practise-en/intro.md create mode 100644 tutorials/katacoda/case-ognl-practise-en/setup.sh create mode 100644 tutorials/katacoda/case-ognl-practise-en/step1.md diff --git a/site/src/site/sphinx/_include_html/arthas-tutorials.html b/site/src/site/sphinx/_include_html/arthas-tutorials.html index 3d28e258e..de62cee87 100644 --- a/site/src/site/sphinx/_include_html/arthas-tutorials.html +++ b/site/src/site/sphinx/_include_html/arthas-tutorials.html @@ -755,6 +755,18 @@ cn: "case-watch-method-exception-cn", } }, + { + id: "case-ognl-practise", + type: "USERCASE", + names: { + en: "Debug ognl express", + cn: "调试ognl表达式", + }, + ids: { + en: "case-ognl-practise-en", + cn: "case-ognl-practise-cn", + } + }, { id: "case-thread", type: "USERCASE", diff --git a/tutorials/katacoda/case-ognl-practise-cn/README.md b/tutorials/katacoda/case-ognl-practise-cn/README.md deleted file mode 100644 index 28889e617..000000000 --- a/tutorials/katacoda/case-ognl-practise-cn/README.md +++ /dev/null @@ -1,25 +0,0 @@ -# Katacoda Hello World -This is an example repository. Starting building your own scenario by editing the files in this directory. Create additional scenarios by adding additional directories to the top level folder. - - -## index.json -The file _index.json_ contains all the information about the scenario. It has the title, description and a heading for each step. - -The file also contains an imageid. This refers to the Katacoda environment. Here are some environment image IDs you may find useful: - -| **Environment** | **Image ID** | -|------------------|---------------| -| Docker | docker | -| Kubernetes | kubernetes | -| CoreOS | coreos | -| Node.js v6 | node6 | -| Go | go | -| C# | c# | -| Java | java8 | -| Bash | bash | - -## Pro Author Accounts -Interested in metrics, private repositories and environments for classroom teaching? Update to become a Pro Author at https://katacoda.com/teach - -## Interactive Developer Portals -Want to take your scenarios to the next level? Visit https://katacoda.com/embed diff --git a/tutorials/katacoda/case-ognl-practise-cn/index.json b/tutorials/katacoda/case-ognl-practise-cn/index.json index 0659314e2..f2e8626ba 100644 --- a/tutorials/katacoda/case-ognl-practise-cn/index.json +++ b/tutorials/katacoda/case-ognl-practise-cn/index.json @@ -1,5 +1,4 @@ { - "noindex": true, "title": "调试 Arthas 的 ognl 表达式", "description": "调试 Arthas 的 ognl 表达式", "details": { @@ -10,8 +9,7 @@ } ], "intro": { - "text": "intro.md", - "credits": "" + "text": "intro.md" }, "finish": { "text": "finish.md" @@ -20,10 +18,9 @@ "files": [ ], "environment": { - "hidefinish": true, "hideHiddenFiles": true, "uilayout": "editor-terminal", - "uisettings": "javascript", + "uisettings": "java", "uieditorpath": "/root/example/ognl-demo" }, "backend": { diff --git a/tutorials/katacoda/case-ognl-practise-en/finish.md b/tutorials/katacoda/case-ognl-practise-en/finish.md new file mode 100644 index 000000000..b9f86b13c --- /dev/null +++ b/tutorials/katacoda/case-ognl-practise-en/finish.md @@ -0,0 +1,12 @@ +The tutorial demonstrates how to debug `ognl` express in Arthas. If you have more tips or questions, please feel free to tell or ask in Issue. + +* For special usage of OGNL, please refer to: https://github.com/alibaba/arthas/issues/71 +* Official Guide to OGNL Expressions: https://commons.apache.org/proper/commons-ognl/language-guide.html + +--- + +* Issues: https://github.com/alibaba/arthas/issues +* Documentation: https://arthas.aliyun.com/doc/en + +If you are using Arthas, please let us know that. Your use is very important to us: [View](https://github.com/alibaba/arthas/issues/111) + diff --git a/tutorials/katacoda/case-ognl-practise-en/index.json b/tutorials/katacoda/case-ognl-practise-en/index.json new file mode 100644 index 000000000..04402c2bf --- /dev/null +++ b/tutorials/katacoda/case-ognl-practise-en/index.json @@ -0,0 +1,29 @@ +{ + "title": "Debug ognl express in Arthas", + "description": "Debug ognl express in Arthas", + "details": { + "steps": [ + { + "text": "step1.md", + "code": "setup.sh" + } + ], + "intro": { + "text": "intro.md" + }, + "finish": { + "text": "finish.md" + } + }, + "files": [ + ], + "environment": { + "hideHiddenFiles": true, + "uilayout": "editor-terminal", + "uisettings": "java", + "uieditorpath": "/root/example/ognl-demo" + }, + "backend": { + "imageid": "openjdk:15" + } +} \ No newline at end of file diff --git a/tutorials/katacoda/case-ognl-practise-en/intro.md b/tutorials/katacoda/case-ognl-practise-en/intro.md new file mode 100644 index 000000000..2415e33ae --- /dev/null +++ b/tutorials/katacoda/case-ognl-practise-en/intro.md @@ -0,0 +1,8 @@ +![Arthas](https://arthas.aliyun.com/doc/_images/arthas.png) + +`Arthas` is a Java diagnostic tool open-sourced by Alibaba middleware team. Arthas helps developers in trouble-shooting issues in production environment for Java based applications without modifying code or restarting servers. + +This tutorial show how to debug `ognl` express in Arths. + +* Github: https://github.com/alibaba/arthas +* Docs: https://arthas.aliyun.com/doc/en \ No newline at end of file diff --git a/tutorials/katacoda/case-ognl-practise-en/setup.sh b/tutorials/katacoda/case-ognl-practise-en/setup.sh new file mode 100644 index 000000000..043faca1d --- /dev/null +++ b/tutorials/katacoda/case-ognl-practise-en/setup.sh @@ -0,0 +1 @@ +mkdir -p example; cd example/; git clone https://github.com/hengyunabc/ognl-demo.git ; cd ognl-demo \ No newline at end of file diff --git a/tutorials/katacoda/case-ognl-practise-en/step1.md b/tutorials/katacoda/case-ognl-practise-en/step1.md new file mode 100644 index 000000000..5e83c6d78 --- /dev/null +++ b/tutorials/katacoda/case-ognl-practise-en/step1.md @@ -0,0 +1,42 @@ + +Demonstrate the workflow of the `ognl` expression in the `watch` command in Arthas. You can modify the expressions in `Demo.java`, and compile and run the code. + +Project: https://github.com/hengyunabc/ognl-demo + +# Open the Demo.java file + +`src/main/java/com/example/ognl/Demo.java`{{open}} + +# Compile and run the code + +`mvn compile exec:java`{{execute}} + +Expression in the code: + +```java +String watchExpress = "{target, params, returnObj, #cost}"; +String conditionExpress = "params[0] > 1 && #cost > 0.1"; +``` + +The result is similar to the following expression: + +```bash +watch com.example.ognl.TestService test "{target, params, returnObj, #cost}" "params[0] > 1 && #cost > 0.1" -x 3 +``` + +# View the expression result when the method throws an exception + +`mvn compile exec:java -DexceptionCase=true`{{execute}} + +Expression in the code: + +```java +String watchExpress = "{target, params, throwExp}"; +String conditionExpress = "params[0] > 1"; +``` + +The result is similar to the following expression: + +```bash +watch com.example.ognl.TestService test "{target, params, throwExp}" "params[0] > 1" -e -x 2 +```