修改一个编译下有多个分组时,未完全将分组取消的问题

This commit is contained in:
RenKaiGe-Office
2018-08-31 16:05:18 +08:00
parent 35d2f29a65
commit 4ec5282ebd

View File

@@ -1043,7 +1043,10 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
String compileStr = "COMPILEGROUP:" + id; String compileStr = "COMPILEGROUP:" + id;
// 获取当前编译配置与分组配置的关联关系 // 获取当前编译配置与分组配置的关联关系
String compileStrVal = JedisUtils.get(compileStr, idRelaRedisDBIndex);// 根据编译id获取该编译下的分组关系 String compileStrVal = JedisUtils.get(compileStr, idRelaRedisDBIndex);// 根据编译id获取该编译下的分组关系
String groupCompileStrs = getRegionInfo(compileStrVal);// 获取编译对应的分组信息,去除后面的redisdb信息 if (compileStrVal != null && !compileStrVal.trim().equals("")) {
String[] compileGroupStrArr = compileStrVal.split(";");
for (String compileGroup : compileGroupStrArr) {
String groupCompileStrs = getRegionInfo(compileGroup);// 获取编译对应的分组信息,去除后面的redisdb信息
if (groupCompileStrs != null && !groupCompileStrs.trim().equals("")) {// 遍历编译和分组的信息 if (groupCompileStrs != null && !groupCompileStrs.trim().equals("")) {// 遍历编译和分组的信息
String[] split = groupCompileStrs.split(";"); String[] split = groupCompileStrs.split(";");
for (String groupId : split) {// GROUPCOMPILE:groupid-redisdb for (String groupId : split) {// GROUPCOMPILE:groupid-redisdb
@@ -1063,8 +1066,8 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
String[] regionKeyArr = regionStr.split(";"); String[] regionKeyArr = regionStr.split(";");
if (regionKeyArr != null && regionKeyArr.length > 0) { if (regionKeyArr != null && regionKeyArr.length > 0) {
// 根据分组与域关联关系找到对应域配置然后删除(重命名) // 根据分组与域关联关系找到对应域配置然后删除(重命名)
removeRegionConfig(maatXmlConfig, regionKeyArr, maatVersion, service, removeRegionConfig(maatXmlConfig, regionKeyArr, maatVersion,
transaction, redisDBIndex); service, transaction, redisDBIndex);
} }
} else { } else {
throw new ServiceRuntimeException( throw new ServiceRuntimeException(
@@ -1090,6 +1093,8 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
"" + idRelaRedisDBIndex + "号redis库中无法获取MAAT配置编译与分组关联关系key为" + compileStr, "" + idRelaRedisDBIndex + "号redis库中无法获取MAAT配置编译与分组关联关系key为" + compileStr,
RestBusinessCode.KeyNotExistsInRedis.getValue()); RestBusinessCode.KeyNotExistsInRedis.getValue());
} }
}
}
} else { } else {
throw new ServiceRuntimeException( throw new ServiceRuntimeException(
"无法从applicationConfig-maatRedis.xml配置文件中获取service为" + service + "对应的规则,请检查业务类型是否正确", "无法从applicationConfig-maatRedis.xml配置文件中获取service为" + service + "对应的规则,请检查业务类型是否正确",
@@ -1279,7 +1284,11 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
// String compileStr = redisDBIndex + ":COMPILEGROUP:" + compileId; // String compileStr = redisDBIndex + ":COMPILEGROUP:" + compileId;
String compileStr = "COMPILEGROUP:" + compileId; String compileStr = "COMPILEGROUP:" + compileId;
String compileStrVal = JedisUtils.get(compileStr, idRelaRedisDBIndex);// 根据编译id获取该编译下的分组关系 String compileStrVal = JedisUtils.get(compileStr, idRelaRedisDBIndex);// 根据编译id获取该编译下的分组关系
String groupCompileStr = getRegionInfo(compileStrVal); if (compileStrVal != null && !compileStrVal.trim().equals("")) {
String[] split1 = compileStrVal.split(";");
for (String str : split1) {
String groupCompileStr = getRegionInfo(str);
// if (compileStrVal != null && compileStrVal.contains("-")) { // if (compileStrVal != null && compileStrVal.contains("-")) {
// String[] split = compileStrVal.split("-"); // String[] split = compileStrVal.split("-");
// groupCompileStr = split[0];// 去除后面的redisdb信息 // groupCompileStr = split[0];// 去除后面的redisdb信息
@@ -1297,15 +1306,16 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
// == 1 // == 1
// && compileGroupStr.equals(compileStr.toUpperCase())) {// // && compileGroupStr.equals(compileStr.toUpperCase())) {//
// 当前的分组关系只属于当前的compileid,说明没有被分组复用,需要将编译配置,分组关系,域配置,置无效 // 当前的分组关系只属于当前的compileid,说明没有被分组复用,需要将编译配置,分组关系,域配置,置无效
if (compileGroupStrSplit[0].toUpperCase().equals(compileStr.toUpperCase())) { if (compileGroupStrSplit[0].toUpperCase()
String groupRegion = groupCompile.replace("GROUPCOMPILE", "GROUPREGION");// groupregion里面value是region的信息,key是group的信息,所以可以直接将GROUPCOMPILE替换为GROUPREGION .equals(compileStr.toUpperCase())) {
String groupRegion = groupCompile.replace("GROUPCOMPILE",
"GROUPREGION");// groupregion里面value是region的信息,key是group的信息,所以可以直接将GROUPCOMPILE替换为GROUPREGION
// 删除分组与域的关联关系 // 删除分组与域的关联关系
if (JedisUtils.exists(groupRegion, idRelaRedisDBIndex)) { if (JedisUtils.exists(groupRegion, idRelaRedisDBIndex)) {
transaction.del(groupRegion); transaction.del(groupRegion);
} else { } else {
throw new ServiceRuntimeException( throw new ServiceRuntimeException("" + idRelaRedisDBIndex
"" + idRelaRedisDBIndex + "号redis库中无法获取MAAT配置分组与域的关联关系key为" + "号redis库中无法获取MAAT配置分组与域的关联关系key为" + groupRegion,
+ groupRegion,
RestBusinessCode.KeyNotExistsInRedis.getValue()); RestBusinessCode.KeyNotExistsInRedis.getValue());
} }
@@ -1322,7 +1332,8 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
if (groupCompileAndDBStr.contains(compileStr.toUpperCase()) if (groupCompileAndDBStr.contains(compileStr.toUpperCase())
&& split.length == 1) { && split.length == 1) {
transaction.del(groupCompile.toUpperCase());// 删除当前组所对应的编译 transaction.del(groupCompile.toUpperCase());// 删除当前组所对应的编译
} else if (!groupCompileAndDBStr.contains(compileStr.toUpperCase())) { } else if (!groupCompileAndDBStr
.contains(compileStr.toUpperCase())) {
sb.append(groupCompileAndDBStr + ";"); sb.append(groupCompileAndDBStr + ";");
} }
} }
@@ -1372,6 +1383,9 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
RestBusinessCode.KeyNotExistsInRedis.getValue()); RestBusinessCode.KeyNotExistsInRedis.getValue());
} }
} }
}
}
} else { } else {
throw new ServiceRuntimeException( throw new ServiceRuntimeException(
"删除配置时,未从service与配置id的对应关系中找到service=" + service + "的配置id,请检查传入的参数是否正确", "删除配置时,未从service与配置id的对应关系中找到service=" + service + "的配置id,请检查传入的参数是否正确",