spring security + oauth2 使用RedisTokenStore 以json格式存储

1.项目架构

 2.自己对 TokenStore 的 redis实现

package com.enterprise.auth.config;import org.springframework.data.redis.connection.RedisConnection;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.core.Cursor;
import org.springframework.data.redis.core.ScanOptions;
import org.springframework.security.oauth2.common.ExpiringOAuth2RefreshToken;
import org.springframework.security.oauth2.common.OAuth2AccessToken;
import org.springframework.security.oauth2.common.OAuth2RefreshToken;
import org.springframework.security.oauth2.provider.OAuth2Authentication;
import org.springframework.security.oauth2.provider.token.AuthenticationKeyGenerator;
import org.springframework.security.oauth2.provider.token.DefaultAuthenticationKeyGenerator;
import org.springframework.security.oauth2.provider.token.TokenStore;
import org.springframework.security.oauth2.provider.token.store.redis.JdkSerializationStrategy;
import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStore;
import org.springframework.security.oauth2.provider.token.store.redis.RedisTokenStoreSerializationStrategy;
import org.springframework.util.ClassUtils;
import org.springframework.util.ReflectionUtils;import java.lang.reflect.Method;
import java.nio.charset.StandardCharsets;
import java.util.*;public class MyRedisTokenStore implements TokenStore {private static final String ACCESS = "access:";private static final String AUTH_TO_ACCESS = "auth_to_access:";private static final String AUTH = "auth:";private static final String REFRESH_AUTH = "refresh_auth:";private static final String ACCESS_TO_REFRESH = "access_to_refresh:";private static final String REFRESH = "refresh:";private static final String REFRESH_TO_ACCESS = "refresh_to_access:";private static final String CLIENT_ID_TO_ACCESS = "client_id_to_access:";private static final String UNAME_TO_ACCESS = "uname_to_access:";private static final boolean springDataRedis_2_0 = ClassUtils.isPresent("org.springframework.data.redis.connection.RedisStandaloneConfiguration", RedisTokenStore.class.getClassLoader());private final RedisConnectionFactory connectionFactory;private AuthenticationKeyGenerator authenticationKeyGenerator = new DefaultAuthenticationKeyGenerator();private RedisTokenStoreSerializationStrategy serializationStrategy = new MyRedisTokenStoreSerializationStrategy();private String prefix = "";private Method redisConnectionSet_2_0;public MyRedisTokenStore(RedisConnectionFactory connectionFactory) {this.connectionFactory = connectionFactory;if (springDataRedis_2_0) {this.loadRedisConnectionMethods_2_0();}}public void setAuthenticationKeyGenerator(AuthenticationKeyGenerator authenticationKeyGenerator) {this.authenticationKeyGenerator = authenticationKeyGenerator;}public void setSerializationStrategy(RedisTokenStoreSerializationStrategy serializationStrategy) {this.serializationStrategy = serializationStrategy;}public void setPrefix(String prefix) {this.prefix = prefix;}private void loadRedisConnectionMethods_2_0() {this.redisConnectionSet_2_0 = ReflectionUtils.findMethod(RedisConnection.class, "set", new Class[]{byte[].class, byte[].class});}private RedisConnection getConnection() {return this.connectionFactory.getConnection();}private byte[] serialize(Object object) {return this.serializationStrategy.serialize(object);}private byte[] serializeKey(String object) {return this.serialize(this.prefix + object);}private OAuth2AccessToken deserializeAccessToken(byte[] bytes) {return (OAuth2AccessToken)this.serializationStrategy.deserialize(bytes, OAuth2AccessToken.class);}private OAuth2Authentication deserializeAuthentication(byte[] bytes) {return (OAuth2Authentication)this.serializationStrategy.deserialize(bytes, OAuth2Authentication.class);}private OAuth2RefreshToken deserializeRefreshToken(byte[] bytes) {return (OAuth2RefreshToken)this.serializationStrategy.deserialize(bytes, OAuth2RefreshToken.class);}private byte[] serialize(String string) {return this.serializationStrategy.serialize(string);}private String deserializeString(byte[] bytes) {return this.serializationStrategy.deserializeString(bytes);}public OAuth2AccessToken getAccessToken(OAuth2Authentication authentication) {String key = this.authenticationKeyGenerator.extractKey(authentication);byte[] serializedKey = this.serializeKey("auth_to_access:" + key);byte[] bytes = null;RedisConnection conn = this.getConnection();try {bytes = conn.get(serializedKey);} finally {conn.close();}OAuth2AccessToken accessToken = this.deserializeAccessToken(bytes);if (accessToken != null) {OAuth2Authentication storedAuthentication = this.readAuthentication(accessToken.getValue());if (storedAuthentication == null || !key.equals(this.authenticationKeyGenerator.extractKey(storedAuthentication))) {this.storeAccessToken(accessToken, authentication);}}return accessToken;}public OAuth2Authentication readAuthentication(OAuth2AccessToken token) {return this.readAuthentication(token.getValue());}public OAuth2Authentication readAuthentication(String token) {byte[] bytes = null;RedisConnection conn = this.getConnection();try {bytes = conn.get(this.serializeKey("auth:" + token));} finally {conn.close();}OAuth2Authentication var4 = this.deserializeAuthentication(bytes);return var4;}public OAuth2Authentication readAuthenticationForRefreshToken(OAuth2RefreshToken token) {return this.readAuthenticationForRefreshToken(token.getValue());}public OAuth2Authentication readAuthenticationForRefreshToken(String token) {RedisConnection conn = this.getConnection();OAuth2Authentication var5;try {byte[] bytes = conn.get(this.serializeKey("refresh_auth:" + token));OAuth2Authentication auth = this.deserializeAuthentication(bytes);var5 = auth;} finally {conn.close();}return var5;}public void storeAccessToken(OAuth2AccessToken token, OAuth2Authentication authentication) {byte[] serializedAccessToken = this.serialize((Object)token);byte[] serializedAuth = this.serialize((Object)authentication);byte[] accessKey = this.serializeKey("access:" + token.getValue());byte[] authKey = this.serializeKey("auth:" + token.getValue());byte[] authToAccessKey = this.serializeKey("auth_to_access:" + this.authenticationKeyGenerator.extractKey(authentication));byte[] approvalKey = this.serializeKey("uname_to_access:" + getApprovalKey(authentication));byte[] clientId = this.serializeKey("client_id_to_access:" + authentication.getOAuth2Request().getClientId());RedisConnection conn = this.getConnection();try {conn.openPipeline();if (springDataRedis_2_0) {try {this.redisConnectionSet_2_0.invoke(conn, accessKey, serializedAccessToken);this.redisConnectionSet_2_0.invoke(conn, authKey, serializedAuth);this.redisConnectionSet_2_0.invoke(conn, authToAccessKey, serializedAccessToken);} catch (Exception var24) {throw new RuntimeException(var24);}} else {conn.set(accessKey, serializedAccessToken);conn.set(authKey, serializedAuth);conn.set(authToAccessKey, serializedAccessToken);}if (!authentication.isClientOnly()) {conn.sAdd(approvalKey, new byte[][]{serializedAccessToken});}conn.sAdd(clientId, new byte[][]{serializedAccessToken});if (token.getExpiration() != null) {int seconds = token.getExpiresIn();conn.expire(accessKey, (long)seconds);conn.expire(authKey, (long)seconds);conn.expire(authToAccessKey, (long)seconds);conn.expire(clientId, (long)seconds);conn.expire(approvalKey, (long)seconds);}OAuth2RefreshToken refreshToken = token.getRefreshToken();if (refreshToken != null && refreshToken.getValue() != null) {byte[] refresh = this.serialize(token.getRefreshToken().getValue());byte[] auth = this.serialize(token.getValue());byte[] refreshToAccessKey = this.serializeKey("refresh_to_access:" + token.getRefreshToken().getValue());byte[] accessToRefreshKey = this.serializeKey("access_to_refresh:" + token.getValue());if (springDataRedis_2_0) {try {this.redisConnectionSet_2_0.invoke(conn, refreshToAccessKey, auth);this.redisConnectionSet_2_0.invoke(conn, accessToRefreshKey, refresh);} catch (Exception var23) {throw new RuntimeException(var23);}} else {conn.set(refreshToAccessKey, auth);conn.set(accessToRefreshKey, refresh);}if (refreshToken instanceof ExpiringOAuth2RefreshToken) {ExpiringOAuth2RefreshToken expiringRefreshToken = (ExpiringOAuth2RefreshToken)refreshToken;Date expiration = expiringRefreshToken.getExpiration();if (expiration != null) {int seconds = Long.valueOf((expiration.getTime() - System.currentTimeMillis()) / 1000L).intValue();conn.expire(refreshToAccessKey, (long)seconds);conn.expire(accessToRefreshKey, (long)seconds);}}}conn.closePipeline();} finally {conn.close();}}private static String getApprovalKey(OAuth2Authentication authentication) {String userName = authentication.getUserAuthentication() == null ? "" : authentication.getUserAuthentication().getName();return getApprovalKey(authentication.getOAuth2Request().getClientId(), userName);}private static String getApprovalKey(String clientId, String userName) {return clientId + (userName == null ? "" : ":" + userName);}public void removeAccessToken(OAuth2AccessToken accessToken) {this.removeAccessToken(accessToken.getValue());}public OAuth2AccessToken readAccessToken(String tokenValue) {byte[] key = this.serializeKey("access:" + tokenValue);byte[] bytes = null;RedisConnection conn = this.getConnection();try {bytes = conn.get(key);} finally {conn.close();}OAuth2AccessToken var5 = this.deserializeAccessToken(bytes);return var5;}public void removeAccessToken(String tokenValue) {byte[] accessKey = this.serializeKey("access:" + tokenValue);byte[] authKey = this.serializeKey("auth:" + tokenValue);byte[] accessToRefreshKey = this.serializeKey("access_to_refresh:" + tokenValue);RedisConnection conn = this.getConnection();try {conn.openPipeline();conn.get(accessKey);conn.get(authKey);conn.del(new byte[][]{accessKey});conn.del(new byte[][]{accessToRefreshKey});conn.del(new byte[][]{authKey});List<Object> results = conn.closePipeline();byte[] access = (byte[])((byte[])results.get(0));byte[] auth = (byte[])((byte[])results.get(1));OAuth2Authentication authentication = this.deserializeAuthentication(auth);if (authentication != null) {String key = this.authenticationKeyGenerator.extractKey(authentication);byte[] authToAccessKey = this.serializeKey("auth_to_access:" + key);byte[] unameKey = this.serializeKey("uname_to_access:" + getApprovalKey(authentication));byte[] clientId = this.serializeKey("client_id_to_access:" + authentication.getOAuth2Request().getClientId());conn.openPipeline();conn.del(new byte[][]{authToAccessKey});conn.sRem(unameKey, new byte[][]{access});conn.sRem(clientId, new byte[][]{access});conn.del(new byte[][]{this.serialize("access:" + key)});conn.closePipeline();}} finally {conn.close();}}public void storeRefreshToken(OAuth2RefreshToken refreshToken, OAuth2Authentication authentication) {byte[] refreshKey = this.serializeKey("refresh:" + refreshToken.getValue());byte[] refreshAuthKey = this.serializeKey("refresh_auth:" + refreshToken.getValue());byte[] serializedRefreshToken = this.serialize((Object)refreshToken);RedisConnection conn = this.getConnection();try {conn.openPipeline();if (springDataRedis_2_0) {try {this.redisConnectionSet_2_0.invoke(conn, refreshKey, serializedRefreshToken);this.redisConnectionSet_2_0.invoke(conn, refreshAuthKey, this.serialize((Object)authentication));} catch (Exception var13) {throw new RuntimeException(var13);}} else {conn.set(refreshKey, serializedRefreshToken);conn.set(refreshAuthKey, this.serialize((Object)authentication));}if (refreshToken instanceof ExpiringOAuth2RefreshToken) {ExpiringOAuth2RefreshToken expiringRefreshToken = (ExpiringOAuth2RefreshToken)refreshToken;Date expiration = expiringRefreshToken.getExpiration();if (expiration != null) {int seconds = Long.valueOf((expiration.getTime() - System.currentTimeMillis()) / 1000L).intValue();conn.expire(refreshKey, (long)seconds);conn.expire(refreshAuthKey, (long)seconds);}}conn.closePipeline();} finally {conn.close();}}public OAuth2RefreshToken readRefreshToken(String tokenValue) {byte[] key = this.serializeKey("refresh:" + tokenValue);byte[] bytes = null;RedisConnection conn = this.getConnection();try {bytes = conn.get(key);} finally {conn.close();}OAuth2RefreshToken var5 = this.deserializeRefreshToken(bytes);return var5;}public void removeRefreshToken(OAuth2RefreshToken refreshToken) {this.removeRefreshToken(refreshToken.getValue());}public void removeRefreshToken(String tokenValue) {byte[] refreshKey = this.serializeKey("refresh:" + tokenValue);byte[] refreshAuthKey = this.serializeKey("refresh_auth:" + tokenValue);byte[] refresh2AccessKey = this.serializeKey("refresh_to_access:" + tokenValue);byte[] access2RefreshKey = this.serializeKey("access_to_refresh:" + tokenValue);RedisConnection conn = this.getConnection();try {conn.openPipeline();conn.del(new byte[][]{refreshKey});conn.del(new byte[][]{refreshAuthKey});conn.del(new byte[][]{refresh2AccessKey});conn.del(new byte[][]{access2RefreshKey});conn.closePipeline();} finally {conn.close();}}public void removeAccessTokenUsingRefreshToken(OAuth2RefreshToken refreshToken) {this.removeAccessTokenUsingRefreshToken(refreshToken.getValue());}private void removeAccessTokenUsingRefreshToken(String refreshToken) {byte[] key = this.serializeKey("refresh_to_access:" + refreshToken);List<Object> results = null;RedisConnection conn = this.getConnection();try {conn.openPipeline();conn.get(key);conn.del(new byte[][]{key});results = conn.closePipeline();} finally {conn.close();}if (results != null) {byte[] bytes = (byte[])((byte[])results.get(0));String accessToken = this.deserializeString(bytes);if (accessToken != null) {this.removeAccessToken(accessToken);}}}private List<byte[]> getByteLists(byte[] approvalKey, RedisConnection conn) {Long size = conn.sCard(approvalKey);List<byte[]> byteList = new ArrayList(size.intValue());Cursor cursor = conn.sScan(approvalKey, ScanOptions.NONE);while(cursor.hasNext()) {Object next = cursor.next();byteList.add(next.toString().getBytes(StandardCharsets.UTF_8));}return byteList;}public Collection<OAuth2AccessToken> findTokensByClientIdAndUserName(String clientId, String userName) {byte[] approvalKey = this.serializeKey("uname_to_access:" + getApprovalKey(clientId, userName));List<byte[]> byteList = null;RedisConnection conn = this.getConnection();try {byteList = this.getByteLists(approvalKey, conn);} finally {conn.close();}if (byteList != null && byteList.size() != 0) {List<OAuth2AccessToken> accessTokens = new ArrayList(byteList.size());Iterator var7 = byteList.iterator();while(var7.hasNext()) {byte[] bytes = (byte[])var7.next();OAuth2AccessToken accessToken = this.deserializeAccessToken(bytes);accessTokens.add(accessToken);}return Collections.unmodifiableCollection(accessTokens);} else {return Collections.emptySet();}}public Collection<OAuth2AccessToken> findTokensByClientId(String clientId) {byte[] key = this.serializeKey("client_id_to_access:" + clientId);List<byte[]> byteList = null;RedisConnection conn = this.getConnection();try {byteList = this.getByteLists(key, conn);} finally {conn.close();}if (byteList != null && byteList.size() != 0) {List<OAuth2AccessToken> accessTokens = new ArrayList(byteList.size());Iterator var6 = byteList.iterator();while(var6.hasNext()) {byte[] bytes = (byte[])var6.next();OAuth2AccessToken accessToken = this.deserializeAccessToken(bytes);accessTokens.add(accessToken);}return Collections.unmodifiableCollection(accessTokens);} else {return Collections.emptySet();}}
}

