当前位置: 首页 > news >正文

SpringCloud学习笔记 - @SentinelResource的fallbackblockHandler配置详解 - sentinel

1. sentinel服务负载均衡测试

sentinel默认开启了负载均衡的轮询模式,为了测试sentinel服务负载均衡的效果,需要先创建两个服务提供者和一个服务消费者。

1.1. 分别创建两个服务提供者-支付服务9003、9004

1. 添加pom依赖: 提供者只需要将自己注册到服务注册中心即可,因此只需要添加spring-cloud-starter-alibaba-nacos-discovery。

	<dependencies><!--自定义api--><dependency><groupId>com.atguigu.springboot</groupId><artifactId>cloud-api-commons</artifactId><version>1.0-SNAPSHOT</version></dependency><!--nacos服务发现--><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId></dependency><!--springboot web--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><!--日常通用jar包--><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId><scope>runtime</scope><optional>true</optional></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies>

2. 编写yaml配置文件: 注意给两个服务分配不同的端口9003、9004

server:port: 9003spring:application:name: nacos-payment-providercloud:nacos:discovery:server-addr: localhost:8848management:endpoints:web:exposure:include: "*"

3. 创建主启动类

@SpringBootApplication
@EnableDiscoveryClient
public class PaymentMain9003 {public static void main(String[] args) {SpringApplication.run(PaymentMain9003.class,args);}
}

4. 创建业务类

package com.atguigu.alibaba.controller;import com.atguigu.springcloud.entities.CommonResult;
import com.atguigu.springcloud.entities.Payment;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;import java.util.HashMap;/*** @author 强浩* @version 1.0.0* Copyright(c) YTANG All Rights Reserved* @className* @project 管理系统* @date 2022年09月14日*/
@RestController
@Slf4j
public class PaymentController {@Value("${server.port}")private String serverPort;//模拟数据库public static HashMap<Long, Payment> hashMap = new HashMap<>();static {hashMap.put(1L, new Payment(1L,"28a8c1e3bc2742d8848569891fb42181"));hashMap.put(2L,new Payment(2L,"bba8c1e3bc2742d8848569891ac32182"));hashMap.put(3L,new Payment(3L,"6ua8c1e3bc2742d8848569891xt92183"));}//传入id获取数据@GetMapping(value = "/paymentSQL/{id}")public CommonResult<Payment> paymentSQL(@PathVariable("id") Long id){Payment payment = hashMap.get(id);CommonResult<Payment> commonResult = new CommonResult(200, "from mysql,serverPort:  " + serverPort, payment);return commonResult;}
}

2. 创建服务消费者-订单服务84

1. 添加pom依赖: 因为之后需要使用sentinel进行限流,所以需要添加sentinel的依赖

    <dependencies><dependency><groupId>com.atguigu.springboot</groupId><artifactId>cloud-api-commons</artifactId><version>1.0-SNAPSHOT</version></dependency><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId></dependency><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-sentinel</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId><scope>runtime</scope><optional>true</optional></dependency><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies>

2. 配置application.yaml文件:

server:port: 84spring:application:name: nacos-order-consumercloud:nacos:discovery:server-addr: localhost:8848sentinel:transport:dashboard: localhost:8080port: 8719server_url:payment_provider: http://nacos-payment-provider

3. 创建主启动类:

@SpringBootApplication
@EnableDiscoveryClient
public class OrderMain84 {public static void main(String[] args) {SpringApplication.run(OrderMain84.class,args);}
}

4. 创建RestTemplate服务调用配置类:

package com.atgugui.alibaba.config;import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;/*** @author 强浩* @version 1.0.0* Copyright(c) YTANG All Rights Reserved* @className* @project 管理系统* @date 2022年09月14日*/
@Configuration
public class ApplicationContextConfig {@Bean@LoadBalancedpublic RestTemplate getRestTemplate(){return new RestTemplate();}
}

5. 创建业务类: 注入RestTemplate进行远程服务调用

package com.atgugui.alibaba.controller;import com.atguigu.springcloud.entities.CommonResult;
import com.atguigu.springcloud.entities.Payment;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.client.RestTemplate;import javax.annotation.Resource;/*** @author 强浩* @version 1.0.0* Copyright(c) YTANG All Rights Reserved* @className* @project 管理系统* @date 2022年09月14日*/
@RestController
@Slf4j
public class CircleBreakerController {public static final String SERVER_URL = "http://nacos-payment-provider";@Resourceprivate RestTemplate restTemplate;@GetMapping("/consumer/fallback/{id}")public CommonResult<Payment> fallback(@PathVariable("id") Long id){CommonResult<Payment> result = restTemplate.getForObject(SERVER_URL + "/paymentSQL/" + id, CommonResult.class, id);if(id == 4){throw new IllegalArgumentException ("IllegalArgumentException,非法参数异常....");}else if(result.getData() == null){throw new NullPointerException ("NullPointerException,该ID没有对应记录,空指针异常");}return result;}
}

