From 5c606a62f395f9a4f0539a656374303969561ca3 Mon Sep 17 00:00:00 2001 From: hengyunabc Date: Fri, 19 Mar 2021 20:05:44 +0800 Subject: [PATCH] add case-ognl-practise-cn --- .../katacoda/case-ognl-practise-cn/README.md | 25 +++++++++++ .../katacoda/case-ognl-practise-cn/finish.md | 20 +++++++++ .../katacoda/case-ognl-practise-cn/index.json | 32 +++++++++++++++ .../katacoda/case-ognl-practise-cn/intro.md | 9 ++++ .../katacoda/case-ognl-practise-cn/setup.sh | 1 + .../katacoda/case-ognl-practise-cn/step1.md | 41 +++++++++++++++++++ 6 files changed, 128 insertions(+) create mode 100644 tutorials/katacoda/case-ognl-practise-cn/README.md create mode 100644 tutorials/katacoda/case-ognl-practise-cn/finish.md create mode 100644 tutorials/katacoda/case-ognl-practise-cn/index.json create mode 100644 tutorials/katacoda/case-ognl-practise-cn/intro.md create mode 100644 tutorials/katacoda/case-ognl-practise-cn/setup.sh create mode 100644 tutorials/katacoda/case-ognl-practise-cn/step1.md diff --git a/tutorials/katacoda/case-ognl-practise-cn/README.md b/tutorials/katacoda/case-ognl-practise-cn/README.md new file mode 100644 index 000000000..28889e617 --- /dev/null +++ b/tutorials/katacoda/case-ognl-practise-cn/README.md @@ -0,0 +1,25 @@ +# 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/finish.md b/tutorials/katacoda/case-ognl-practise-cn/finish.md new file mode 100644 index 000000000..1eceecb80 --- /dev/null +++ b/tutorials/katacoda/case-ognl-practise-cn/finish.md @@ -0,0 +1,20 @@ +我们演示如何调试Arthas的`ognl`表达式。如果有更多的技巧或者使用疑问,欢迎在Issue里提出。 + + +更多参考: + +* 特殊用法请参考:[https://github.com/alibaba/arthas/issues/71](https://github.com/alibaba/arthas/issues/71) +* OGNL表达式官网:[https://commons.apache.org/proper/commons-ognl/language-guide.html](https://commons.apache.org/proper/commons-ognl/language-guide.html) + + +--- + +* Issues: https://github.com/alibaba/arthas/issues +* 文档: https://arthas.aliyun.com/doc + +如果您在使用Arthas,请让我们知道。您的使用对我们非常重要:[查看](https://github.com/alibaba/arthas/issues/111) + +欢迎关注公众号,获取Arthas项目的信息、源码分析、案例实践。 + +![Arthas公众号](/arthas/scenarios/common-resources/assets/qrcode_gongzhonghao.jpg) + diff --git a/tutorials/katacoda/case-ognl-practise-cn/index.json b/tutorials/katacoda/case-ognl-practise-cn/index.json new file mode 100644 index 000000000..0659314e2 --- /dev/null +++ b/tutorials/katacoda/case-ognl-practise-cn/index.json @@ -0,0 +1,32 @@ +{ + "noindex": true, + "title": "调试 Arthas 的 ognl 表达式", + "description": "调试 Arthas 的 ognl 表达式", + "details": { + "steps": [ + { + "text": "step1.md", + "code": "setup.sh" + } + ], + "intro": { + "text": "intro.md", + "credits": "" + }, + "finish": { + "text": "finish.md" + } + }, + "files": [ + ], + "environment": { + "hidefinish": true, + "hideHiddenFiles": true, + "uilayout": "editor-terminal", + "uisettings": "javascript", + "uieditorpath": "/root/example/ognl-demo" + }, + "backend": { + "imageid": "openjdk:15" + } +} \ No newline at end of file diff --git a/tutorials/katacoda/case-ognl-practise-cn/intro.md b/tutorials/katacoda/case-ognl-practise-cn/intro.md new file mode 100644 index 000000000..bb91575d0 --- /dev/null +++ b/tutorials/katacoda/case-ognl-practise-cn/intro.md @@ -0,0 +1,9 @@ +![Arthas](https://arthas.aliyun.com/doc/_images/arthas.png) + +`Arthas` 是Alibaba开源的Java诊断工具,深受开发者喜爱。在线排查问题,无需重启;动态跟踪Java代码;实时监控JVM状态。 + + +本教程会以一个简单的应用为例,演示如果调试`ognl`表达式。 + +* Github: https://github.com/alibaba/arthas +* 文档: https://arthas.aliyun.com/doc/ \ No newline at end of file diff --git a/tutorials/katacoda/case-ognl-practise-cn/setup.sh b/tutorials/katacoda/case-ognl-practise-cn/setup.sh new file mode 100644 index 000000000..043faca1d --- /dev/null +++ b/tutorials/katacoda/case-ognl-practise-cn/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-cn/step1.md b/tutorials/katacoda/case-ognl-practise-cn/step1.md new file mode 100644 index 000000000..ace129db5 --- /dev/null +++ b/tutorials/katacoda/case-ognl-practise-cn/step1.md @@ -0,0 +1,41 @@ + +演示Arthas里`watch`命令中`ognl`表达式的工作流程。用户可以自己修改`Demo.java`里的表达式,再执行验证。 + +项目地址: https://github.com/hengyunabc/ognl-demo +# 打开Demo.java文件 + +`src/main/java/com/example/ognl/Demo.java`{{open}} + +# 编译运行代码 + +`mvn compile exec:java`{{execute}} + +代码里的表达式: + +```java +String watchExpress = "{target, params, returnObj, #cost}"; +String conditionExpress = "params[0] > 1 && #cost > 0.1"; +``` + +结果类似下面的表达式: + +```bash +watch com.example.ognl.TestService test "{target, params, returnObj, #cost}" "params[0] > 1 && #cost > 0.1" -x 3 +``` + +# 查看函数抛出异常时的表达式结果 + +`mvn compile exec:java -DexceptionCase=true`{{execute}} + +代码里的表达式: + +```java +String watchExpress = "{target, params, throwExp}"; +String conditionExpress = "params[0] > 1"; +``` + +结果类似下面的表达式: + +```bash +watch com.example.ognl.TestService test "{target, params, throwExp}" "params[0] > 1" -e -x 2 +```