3.自定义序列化类

package com.enterprise.auth.config;import com.google.gson.Gson;
import org.springframework.security.oauth2.provider.token.store.redis.BaseRedisTokenStoreSerializationStrategy;import java.nio.charset.StandardCharsets;
import java.util.Map;public class MyRedisTokenStoreSerializationStrategy extends BaseRedisTokenStoreSerializationStrategy {@Override//反序列化内部protected <T> T deserializeInternal(byte[] bytes, Class<T> aClass) {String s = new String(bytes);Gson gson = new Gson();return gson.fromJson(s,aClass);}@Override//反序列化字符串内部protected String deserializeStringInternal(byte[] bytes) {return new String(bytes);}@Override//序列化内部protected byte[] serializeInternal(Object o) {Gson gson = new Gson();String json = gson.toJson(o);return json.getBytes(StandardCharsets.UTF_8);}@Override//序列化内部protected byte[] serializeInternal(String s) {return  s.getBytes(StandardCharsets.UTF_8);}
}

4.配置使用redis类型的 TokenStore

package com.enterprise.auth.config;import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.security.oauth2.provider.token.TokenStore;@Configuration
public class MyRedisTokenStoreConfig {@Autowiredprivate RedisConnectionFactory redisConnectionFactory;@Beanpublic TokenStore tokenStore() {MyRedisTokenStore redisTokenStore = new MyRedisTokenStore(redisConnectionFactory);return redisTokenStore;}
}