5. 测试访问: 查看负载均衡的轮询效果
访问 http://localhost:84/consumer/fallback/1,多次访问,通过观察端口号可以发现,对支付服务进行了轮询访问。

2. fallback-业务错误处理

fallback只负责业务异常

1. 添加@SentinelResource注解,并配置fallback参数,指定服务降级处理方法

    @GetMapping("/consumer/fallback/{id}")@SentinelResource(value = "fallback", fallback = "handlerFallback")//指定fallback服务降级处理方法public CommonResult<Payment> fallback(@PathVariable("id") Long id){CommonResult<Payment> result = restTemplate.getForObject(SERVER_URL + "/paymentSQL/" + id, CommonResult.class, id);if(id == 4){throw new IllegalArgumentException ("IllegalArgumentException,非法参数异常....");}else if(result.getData() == null){throw new NullPointerException ("NullPointerException,该ID没有对应记录,空指针异常");}return result;}public CommonResult<Payment> handlerFallback(@PathVariable Long id,Throwable e){Payment payment = new Payment(id,"null");return new CommonResult<>(444,"兜底异常handlerFallback,exception内容  "+e.getMessage(),payment);}

2. 测试: http://localhost:84/consumer/fallback/5,在没有降级处理的时候会直接报错,添加了fallback后进入降级处理方法。
在这里插入图片描述

3. blockHandler-限流规则处理

blockHandler处理违反了限流规则的请求

1. 给fallback方法资源添加限流规则
在这里插入图片描述

2. 配置@SentinelResource的blockHandler参数指定流控服务降级方法

    @GetMapping("/consumer/fallback/{id}")@SentinelResource(value = "fallback", blockHandler = "blockHandler")public CommonResult<Payment> fallback(@PathVariable("id") Long id){CommonResult<Payment> result = restTemplate.getForObject(SERVER_URL + "/paymentSQL/" + id, CommonResult.class, id);if(id == 4){throw new IllegalArgumentException ("IllegalArgumentException,非法参数异常....");}else if(result.getData() == null){throw new NullPointerException ("NullPointerException,该ID没有对应记录,空指针异常");}return result;}public CommonResult<Payment> blockHandler(@PathVariable Long id, BlockException blockException){Payment payment = new Payment(id,"null");return new CommonResult<>(445,"blockHandler-sentinel限流,无此流水: blockException  "+blockException.getMessage(),payment);}

3. 测试:http://localhost:84/consumer/fallback/5
在这里插入图片描述

4. 服务熔断fallback和blockHandler同时配置

blockHandler和fallback 都进行了配置,则被限流降级而抛出BlockException时只会进入blockHandler处理逻辑。也就是说会优先处理服务限流,保证高可用,不要卡死服务器。

@RestController
@Slf4j
public class CircleBreakerController {public static final String SERVER_URL = "http://nacos-payment-provider";@Resourceprivate RestTemplate restTemplate;@GetMapping("/consumer/fallback/{id}")@SentinelResource(value = "fallback", blockHandler = "blockHandler", fallback = "handlerFallback")public CommonResult<Payment> fallback(@PathVariable("id") Long id){CommonResult<Payment> result = restTemplate.getForObject(SERVER_URL + "/paymentSQL/" + id, CommonResult.class, id);if(id == 4){throw new IllegalArgumentException ("IllegalArgumentException,非法参数异常....");}else if(result.getData() == null){throw new NullPointerException ("NullPointerException,该ID没有对应记录,空指针异常");}return result;}public CommonResult handlerFallback(@PathVariable  Long id,Throwable e) {Payment payment = new Payment(id,"null");return new CommonResult<>(444,"兜底异常handlerFallback,exception内容  "+e.getMessage(),payment);}public CommonResult<Payment> blockHandler(@PathVariable Long id, BlockException blockException){Payment payment = new Payment(id,"null");return new CommonResult<>(445,"blockHandler-sentinel限流,无此流水: blockException  "+blockException.getMessage(),payment);}
}

5. exceptionsToIgnore忽略指定异常

