分类 技术相关 下的文章

Arthas
Arthas 是一款线上监控诊断产品,通过全局视角实时查看应用 load、内存、gc、线程的状态信息,并能在不修改应用代码的情况下,对业务问题进行诊断,包括查看方法调用的出入参、异常,监测方法执行耗时,类加载信息等,大大提升线上问题排查效率。

官网地址:https://arthas.aliyun.com/

Arthas 是Alibaba开源的Java诊断工具,深受开发者喜爱。当你遇到以下类似问题而束手无策时,Arthas可以帮助你解决:
1、这个类从哪个 jar 包加载的?为什么会报各种类相关的 Exception?
2、我改的代码为什么没有执行到?难道是我没 commit?分支搞错了?
3、遇到问题无法在线上 debug,难道只能通过加日志再重新发布吗?
4、线上遇到某个用户的数据处理有问题,但线上同样无法 debug,线下无法重现!
5、是否有一个全局视角来查看系统的运行状况?
6、有什么办法可以监控到JVM的实时运行状态?
图片

上面是Arthas的官方简介,这次我只需要用他的一个小功能 trace 。动态计算方法调用路径和时间,这样我就可以定位时间在哪个地方被消耗了。
1、trace 方法内部调用路径,并输出方法路径上的每个节点上耗时
2、trace 命令能主动搜索 class-pattern/method-pattern
3、对应的方法调用路径,渲染和统计整个调用链路上的所有性能开销和追踪调用链路。
有了神器,那么该追踪什么方法呢?由于我对Tomcat源码不是很熟,所以只能从spring mvc下手,先来trace一下spring mvc的入口:

Arthas的官方简介

功能介绍

stack 输出当前方法被调用的调用路径
很多时候我们都知道一个方法被执行,但这个方法被执行的路径非常多,或者你根本就不知道这个方法是从那里被执行了,此时你需要的是 stack 命令。

watch方法执行数据观测
让你能方便的观察到指定方法的调用情况。能观察到的范围为:返回值、抛出异常、入参,通过编写 OGNL 表达式进行对应变量的查看。

News on September 22, today, at the International Cloud Summit held in Thailand, Alibaba Cloud announced that it will continue to accelerate its overseas market layout, invest 7 billion yuan in the next three years to build an international localized ecosystem, and add 6 overseas service centers. Porto, Mexico City, Kuala Lumpur, Dubai, etc.

Alibaba Cloud's
In the past year, Alibaba Cloud has added seven overseas data centers in South Korea, Thailand, Germany, Indonesia, the Philippines, and Saudi Arabia. Currently, Alibaba Cloud operates 85 availability zones in 28 regions around the world, covering more than 200 countries and regions around the world.

In terms of product technology, Alibaba Cloud announced the launch of the eighth-generation ECS cloud server, cloud box, enterprise networking CEN2.0, container service ACK ONE, self-developed database PolarDB-X, self-developed multimodal database Lindorm and other international versions.

According to Canalys data, spending on cloud infrastructure services in mainland China increased by 11% year-on-year to reach $7.3 billion in the second quarter of 2022, accounting for 12% of overall global cloud spending. Among them, Alibaba Cloud accounted for 34% of the market share this quarter, an increase of about 10% year-on-year.

springboot
使用springcloud的时候要注意spring cloud和spring boot的版本是有对应关系的,如果使用了不对应的版本,往往会导致一些奇奇怪怪得bug;
具体对应关系可以通过官方给的网址来获取:https://start.spring.io/actuator/info
访问该网址后可以得到一个json,通过这个json来获得对应版本,格式化可以使用https://www.bejson.com/进行格式化
例如:查看Spring cloud和spring boot的版本对应关系:
spring cloud和spring boot的版本

17042-2ipydmtus8e.png

docker exec 的使用-it操作
首先进入容器:
docker命令
docker exec -it CONTAINER_ID bash 进入容器终端并且的保留为容器终端的输入形式(-it和bash的结合作用)

官方解释:
exec: Run a command in a running container(在运行的容器中运行命令)
exec -i: --interactive(相互作用的)
exec -t: --tty Allocate a pseudo-TTY(分配一个 冒充的终端设备)
CONTAINER_ID : 容器id只要是能够证明唯一就可以,不用全输入例子:

查看正在运行的容器:

docker Ps

进入容器

进入容器命令
docker exec -it CONTAINER_ID bash 进入容器终端并且的保留为容器终端的输入形式.

1.抽象类

跟普通类没啥区别,只是多了抽象方法。不能new。
属于顶层设计,定义出共有的属性和方法。含有抽象方法一定是抽象类

抽象类跟接口区别

2.接口

更严格,不能new,定义的变量都是常量 public static final,默认的可忽略
只能有抽象方法,默认就是public abstract 可以忽略。
不能有构造方法
jdk1.8之后,放宽条件、
可以 defalut关键字声明普通方法、静态方法

使用场景:
抽象类,一般用于含有共有属性及功能的抽取,如人。java是单继承,继承后可以有男人女人

接口,可以多实现、继承,解耦,多态。 动物>>狗和猫,而狗和猫的差别很大,属于多态。

父接口引用,指向一个具体的实现类,体现多态,如参数是接口,但是传入的类型可以是不同的实现类。
同理。父类指向一个子类的引用,可以调用父类方法,要想调用子类方法,需要向下转型。

免责声明
本博客部分内容来自于互联网,不代表作者的观点和立场,如若侵犯到您的权益,请联系[email protected]。我们会在24小时内进行删除。