5.完成认证模块的编写后,测试登录

 

 json已经保存在数据库了

但是!!!!!,保存没问题,取出来的时候就有问题了,把这三个文件复制到资源服务器,让资源服务器也用MyRedisTokenStore 的方式读取权限信息.

 然后访问,到json权限信息转成实体类的时候,就有问题了,各种各样oauth2 中的数据实体类,没有构造方法,无法创建对象,先转成map在手动新建对象同样不行,

 redis中的配置已经读到了

 但是需要实例化的对象类路径,这么长一串,没有构造方法,无法新建对象.

报错>>>

 

结束<<<<<<<<

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/25075.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

深度学习入门必读 | 深度学习算法技术原理和发展

前言&#xff1a;Hello大家好&#xff0c;我是小哥谈。随着人工智能技术的发展&#xff0c;深度学习已经成为了一个热门话题。为了让大家能够更清晰直观的了解深度学习&#xff0c;今天这篇文章就重点给大家介绍一下深度学习算法的技术原理和发展&#xff01;&#x1f308; 目录…

Python中的PDF文本提取:使用fitz和wxPython库(带进度条)

引言&#xff1a; 处理大量PDF文档的文本提取任务可能是一项繁琐的工作。本文将介绍一个使用Python编写的工具&#xff0c;可通过简单的操作一键提取大量PDF文档中的文本内容&#xff0c;极大地提高工作效率。 import wx import pathlib import fitzclass PDFExtractor(wx.Fr…