@RestController
@Slf4j
public class CircleBreakerController {public static final String SERVER_URL = "http://nacos-payment-provider";@Resourceprivate RestTemplate restTemplate;@GetMapping("/consumer/fallback/{id}")@SentinelResource(value = "fallback", blockHandler = "blockHandler", fallback = "handlerFallback",exceptionsToIgnore = IllegalArgumentException.class)public CommonResult<Payment> fallback(@PathVariable("id") Long id){CommonResult<Payment> result = restTemplate.getForObject(SERVER_URL + "/paymentSQL/" + id, CommonResult.class, id);if(id == 4){throw new IllegalArgumentException ("IllegalArgumentException,非法参数异常....");}else if(result.getData() == null){throw new NullPointerException ("NullPointerException,该ID没有对应记录,空指针异常");}return result;}public CommonResult handlerFallback(@PathVariable  Long id,Throwable e) {Payment payment = new Payment(id,"null");return new CommonResult<>(444,"兜底异常handlerFallback,exception内容  "+e.getMessage(),payment);}public CommonResult<Payment> blockHandler(@PathVariable Long id, BlockException blockException){Payment payment = new Payment(id,"null");return new CommonResult<>(445,"blockHandler-sentinel限流,无此流水: blockException  "+blockException.getMessage(),payment);}}

设置了忽略IllegalArgumentException异常,当出现该异常时不会进入降级逻辑。
在这里插入图片描述

6. sentinel整合openFeign实现服务熔断降级

一般在消费端添加feign组件实现服务降级:在84消费端添加openFeign的依赖,实现服务的熔断降级。

1. 引入openFeign的pom依赖: 这里因为版本冲突问题,需要将devtools组件取消掉,目前具体冲突原因还不知道。

<dependencies><dependency><groupId>com.atguigu.springboot</groupId><artifactId>cloud-api-commons</artifactId><version>1.0-SNAPSHOT</version></dependency><dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-nacos-discovery</artifactId></dependency><!--添加openFeign依赖--><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId></dependency><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-alibaba-sentinel</artifactId><version>0.2.2.RELEASE</version></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-web</artifactId></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-actuator</artifactId></dependency><!--<dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-devtools</artifactId><scope>runtime</scope><optional>true</optional></dependency>--><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><optional>true</optional></dependency><dependency><groupId>org.springframework.boot</groupId><artifactId>spring-boot-starter-test</artifactId><scope>test</scope></dependency></dependencies>

2. 修改yaml文件,添加fegin对sentinel的支持:

server:port: 84spring:application:name: nacos-order-consumercloud:nacos:discovery:server-addr: localhost:8848sentinel:transport:dashboard: localhost:8080port: 8719server_url:payment_provider: http://nacos-payment-providerfeign:sentinel:enabled: true

3. 在主启动类开启openFeign:

@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
public class OrderMain84 {public static void main(String[] args) {SpringApplication.run(OrderMain84.class,args);}
}

4. 编写业务类: 使用@FeignClient注解,指定要进行访问的微服务名称,和发生熔断时所要调用的fallback方法

@FeignClient(value = "nacos-payment-provider",fallback = PaymentFallbackServiceImpl.class)
public interface PaymentService {@GetMapping(value = "/paymentSQL/{id}")public CommonResult<Payment> paymentSQL(@PathVariable("id") Long id);
}

5. 服务降级方法实现类: 相当于给PaymentService增加了一个实现类,在发生熔断的情况下自动调用方法的fallback实现,来快速返回结果,防止系统卡死。

@Service
public class PaymentFallbackServiceImpl implements PaymentService {@Overridepublic CommonResult<Payment> paymentSQL(Long id) {return new CommonResult<>(44444,"服务降级返回,---PaymentFallbackService",new Payment(id,"errorSerial"));}
}

6. 现在就可以使用openFeign进行远程服务调用,我们只需要像之前一样将服务接口注入到controller层中,即可实现无感的远程服务调用了:

@RestController
@Slf4j
public class CircleBreakerController {//注入openFeign远程调用接口@Resourceprivate PaymentService paymentService;@GetMapping(value = "/consumer/paymentSQL/{id}")public CommonResult<Payment> paymentSQL(@PathVariable("id") Long id){CommonResult<Payment> result = paymentService.paymentSQL(id);return result;}
}

7. 测试: 访问 http://localhost:84/consumer/paymentSQL/2,此时将9003服务提供者断开,84消费侧自动降级,不会被耗死。
在这里插入图片描述

