1:为配置下发添加相关逻辑说明
2:修改配置下发和取消的冗余代码 3:删除分组复用相关内容 4:删除redis-pipeline相关的内容 5:删除项目启动加载maat关联关系的逻辑
This commit is contained in:
@@ -188,8 +188,8 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
if (redisDBIndex >= 0 && redisDBIndex < Configurations.getIntProperty("maxRedisDBIndex", 6)) {
|
||||
List<MaatConfig> maatConfigList = configMap.get(redisDBIndex);
|
||||
if (maatConfigList != null && maatConfigList.size() > 0) {
|
||||
Map<String, List<String>> compileAndGroupMap = new HashMap<String, List<String>>();
|
||||
Map<String, List<String>> groupAndCompileMap = new HashMap<String, List<String>>();
|
||||
Map<String, List<String>> compileAndGroupMap = new HashMap<String, List<String>>();// 记录编译下面有哪些组,在哪些redisdb中
|
||||
Map<String, List<String>> groupAndCompileMap = new HashMap<String, List<String>>();// 记录每个组属于哪些编译,公共组可能会属于很多的编译redisdb中
|
||||
for (MaatConfig maatConfig : maatConfigList) {
|
||||
List<Map<String, String>> groupMapList = maatConfig.getGroupMapList();
|
||||
if (groupMapList != null && groupMapList.size() > 0) {
|
||||
@@ -380,10 +380,16 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 封装组id与域id对应关系并添加到对象中
|
||||
* 封装组id与域id对应关系
|
||||
*
|
||||
* @param maatXmlConfig
|
||||
* @param service
|
||||
* @param type
|
||||
* @param regionMapList
|
||||
* @param compileAndGroupRelations
|
||||
* @param groupAndRegionMap
|
||||
* @param redisDBSetStr 当前配置下发到哪些redisdb中
|
||||
* @param commonGroupIdList 公共组id集合
|
||||
* @return
|
||||
*/
|
||||
private Map<String, Set<String>> addGroupAndRegionRelations(MaatXmlConfig maatXmlConfig, int service, int type,
|
||||
List<Map<String, String>> regionMapList, Map<String, Set<String>> groupAndRegionMap, String redisDBSetStr,
|
||||
@@ -429,7 +435,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
|
||||
String groupIdStr = "GROUPREGION:" + groupId;// groupregion里面value是region的信息,key是group的信息
|
||||
if (commonGroupIdList.contains(groupId)) {
|
||||
groupIdStr = "COMMONGROUPREGION:" + groupId;
|
||||
groupIdStr = "COMMONGROUPREGION:" + groupId;// 公共组以COMMONGROUPREGION开头和普通的组标识开
|
||||
}
|
||||
|
||||
if (groupAndRegionMap.containsKey(groupIdStr.toUpperCase())) {
|
||||
@@ -479,13 +485,13 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
setConfig(maatConfig, maatXmlConfig, maatVersion, service, transaction,
|
||||
redisDBIndex, commonGroupIdList);
|
||||
}
|
||||
if (commonGroupIdList != null && commonGroupIdList.size() > 0) {
|
||||
if (commonGroupIdList != null && commonGroupIdList.size() > 0) {// 如果有公共组则将每个redisdb的版本都加1
|
||||
for (String db : Constants.COMMONGROUPDBARR) {
|
||||
transaction.select(Integer.parseInt(db));
|
||||
transaction.incrBy("MAAT_VERSION", 1l);
|
||||
logger.info("向{}号redis数据库更新了MAAT_VERSION", Integer.parseInt(db));
|
||||
}
|
||||
} else {
|
||||
} else {// 没有公共组则只更新当前的redisdb
|
||||
transaction.select(redisDBIndex);
|
||||
transaction.incrBy("MAAT_VERSION", 1l);
|
||||
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDBIndex,
|
||||
@@ -571,23 +577,23 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 将整理好的数据添加到redis中,如果是分组复用时,则去临时库将对应的域找到复制过来,如果当前库存在则不复制了(在复制就重复了)
|
||||
* 将整理好的数据添加到redis中
|
||||
*
|
||||
* @param maatXmlConfig
|
||||
* @param map
|
||||
* @param type
|
||||
* @param maatVersion
|
||||
* @param service
|
||||
* @param redisTemplate
|
||||
* @param map 数据
|
||||
* @param type 标识是编译,组还是ip域,字符串域,数值域等
|
||||
* @param maatVersion maatversion
|
||||
* @param service 业务类型
|
||||
* @param transaction
|
||||
* @param redisDBIndex
|
||||
* @param compileId
|
||||
* @param isReuse 是否是分组复用
|
||||
*/
|
||||
private void setCommonConfig(MaatXmlConfig maatXmlConfig, Map<String, String> map, int type, Double maatVersion,
|
||||
int service, Transaction transaction, Integer redisDBIndex, String compileId) {
|
||||
if (maatXmlConfig != null && map != null && map.size() > 0) {
|
||||
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
|
||||
String maatKey = null;
|
||||
transaction.select(redisDBIndex);
|
||||
for (MaatXmlExpr maatXmlExpr : expressionList) {
|
||||
if (type == maatXmlExpr.getType().intValue()) {
|
||||
StringBuffer keyBF = new StringBuffer();
|
||||
@@ -678,17 +684,13 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
valBF.append(valStr.trim());
|
||||
}
|
||||
}
|
||||
transaction.select(redisDBIndex);
|
||||
maatKey = keyBF.toString();
|
||||
transaction.set(maatKey.toUpperCase(), valBF.toString());
|
||||
logger.info("向{}号redis数据库添加了一条配置,key是{},value是{}", redisDBIndex, maatKey.toUpperCase(),
|
||||
valBF.toString());
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
transaction.select(redisDBIndex);
|
||||
updateMaatInfo(expressionList, maatKey, transaction, maatVersion, redisDBIndex, false);
|
||||
} else {
|
||||
if (maatXmlConfig == null) {
|
||||
@@ -1009,10 +1011,12 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
for (Long id : list) {
|
||||
// 按序号选择Redis数据库
|
||||
transaction.select(redisDb);
|
||||
if (!isStart && compileGroupMap.size() > 0) {
|
||||
if (!isStart && compileGroupMap.size() > 0) {// 失效并且有需要保留的group则将groupid的集合传到下一个方法中
|
||||
// 如果某一个配置下包含两个组,一个普通组,一个公共组,界面调用该接口时一定会保留公共组,
|
||||
// 该接口不能修改公共组的状态如果想对公共组进行操作,调用公共组的相关方法即可
|
||||
removeConfig(id, maatXmlConfig, maatVersion, service, transaction, redisDb,
|
||||
idRelaRedisDBIndex, isStart, compileGroupMap.get(id));
|
||||
} else {
|
||||
} else {// 将配置置为生效,或者删除时不保留groupid
|
||||
removeConfig(id, maatXmlConfig, maatVersion, service, transaction, redisDb,
|
||||
idRelaRedisDBIndex, isStart, null);
|
||||
}
|
||||
@@ -1085,7 +1089,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除maat类配置
|
||||
* 将配置置为生效或失效
|
||||
*
|
||||
* @param id 配置id
|
||||
* @param maatXmlConfig maat.xml中关于当前业务类型的key和value写法的对象
|
||||
@@ -1099,11 +1103,9 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
private void removeConfig(Long id, MaatXmlConfig maatXmlConfig, Double maatVersion, int service,
|
||||
Transaction transaction, int redisDBIndex, int idRelaRedisDBIndex, boolean isStart,
|
||||
List<Long> keepGroupId) {
|
||||
|
||||
Map<String, Boolean> groupIsCommonMap = new HashMap<>();
|
||||
|
||||
Map<String, Boolean> groupIsCommonMap = new HashMap<>();// 记录公共组是否存在,避免每次都去redis中查询影响性能,,key是COMMONGROUPREGION:groupid,value是该组是否存在的标志
|
||||
if (maatXmlConfig != null) {
|
||||
Map<String, String> keyMap = new HashMap<>();
|
||||
Map<String, String> keyMap = new HashMap<>();// 记录每个key对应的value,避免每次去redis中查询,影响性能
|
||||
// 删除(重命名)编译配置
|
||||
removeCompileAndGroupConfig(maatXmlConfig, id + "", 10, maatVersion, service, transaction, redisDBIndex,
|
||||
null, isStart);// 10代表是编译配置
|
||||
@@ -1113,115 +1115,104 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
String compileStrVal = JedisUtils.get(compileStr, idRelaRedisDBIndex);// 根据编译id获取该编译下的分组关系,示例:
|
||||
// GROUPCOMPILE:25166-2,5;GROUPCOMPILE:25167-2,5;GROUPCOMPILE:25168-2,5
|
||||
if (compileStrVal != null && !compileStrVal.trim().equals("")) {
|
||||
String[] compileGroupStrArr = org.apache.commons.lang.StringUtils.split(compileStrVal, ";");
|
||||
String[] compileGroupStrArr = org.apache.commons.lang.StringUtils.split(compileStrVal, ";");// 获取当前编译下有哪些组
|
||||
for (String compileGroup : compileGroupStrArr) {
|
||||
// compileGroup=GROUPCOMPILE:25166-2, 5
|
||||
// compileGroup=GROUPCOMPILE:编译id-redisdb1,redisdb2
|
||||
if (compileGroup != null && !compileGroup.trim().equals("")) {
|
||||
String groupCompileStrs = getRegionInfo(compileGroup);// 获取编译对应的分组信息,去除后面的redisdb信息,GROUPCOMPILE:25166
|
||||
if (groupCompileStrs != null && !groupCompileStrs.trim().equals("")) {// 遍历编译和分组的信息
|
||||
String[] split = org.apache.commons.lang.StringUtils.split(groupCompileStrs, ";");
|
||||
|
||||
for (String groupId : split) {// GROUPCOMPILE:groupid
|
||||
if (groupId != null && !groupId.trim().equals("")) {
|
||||
String groupCompileAndDBStrs = null;
|
||||
if (!keyMap.containsKey(groupId)) {
|
||||
groupCompileAndDBStrs = JedisUtils.get(groupId, idRelaRedisDBIndex);
|
||||
keyMap.put(groupId, groupCompileAndDBStrs);
|
||||
} else {
|
||||
groupCompileAndDBStrs = keyMap.get(groupId);
|
||||
}
|
||||
String groupIdReal = groupId.replace("GROUPCOMPILE:", "");
|
||||
String[] compileGroupArr = org.apache.commons.lang.StringUtils
|
||||
.split(groupCompileAndDBStrs, ";");// 获取组对应的编译id,示例:
|
||||
// ;COMPILEGROUP:24070-2, 5
|
||||
for (String groupAndCompileStr : compileGroupArr) {
|
||||
if (groupAndCompileStr != null && !groupAndCompileStr.trim().equals("")) {
|
||||
String compileId = getRegionInfo(groupAndCompileStr);// COMPILEGROUP:24070
|
||||
if (compileId != null && !compileId.trim().equals("")) {
|
||||
|
||||
if (isStart || (keepGroupId != null && keepGroupId.size() > 0
|
||||
&& !keepGroupId.contains(Long.parseLong(groupIdReal)))) {// 如果是修改为生效则置为生效,如果是失效如果包含保留的group,则不将域置为失效,否则将域置为失效,否
|
||||
if (compileId.equals(compileStr)) {//
|
||||
String groupRegionKey = groupId.replace("GROUPCOMPILE",
|
||||
"GROUPREGION");// groupregion里面value是region的信息,key是group的信息,所以可以直接将GROUPCOMPILE替换为GROUPREGION
|
||||
boolean isCommonGroup = false;
|
||||
if (isStart) {
|
||||
String commonGroupRegionKey = groupId
|
||||
.replace("GROUPCOMPILE", "COMMONGROUPREGION");// groupregion里面value是region的信息,key是group的信息,所以可以直接将GROUPCOMPILE替换为GROUPREGION
|
||||
if (!groupIsCommonMap.containsKey(commonGroupRegionKey)) {
|
||||
boolean exist = JedisUtils.exists(commonGroupRegionKey,
|
||||
idRelaRedisDBIndex);
|
||||
groupIsCommonMap.put(commonGroupRegionKey, exist);
|
||||
if (exist) {
|
||||
isCommonGroup = true;
|
||||
}
|
||||
|
||||
} else {
|
||||
isCommonGroup = groupIsCommonMap
|
||||
.get(commonGroupRegionKey);
|
||||
}
|
||||
String groupId = getRegionInfo(compileGroup);// 获取编译对应的分组信息,去除后面的redisdb信息,GROUPCOMPILE:25166
|
||||
if (groupId != null && !groupId.trim().equals("")) {
|
||||
String groupCompileAndDBStrs = null;
|
||||
if (!keyMap.containsKey(groupId)) {
|
||||
groupCompileAndDBStrs = JedisUtils.get(groupId, idRelaRedisDBIndex);
|
||||
keyMap.put(groupId, groupCompileAndDBStrs);
|
||||
} else {
|
||||
groupCompileAndDBStrs = keyMap.get(groupId);
|
||||
}
|
||||
String groupIdReal = groupId.replace("GROUPCOMPILE:", "");// 获取真实的groupid
|
||||
String[] compileGroupArr = org.apache.commons.lang.StringUtils.split(groupCompileAndDBStrs,
|
||||
";");// 获取组对应的编译id,示例:
|
||||
// ;COMPILEGROUP:24070-2, 5
|
||||
for (String groupAndCompileStr : compileGroupArr) {
|
||||
if (groupAndCompileStr != null && !groupAndCompileStr.trim().equals("")) {
|
||||
String compileId = getRegionInfo(groupAndCompileStr);// COMPILEGROUP:24070
|
||||
if (compileId != null && !compileId.trim().equals("")) {
|
||||
if (isStart || (keepGroupId != null && keepGroupId.size() > 0
|
||||
&& !keepGroupId.contains(Long.parseLong(groupIdReal)))) {
|
||||
// 如果是生效则根据关联关系将组下的域都改为生效
|
||||
// 如果是失效并且当前组不是需要保留的组,则将该组下的域置为失效
|
||||
if (compileId.equals(compileStr)) {// 判断编译id是否一致
|
||||
String groupRegionKey = groupId.replace("GROUPCOMPILE", "GROUPREGION");// groupregion里面value是region的信息,key是group的信息,所以可以直接将GROUPCOMPILE替换为GROUPREGION
|
||||
boolean isCommonGroup = false;
|
||||
if (isStart) {// 如果是生效,判断下是否是公共组
|
||||
String commonGroupRegionKey = groupId.replace("GROUPCOMPILE",
|
||||
"COMMONGROUPREGION");// groupregion里面value是region的信息,key是group的信息,所以可以直接将GROUPCOMPILE替换为GROUPREGION
|
||||
if (!groupIsCommonMap.containsKey(commonGroupRegionKey)) {
|
||||
boolean exist = JedisUtils.exists(commonGroupRegionKey,
|
||||
idRelaRedisDBIndex);
|
||||
groupIsCommonMap.put(commonGroupRegionKey, exist);
|
||||
if (exist) {
|
||||
isCommonGroup = true;
|
||||
}
|
||||
if (!isCommonGroup) {// 如果是公共组则不进行操作,因为公共组本来就是有效的
|
||||
String regionStrs = null;
|
||||
if (!keyMap.containsKey(groupRegionKey)) {
|
||||
regionStrs = JedisUtils.get(groupRegionKey,
|
||||
idRelaRedisDBIndex);
|
||||
keyMap.put(groupRegionKey, regionStrs);
|
||||
} else {
|
||||
regionStrs = keyMap.get(groupRegionKey);
|
||||
}
|
||||
if (regionStrs != null && !regionStrs.trim().equals("")) {
|
||||
String[] regionStrArr = regionStrs.split(";");
|
||||
for (String str : regionStrArr) {
|
||||
if (str != null && !str.trim().equals("")) {
|
||||
|
||||
String regionStr = getRegionInfo(str);
|
||||
if (regionStr != null
|
||||
&& !regionStr.trim().equals("")) {
|
||||
String[] regionKeyArr = regionStr
|
||||
.split(";");
|
||||
if (regionKeyArr != null
|
||||
&& regionKeyArr.length > 0) {
|
||||
// 根据分组与域关联关系找到对应域配置然后删除(重命名)
|
||||
removeRegionConfig(maatXmlConfig,
|
||||
regionKeyArr, maatVersion,
|
||||
service, transaction,
|
||||
redisDBIndex, isStart);
|
||||
}
|
||||
} else {
|
||||
throw new ServiceRuntimeException("从"
|
||||
+ idRelaRedisDBIndex
|
||||
} else {
|
||||
isCommonGroup = groupIsCommonMap.get(commonGroupRegionKey);
|
||||
}
|
||||
}
|
||||
if (!isCommonGroup) {
|
||||
// 如果是改为生效状态并且不是公共组,则将其下的域改为生效
|
||||
// 如果是失效(默认不是公共组isCommonGroup=false),则将其下的域改为失效
|
||||
String regionStrs = null;
|
||||
if (!keyMap.containsKey(groupRegionKey)) {
|
||||
regionStrs = JedisUtils.get(groupRegionKey, idRelaRedisDBIndex);// 获取组下面对应的域配置
|
||||
keyMap.put(groupRegionKey, regionStrs);
|
||||
} else {
|
||||
regionStrs = keyMap.get(groupRegionKey);
|
||||
}
|
||||
if (regionStrs != null && !regionStrs.trim().equals("")) {
|
||||
String[] regionStrArr = regionStrs.split(";");
|
||||
for (String str : regionStrArr) {
|
||||
if (str != null && !str.trim().equals("")) {
|
||||
String regionStr = getRegionInfo(str);
|
||||
if (regionStr != null && !regionStr.trim().equals("")) {
|
||||
String[] regionKeyArr = regionStr.split(";");
|
||||
if (regionKeyArr != null
|
||||
&& regionKeyArr.length > 0) {
|
||||
// 根据分组与域关联关系找到对应域配置,将域配置置为生效或失效(重命名)
|
||||
removeRegionConfig(maatXmlConfig, regionKeyArr,
|
||||
maatVersion, service, transaction,
|
||||
redisDBIndex, isStart);
|
||||
}
|
||||
} else {
|
||||
throw new ServiceRuntimeException(
|
||||
"从" + idRelaRedisDBIndex
|
||||
+ "号redis库中无法获取MAAT配置分组与域的关联关系,key为"
|
||||
+ groupRegionKey,
|
||||
RestBusinessCode.KeyNotExistsInRedis
|
||||
.getValue());
|
||||
}
|
||||
}
|
||||
RestBusinessCode.KeyNotExistsInRedis
|
||||
.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// 根据分组与编译关联关系找到对应分组配置然后删除(重命名)
|
||||
removeCompileAndGroupConfig(maatXmlConfig,
|
||||
groupId.replace("GROUPCOMPILE:", ""), 11, maatVersion, service,
|
||||
transaction, redisDBIndex, id + "", isStart);// 11代表是分组配置
|
||||
|
||||
} else {
|
||||
throw new ServiceRuntimeException(
|
||||
"从" + idRelaRedisDBIndex + "号redis库中无法获取MAAT配置分组与编译的关联关系,key为"
|
||||
+ groupId,
|
||||
RestBusinessCode.KeyNotExistsInRedis.getValue());
|
||||
}
|
||||
}
|
||||
// 根据分组与编译关联关系找到对应分组配置然后置为生效或失效(重命名)
|
||||
removeCompileAndGroupConfig(maatXmlConfig, groupId.replace("GROUPCOMPILE:", ""),
|
||||
11, maatVersion, service, transaction, redisDBIndex, id + "", isStart);// 11代表是分组配置
|
||||
|
||||
} else {
|
||||
throw new ServiceRuntimeException("从" + idRelaRedisDBIndex
|
||||
+ "号redis库中无法获取MAAT配置分组与编译的关联关系,key为" + groupId,
|
||||
RestBusinessCode.KeyNotExistsInRedis.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new ServiceRuntimeException(
|
||||
"从" + idRelaRedisDBIndex + "号redis库中无法获取MAAT配置编译与分组关联关系,key为" + compileStr,
|
||||
RestBusinessCode.KeyNotExistsInRedis.getValue());
|
||||
}
|
||||
} else {
|
||||
throw new ServiceRuntimeException(
|
||||
"从" + idRelaRedisDBIndex + "号redis库中无法获取MAAT配置编译与分组关联关系,key为" + compileStr,
|
||||
RestBusinessCode.KeyNotExistsInRedis.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1425,7 +1416,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
* @param map redisdb与编译id的对应
|
||||
* @param transaction
|
||||
* @param isStart 是否将配置置为生效
|
||||
* @param compileGroupMap 将配置置为失效时,需要保留哪些组(一般针对分组复用的配置,保留当前组,下次可以重复利用改组及其下的域)
|
||||
* @param compileGroupMap 将配置置为失效时,需要保留哪些组(一般针对公共组的配置,保留当前组,下次可以重复利用改组及其下的域)
|
||||
* @return
|
||||
*/
|
||||
private boolean removeMaatRelation(Map<Integer, List<Long>> map, Transaction transaction, Boolean isStart,
|
||||
@@ -1437,74 +1428,93 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
List<Long> idList = map.get(service);
|
||||
if (idList != null && idList.size() > 0) {
|
||||
for (Long compileId : idList) {
|
||||
|
||||
List<Long> keepGroupIdList = compileGroupMap.get(compileId);
|
||||
|
||||
String compileStr = "COMPILEGROUP:" + compileId;
|
||||
String compileStrVal = JedisUtils.get(compileStr, idRelaRedisDBIndex);// 根据编译id获取该编译下的分组关系
|
||||
if (compileStrVal != null && !compileStrVal.trim().equals("")) {
|
||||
String[] split1 = org.apache.commons.lang.StringUtils.split(compileStrVal, ";");
|
||||
|
||||
for (String str : split1) {
|
||||
for (String str : split1) {// 遍历编译下的所有组
|
||||
if (str != null && !str.trim().equals("")) {
|
||||
String groupCompileStr = getRegionInfo(str);
|
||||
if (groupCompileStr != null && !groupCompileStr.equals("")) {
|
||||
String[] groupCompileStrSplit =
|
||||
String groupCompile = getRegionInfo(str);// 去除redisdb,获取组的真实groupcompile
|
||||
if (groupCompile != null && !groupCompile.equals("")) {
|
||||
String compileGroupStr = JedisUtils.get(groupCompile.toUpperCase(),
|
||||
idRelaRedisDBIndex); // 获取当前分组关系对应的编译信息
|
||||
if (compileGroupStr != null && !compileGroupStr.equals("")) {
|
||||
String[] compileGroupStrSplit = org.apache.commons.lang.StringUtils
|
||||
.split(compileGroupStr, ";");
|
||||
for (String compileGroup : compileGroupStrSplit) {
|
||||
compileGroup = getRegionInfo(compileGroup);
|
||||
if (compileGroup.toUpperCase().equals(compileStr.toUpperCase())) {// 判断是否是同一个配置
|
||||
// 域
|
||||
String groupRegion = groupCompile.replace("GROUPCOMPILE",
|
||||
"GROUPREGION");// groupregion里面value是region的信息,key是group的信息,所以可以直接将GROUPCOMPILE替换为GROUPREGION
|
||||
// String commonGroupRegion = groupCompile.replace("GROUPCOMPILE",
|
||||
// "COMMONGROUPREGION");// groupregion里面value是region的信息,key是group的信息,所以可以直接将GROUPCOMPILE替换为GROUPREGION
|
||||
|
||||
org.apache.commons.lang.StringUtils.split(groupCompileStr, ";");// 得到分组关系
|
||||
for (String groupCompile : groupCompileStrSplit) {// 遍历所有分组关系
|
||||
String groupRegionVal = JedisUtils.get(groupRegion,
|
||||
idRelaRedisDBIndex);// 获取普通group下面的region
|
||||
|
||||
if (groupCompile != null && !groupCompile.trim().equals("")) {
|
||||
if (groupRegionVal == null || groupRegionVal.trim().equals("")) {// 如果从普通的组中无法获,取则尝试下获取公共组
|
||||
|
||||
String compileGroupStr = getRegionInfo(
|
||||
JedisUtils.get(groupCompile.toUpperCase(), idRelaRedisDBIndex));// 获取当前分组关系对应的编译信息
|
||||
if (compileGroupStr != null && !compileGroupStr.equals("")) {
|
||||
String[] compileGroupStrSplit = org.apache.commons.lang.StringUtils
|
||||
.split(compileGroupStr, ";");
|
||||
// 被分组复用的业务,不能将域置为失效,其分组关系也不置为失效
|
||||
groupRegion = groupCompile.replace("GROUPCOMPILE",
|
||||
"COMMONGROUPREGION");
|
||||
|
||||
if (compileGroupStrSplit[0].toUpperCase()
|
||||
.equals(compileStr.toUpperCase())) {
|
||||
String groupRegion = groupCompile.replace("GROUPCOMPILE",
|
||||
"GROUPREGION");// groupregion里面value是region的信息,key是group的信息,所以可以直接将GROUPCOMPILE替换为GROUPREGION
|
||||
// String commonGroupRegion = groupCompile.replace("GROUPCOMPILE",
|
||||
// "COMMONGROUPREGION");// groupregion里面value是region的信息,key是group的信息,所以可以直接将GROUPCOMPILE替换为GROUPREGION
|
||||
|
||||
String groupRegionVal = JedisUtils.get(groupRegion,
|
||||
groupRegionVal = JedisUtils.get(groupRegion,
|
||||
idRelaRedisDBIndex);
|
||||
|
||||
if (groupRegionVal == null
|
||||
|| groupRegionVal.trim().equals("")) {// 如果从普通的组中无法获,取则尝试下获取公共组
|
||||
|
||||
groupRegion = groupCompile.replace("GROUPCOMPILE",
|
||||
"COMMONGROUPREGION");
|
||||
|
||||
groupRegionVal = JedisUtils.get(groupRegion,
|
||||
idRelaRedisDBIndex);
|
||||
break;
|
||||
}
|
||||
if (groupRegionVal == null
|
||||
|| groupRegionVal.trim().equals("")) {// 如果普通的组和公共组都无法获取则给出错误提示
|
||||
throw new ServiceRuntimeException("从" + idRelaRedisDBIndex
|
||||
+ "号redis库中无法获取"
|
||||
+ groupCompile.replace("GROUPCOMPILE",
|
||||
"COMMONGROUPREGION")
|
||||
+ "和"
|
||||
+ groupCompile.replace("GROUPCOMPILE",
|
||||
"GROUPREGION")
|
||||
+ ",请检查groupid是否正确,或联系开发人员检查删除redis数据是否被人为删除了",
|
||||
RestBusinessCode.KeyNotExistsInRedis.getValue());
|
||||
}
|
||||
try {
|
||||
// 为了提高效率,不判断了,如果报错直接捕捉异常处理
|
||||
// 删除分组与域的关联关系
|
||||
if (isStart) {// 将失效置为生效
|
||||
groupRegionVal = groupRegionVal.replace("OBSOLETE_RULE",
|
||||
"EFFECTIVE_RULE");
|
||||
}
|
||||
if (groupRegionVal == null || groupRegionVal.trim().equals("")) {// 如果普通的组和公共组都无法获取则给出错误提示
|
||||
throw new ServiceRuntimeException(
|
||||
"从" + idRelaRedisDBIndex + "号redis库中无法获取"
|
||||
+ groupCompile.replace(
|
||||
"GROUPCOMPILE", "COMMONGROUPREGION")
|
||||
+ "和"
|
||||
+ groupCompile.replace("GROUPCOMPILE",
|
||||
"GROUPREGION")
|
||||
+ ",请检查groupid是否正确,或联系开发人员检查删除redis数据是否被人为删除了",
|
||||
RestBusinessCode.KeyNotExistsInRedis.getValue());
|
||||
}
|
||||
try {
|
||||
// 修改分组与域的关联关系
|
||||
if (isStart) {// 将失效置为生效
|
||||
groupRegionVal = groupRegionVal.replace("OBSOLETE_RULE",
|
||||
"EFFECTIVE_RULE");
|
||||
String[] split = org.apache.commons.lang.StringUtils
|
||||
.split(groupRegionVal, ";");
|
||||
if (split.length > 1) {
|
||||
Set<String> set = new HashSet<>();
|
||||
for (String regionKeyStr : split) {
|
||||
if (regionKeyStr != null
|
||||
&& !regionKeyStr.trim().equals("")) {
|
||||
set.add(regionKeyStr);
|
||||
}
|
||||
}
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (String regionKeyStr : set) {
|
||||
sb.append(";");
|
||||
sb.append(regionKeyStr);
|
||||
}
|
||||
transaction.set(groupRegion, sb.toString());// 避免有多个重复的region-key
|
||||
} else {
|
||||
transaction.set(groupRegion.toUpperCase(),
|
||||
groupRegionVal);
|
||||
}
|
||||
} else {// 将生效变为失效
|
||||
long groupId = -1l;
|
||||
if (groupRegion.contains("COMMONGROUPREGION:")) {
|
||||
groupId = Long.parseLong(
|
||||
groupRegion.replace("COMMONGROUPREGION:", ""));// 获取真实的groupid
|
||||
} else {
|
||||
groupId = Long.parseLong(
|
||||
groupRegion.replace("GROUPREGION:", ""));// 获取真实的groupid
|
||||
}
|
||||
if (!keepGroupIdList.contains(groupId)) {// 如果不是需要保留的groupid则失效(公共组不失效[如需失效使用公共组失效接口],非公共组则失效)
|
||||
groupRegionVal = groupRegionVal
|
||||
.replace("EFFECTIVE_RULE", "OBSOLETE_RULE");
|
||||
String[] split = org.apache.commons.lang.StringUtils
|
||||
.split(groupRegionVal, ";");
|
||||
if (split.length > 1) {
|
||||
Set<String> set = new HashSet<>();
|
||||
|
||||
for (String regionKeyStr : split) {
|
||||
if (regionKeyStr != null
|
||||
&& !regionKeyStr.trim().equals("")) {
|
||||
@@ -1517,208 +1527,111 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
sb.append(regionKeyStr);
|
||||
}
|
||||
transaction.set(groupRegion, sb.toString());// 避免有多个重复的region-key
|
||||
|
||||
} else {
|
||||
transaction.set(groupRegion.toUpperCase(),
|
||||
groupRegionVal);
|
||||
}
|
||||
} else {// 将生效变为失效
|
||||
long groupId = Long.parseLong(
|
||||
groupRegion.replace("GROUPREGION:", ""));
|
||||
|
||||
if (!keepGroupIdList.contains(groupId)) {
|
||||
groupRegionVal = groupRegionVal
|
||||
.replace("EFFECTIVE_RULE", "OBSOLETE_RULE");
|
||||
String[] split = org.apache.commons.lang.StringUtils
|
||||
.split(groupRegionVal, ";");
|
||||
if (split.length > 1) {
|
||||
Set<String> set = new HashSet<>();
|
||||
|
||||
for (String regionKeyStr : split) {
|
||||
if (regionKeyStr != null && !regionKeyStr
|
||||
.trim().equals("")) {
|
||||
set.add(regionKeyStr);
|
||||
}
|
||||
}
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (String regionKeyStr : set) {
|
||||
sb.append(";");
|
||||
sb.append(regionKeyStr);
|
||||
}
|
||||
transaction.set(groupRegion, sb.toString());// 避免有多个重复的region-key
|
||||
|
||||
} else {
|
||||
transaction.set(groupRegion.toUpperCase(),
|
||||
groupRegionVal);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
throw new ServiceRuntimeException("从" + idRelaRedisDBIndex
|
||||
+ "号redis库中删除" + groupRegion
|
||||
+ "失败,redis中不存在该值,请联系开发人员检查删除逻辑是否正确或redis数据是否出现了异常",
|
||||
RestBusinessCode.KeyNotExistsInRedis.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
// }
|
||||
|
||||
String groupCompileStrVal = JedisUtils
|
||||
.get(groupCompile.toUpperCase(), idRelaRedisDBIndex);
|
||||
// 删除分组与编译的关联关系
|
||||
if (groupCompileStrVal != null
|
||||
&& !groupCompileStrVal.trim().equals("")) {
|
||||
String[] split = org.apache.commons.lang.StringUtils
|
||||
.split(groupCompileStrVal, ";");
|
||||
Set<String> set = new HashSet<>();
|
||||
for (String groupCompileAndDBStr : split) {
|
||||
if (groupCompileAndDBStr != null
|
||||
&& !groupCompileAndDBStr.trim().equals("")) {
|
||||
|
||||
if (groupCompileAndDBStr
|
||||
.contains(compileStr.toUpperCase())
|
||||
&& split.length == 1) {
|
||||
try {
|
||||
// 为了提高效率,不判断了,如果报错直接捕捉异常处理
|
||||
// 删除当前组所对应的编译
|
||||
String groupRegionVal = JedisUtils.get(
|
||||
groupCompile.toUpperCase(),
|
||||
idRelaRedisDBIndex);
|
||||
if (isStart == null) {// 删除
|
||||
transaction.del(groupCompile.toUpperCase());// 删除编译与分组的关联关系
|
||||
} else if (isStart) {// 将失效置为生效
|
||||
groupRegionVal = groupRegionVal.replace(
|
||||
"OBSOLETE_RULE", "EFFECTIVE_RULE");
|
||||
String[] split2 = org.apache.commons.lang.StringUtils
|
||||
.split(groupRegionVal, ";");
|
||||
if (split2.length > 1) {
|
||||
Set<String> set1 = new HashSet<>();
|
||||
for (String regionKeyStr : split2) {
|
||||
if (regionKeyStr != null
|
||||
&& !regionKeyStr.trim()
|
||||
.equals("")) {
|
||||
set1.add(regionKeyStr);
|
||||
}
|
||||
}
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (String regionKeyStr : set1) {
|
||||
sb.append(";");
|
||||
sb.append(regionKeyStr);
|
||||
}
|
||||
transaction.set(
|
||||
groupCompile.toUpperCase(),
|
||||
sb.toString());
|
||||
|
||||
} else {
|
||||
transaction.set(
|
||||
groupCompile.toUpperCase(),
|
||||
groupRegionVal);
|
||||
}
|
||||
} else {// 将生效变为失效
|
||||
groupRegionVal = groupRegionVal.replace(
|
||||
"EFFECTIVE_RULE", "OBSOLETE_RULE");
|
||||
|
||||
String[] split2 = org.apache.commons.lang.StringUtils
|
||||
.split(groupRegionVal, ";");
|
||||
if (split2.length > 1) {
|
||||
|
||||
Set<String> set2 = new HashSet<>();
|
||||
for (String regionKeyStr : split2) {
|
||||
if (regionKeyStr != null
|
||||
&& !regionKeyStr.trim()
|
||||
.equals("")) {
|
||||
set2.add(regionKeyStr);
|
||||
}
|
||||
}
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (String regionKeyStr : set2) {
|
||||
sb.append(";");
|
||||
sb.append(regionKeyStr);
|
||||
}
|
||||
transaction.set(
|
||||
groupCompile.toUpperCase(),
|
||||
sb.toString());
|
||||
} else {
|
||||
transaction.set(
|
||||
groupCompile.toUpperCase(),
|
||||
groupRegionVal);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ServiceRuntimeException("从"
|
||||
+ idRelaRedisDBIndex + "号redis库中删除"
|
||||
+ groupCompile.toUpperCase()
|
||||
+ "失败,redis中不存在该值,请联系开发人员检查删除逻辑是否正确或redis数据是否出现了异常",
|
||||
RestBusinessCode.KeyNotExistsInRedis
|
||||
.getValue());
|
||||
}
|
||||
|
||||
// } else if (!groupCompileAndDBStr
|
||||
// .contains(compileStr.toUpperCase())) {
|
||||
} else {
|
||||
set.add(groupCompileAndDBStr);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (set.size() > 0) {
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (String regionKeyStr : set) {
|
||||
sb.append(";");
|
||||
sb.append(regionKeyStr);
|
||||
}
|
||||
transaction.set(groupCompile.toUpperCase(), sb.toString());// 重新设置分组与编译
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new ServiceRuntimeException(
|
||||
"从" + idRelaRedisDBIndex
|
||||
+ "号redis库中无法获取MAAT配置分组与编译的关联关系,key为"
|
||||
+ groupCompile.toUpperCase(),
|
||||
} catch (Exception e) {
|
||||
throw new ServiceRuntimeException("从" + idRelaRedisDBIndex
|
||||
+ "号redis库中删除" + groupRegion
|
||||
+ "失败,redis中不存在该值,请联系开发人员检查删除逻辑是否正确或redis数据是否出现了异常",
|
||||
RestBusinessCode.KeyNotExistsInRedis.getValue());
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new ServiceRuntimeException(
|
||||
"从" + idRelaRedisDBIndex
|
||||
+ "号redis库中无法获取MAAT配置分组与编译的关联关系,key为"
|
||||
+ groupCompile.toUpperCase(),
|
||||
RestBusinessCode.KeyNotExistsInRedis.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
//
|
||||
Set<String> set = new HashSet<>();
|
||||
if (compileGroup.toUpperCase().equals(compileStr.toUpperCase())
|
||||
&& compileGroupStrSplit.length == 1) {// 判断是否是同一个配置
|
||||
try {
|
||||
// 为了提高效率,不判断了,如果报错直接捕捉异常处理
|
||||
// 删除当前组所对应的编译
|
||||
String groupRegionVal = JedisUtils
|
||||
.get(groupCompile.toUpperCase(), idRelaRedisDBIndex);
|
||||
if (isStart == null) {// 删除
|
||||
transaction.del(groupCompile.toUpperCase());// 删除编译与分组的关联关系
|
||||
} else if (isStart) {// 将失效置为生效
|
||||
groupRegionVal = groupRegionVal.replace("OBSOLETE_RULE",
|
||||
"EFFECTIVE_RULE");
|
||||
String[] split2 = org.apache.commons.lang.StringUtils
|
||||
.split(groupRegionVal, ";");
|
||||
if (split2.length > 1) {
|
||||
Set<String> set1 = new HashSet<>();
|
||||
for (String regionKeyStr : split2) {
|
||||
if (regionKeyStr != null
|
||||
&& !regionKeyStr.trim().equals("")) {
|
||||
set1.add(regionKeyStr);
|
||||
}
|
||||
}
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (String regionKeyStr : set1) {
|
||||
sb.append(";");
|
||||
sb.append(regionKeyStr);
|
||||
}
|
||||
transaction.set(groupCompile.toUpperCase(),
|
||||
sb.toString());
|
||||
|
||||
} else {
|
||||
transaction.set(groupCompile.toUpperCase(),
|
||||
groupRegionVal);
|
||||
}
|
||||
} else {// 将生效变为失效
|
||||
groupRegionVal = groupRegionVal.replace("EFFECTIVE_RULE",
|
||||
"OBSOLETE_RULE");
|
||||
|
||||
String[] split2 = org.apache.commons.lang.StringUtils
|
||||
.split(groupRegionVal, ";");
|
||||
if (split2.length > 1) {
|
||||
|
||||
Set<String> set2 = new HashSet<>();
|
||||
for (String regionKeyStr : split2) {
|
||||
if (regionKeyStr != null
|
||||
&& !regionKeyStr.trim().equals("")) {
|
||||
set2.add(regionKeyStr);
|
||||
}
|
||||
}
|
||||
StringBuffer sb = new StringBuffer();
|
||||
for (String regionKeyStr : set2) {
|
||||
sb.append(";");
|
||||
sb.append(regionKeyStr);
|
||||
}
|
||||
transaction.set(groupCompile.toUpperCase(),
|
||||
sb.toString());
|
||||
} else {
|
||||
transaction.set(groupCompile.toUpperCase(),
|
||||
groupRegionVal);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new ServiceRuntimeException("从" + idRelaRedisDBIndex
|
||||
+ "号redis库中删除" + groupCompile.toUpperCase()
|
||||
+ "失败,redis中不存在该值,请联系开发人员检查删除逻辑是否正确或redis数据是否出现了异常",
|
||||
RestBusinessCode.KeyNotExistsInRedis.getValue());
|
||||
}
|
||||
} else {
|
||||
set.add(compileGroup);
|
||||
}
|
||||
|
||||
try {
|
||||
if (isStart == null) {// 删除
|
||||
transaction.del(compileStr.toUpperCase());// 删除编译与分组的关联关系
|
||||
} else if (isStart) {// 将失效置为生效
|
||||
String groupRegionVal = JedisUtils.get(compileStr.toUpperCase(),
|
||||
idRelaRedisDBIndex);
|
||||
groupRegionVal = groupRegionVal.replace("OBSOLETE_RULE",
|
||||
"EFFECTIVE_RULE");
|
||||
transaction.set(compileStr.toUpperCase(), groupRegionVal);
|
||||
} else {// 将生效变为失效
|
||||
String groupRegionVal = JedisUtils.get(compileStr.toUpperCase(),
|
||||
idRelaRedisDBIndex);
|
||||
groupRegionVal = groupRegionVal.replace("EFFECTIVE_RULE",
|
||||
"OBSOLETE_RULE");
|
||||
transaction.set(compileStr.toUpperCase(), groupRegionVal);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
} else {
|
||||
throw new ServiceRuntimeException(
|
||||
"从" + idRelaRedisDBIndex + "号redis关联关系库中删除" + compileStr
|
||||
+ "失败,redis中不存在该值,请联系开发人员检查删除逻辑是否正确或redis数据是否出现了异常",
|
||||
"从" + idRelaRedisDBIndex + "号redis库中无法获取MAAT配置分组与编译的关联关系,key为"
|
||||
+ groupCompile.toUpperCase(),
|
||||
RestBusinessCode.KeyNotExistsInRedis.getValue());
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new ServiceRuntimeException(
|
||||
"从" + idRelaRedisDBIndex + "号redis关联关系库中获取" + compileStr
|
||||
+ "的值为null,redis中不存在该值,请联系开发人员检查删除逻辑是否正确或redis数据是否出现了异常",
|
||||
RestBusinessCode.KeyNotExistsInRedis.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
throw new ServiceRuntimeException(
|
||||
"从" + idRelaRedisDBIndex + "号redis关联关系库中获取" + compileStr
|
||||
+ "的值为null,redis中不存在该值,请联系开发人员检查删除逻辑是否正确或redis数据是否出现了异常",
|
||||
RestBusinessCode.KeyNotExistsInRedis.getValue());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -1760,7 +1673,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
if (keyStr.toLowerCase().contains("table_name")) {
|
||||
String argTableName = map.get("table_name");
|
||||
if (argTableName == null) {
|
||||
throw new ServiceRuntimeException("添加分组复用域配置时,必须要传入表名,请检查参数,配置类型:" + type + ",对应的真实表名",
|
||||
throw new ServiceRuntimeException("添加公共组域配置时,必须要传入表名,请检查参数,配置类型:" + type + ",对应的真实表名",
|
||||
RestBusinessCode.NotFoundTableName.getValue());
|
||||
} else {
|
||||
keyBF.append(argTableName);
|
||||
@@ -1884,9 +1797,6 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean updateGroupRegion(List<MaatConfig> configList, boolean isAdd) {
|
||||
Jedis resource = JedisUtils.getResource(0);
|
||||
@@ -1929,18 +1839,18 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
|
||||
}
|
||||
} else {
|
||||
throw new ServiceRuntimeException("添加分组复用域配置时,未发现对应的配置信息,请检查配置参数是否正确",
|
||||
throw new ServiceRuntimeException("添加公共组域配置时,未发现对应的配置信息,请检查配置参数是否正确",
|
||||
RestBusinessCode.ConfigSourceIsNull.getValue());
|
||||
}
|
||||
transaction.exec();
|
||||
return true;
|
||||
} catch (JedisConnectionException e) {
|
||||
String error = "连接redis异常,保存分组复用maat类域配置失败" + e.getMessage();
|
||||
String error = "连接redis异常,保存公共组maat类域配置失败" + e.getMessage();
|
||||
logger.error(error + " " + ExceptionUtil.getExceptionMsg(e));
|
||||
throw new ServiceRuntimeException(error, RestBusinessCode.CannotConnectionRedis.getValue());
|
||||
} catch (Exception e) {
|
||||
|
||||
String error = "保存分组复用maat类域配置发生了异常" + e.getMessage();
|
||||
String error = "保存公共组maat类域配置发生了异常" + e.getMessage();
|
||||
logger.error(error + " " + ExceptionUtil.getExceptionMsg(e));
|
||||
transaction.discard();
|
||||
throw new ServiceRuntimeException(error, RestBusinessCode.SaveDataInError.getValue());
|
||||
@@ -1994,29 +1904,41 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param maatConfig
|
||||
* @param maatXmlConfig
|
||||
* @param maatVersion
|
||||
* @param service
|
||||
* @param transaction
|
||||
* @param redisDBIndex
|
||||
* @param isCommonGroup 是否是公共组,如果是公共组则需要向所有的db下发
|
||||
*/
|
||||
|
||||
/**
|
||||
* 保存域配置信息,如果当前域所属的组是公共组则需要向所有的redisdb中下发域配置,否则只向指定的组下发
|
||||
*
|
||||
* @param maatConfig 配置信息
|
||||
* @param maatXmlConfig 配置的表达式
|
||||
* @param maatVersion 版本号
|
||||
* @param service 业务类型
|
||||
* @param transaction redis连接
|
||||
* @param redisDBIndex redis编号
|
||||
* @param isCommonGroup 是否是公共组,如果是公共组则需要向所有的db下发
|
||||
* @param maatConfig 配置信息
|
||||
* @param maatXmlConfig 配置的表达式
|
||||
* @param maatVersion 版本号
|
||||
* @param service 业务类型
|
||||
* @param transaction redis连接
|
||||
* @param redisDBIndex redis编号
|
||||
* @param commonGroupIdList
|
||||
* @return
|
||||
*/
|
||||
private Integer addRegion(MaatConfig maatConfig, MaatXmlConfig maatXmlConfig, Double maatVersion, int service,
|
||||
Transaction transaction, Integer redisDBIndex, List<Long> commonGroupIdList) {
|
||||
// Boolean serviceIsReuse = ServiceAndRDBIndexReal.serviceIsReuse(service);
|
||||
int count = 0;// 计算下所有的域是不是都没有值,如果没有值则给出提示
|
||||
int count = 0;// 计算下所有的域
|
||||
List<Map<String, String>> ipRegionMapList = maatConfig.getIpRegionMapList();
|
||||
|
||||
if (ipRegionMapList != null && ipRegionMapList.size() > 0) {
|
||||
count += ipRegionMapList.size();
|
||||
for (Map<String, String> map : ipRegionMapList) {
|
||||
Long groupId = Long.parseLong(map.get("group_id"));
|
||||
boolean isCommonGroup = commonGroupIdList.contains(groupId);
|
||||
if (isCommonGroup) {
|
||||
boolean isCommonGroup = commonGroupIdList.contains(groupId);// 判断当前域是否属于公共组
|
||||
if (isCommonGroup) {// 如果属于公共组则向所有的数据库下发一份
|
||||
for (String db : Constants.COMMONGROUPDBARR) {
|
||||
setCommonConfig(maatXmlConfig, map, 12, maatVersion, service, transaction, Integer.parseInt(db),
|
||||
null);// 12代表是ip类域配置
|
||||
@@ -2124,15 +2046,12 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
}
|
||||
|
||||
// if (count == 0 && isReuseSaveRegion) {
|
||||
// throw new ServiceRuntimeException("添加分组复用域配置时,所有的域配置都为空,请检查配置参数是否正确",
|
||||
// throw new ServiceRuntimeException("添加公共组域配置时,所有的域配置都为空,请检查配置参数是否正确",
|
||||
// RestBusinessCode.ConfigSourceIsNull.getValue());
|
||||
// }
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public boolean delCommonGroup(Set<Long> groupIdList) {
|
||||
Jedis resource = JedisUtils.getResource(0);
|
||||
@@ -2173,7 +2092,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
transaction.select(everyDb);
|
||||
for (String regionKey : set) {
|
||||
String obsKey = regionKey.replace("EFFECTIVE_RULE", "OBSOLETE_RULE");
|
||||
transaction.rename(regionKey,obsKey);
|
||||
transaction.rename(regionKey, obsKey);
|
||||
updateMaatInfo(expressionList, obsKey, transaction, maatVersion, everyDb, true);
|
||||
}
|
||||
}
|
||||
@@ -2191,12 +2110,12 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
}
|
||||
|
||||
} catch (JedisConnectionException e) {
|
||||
String error = "连接redis异常,删除分组复用maat类域配置失败" + e.getMessage();
|
||||
String error = "连接redis异常,删除公共组maat类域配置失败" + e.getMessage();
|
||||
logger.error(error + " " + ExceptionUtil.getExceptionMsg(e));
|
||||
throw new ServiceRuntimeException(error, RestBusinessCode.CannotConnectionRedis.getValue());
|
||||
} catch (Exception e) {
|
||||
|
||||
String error = "删除分组复用maat类域配置发生了异常" + e.getMessage();
|
||||
String error = "删除公共组maat类域配置发生了异常" + e.getMessage();
|
||||
logger.error(error + " " + ExceptionUtil.getExceptionMsg(e));
|
||||
transaction.discard();
|
||||
throw new ServiceRuntimeException(error, RestBusinessCode.SaveDataInError.getValue());
|
||||
|
||||
Reference in New Issue
Block a user