自动化测试po模式是什么

一、什么是PO模式 全称&#xff1a;page object model 简称&#xff1a;POM/PO PO模式最核心的思想是分层&#xff0c;实现松耦合&#xff01;实现脚本重复使用&#xff0c;实现脚本易维护性&#xff01; 主要分三层&#xff1a; 1.基础层BasePage&#xff1a;封装一些最基…

LVS负载均衡(DR)

文章目录 LVS-DR模式配置原理注DR配置添加VIP下载ipvsadm在DR上管理LVS Real-Server RS配置绑定VIP到环回网卡添加访问VIP的路由配置ARP抑制测试&#xff1a; LVS-DR模式配置 原理 当客户端发起请求后由DR处理&#xff0c;通过算法将流量转发至Real-Server中的某一个处理。然后…

HDFS介绍

目录 ​编辑 一、HDFS基础 1.1 概述 1.2 HDFS的设计目标 1.2.1 硬件故障 1.2.2 流式数据访问 1.2.3 超大数据集 1.2.4 简单的一致性模型 1.2.5 移动计算而不是移动数据 1.2.6 跨异构硬件和软件平台的可移植性 1.3 基础概念 1.3.1 块&#xff08;Block&#xff09; 1.3.2 复制…

【MySQL】检索数据使用数据处理函数

