修改非maat配置时支持将配置从失效再次置为有效的状态
This commit is contained in:
@@ -126,7 +126,7 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
map.put(service, arrayList);
|
||||
Map<Integer, Map<Integer, List<Long>>> idMap = new HashMap<Integer, Map<Integer, List<Long>>>();
|
||||
idMap.put(redisDB, map);
|
||||
configRedisService.delUnMaatConfig(idMap);
|
||||
configRedisService.delUnMaatConfig(idMap,true);
|
||||
// configRedisService.saveMaatConfig(listMap, service);
|
||||
// new ConfigRedisServiceimpl().GETMaatConfig(listMap);
|
||||
return "ok";
|
||||
|
||||
@@ -744,7 +744,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean delUnMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap) {
|
||||
public boolean delUnMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap, boolean isInvalid) {
|
||||
if (idMap != null && idMap.size() > 0) {
|
||||
int count = 0;
|
||||
Jedis resource = JedisUtils.getResource(0);
|
||||
@@ -777,7 +777,14 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
for (String keyStr : keySplit) {
|
||||
if (!StringUtils.isEmpty(keyStr)
|
||||
&& keyStr.toUpperCase().equals("EFFECTIVE_RULE")) {
|
||||
|
||||
if(isInvalid) {
|
||||
keyStr = "OBSOLETE_RULE";
|
||||
}else {
|
||||
keyStr = "EFFECTIVE_RULE";
|
||||
}
|
||||
|
||||
|
||||
keyBF.append(keyStr.trim());
|
||||
} else if (!StringUtils.isEmpty(keyStr)
|
||||
&& keyStr.trim().startsWith("[")) {
|
||||
@@ -801,15 +808,22 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
keyBF.append(keyStr.trim());
|
||||
}
|
||||
}
|
||||
String oldKey = null;
|
||||
maatKey = keyBF.toString();
|
||||
String oldKey = maatKey.replace("OBSOLETE_RULE", "EFFECTIVE_RULE");
|
||||
if (isInvalid) {
|
||||
oldKey = maatKey.replace("OBSOLETE_RULE", "EFFECTIVE_RULE");
|
||||
} else {
|
||||
oldKey = maatKey.replace("EFFECTIVE_RULE", "OBSOLETE_RULE");
|
||||
}
|
||||
|
||||
|
||||
if (JedisUtils.exists(oldKey.toString().toUpperCase(),
|
||||
redisDBIndex)) {
|
||||
transaction.rename(oldKey.toString().toUpperCase(),
|
||||
keyBF.toString().toUpperCase());
|
||||
maatKey.toString().toUpperCase());
|
||||
logger.info("向{}号redis数据库修改了一条配置,修改前key是{},修改后key是{}",
|
||||
redisDBIndex, oldKey.toString().toUpperCase(),
|
||||
keyBF.toString().toUpperCase());
|
||||
maatKey.toString().toUpperCase());
|
||||
break;
|
||||
} else {
|
||||
throw new RuntimeException("后台错误:" + redisDBIndex
|
||||
@@ -821,10 +835,17 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
if (maatXmlExpr.getKeyExpression().toUpperCase()
|
||||
.equals("MAAT_UPDATE_STATUS")) {
|
||||
if (maatKey != null) {
|
||||
if (isInvalid) {
|
||||
String zset = maatKey.replace("OBSOLETE_RULE:", "DEL,");
|
||||
transaction.zadd("MAAT_UPDATE_STATUS", maatVersion, zset);
|
||||
logger.info("向{}号redis数据库更新了MAAT_UPDATE_STATUS,内容是{},SCORES是{}",
|
||||
redisDBIndex, zset.toUpperCase(), maatVersion);
|
||||
}else {
|
||||
String zset = maatKey.replace("EFFECTIVE_RULE:", "ADD,");
|
||||
transaction.zadd("MAAT_UPDATE_STATUS", maatVersion, zset);
|
||||
logger.info("向{}号redis数据库更新了MAAT_UPDATE_STATUS,内容是{},SCORES是{}",
|
||||
redisDBIndex, zset.toUpperCase(), maatVersion);
|
||||
}
|
||||
}
|
||||
} else if (maatXmlExpr.getKeyExpression().toUpperCase()
|
||||
.equals("MAAT_RULE_TIMER")) {
|
||||
|
||||
@@ -44,9 +44,10 @@ public interface ConfigRedisService {
|
||||
/**
|
||||
* 删除非maat类配置,第一个key是redisDBIndex,第二个key是业务类型,value是配置id集合
|
||||
* @param idMap
|
||||
* @param isInvalid 是否将配置置为无效
|
||||
* @return 成功返回true,失败返回false或抛出异常
|
||||
*/
|
||||
public boolean delUnMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap);
|
||||
public boolean delUnMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap,boolean isInvalid);
|
||||
|
||||
/**
|
||||
* 删除maat类配置,第一个key是redisDBIndex,第二个key是业务类型,value是配置id集合
|
||||
|
||||
Reference in New Issue
Block a user