Arthas portal has earned nearly 10,000 stars since its launch in September 2018, thanks to the recognition of developers. This Arthas 3.1.0 release brings not only a new LOGO voted for, but also powerful new features and improved ease of use, as described below.

Online tutorials

Arthas has added an online tutorial that allows users to run an online Demo to learn how to use Arthas in a step-by-step way.

  • Arthas Basic tutorial
  • Arthas Advanced Tutorial

You are more than welcome to improve these tutorials.

Added in-memory compiler support, online editing of hot update code

In version 3.1.0, the MC command was added, not in cube game MC, but in Memory Compiler.

In the previous version, re-define was added to hot update bytecode. But there is an inconvenience: you need to upload the.class file to the server.

In version 3.1.0, a combination of JAD/MC/Re-define worked perfectly.

Take the UserController in the Arthas online tutorial for example:

  1. Decompile code using JAD

    jad --source-only com.example.demo.arthas.user.UserController > /tmp/UserController.javaCopy the code
  2. Compile code using VIm

    If the user ID is less than 1, the system returns the same value without raising an exception:

        @GetMapping("/user/{id}")
        public User findUserById(@PathVariable Integer id) {
            logger.info("id: {}" , id);
    
            if(id ! = null && id < 1) {return new User(id, "name" + id);
                // throw new IllegalArgumentException("id < 1");
            } else {
                return new User(id, "name"+ id); }}Copy the code
  3. Compile the modified userController.java using the MC command

    $ mc /tmp/UserController.java -d /tmp
    Memory compiler output:
    /tmp/com/example/demo/arthas/user/UserController.class
    Affect(row-cnt:1) cost in 346 msCopy the code
  4. Use the re-define command because code can be hot updated

    $ redefine /tmp/com/example/demo/arthas/user/UserController.class
    redefine success, size: 1Copy the code

Silky automatic completion

In the new version, improved the automatic completion of many commands, such as watch/trace/tt/monitor/stack, etc.

The following is the first Tab completion result of the watch command. The user can easily complete the class name and function name step by step:

$ watch
com.   sun.   javax. ch.    io.    demo.  jdk.   org.   java.Copy the code

In addition, newly added JAD/SC/SM/Re-define and other commands auto-complete support, more press Tab surprise.

New version of the Web Console

The new version of the Web Console switches to Xtermd.js to better support modern browsers.

  • supportCtrl + Ccopy
  • Support full screen

Docker image support

Arthas now supports Docker images

  • Users can easily diagnose Java processes in Docker/ K8S
  • You can also easily add Arthas to your base image

Reference: alibaba. Making. IO/arthas/dock…

Redirection redesign

In previous versions Arthas was redirected to a ~/logs/arthas-cache/ directory, which was counterintuitive.

In the new version, the redirection is the same as under Linux, and the >/>> behavior is the same as under Linux.

In addition, the cat/ PWD command is added, which can be configured.

conclusion

Overall, Arthas 3.1.0 has a lot of new features and improved user experience, and we welcome feedback.

  • Arthas online tutorials have many tips to learn
  • Jad/MC/Re-define a dragon is very powerful
  • Silky auto completion is worth trying
  • The new version of the Web Console has surprises

The original link

This article is the original content of the cloud habitat community, shall not be reproduced without permission.