函数 与其他大多数计算机语言一样&#xff0c;SQL支持利用函数来处理数据。函数一般是在数据上执行的&#xff0c;它给数据的转换和处理提供了方便。 函数没有SQL的可移植性强&#xff1a;能运行在多个系统上的代码称为可移植的。多数SQL语句是可移植的&#xff0c;而函数的可…

虹科案例 | PLC如何应用于建筑的3D打印?

客户&#xff1a;Rebuild 合作伙伴&#xff1a;ASTOR 应用&#xff1a;用于建筑的大尺寸3D打印 应用产品&#xff1a;3D混凝土打印机 &#xff08;一&#xff09;应用背景 自从20世纪80年代以来&#xff0c;增材制造技术&#xff08;即3D打印&#xff09;不断发展。大部分3D打印…

ArduPilot开源代码之Companion Computers简单分析

ArduPilot开源代码之Companion Computers简单分析 1. 源由2. 伴机系统2.1 APSync2.2 DroneKit2.3 FlytOS2.4 Maverick2.5 ROS2.6 Rpanion-server 3. 总结4. 参考资料 1. 源由 从稳定性&#xff0c;社区群体&#xff0c;以及开源方式的角度看&#xff0c;Ardupilot是不错的选择…

HttpRunner自动化测试工具之录制工具使用--使用抓包工具通过命令转成yml文件

录制工具使用&#xff1a; 为了简化测试用例的编写工作&#xff0c;HttpRunner实现了测试用例生成的功能&#xff0c;对应的转换工具为一个独立的项目&#xff1a;har2case 使用操作步骤&#xff1a; 1、通过抓包工具获取HAR格式的数据包 2、通过命令har2case har的数据包路径…