7. 各熔断框架比较

SentinelHystrixresilience4j
隔离策略信号量隔离(并发线程数限流)线程池隔商/信号量隔离信号量隔离
熔断降级策略基于响应时间、异常比率、异常数基于异常比率基于异常比率、响应时间
实时统计实现滑动窗口(LeapArray)滑动窗口(基于RxJava)Ring Bit Buffer
动态规则配置支持多种数据源支持多种数据源有限支持
拓展性多个扩展点插件的形式接口的形式
基于注解的支持支持支持支持
限流基于QPS,支持基于调用关系的限流有限的支持Rate Limiter
流量整形支持预热模式匀速器模式、预热排队模式不支持简单的Rate Limiter模式
系统自适应保护支持不支持不支持
控制台提供开箱即用的控制台,可配置规则、查看秒级监控,机器发观等简单的监控查看不提供控制台,可对接其它监控系统

相关文章:

SpringCloud学习笔记 - @SentinelResource的fallbackblockHandler配置详解 - sentinel

1. sentinel服务负载均衡测试 sentinel默认开启了负载均衡的轮询模式&#xff0c;为了测试sentinel服务负载均衡的效果&#xff0c;需要先创建两个服务提供者和一个服务消费者。 1.1. 分别创建两个服务提供者-支付服务9003、9004 1. 添加pom依赖&#xff1a; 提供者只需要将…...

华为OD机试题 - 静态扫描最优成本(JavaScript)