40.利用欧拉法求解微分方程组(matlab程序)

1.简述 求解微分方程的时候&#xff0c;如果不能将求出结果的表达式&#xff0c;则可以对利用数值积分对微分方程求解&#xff0c;获取数值解。欧拉方法是最简单的一种数值解法。前面介绍过MATLAB实例讲解欧拉法求解微分方程&#xff0c;今天实例讲解欧拉法求解一阶微分方程组。…

车载软件架构 —— 闲聊几句AUTOSAR OS(十一)

我是穿拖鞋的汉子,魔都中坚持长期主义的汽车电子工程师。 老规矩,分享一段喜欢的文字,避免自己成为高知识低文化的工程师: 没有人关注你。也无需有人关注你。你必须承认自己的价值,你不能站在他人的角度来反对自己。人生在世,最怕的就是把别人的眼光当成自己生活的唯一标…

TBB库中实现协程(coroutine)的源码说明

源码请见: https://github.com/oneapi-src/oneTBB/blob/master/src/tbb/co_context.h 在windows系统&#xff0c;TBB(也就是intel 的 oneTBB库)&#xff0c;通过windwos fiber(纤程)来实现协程(coroutine)。 创建一个协程,代码很简洁: inline void create_coroutine(corouti…

C++动态规划经典试题解析之打家劫舍系列

1.前言 力扣上有几道与打家劫舍相关的题目,算是学习动态规划时常被提及的经典试题,很有代表性,常在因内大大小小的社区内看到众人对此类问题的讨论。 学习最好的方式便是归纳总结、借鉴消化,基于这个目的,本文对此类问题也做了讲解,在一些优秀思想的基础上添加了个人观…

react中PureComponent的理解与使用

一、作用 它是一个纯组件&#xff0c;会做一个数据的浅比较&#xff0c;当props和state没改变的时候&#xff0c;不会render重新渲染&#xff0c; 改变后才会render重新渲染&#xff0c;提高性能。 二、使用 三、注意 它不能和shouldComponentUpdate生命周期同时使用。因为它…

【CSS】3D卡片效果

效果 index.html <!DOCTYPE html> <html><head><title> Document </title><link type"text/css" rel"styleSheet" href"index.css" /></head><body><div class"card"><img…

【JAVA】继承

作者主页&#xff1a;paper jie的博客 本文作者&#xff1a;大家好&#xff0c;我是paper jie&#xff0c;感谢你阅读本文&#xff0c;欢迎一建三连哦。 本文录入于《JAVASE语法系列》专栏&#xff0c;本专栏是针对于大学生&#xff0c;编程小白精心打造的。笔者用重金(时间和精…

HDFS集群滚动升级以及回滚相关

HDFS集群滚动升级以及回滚相关 介绍不停机滚动升级非联邦HA集群联邦HA集群 停机升级--非HA集群HDFS集群降级和回滚异同点共同点不同点 HA集群降级&#xff08;downgrade&#xff09;注意事项 集群回滚操作 介绍 在hadoop v2中&#xff0c;HDFS支持namenode高可用&#xff08;H…

如何将 dubbo filter 拦截器原理运用到日志拦截器中?

业务背景 我们希望可以在使用日志拦截器时&#xff0c;定义属于自己的拦截器方法。 实现的方式有很多种&#xff0c;我们分别来看一下。 拓展阅读 java 注解结合 spring aop 实现自动输出日志 java 注解结合 spring aop 实现日志traceId唯一标识 java 注解结合 spring ao…

思科单臂路由、lacp链路聚合、NAT实验

实验拓扑图&#xff1a; 实验目的&#xff1a; 如图所示配置相应IP地址和VLAN&#xff0c;并通过在AR1上配置单臂路由&#xff0c;实现VLAN10和VLAN20的主机能够在VLAN间通信&#xff1b;在SW1和SW2的三条链路实施链路聚合&#xff0c;使用静态LACP模式&#xff0c;使一条链…

Visual Studio在Debug模式下,MFC工程中包含Eigen库时的定义冲突的问题

Visual Studio在Debug模式下&#xff0c;MFC工程中包含Eigen库时的定义冲突的问题 报错信息 Eigen\src\Core\PlainObjectBase.h(143,5): error C2061: 语法错误: 标识符“THIS_FILE” Eigen\src\Core\PlainObjectBase.h(143,1): error C2333: “Eigen::PlainObjectBase::opera…