最近更新的博客 2023新华为OD机试题 - 斗地主(JavaScript)2023新华为OD机试题 - 箱子之形摆放(JavaScript)2023新华为OD机试题 - 考古学家(JavaScript)2023新华为OD机试题 - 相同数字的积木游戏 1(JavaScript)2023新华为OD机试题 - 最多等和不相交连续子序列(JavaScri…...

mysql大数据量批量提交

DROP PROCEDURE IF EXISTS test.insert_bacth_commit_test1;CREATE PROCEDURE test.insert_bacth_commit_test1()begindeclare start_num int default 0; -- 初始设置起始行数declare end_num int default 5;-- 初始设施结束行数declare cnt_srouce int default 0; -- 定义源表…...

IP SAN组网配置

目录一、确认网络连接畅通二、服务器端ISCSI启动器配置1.以root身份登录2.验证是否已安装iSCSI启动器3.安装iSCSI启动器4.启动iSCSI服务5.给iSCSI启动器命名6.扫描目标器7.登录目标器8.将登录目标器行为设置为自启动三、主机多路径配置四、存储配置五、主机挂载背景&#xff1a…...

面试7分看能力,3分靠嘴皮,剩下90分就靠这份Java面试八股文

有句话说的好&#xff0c;面试中7分靠能力&#xff0c;3分靠嘴皮刚开始面试的时候&#xff0c;介绍项目一般都是凸显我们技能的重中之重&#xff0c;它对一次面试的成败可以说具有决定性作用&#xff0c;这就涉及到我们的表达能力了&#xff0c;有人说我其实水平都在线&#xf…...

api接口如何对接?

对于很多产品小白或求职者而言&#xff0c;API接口是一个产品和研发领域的专业术语&#xff0c;大家可能在文章或者PRD中都已经有接触过API接口的概念。 实际上&#xff0c;接口的应用已经非常广泛和成熟&#xff0c;这个概念主要活跃在公司内部的各系统之间的衔接和对接以及公…...

毕业2年不到选择跳槽,居然拿到25K的薪资,简直了···

本人本科就读于某普通院校&#xff0c;毕业后通过同学的原因加入软件测试这个行业&#xff0c;角色也从测试小白到了目前的资深工程师&#xff0c;从功能测试转变为测试开发&#xff0c;并顺利拿下了某二线城市互联网企业的Offer&#xff0c;年薪 30W 。 选择和努力哪个重要&am…...

Java反序列化漏洞——CommonsCollections3链分析

一、原理CC1链中我们是通过调用Runtime.getRuntime.exec()来执行系统命令&#xff0c;而另一个方向我们可以通过TemplatesImpl加载字节码的类&#xff0c;通过调⽤其newTransformer() 方法&#xff0c;即可执⾏这段字节码的类构造器&#xff0c;我们在类构造器中加入恶意代码&a…...

英文论文(sci)解读复现【NO.5】让RepVGG再次变得更强大:一种量化感知方法

此前出了目标检测算法改进专栏&#xff0c;但是对于应用于什么场景&#xff0c;需要什么改进方法对应与自己的应用场景有效果&#xff0c;并且多少改进点能发什么水平的文章&#xff0c;为解决大家的困惑&#xff0c;此系列文章旨在给大家解读发表高水平学术期刊中的SCI论文&am…...

hive学习(仅供参考)

hive搭建Hive什么是hiveHive的优势和特点hive搭建解压、改名修改环境变量添加hive-site.xml将maven架包拷贝到hive替换一下gua包使环境变量生效初始化安装成功Hive 什么是hive 将结构化的数据文件映射为数据库表 提供类sql的查询语言HQL(Hive Query Language) Hive让更多的人…...

新生儿住月子中心20天患败血症 什么是败血症?有哪些危害

12月7日&#xff0c;四川眉山市民唐先生说&#xff0c;他刚出生的儿子在妇产医院分娩中心住了20天后感染了败血症。据唐先生介绍&#xff0c;哈子出院时各项指标正常。他在分娩中心住了半个月左右&#xff0c;孩子喝牛奶异常易怒&#xff0c;第二天开始发烧。当天&#xff0c;在…...

2023年美赛赛题A题赛题公布

问题A:遭受旱灾的植物群落背景不同种类的植物对压力的反应方式不同。例如&#xff0c;草原是相当的对干旱敏感。干旱发生的频率和严重程度各不相同。大量的观察表明&#xff0c;不同物种的数量在一个物种如何生长的过程中起着重要作用植物群落在连续几代的干旱周期中适应。在一…...

交互式前端开发最好用的WebGL框架

JavaScript是创建Web最有用的编程语言之一&#xff0c;尤其是在WebGL库的支持下。有了WebGL&#xff0c;可以很方便地使用 HTML5 Canvas 元素动态生成图形。因此&#xff0c;设计师和开发人员很容易创建流畅的2D和3D效果。WebGL是JavaScript API或基于OpenGL的库&#xff0c;它…...

【Java 面试合集】包装类的缓存问题

包装类的缓存问题1. 概述 嗨&#xff0c;大家好&#xff0c;【Java 面试合集】每日一题又来了。今天我们分享的内容是&#xff1a;包装类的缓存问题。 我们下面的案例以Integer 为例 2. 表现 public class TestCache {public static void main(String[] args) {Integer i 127…...

JAVA PYTHONGOLANG在STR LIST MAP 等数据结构的一些底层设计

一、列表和扩容机制 JAVA的列表主要分为list和vector,list是线程不安全的。list又主要分为ArrayList和LinkedList,ArrayList底层通过object数组实现,可以实现快速查找,LinkedList底层通过双向列表实现。java常用的列表实现类为ArrayList,ArrayList的主要源码如下: publi…...

SpringMVC处理ajax请求

RequestBodyRequestBody:将请求体中的内容和控制器方法的形参进行绑定。使用RequestBody注解将json格式请求参数转换为java对象。条件&#xff1a;1. 导入jackson依赖 (默认调用jackson功能实现的)2. 在springmvc的配置文件中设置开启<mvc:annotation-driven/>3. 在处理请…...

Spire.Office 8.2.2 for NET 开年之喜

Spire.Office for .NET对文档的操作包括打开&#xff0c;创建&#xff0c;修改&#xff0c;转换&#xff0c;打印&#xff0c;浏览 Word、Excel、PowerPoint 和 PDF 文档&#xff0c;以及将数据从数据源导出为常用的文档格式&#xff0c;如&#xff1a;Word&#xff0c;Excel&a…...

python中的.nc文件处理 | 04 利用矢量边界提取NC数据

利用矢量边界提取.nc数据 import osimport numpy as np import pandas as pd import matplotlib.pyplot as plt import cartopy.crs as ccrs import cartopy.feature as cfeature import seaborn as sns import geopandas as gpd import earthpy as et import xarray as xr # …...

使用 PyNeuraLogic 超越 Transformers

展示神经符号编程的力量neuro-symbolic1. 简介 在过去的几年里&#xff0c;我们看到了基于 Transformer 的模型的兴起&#xff0c;并在自然语言处理或计算机视觉等许多领域取得了成功的应用。在本文[1]中&#xff0c;我们将探索一种简洁、可解释和可扩展的方式来表达深度学习模…...

微信点金计划(服务商角度)

时间&#xff1a;2023/2/17 背景&#xff1a;微信在推出点金计划后&#xff0c;原本window.WeixinJSBridge.invoke方法的回调失效了&#xff0c;需要在微信支付服务商平台&#xff5c;平台开放更多能力&#xff0c;与服务商一起成长这里进行配置&#xff0c;配置流程跟着官方给…...

Vim 调用外部命令学习笔记

Vim 外部命令集成完全指南 文章目录 Vim 外部命令集成完全指南核心概念理解命令语法解析语法对比 常用外部命令详解文本排序与去重文本筛选与搜索高级 grep 搜索技巧文本替换与编辑字符处理高级文本处理编程语言处理其他实用命令 范围操作示例指定行范围处理复合命令示例 实用技…...

网络六边形受到攻击

大家读完觉得有帮助记得关注和点赞&#xff01;&#xff01;&#xff01; 抽象 现代智能交通系统 &#xff08;ITS&#xff09; 的一个关键要求是能够以安全、可靠和匿名的方式从互联车辆和移动设备收集地理参考数据。Nexagon 协议建立在 IETF 定位器/ID 分离协议 &#xff08;…...

Redis相关知识总结(缓存雪崩,缓存穿透,缓存击穿,Redis实现分布式锁,如何保持数据库和缓存一致)

文章目录 1.什么是Redis&#xff1f;2.为什么要使用redis作为mysql的缓存&#xff1f;3.什么是缓存雪崩、缓存穿透、缓存击穿&#xff1f;3.1缓存雪崩3.1.1 大量缓存同时过期3.1.2 Redis宕机 3.2 缓存击穿3.3 缓存穿透3.4 总结 4. 数据库和缓存如何保持一致性5. Redis实现分布式…...

在HarmonyOS ArkTS ArkUI-X 5.0及以上版本中,手势开发全攻略:

在 HarmonyOS 应用开发中&#xff0c;手势交互是连接用户与设备的核心纽带。ArkTS 框架提供了丰富的手势处理能力&#xff0c;既支持点击、长按、拖拽等基础单一手势的精细控制&#xff0c;也能通过多种绑定策略解决父子组件的手势竞争问题。本文将结合官方开发文档&#xff0c…...

Linux相关概念和易错知识点(42)(TCP的连接管理、可靠性、面临复杂网络的处理)

目录 1.TCP的连接管理机制&#xff08;1&#xff09;三次握手①握手过程②对握手过程的理解 &#xff08;2&#xff09;四次挥手&#xff08;3&#xff09;握手和挥手的触发&#xff08;4&#xff09;状态切换①挥手过程中状态的切换②握手过程中状态的切换 2.TCP的可靠性&…...

STM32F4基本定时器使用和原理详解

STM32F4基本定时器使用和原理详解 前言如何确定定时器挂载在哪条时钟线上配置及使用方法参数配置PrescalerCounter ModeCounter Periodauto-reload preloadTrigger Event Selection 中断配置生成的代码及使用方法初始化代码基本定时器触发DCA或者ADC的代码讲解中断代码定时启动…...

相机从app启动流程

一、流程框架图 二、具体流程分析 1、得到cameralist和对应的静态信息 目录如下: 重点代码分析: 启动相机前,先要通过getCameraIdList获取camera的个数以及id,然后可以通过getCameraCharacteristics获取对应id camera的capabilities(静态信息)进行一些openCamera前的…...

大学生职业发展与就业创业指导教学评价

这里是引用 作为软工2203/2204班的学生&#xff0c;我们非常感谢您在《大学生职业发展与就业创业指导》课程中的悉心教导。这门课程对我们即将面临实习和就业的工科学生来说至关重要&#xff0c;而您认真负责的教学态度&#xff0c;让课程的每一部分都充满了实用价值。 尤其让我…...

图表类系列各种样式PPT模版分享

图标图表系列PPT模版&#xff0c;柱状图PPT模版&#xff0c;线状图PPT模版&#xff0c;折线图PPT模版&#xff0c;饼状图PPT模版&#xff0c;雷达图PPT模版&#xff0c;树状图PPT模版 图表类系列各种样式PPT模版分享&#xff1a;图表系列PPT模板https://pan.quark.cn/s/20d40aa…...

短视频矩阵系统文案创作功能开发实践,定制化开发

在短视频行业迅猛发展的当下&#xff0c;企业和个人创作者为了扩大影响力、提升传播效果&#xff0c;纷纷采用短视频矩阵运营策略&#xff0c;同时管理多个平台、多个账号的内容发布。然而&#xff0c;频繁的文案创作需求让运营者疲于应对&#xff0c;如何高效产出高质量文案成…...