|
|
|
@@ -6,7 +6,6 @@ import java.util.HashSet;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Map;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.Set;
|
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
@@ -23,6 +22,7 @@ import com.nis.domain.restful.GroupAndRegionRelations;
|
|
|
|
import com.nis.domain.restful.MaatConfig;
|
|
|
|
import com.nis.domain.restful.MaatConfig;
|
|
|
|
import com.nis.domain.restful.MaatRelation;
|
|
|
|
import com.nis.domain.restful.MaatRelation;
|
|
|
|
import com.nis.listener.CompileGroupRegionRela;
|
|
|
|
import com.nis.listener.CompileGroupRegionRela;
|
|
|
|
|
|
|
|
import com.nis.util.Configurations;
|
|
|
|
import com.nis.util.ReadMaatXmlUtil;
|
|
|
|
import com.nis.util.ReadMaatXmlUtil;
|
|
|
|
import com.nis.util.ServiceAndRDBIndexReal;
|
|
|
|
import com.nis.util.ServiceAndRDBIndexReal;
|
|
|
|
import com.nis.web.service.SpringContextHolder;
|
|
|
|
import com.nis.web.service.SpringContextHolder;
|
|
|
|
@@ -31,28 +31,11 @@ import com.nis.web.service.SpringContextHolder;
|
|
|
|
public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|
|
|
public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(ConfigRedisServiceimpl.class);
|
|
|
|
private static Logger logger = LoggerFactory.getLogger(ConfigRedisServiceimpl.class);
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
|
|
|
|
public void saveTestConfig(List<Map<String, String>> listMap, int service) {
|
|
|
|
|
|
|
|
RedisTemplate<String, String> redisTemplate0 = SpringContextHolder.getBean("redisTemplate2");
|
|
|
|
|
|
|
|
RedisTemplate<String, String> redisTemplate1 = SpringContextHolder.getBean("redisTemplate1");
|
|
|
|
|
|
|
|
System.out.println(redisTemplate0.opsForValue().get("MAAT_VERSION"));
|
|
|
|
|
|
|
|
System.out.println(redisTemplate1.opsForValue().get("MAAT_VERSION"));
|
|
|
|
|
|
|
|
redisTemplate0.boundValueOps("MAAT_VERSION").increment(2l);
|
|
|
|
|
|
|
|
if (service == 2) {
|
|
|
|
|
|
|
|
int i = service / 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
redisTemplate1.boundValueOps("MAAT_VERSION").increment(1l);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// redisTemplate0.exec();
|
|
|
|
|
|
|
|
// redisTemplate1.exec();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Transactional
|
|
|
|
@Transactional
|
|
|
|
public void saveUnMaatConfig(Map<Integer, List<Map<String, String>>> configMap) {
|
|
|
|
public void saveUnMaatConfig(Map<Integer, List<Map<String, String>>> configMap) {
|
|
|
|
if (configMap != null && configMap.size() > 0) {
|
|
|
|
if (configMap != null && configMap.size() > 0) {
|
|
|
|
for (Integer redisDBIndex : configMap.keySet()) {
|
|
|
|
for (Integer redisDBIndex : configMap.keySet()) {
|
|
|
|
if (redisDBIndex >= 0 && redisDBIndex <= 15) {
|
|
|
|
if (redisDBIndex >= 0 && redisDBIndex < Configurations.getIntProperty("maxRedisDBIndex", 6)) {
|
|
|
|
RedisTemplate<String, String> redisTemplate = SpringContextHolder
|
|
|
|
RedisTemplate<String, String> redisTemplate = SpringContextHolder
|
|
|
|
.getBean("redisTemplate" + redisDBIndex);
|
|
|
|
.getBean("redisTemplate" + redisDBIndex);
|
|
|
|
List<Map<String, String>> listMap = configMap.get(redisDBIndex);
|
|
|
|
List<Map<String, String>> listMap = configMap.get(redisDBIndex);
|
|
|
|
@@ -69,7 +52,7 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|
|
|
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(service);
|
|
|
|
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(service);
|
|
|
|
if (maatXmlConfig != null) {
|
|
|
|
if (maatXmlConfig != null) {
|
|
|
|
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
|
|
|
|
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
|
|
|
|
String maatKey = "";
|
|
|
|
String maatKey = null;
|
|
|
|
for (MaatXmlExpr maatXmlExpr : expressionList) {
|
|
|
|
for (MaatXmlExpr maatXmlExpr : expressionList) {
|
|
|
|
if (0 == maatXmlExpr.getType().intValue()) {
|
|
|
|
if (0 == maatXmlExpr.getType().intValue()) {
|
|
|
|
StringBuffer keyBF = new StringBuffer();
|
|
|
|
StringBuffer keyBF = new StringBuffer();
|
|
|
|
@@ -97,26 +80,40 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
maatKey = keyBF.toString();
|
|
|
|
maatKey = keyBF.toString();
|
|
|
|
System.out.println(keyBF.toString());
|
|
|
|
|
|
|
|
System.out.println(valBF.toString());
|
|
|
|
|
|
|
|
redisTemplate.opsForValue().set(keyBF.toString().toUpperCase(),
|
|
|
|
redisTemplate.opsForValue().set(keyBF.toString().toUpperCase(),
|
|
|
|
valBF.toString());
|
|
|
|
valBF.toString());
|
|
|
|
|
|
|
|
logger.info("向{}号redis数据库添加了一条配置,key是{},value是{}", redisDBIndex,
|
|
|
|
|
|
|
|
keyBF.toString().toUpperCase(), valBF.toString());
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (MaatXmlExpr maatXmlExpr : expressionList) {
|
|
|
|
for (MaatXmlExpr maatXmlExpr : expressionList) {
|
|
|
|
if (maatXmlExpr.getKeyExpression().toUpperCase().equals("MAAT_UPDATE_STATUS")) {
|
|
|
|
if (maatXmlExpr.getKeyExpression().toUpperCase().equals("MAAT_UPDATE_STATUS")) {
|
|
|
|
String zset = maatKey.replace("EFFECTIVE_RULE:", "ADD,");
|
|
|
|
if (maatKey != null) {
|
|
|
|
redisTemplate.boundZSetOps("MAAT_UPDATE_STATUS").add(zset, maatVersion);
|
|
|
|
String zset = maatKey.replace("EFFECTIVE_RULE:", "ADD,");
|
|
|
|
|
|
|
|
redisTemplate.boundZSetOps("MAAT_UPDATE_STATUS").add(zset, maatVersion);
|
|
|
|
|
|
|
|
logger.info("向{}号redis数据库更新了MAAT_UPDATE_STATUS,内容是{},SCORES是{}",
|
|
|
|
|
|
|
|
redisDBIndex, zset.toUpperCase(), maatVersion);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
} else if (maatXmlExpr.getKeyExpression().toUpperCase().equals("MAAT_RULE_TIMER")) {
|
|
|
|
} else if (maatXmlExpr.getKeyExpression().toUpperCase().equals("MAAT_RULE_TIMER")) {
|
|
|
|
Double score = 0d;// 界面下发的配置没有超时时间所以这里设置为0
|
|
|
|
if (maatKey != null) {
|
|
|
|
redisTemplate.boundZSetOps("MAAT_RULE_TIMER").add(maatKey, score);
|
|
|
|
Double score = 0d;// 界面下发的配置没有超时时间所以这里设置为0
|
|
|
|
|
|
|
|
redisTemplate.boundZSetOps("MAAT_RULE_TIMER").add(maatKey, score);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger.info("向{}号redis数据库更新了MAAT_RULE_TIMER,内容是{},SCORES是{}", redisDBIndex,
|
|
|
|
|
|
|
|
maatKey, score);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
} else if (maatXmlExpr.getKeyExpression().toUpperCase()
|
|
|
|
} else if (maatXmlExpr.getKeyExpression().toUpperCase()
|
|
|
|
.equals("MAAT_VERSION_TIMER")) {
|
|
|
|
.equals("MAAT_VERSION_TIMER")) {
|
|
|
|
Long nowTime = new Date().getTime();
|
|
|
|
Long nowTime = new Date().getTime();
|
|
|
|
nowTime = nowTime / 1000l;
|
|
|
|
nowTime = nowTime / 1000l;
|
|
|
|
Double score = nowTime.doubleValue();// 使用redis自带的time,得到当前时间的秒
|
|
|
|
Double score = nowTime.doubleValue();// 使用redis自带的time,得到当前时间的秒
|
|
|
|
redisTemplate.boundZSetOps("MAAT_VERSION_TIMER").add(maatVersion + "", score);
|
|
|
|
redisTemplate.boundZSetOps("MAAT_VERSION_TIMER").add(maatVersion + "", score);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger.info("向{}号redis数据库更新了MAAT_VERSION_TIMER,内容是{},SCORES是{}", redisDBIndex,
|
|
|
|
|
|
|
|
maatVersion, score);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<MaatXmlSeq> seqList = maatXmlConfig.getSequenceList();
|
|
|
|
List<MaatXmlSeq> seqList = maatXmlConfig.getSequenceList();
|
|
|
|
@@ -137,24 +134,28 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
|
|
|
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
|
|
|
|
|
|
|
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDBIndex,
|
|
|
|
|
|
|
|
Integer.valueOf(maatVersionStr) + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 下发配置成功后,需要更新编译,组,域等配置id的对应关系
|
|
|
|
|
|
|
|
*/
|
|
|
|
public void addMaatRelation(Map<Integer, List<MaatConfig>> configMap) {
|
|
|
|
public void addMaatRelation(Map<Integer, List<MaatConfig>> configMap) {
|
|
|
|
if (configMap != null && configMap.size() > 0) {
|
|
|
|
if (configMap != null && configMap.size() > 0) {
|
|
|
|
for (Integer redisDBIndex : configMap.keySet()) {
|
|
|
|
for (Integer redisDBIndex : configMap.keySet()) {
|
|
|
|
if (redisDBIndex >= 0 && redisDBIndex <= 15) {
|
|
|
|
if (redisDBIndex >= 0 && redisDBIndex < Configurations.getIntProperty("maxRedisDBIndex", 6)) {
|
|
|
|
// MaatRelation maatRelation =
|
|
|
|
// MaatRelation maatRelation =
|
|
|
|
// CompileGroupRegionRela.getIdRelationMap().get(redisDBIndex);
|
|
|
|
// CompileGroupRegionRela.getIdRelationMap().get(redisDBIndex);
|
|
|
|
List<MaatConfig> maatConfigList = configMap.get(redisDBIndex);
|
|
|
|
List<MaatConfig> maatConfigList = configMap.get(redisDBIndex);
|
|
|
|
if (maatConfigList != null && maatConfigList.size() > 0) {
|
|
|
|
if (maatConfigList != null && maatConfigList.size() > 0) {
|
|
|
|
for (MaatConfig maatConfig : maatConfigList) {
|
|
|
|
for (MaatConfig maatConfig : maatConfigList) {
|
|
|
|
Map<String, String> compileMap = maatConfig.getCompileMap();
|
|
|
|
Map<String, String> compileMap = maatConfig.getCompileMap();
|
|
|
|
String cfgIdStr = compileMap.get("cfg_id");
|
|
|
|
String cfgIdStr = compileMap.get("compile_id");
|
|
|
|
CompileAndGroupRelations compileAndGroupRelations = new CompileAndGroupRelations();
|
|
|
|
CompileAndGroupRelations compileAndGroupRelations = new CompileAndGroupRelations();
|
|
|
|
compileAndGroupRelations.setCompileId(Long.valueOf(cfgIdStr));
|
|
|
|
compileAndGroupRelations.setCompileId(Long.valueOf(cfgIdStr));
|
|
|
|
compileAndGroupRelations.setGroupIdList(new ArrayList<GroupAndRegionRelations>());
|
|
|
|
compileAndGroupRelations.setGroupIdList(new ArrayList<GroupAndRegionRelations>());
|
|
|
|
@@ -176,7 +177,12 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void addGroupAndRegionRelations(List<Map<String, String>> regionMapList,
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 封装组id与域id对应关系并添加到对象中
|
|
|
|
|
|
|
|
* @param regionMapList
|
|
|
|
|
|
|
|
* @param compileAndGroupRelations
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private void addGroupAndRegionRelations(List<Map<String, String>> regionMapList,
|
|
|
|
CompileAndGroupRelations compileAndGroupRelations) {
|
|
|
|
CompileAndGroupRelations compileAndGroupRelations) {
|
|
|
|
if (regionMapList != null && regionMapList.size() > 0 && compileAndGroupRelations != null) {
|
|
|
|
if (regionMapList != null && regionMapList.size() > 0 && compileAndGroupRelations != null) {
|
|
|
|
for (Map<String, String> map : regionMapList) {
|
|
|
|
for (Map<String, String> map : regionMapList) {
|
|
|
|
@@ -191,118 +197,12 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void addMaatRelationOld(Map<Integer, List<MaatConfig>> configMap) {
|
|
|
|
|
|
|
|
if (configMap != null && configMap.size() > 0) {
|
|
|
|
|
|
|
|
for (Integer redisDBIndex : configMap.keySet()) {
|
|
|
|
|
|
|
|
if (redisDBIndex >= 0 && redisDBIndex <= 15) {
|
|
|
|
|
|
|
|
MaatRelation maatRelation = CompileGroupRegionRela.getIdRelationMap().get(redisDBIndex);
|
|
|
|
|
|
|
|
List<MaatConfig> maatConfigList = configMap.get(redisDBIndex);
|
|
|
|
|
|
|
|
if (maatConfigList != null && maatConfigList.size() > 0) {
|
|
|
|
|
|
|
|
for (MaatConfig maatConfig : maatConfigList) {
|
|
|
|
|
|
|
|
// MaatXmlConfig maatXmlConfig =
|
|
|
|
|
|
|
|
// ReadMaatXmlUtil.getMaatConfigByService(service);
|
|
|
|
|
|
|
|
List<Map<String, String>> groupMapList = maatConfig.getGroupMapList();
|
|
|
|
|
|
|
|
if (groupMapList != null && groupMapList.size() > 0) {
|
|
|
|
|
|
|
|
for (Map<String, String> map : groupMapList) {
|
|
|
|
|
|
|
|
String compileIdStr = map.get("cfg_id");
|
|
|
|
|
|
|
|
String groupIdStr = map.get("group_id");
|
|
|
|
|
|
|
|
if (compileIdStr != null && !compileIdStr.equals("") && groupIdStr != null
|
|
|
|
|
|
|
|
&& !groupIdStr.equals("")) {
|
|
|
|
|
|
|
|
Long groupId = Long.valueOf(groupIdStr);
|
|
|
|
|
|
|
|
Long compileId = Long.valueOf(compileIdStr);
|
|
|
|
|
|
|
|
Map<Long, Set<Long>> groupAndCompileMap = maatRelation.getGroupAndCompileMap();
|
|
|
|
|
|
|
|
if (groupAndCompileMap != null) {
|
|
|
|
|
|
|
|
if (groupAndCompileMap.containsKey(groupId)) {
|
|
|
|
|
|
|
|
groupAndCompileMap.get(groupId).add(compileId);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Set<Long> set = new HashSet<Long>();
|
|
|
|
|
|
|
|
set.add(compileId);
|
|
|
|
|
|
|
|
groupAndCompileMap.put(groupId, set);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Map<Long, Set<Long>> groupAndCompileMap1 = new ConcurrentHashMap<Long, Set<Long>>();
|
|
|
|
|
|
|
|
Set<Long> set = new HashSet<Long>();
|
|
|
|
|
|
|
|
set.add(compileId);
|
|
|
|
|
|
|
|
groupAndCompileMap1.put(groupId, set);
|
|
|
|
|
|
|
|
maatRelation.setGroupAndCompileMap(groupAndCompileMap1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Map<Long, Set<Long>> compileAndGroupMap = maatRelation.getCompileAndGroupMap();
|
|
|
|
|
|
|
|
if (compileAndGroupMap != null) {
|
|
|
|
|
|
|
|
if (compileAndGroupMap.containsKey(compileId)) {
|
|
|
|
|
|
|
|
compileAndGroupMap.get(compileId).add(groupId);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Set<Long> set = new HashSet<Long>();
|
|
|
|
|
|
|
|
set.add(groupId);
|
|
|
|
|
|
|
|
compileAndGroupMap.put(compileId, set);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Map<Long, Set<Long>> compileAndGroupMap1 = new ConcurrentHashMap<Long, Set<Long>>();
|
|
|
|
|
|
|
|
Set<Long> set = new HashSet<Long>();
|
|
|
|
|
|
|
|
set.add(groupId);
|
|
|
|
|
|
|
|
compileAndGroupMap1.put(compileId, set);
|
|
|
|
|
|
|
|
maatRelation.setCompileAndGroupMap(compileAndGroupMap1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
List<Map<String, String>> ipRegionMapList = maatConfig.getIpRegionMapList();
|
|
|
|
|
|
|
|
setReionAndGroupRela(ipRegionMapList, maatRelation);
|
|
|
|
|
|
|
|
List<Map<String, String>> numRegionMapList = maatConfig.getNumRegionMapList();
|
|
|
|
|
|
|
|
setReionAndGroupRela(numRegionMapList, maatRelation);
|
|
|
|
|
|
|
|
List<Map<String, String>> strRegionMapList = maatConfig.getStrRegionMapList();
|
|
|
|
|
|
|
|
setReionAndGroupRela(strRegionMapList, maatRelation);
|
|
|
|
|
|
|
|
List<Map<String, String>> strStrRegionMapList = maatConfig.getStrStrRegionMapList();
|
|
|
|
|
|
|
|
setReionAndGroupRela(strStrRegionMapList, maatRelation);
|
|
|
|
|
|
|
|
List<Map<String, String>> fileDigestRegionMapList = maatConfig.getFileDigestRegionMapList();
|
|
|
|
|
|
|
|
setReionAndGroupRela(fileDigestRegionMapList, maatRelation);
|
|
|
|
|
|
|
|
List<Map<String, String>> fileLikeRegionMapList = maatConfig.getFileLikeRegionMapList();
|
|
|
|
|
|
|
|
setReionAndGroupRela(fileLikeRegionMapList, maatRelation);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void setReionAndGroupRela(List<Map<String, String>> regionMapList, MaatRelation maatRelation) {
|
|
|
|
|
|
|
|
if (regionMapList != null && regionMapList.size() > 0) {
|
|
|
|
|
|
|
|
for (Map<String, String> map : regionMapList) {
|
|
|
|
|
|
|
|
String regionIdStr = map.get("region_id");
|
|
|
|
|
|
|
|
String groupIdStr = map.get("group_id");
|
|
|
|
|
|
|
|
if (regionIdStr != null && !regionIdStr.equals("") && groupIdStr != null && !groupIdStr.equals("")) {
|
|
|
|
|
|
|
|
Long groupId = Long.valueOf(groupIdStr);
|
|
|
|
|
|
|
|
Long regionId = Long.valueOf(regionIdStr);
|
|
|
|
|
|
|
|
Map<Long, Set<Long>> groupAndRegionMap = maatRelation.getGroupAndRegionMap();
|
|
|
|
|
|
|
|
if (groupAndRegionMap != null) {
|
|
|
|
|
|
|
|
if (groupAndRegionMap.containsKey(groupId)) {
|
|
|
|
|
|
|
|
groupAndRegionMap.get(groupId).add(regionId);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Set<Long> set = new HashSet<Long>();
|
|
|
|
|
|
|
|
set.add(regionId);
|
|
|
|
|
|
|
|
groupAndRegionMap.put(groupId, set);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
Map<Long, Set<Long>> groupAndRegionMap1 = new ConcurrentHashMap<Long, Set<Long>>();
|
|
|
|
|
|
|
|
Set<Long> set = new HashSet<Long>();
|
|
|
|
|
|
|
|
set.add(regionId);
|
|
|
|
|
|
|
|
groupAndRegionMap1.put(groupId, set);
|
|
|
|
|
|
|
|
maatRelation.setGroupAndRegionMap(groupAndRegionMap1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@Transactional
|
|
|
|
@Transactional
|
|
|
|
public void saveMaatConfig(Map<Integer, List<MaatConfig>> configMap) {
|
|
|
|
public void saveMaatConfig(Map<Integer, List<MaatConfig>> configMap) {
|
|
|
|
if (configMap != null && configMap.size() > 0) {
|
|
|
|
if (configMap != null && configMap.size() > 0) {
|
|
|
|
for (Integer redisDBIndex : configMap.keySet()) {
|
|
|
|
for (Integer redisDBIndex : configMap.keySet()) {
|
|
|
|
if (redisDBIndex >= 0 && redisDBIndex <= 15) {
|
|
|
|
if (redisDBIndex >= 0 && redisDBIndex < Configurations.getIntProperty("maxRedisDBIndex", 6)) {
|
|
|
|
RedisTemplate<String, String> redisTemplate = SpringContextHolder
|
|
|
|
RedisTemplate<String, String> redisTemplate = SpringContextHolder
|
|
|
|
.getBean("redisTemplate" + redisDBIndex);
|
|
|
|
.getBean("redisTemplate" + redisDBIndex);
|
|
|
|
String maatVersionStr = redisTemplate.opsForValue().get("MAAT_VERSION");
|
|
|
|
String maatVersionStr = redisTemplate.opsForValue().get("MAAT_VERSION");
|
|
|
|
@@ -316,73 +216,101 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|
|
|
for (MaatConfig maatConfig : maatConfigList) {
|
|
|
|
for (MaatConfig maatConfig : maatConfigList) {
|
|
|
|
int service = maatConfig.getService();
|
|
|
|
int service = maatConfig.getService();
|
|
|
|
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(service);
|
|
|
|
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(service);
|
|
|
|
setConfig(maatConfig, maatXmlConfig, maatVersion, service, redisTemplate);
|
|
|
|
setConfig(maatConfig, maatXmlConfig, maatVersion, service, redisTemplate, redisDBIndex);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
|
|
|
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
|
|
|
|
|
|
|
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDBIndex,
|
|
|
|
|
|
|
|
Integer.valueOf(maatVersionStr) + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// addMaatRelation(configMap);
|
|
|
|
addMaatRelation(configMap);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 将编译,分组,域等配置拆开分别添加到redis中
|
|
|
|
|
|
|
|
* @param maatConfig
|
|
|
|
|
|
|
|
* @param maatXmlConfig
|
|
|
|
|
|
|
|
* @param maatVersion
|
|
|
|
|
|
|
|
* @param service
|
|
|
|
|
|
|
|
* @param redisTemplate
|
|
|
|
|
|
|
|
* @param redisDBIndex
|
|
|
|
|
|
|
|
*/
|
|
|
|
public void setConfig(MaatConfig maatConfig, MaatXmlConfig maatXmlConfig, Long maatVersion, int service,
|
|
|
|
public void setConfig(MaatConfig maatConfig, MaatXmlConfig maatXmlConfig, Long maatVersion, int service,
|
|
|
|
RedisTemplate<String, String> redisTemplate) {
|
|
|
|
RedisTemplate<String, String> redisTemplate, Integer redisDBIndex) {
|
|
|
|
Map<String, String> compileMap = maatConfig.getCompileMap();
|
|
|
|
Map<String, String> compileMap = maatConfig.getCompileMap();
|
|
|
|
setCommonConfig(maatXmlConfig, compileMap, 10, maatVersion.doubleValue(), service, redisTemplate);// 10代表是编译配置
|
|
|
|
setCommonConfig(maatXmlConfig, compileMap, 10, maatVersion.doubleValue(), service, redisTemplate, redisDBIndex);// 10代表是编译配置
|
|
|
|
List<Map<String, String>> groupMapList = maatConfig.getGroupMapList();
|
|
|
|
List<Map<String, String>> groupMapList = maatConfig.getGroupMapList();
|
|
|
|
if (groupMapList != null && groupMapList.size() > 0) {
|
|
|
|
if (groupMapList != null && groupMapList.size() > 0) {
|
|
|
|
for (Map<String, String> map : groupMapList) {
|
|
|
|
for (Map<String, String> map : groupMapList) {
|
|
|
|
setCommonConfig(maatXmlConfig, map, 11, maatVersion.doubleValue(), service, redisTemplate);// 11代表是分组配置
|
|
|
|
setCommonConfig(maatXmlConfig, map, 11, maatVersion.doubleValue(), service, redisTemplate,
|
|
|
|
|
|
|
|
redisDBIndex);// 11代表是分组配置
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<Map<String, String>> ipRegionMapList = maatConfig.getIpRegionMapList();
|
|
|
|
List<Map<String, String>> ipRegionMapList = maatConfig.getIpRegionMapList();
|
|
|
|
if (ipRegionMapList != null && ipRegionMapList.size() > 0) {
|
|
|
|
if (ipRegionMapList != null && ipRegionMapList.size() > 0) {
|
|
|
|
for (Map<String, String> map : ipRegionMapList) {
|
|
|
|
for (Map<String, String> map : ipRegionMapList) {
|
|
|
|
setCommonConfig(maatXmlConfig, map, 12, maatVersion.doubleValue(), service, redisTemplate);// 12代表是ip类域配置
|
|
|
|
setCommonConfig(maatXmlConfig, map, 12, maatVersion.doubleValue(), service, redisTemplate,
|
|
|
|
|
|
|
|
redisDBIndex);// 12代表是ip类域配置
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<Map<String, String>> numRegionMapList = maatConfig.getNumRegionMapList();
|
|
|
|
List<Map<String, String>> numRegionMapList = maatConfig.getNumRegionMapList();
|
|
|
|
if (numRegionMapList != null && numRegionMapList.size() > 0) {
|
|
|
|
if (numRegionMapList != null && numRegionMapList.size() > 0) {
|
|
|
|
for (Map<String, String> map : numRegionMapList) {
|
|
|
|
for (Map<String, String> map : numRegionMapList) {
|
|
|
|
setCommonConfig(maatXmlConfig, map, 13, maatVersion.doubleValue(), service, redisTemplate);// 13代表是数值类配置
|
|
|
|
setCommonConfig(maatXmlConfig, map, 13, maatVersion.doubleValue(), service, redisTemplate,
|
|
|
|
|
|
|
|
redisDBIndex);// 13代表是数值类配置
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<Map<String, String>> strRegionMapList = maatConfig.getStrRegionMapList();
|
|
|
|
List<Map<String, String>> strRegionMapList = maatConfig.getStrRegionMapList();
|
|
|
|
if (strRegionMapList != null && strRegionMapList.size() > 0) {
|
|
|
|
if (strRegionMapList != null && strRegionMapList.size() > 0) {
|
|
|
|
for (Map<String, String> map : strRegionMapList) {
|
|
|
|
for (Map<String, String> map : strRegionMapList) {
|
|
|
|
setCommonConfig(maatXmlConfig, map, 14, maatVersion.doubleValue(), service, redisTemplate);// 14代表是字符串类域配置
|
|
|
|
setCommonConfig(maatXmlConfig, map, 14, maatVersion.doubleValue(), service, redisTemplate,
|
|
|
|
|
|
|
|
redisDBIndex);// 14代表是字符串类域配置
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<Map<String, String>> strStrRegionMapList = maatConfig.getStrStrRegionMapList();
|
|
|
|
List<Map<String, String>> strStrRegionMapList = maatConfig.getStrStrRegionMapList();
|
|
|
|
if (strStrRegionMapList != null && strStrRegionMapList.size() > 0) {
|
|
|
|
if (strStrRegionMapList != null && strStrRegionMapList.size() > 0) {
|
|
|
|
for (Map<String, String> map : strStrRegionMapList) {
|
|
|
|
for (Map<String, String> map : strStrRegionMapList) {
|
|
|
|
setCommonConfig(maatXmlConfig, map, 15, maatVersion.doubleValue(), service, redisTemplate);// 15代表是增强字符串类域配置
|
|
|
|
setCommonConfig(maatXmlConfig, map, 15, maatVersion.doubleValue(), service, redisTemplate,
|
|
|
|
|
|
|
|
redisDBIndex);// 15代表是增强字符串类域配置
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<Map<String, String>> fileDigestRegionMapList = maatConfig.getFileDigestRegionMapList();
|
|
|
|
List<Map<String, String>> fileDigestRegionMapList = maatConfig.getFileDigestRegionMapList();
|
|
|
|
if (fileDigestRegionMapList != null && fileDigestRegionMapList.size() > 0) {
|
|
|
|
if (fileDigestRegionMapList != null && fileDigestRegionMapList.size() > 0) {
|
|
|
|
for (Map<String, String> map : fileDigestRegionMapList) {
|
|
|
|
for (Map<String, String> map : fileDigestRegionMapList) {
|
|
|
|
setCommonConfig(maatXmlConfig, map, 16, maatVersion.doubleValue(), service, redisTemplate);// 16代表是文件摘要类域配置
|
|
|
|
setCommonConfig(maatXmlConfig, map, 16, maatVersion.doubleValue(), service, redisTemplate,
|
|
|
|
|
|
|
|
redisDBIndex);// 16代表是文件摘要类域配置
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<Map<String, String>> fileLikeRegionMapList = maatConfig.getFileLikeRegionMapList();
|
|
|
|
List<Map<String, String>> fileLikeRegionMapList = maatConfig.getFileLikeRegionMapList();
|
|
|
|
if (fileLikeRegionMapList != null && fileLikeRegionMapList.size() > 0) {
|
|
|
|
if (fileLikeRegionMapList != null && fileLikeRegionMapList.size() > 0) {
|
|
|
|
for (Map<String, String> map : fileLikeRegionMapList) {
|
|
|
|
for (Map<String, String> map : fileLikeRegionMapList) {
|
|
|
|
setCommonConfig(maatXmlConfig, map, 17, maatVersion.doubleValue(), service, redisTemplate);// 17代表是文本相似性域配置
|
|
|
|
setCommonConfig(maatXmlConfig, map, 17, maatVersion.doubleValue(), service, redisTemplate,
|
|
|
|
|
|
|
|
redisDBIndex);// 17代表是文本相似性域配置
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// updateCommonKey(maatXmlConfig);
|
|
|
|
// updateCommonKey(maatXmlConfig);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 将整理好的数据添加到redis中
|
|
|
|
|
|
|
|
* @param maatXmlConfig
|
|
|
|
|
|
|
|
* @param map
|
|
|
|
|
|
|
|
* @param type
|
|
|
|
|
|
|
|
* @param maatVersion
|
|
|
|
|
|
|
|
* @param service
|
|
|
|
|
|
|
|
* @param redisTemplate
|
|
|
|
|
|
|
|
* @param redisDBIndex
|
|
|
|
|
|
|
|
*/
|
|
|
|
public void setCommonConfig(MaatXmlConfig maatXmlConfig, Map<String, String> map, int type, Double maatVersion,
|
|
|
|
public void setCommonConfig(MaatXmlConfig maatXmlConfig, Map<String, String> map, int type, Double maatVersion,
|
|
|
|
int service, RedisTemplate<String, String> redisTemplate) {
|
|
|
|
int service, RedisTemplate<String, String> redisTemplate, Integer redisDBIndex) {
|
|
|
|
if (maatXmlConfig != null && map != null && map.size() > 0) {
|
|
|
|
if (maatXmlConfig != null && map != null && map.size() > 0) {
|
|
|
|
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
|
|
|
|
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
|
|
|
|
String maatKey = "";
|
|
|
|
String maatKey = null;
|
|
|
|
for (MaatXmlExpr maatXmlExpr : expressionList) {
|
|
|
|
for (MaatXmlExpr maatXmlExpr : expressionList) {
|
|
|
|
if (type == maatXmlExpr.getType().intValue()) {
|
|
|
|
if (type == maatXmlExpr.getType().intValue()) {
|
|
|
|
StringBuffer keyBF = new StringBuffer();
|
|
|
|
StringBuffer keyBF = new StringBuffer();
|
|
|
|
@@ -416,9 +344,10 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
maatKey = keyBF.toString();
|
|
|
|
maatKey = keyBF.toString();
|
|
|
|
System.out.println(keyBF.toString());
|
|
|
|
|
|
|
|
System.out.println(valBF.toString());
|
|
|
|
|
|
|
|
redisTemplate.opsForValue().set(maatKey.toUpperCase(), valBF.toString());
|
|
|
|
redisTemplate.opsForValue().set(maatKey.toUpperCase(), valBF.toString());
|
|
|
|
|
|
|
|
logger.info("向{}号redis数据库添加了一条配置,key是{},value是{}", redisDBIndex, maatKey.toUpperCase(),
|
|
|
|
|
|
|
|
valBF.toString());
|
|
|
|
|
|
|
|
|
|
|
|
// redisTemplate.boundValueOps(keyBF.toString()).set(valBF.toString());
|
|
|
|
// redisTemplate.boundValueOps(keyBF.toString()).set(valBF.toString());
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -426,19 +355,27 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (MaatXmlExpr maatXmlExpr : expressionList) {
|
|
|
|
for (MaatXmlExpr maatXmlExpr : expressionList) {
|
|
|
|
if (maatXmlExpr.getKeyExpression().toUpperCase().equals("MAAT_UPDATE_STATUS")) {
|
|
|
|
if (maatXmlExpr.getKeyExpression().toUpperCase().equals("MAAT_UPDATE_STATUS")) {
|
|
|
|
String zset = maatKey.replace("EFFECTIVE_RULE:", "ADD,");
|
|
|
|
if (maatKey != null) {
|
|
|
|
redisTemplate.boundZSetOps("MAAT_UPDATE_STATUS").add(zset, maatVersion);
|
|
|
|
String zset = maatKey.replace("EFFECTIVE_RULE:", "ADD,");
|
|
|
|
|
|
|
|
redisTemplate.boundZSetOps("MAAT_UPDATE_STATUS").add(zset, maatVersion);
|
|
|
|
|
|
|
|
logger.info("向{}号redis数据库更新了MAAT_UPDATE_STATUS,内容是{},SCORES是{}", redisDBIndex,
|
|
|
|
|
|
|
|
zset.toUpperCase(), maatVersion);
|
|
|
|
|
|
|
|
}
|
|
|
|
} else if (maatXmlExpr.getKeyExpression().toUpperCase().equals("MAAT_RULE_TIMER")) {
|
|
|
|
} else if (maatXmlExpr.getKeyExpression().toUpperCase().equals("MAAT_RULE_TIMER")) {
|
|
|
|
Double score = 0d;// 界面下发的配置没有超时时间所以这里设置为0
|
|
|
|
if (maatKey != null) {
|
|
|
|
redisTemplate.boundZSetOps("MAAT_RULE_TIMER").add(maatKey, score);
|
|
|
|
Double score = 0d;// 界面下发的配置没有超时时间所以这里设置为0
|
|
|
|
|
|
|
|
redisTemplate.boundZSetOps("MAAT_RULE_TIMER").add(maatKey, score);
|
|
|
|
|
|
|
|
logger.info("向{}号redis数据库更新了MAAT_RULE_TIMER,内容是{},SCORES是{}", redisDBIndex, maatKey, score);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
} else if (maatXmlExpr.getKeyExpression().toUpperCase().equals("MAAT_VERSION_TIMER")) {
|
|
|
|
} else if (maatXmlExpr.getKeyExpression().toUpperCase().equals("MAAT_VERSION_TIMER")) {
|
|
|
|
Long nowTime = new Date().getTime();
|
|
|
|
Long nowTime = new Date().getTime();
|
|
|
|
nowTime = nowTime / 1000l;
|
|
|
|
nowTime = nowTime / 1000l;
|
|
|
|
Double score = nowTime.doubleValue();// 使用redis自带的time,得到当前时间的秒
|
|
|
|
Double score = nowTime.doubleValue();// 使用redis自带的time,得到当前时间的秒
|
|
|
|
redisTemplate.boundZSetOps("MAAT_VERSION_TIMER").add(maatVersion + "", score);
|
|
|
|
redisTemplate.boundZSetOps("MAAT_VERSION_TIMER").add(maatVersion + "", score);
|
|
|
|
|
|
|
|
logger.info("向{}号redis数据库更新了MAAT_VERSION_TIMER,内容是{},SCORES是{}", redisDBIndex, maatVersion, score);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -457,7 +394,9 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|
|
|
|
|
|
|
|
|
|
|
public Long getIncrId(String key) {
|
|
|
|
public Long getIncrId(String key) {
|
|
|
|
RedisTemplate<String, String> redisTemplate = SpringContextHolder.getBean("redisTemplate0");
|
|
|
|
RedisTemplate<String, String> redisTemplate = SpringContextHolder.getBean("redisTemplate0");
|
|
|
|
return redisTemplate.boundValueOps(key.toUpperCase()).increment(1l);
|
|
|
|
Long id = redisTemplate.boundValueOps(key.toUpperCase()).increment(1l);
|
|
|
|
|
|
|
|
logger.info("从0号redis数据库获取{}成功,自增后的值是{}", key, id);
|
|
|
|
|
|
|
|
return id;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@@ -482,7 +421,7 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|
|
|
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(service);
|
|
|
|
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(service);
|
|
|
|
if (maatXmlConfig != null) {
|
|
|
|
if (maatXmlConfig != null) {
|
|
|
|
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
|
|
|
|
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
|
|
|
|
String maatKey = "";
|
|
|
|
String maatKey = null;
|
|
|
|
for (MaatXmlExpr maatXmlExpr : expressionList) {
|
|
|
|
for (MaatXmlExpr maatXmlExpr : expressionList) {
|
|
|
|
if (0 == maatXmlExpr.getType().intValue()) {
|
|
|
|
if (0 == maatXmlExpr.getType().intValue()) {
|
|
|
|
StringBuffer keyBF = new StringBuffer();
|
|
|
|
StringBuffer keyBF = new StringBuffer();
|
|
|
|
@@ -504,6 +443,9 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|
|
|
String oldKey = maatKey.replace("OBSOLETE_RULE", "EFFECTIVE_RULE");
|
|
|
|
String oldKey = maatKey.replace("OBSOLETE_RULE", "EFFECTIVE_RULE");
|
|
|
|
redisTemplate.rename(oldKey.toString().toUpperCase(),
|
|
|
|
redisTemplate.rename(oldKey.toString().toUpperCase(),
|
|
|
|
keyBF.toString().toUpperCase());
|
|
|
|
keyBF.toString().toUpperCase());
|
|
|
|
|
|
|
|
logger.info("向{}号redis数据库修改了一条配置,修改前key是{},修改后key是{}", redisDBIndex,
|
|
|
|
|
|
|
|
oldKey.toString().toUpperCase(),
|
|
|
|
|
|
|
|
keyBF.toString().toUpperCase());
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// redisTemplate.boundValueOps(keyBF.toString().toUpperCase()).set(valBF.toString());
|
|
|
|
// redisTemplate.boundValueOps(keyBF.toString().toUpperCase()).set(valBF.toString());
|
|
|
|
@@ -512,12 +454,21 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|
|
|
for (MaatXmlExpr maatXmlExpr : expressionList) {
|
|
|
|
for (MaatXmlExpr maatXmlExpr : expressionList) {
|
|
|
|
if (maatXmlExpr.getKeyExpression().toUpperCase()
|
|
|
|
if (maatXmlExpr.getKeyExpression().toUpperCase()
|
|
|
|
.equals("MAAT_UPDATE_STATUS")) {
|
|
|
|
.equals("MAAT_UPDATE_STATUS")) {
|
|
|
|
String zset = maatKey.replace("OBSOLETE_RULE:", "DEL,");
|
|
|
|
if (maatKey != null) {
|
|
|
|
redisTemplate.boundZSetOps("MAAT_UPDATE_STATUS").add(zset, maatVersion);
|
|
|
|
String zset = maatKey.replace("OBSOLETE_RULE:", "DEL,");
|
|
|
|
|
|
|
|
redisTemplate.boundZSetOps("MAAT_UPDATE_STATUS").add(zset,
|
|
|
|
|
|
|
|
maatVersion);
|
|
|
|
|
|
|
|
logger.info("向{}号redis数据库更新了MAAT_UPDATE_STATUS,内容是{},SCORES是{}",
|
|
|
|
|
|
|
|
redisDBIndex, zset.toUpperCase(), maatVersion);
|
|
|
|
|
|
|
|
}
|
|
|
|
} else if (maatXmlExpr.getKeyExpression().toUpperCase()
|
|
|
|
} else if (maatXmlExpr.getKeyExpression().toUpperCase()
|
|
|
|
.equals("MAAT_RULE_TIMER")) {
|
|
|
|
.equals("MAAT_RULE_TIMER")) {
|
|
|
|
Double score = 0d;// 界面下发的配置没有超时时间所以这里设置为0
|
|
|
|
if (maatKey != null) {
|
|
|
|
redisTemplate.boundZSetOps("MAAT_RULE_TIMER").add(maatKey, score);
|
|
|
|
Double score = 0d;// 界面下发的配置没有超时时间所以这里设置为0
|
|
|
|
|
|
|
|
redisTemplate.boundZSetOps("MAAT_RULE_TIMER").add(maatKey, score);
|
|
|
|
|
|
|
|
logger.info("向{}号redis数据库更新了MAAT_RULE_TIMER,内容是{},SCORES是{}",
|
|
|
|
|
|
|
|
redisDBIndex, maatKey, score);
|
|
|
|
|
|
|
|
}
|
|
|
|
} else if (maatXmlExpr.getKeyExpression().toUpperCase()
|
|
|
|
} else if (maatXmlExpr.getKeyExpression().toUpperCase()
|
|
|
|
.equals("MAAT_VERSION_TIMER")) {
|
|
|
|
.equals("MAAT_VERSION_TIMER")) {
|
|
|
|
Long nowTime = new Date().getTime();
|
|
|
|
Long nowTime = new Date().getTime();
|
|
|
|
@@ -525,6 +476,8 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|
|
|
Double score = nowTime.doubleValue();// 使用redis自带的time,得到当前时间的秒
|
|
|
|
Double score = nowTime.doubleValue();// 使用redis自带的time,得到当前时间的秒
|
|
|
|
redisTemplate.boundZSetOps("MAAT_VERSION_TIMER").add(maatVersion + "",
|
|
|
|
redisTemplate.boundZSetOps("MAAT_VERSION_TIMER").add(maatVersion + "",
|
|
|
|
score);
|
|
|
|
score);
|
|
|
|
|
|
|
|
logger.info("向{}号redis数据库更新了MAAT_VERSION_TIMER,内容是{},SCORES是{}",
|
|
|
|
|
|
|
|
redisDBIndex, maatVersion, score);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<MaatXmlSeq> seqList = maatXmlConfig.getSequenceList();
|
|
|
|
List<MaatXmlSeq> seqList = maatXmlConfig.getSequenceList();
|
|
|
|
@@ -542,11 +495,11 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
|
|
|
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
|
|
|
|
|
|
|
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDBIndex,
|
|
|
|
|
|
|
|
Integer.valueOf(maatVersionStr) + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -574,11 +527,13 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|
|
|
Long maatVersion = Long.valueOf(maatVersionStr) + 1;
|
|
|
|
Long maatVersion = Long.valueOf(maatVersionStr) + 1;
|
|
|
|
for (Integer service : serviceConfigMap.keySet()) {
|
|
|
|
for (Integer service : serviceConfigMap.keySet()) {
|
|
|
|
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(service);
|
|
|
|
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(service);
|
|
|
|
setConfig(serviceConfigMap.get(service), maatXmlConfig, maatVersion, service, redisTemplate,
|
|
|
|
removeConfig(serviceConfigMap.get(service), maatXmlConfig, maatVersion, service,
|
|
|
|
maatRelation);
|
|
|
|
redisTemplate, maatRelation, redisDBIndex);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
|
|
|
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
|
|
|
|
|
|
|
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDBIndex,
|
|
|
|
|
|
|
|
Integer.valueOf(maatVersionStr) + 1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -588,31 +543,42 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setConfig(List<Long> idList, MaatXmlConfig maatXmlConfig, Long maatVersion, int service,
|
|
|
|
/**
|
|
|
|
RedisTemplate<String, String> redisTemplate, MaatRelation maatRelation) {
|
|
|
|
* 删除maat类配置
|
|
|
|
|
|
|
|
* @param idList 配置id集合
|
|
|
|
|
|
|
|
* @param maatXmlConfig maat.xml中关于当前业务类型的key和value写法的对象
|
|
|
|
|
|
|
|
* @param maatVersion 版本号
|
|
|
|
|
|
|
|
* @param service 业务类型
|
|
|
|
|
|
|
|
* @param redisTemplate
|
|
|
|
|
|
|
|
* @param maatRelation id对应关系对象
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private void removeConfig(List<Long> idList, MaatXmlConfig maatXmlConfig, Long maatVersion, int service,
|
|
|
|
|
|
|
|
RedisTemplate<String, String> redisTemplate, MaatRelation maatRelation, int redisDBIndex) {
|
|
|
|
if (maatRelation != null && idList != null && idList.size() > 0 && maatXmlConfig != null) {
|
|
|
|
if (maatRelation != null && idList != null && idList.size() > 0 && maatXmlConfig != null) {
|
|
|
|
for (Long id : idList) {
|
|
|
|
for (Long id : idList) {
|
|
|
|
Set<Long> compileIdList = new HashSet<Long>();
|
|
|
|
Set<Long> compileIdList = new HashSet<Long>();
|
|
|
|
compileIdList.add(id);
|
|
|
|
compileIdList.add(id);
|
|
|
|
setCommonConfig(maatXmlConfig, compileIdList, 10, maatVersion.doubleValue(), service, redisTemplate);// 10代表是编译配置
|
|
|
|
removeCommonConfig(maatXmlConfig, compileIdList, 10, maatVersion.doubleValue(), service, redisTemplate,
|
|
|
|
|
|
|
|
redisDBIndex);// 10代表是编译配置
|
|
|
|
Set<Long> groupSet = maatRelation.getCompileAndGroupMap().get(id);
|
|
|
|
Set<Long> groupSet = maatRelation.getCompileAndGroupMap().get(id);
|
|
|
|
if (groupSet != null && groupSet.size() > 0) {
|
|
|
|
if (groupSet != null && groupSet.size() > 0) {
|
|
|
|
setCommonConfig(maatXmlConfig, groupSet, 11, maatVersion.doubleValue(), service, redisTemplate);// 11代表是分组配置
|
|
|
|
removeCommonConfig(maatXmlConfig, groupSet, 11, maatVersion.doubleValue(), service, redisTemplate,
|
|
|
|
|
|
|
|
redisDBIndex);// 11代表是分组配置
|
|
|
|
for (Long groupId : groupSet) {
|
|
|
|
for (Long groupId : groupSet) {
|
|
|
|
Set<Long> regionIdSet = maatRelation.getGroupAndRegionMap().get(groupId);
|
|
|
|
Set<Long> regionIdSet = maatRelation.getGroupAndRegionMap().get(groupId);
|
|
|
|
if (regionIdSet != null && regionIdSet.size() > 0) {
|
|
|
|
if (regionIdSet != null && regionIdSet.size() > 0) {
|
|
|
|
setCommonConfig(maatXmlConfig, regionIdSet, 12, maatVersion.doubleValue(), service,
|
|
|
|
removeCommonConfig(maatXmlConfig, regionIdSet, 12, maatVersion.doubleValue(), service,
|
|
|
|
redisTemplate);// 12代表是ip类域配置
|
|
|
|
redisTemplate, redisDBIndex);// 12代表是ip类域配置
|
|
|
|
setCommonConfig(maatXmlConfig, regionIdSet, 13, maatVersion.doubleValue(), service,
|
|
|
|
removeCommonConfig(maatXmlConfig, regionIdSet, 13, maatVersion.doubleValue(), service,
|
|
|
|
redisTemplate);// 13代表是数值类配置
|
|
|
|
redisTemplate, redisDBIndex);// 13代表是数值类配置
|
|
|
|
setCommonConfig(maatXmlConfig, regionIdSet, 14, maatVersion.doubleValue(), service,
|
|
|
|
removeCommonConfig(maatXmlConfig, regionIdSet, 14, maatVersion.doubleValue(), service,
|
|
|
|
redisTemplate);// 14代表是字符串类域配置
|
|
|
|
redisTemplate, redisDBIndex);// 14代表是字符串类域配置
|
|
|
|
setCommonConfig(maatXmlConfig, regionIdSet, 15, maatVersion.doubleValue(), service,
|
|
|
|
removeCommonConfig(maatXmlConfig, regionIdSet, 15, maatVersion.doubleValue(), service,
|
|
|
|
redisTemplate);// 15代表是增强字符串类域配置
|
|
|
|
redisTemplate, redisDBIndex);// 15代表是增强字符串类域配置
|
|
|
|
setCommonConfig(maatXmlConfig, regionIdSet, 16, maatVersion.doubleValue(), service,
|
|
|
|
removeCommonConfig(maatXmlConfig, regionIdSet, 16, maatVersion.doubleValue(), service,
|
|
|
|
redisTemplate);// 16代表是文件摘要类域配置
|
|
|
|
redisTemplate, redisDBIndex);// 16代表是文件摘要类域配置
|
|
|
|
setCommonConfig(maatXmlConfig, regionIdSet, 17, maatVersion.doubleValue(), service,
|
|
|
|
removeCommonConfig(maatXmlConfig, regionIdSet, 17, maatVersion.doubleValue(), service,
|
|
|
|
redisTemplate);// 17代表是文本相似性域配置
|
|
|
|
redisTemplate, redisDBIndex);// 17代表是文本相似性域配置
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -620,8 +586,17 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setCommonConfig(MaatXmlConfig maatXmlConfig, Set<Long> idList, int type, Double maatVersion,
|
|
|
|
/**
|
|
|
|
int service, RedisTemplate<String, String> redisTemplate) {
|
|
|
|
* 删除maat配置时,对redis进行相关操作,主要是重命名key和记录相关状态
|
|
|
|
|
|
|
|
* @param maatXmlConfig
|
|
|
|
|
|
|
|
* @param idList
|
|
|
|
|
|
|
|
* @param type
|
|
|
|
|
|
|
|
* @param maatVersion
|
|
|
|
|
|
|
|
* @param service
|
|
|
|
|
|
|
|
* @param redisTemplate
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public void removeCommonConfig(MaatXmlConfig maatXmlConfig, Set<Long> idList, int type, Double maatVersion,
|
|
|
|
|
|
|
|
int service, RedisTemplate<String, String> redisTemplate, int redisDBIndex) {
|
|
|
|
if (maatXmlConfig != null && idList != null && idList.size() > 0) {
|
|
|
|
if (maatXmlConfig != null && idList != null && idList.size() > 0) {
|
|
|
|
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
|
|
|
|
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
|
|
|
|
String maatKey = null;
|
|
|
|
String maatKey = null;
|
|
|
|
@@ -647,6 +622,8 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|
|
|
String oldKey = keyBF.toString().toUpperCase();
|
|
|
|
String oldKey = keyBF.toString().toUpperCase();
|
|
|
|
maatKey = oldKey.replace("EFFECTIVE_RULE", "OBSOLETE_RULE");
|
|
|
|
maatKey = oldKey.replace("EFFECTIVE_RULE", "OBSOLETE_RULE");
|
|
|
|
redisTemplate.rename(oldKey, maatKey.toUpperCase());
|
|
|
|
redisTemplate.rename(oldKey, maatKey.toUpperCase());
|
|
|
|
|
|
|
|
logger.info("向{}号redis数据库修改了一条配置,修改前key是{},修改后key是{}", redisDBIndex, oldKey,
|
|
|
|
|
|
|
|
maatKey.toUpperCase());
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@@ -655,6 +632,10 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|
|
|
if (maatKey != null) {
|
|
|
|
if (maatKey != null) {
|
|
|
|
String zset = maatKey.replace("OBSOLETE_RULE:", "DEL,");
|
|
|
|
String zset = maatKey.replace("OBSOLETE_RULE:", "DEL,");
|
|
|
|
redisTemplate.boundZSetOps("MAAT_UPDATE_STATUS").add(zset, maatVersion);
|
|
|
|
redisTemplate.boundZSetOps("MAAT_UPDATE_STATUS").add(zset, maatVersion);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
logger.info("向{}号redis数据库更新了MAAT_UPDATE_STATUS,内容是{},SCORES是{}", redisDBIndex,
|
|
|
|
|
|
|
|
zset.toUpperCase(), maatVersion);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
} else if (maatXmlExpr.getKeyExpression().toUpperCase().equals("MAAT_RULE_TIMER")) {
|
|
|
|
} else if (maatXmlExpr.getKeyExpression().toUpperCase().equals("MAAT_RULE_TIMER")) {
|
|
|
|
@@ -662,23 +643,31 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|
|
|
|
|
|
|
|
|
|
|
Double score = 0d;// 界面下发的配置没有超时时间所以这里设置为0
|
|
|
|
Double score = 0d;// 界面下发的配置没有超时时间所以这里设置为0
|
|
|
|
redisTemplate.boundZSetOps("MAAT_RULE_TIMER").add(maatKey, score);
|
|
|
|
redisTemplate.boundZSetOps("MAAT_RULE_TIMER").add(maatKey, score);
|
|
|
|
|
|
|
|
logger.info("向{}号redis数据库更新了MAAT_RULE_TIMER,内容是{},SCORES是{}", redisDBIndex, maatKey, score);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (maatXmlExpr.getKeyExpression().toUpperCase().equals("MAAT_VERSION_TIMER")) {
|
|
|
|
} else if (maatXmlExpr.getKeyExpression().toUpperCase().equals("MAAT_VERSION_TIMER")) {
|
|
|
|
Long nowTime = new Date().getTime();
|
|
|
|
Long nowTime = new Date().getTime();
|
|
|
|
nowTime = nowTime / 1000l;
|
|
|
|
nowTime = nowTime / 1000l;
|
|
|
|
Double score = nowTime.doubleValue();// 使用redis自带的time,得到当前时间的秒
|
|
|
|
Double score = nowTime.doubleValue();// 使用redis自带的time,得到当前时间的秒
|
|
|
|
redisTemplate.boundZSetOps("MAAT_VERSION_TIMER").add(maatVersion + "", score);
|
|
|
|
redisTemplate.boundZSetOps("MAAT_VERSION_TIMER").add(maatVersion + "", score);
|
|
|
|
|
|
|
|
logger.info("向{}号redis数据库更新了MAAT_VERSION_TIMER,内容是{},SCORES是{}", redisDBIndex, maatVersion,
|
|
|
|
|
|
|
|
score);
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 删除配置成功后,需要更新编译,组,域等配置id的对应关系
|
|
|
|
|
|
|
|
* @param idMap
|
|
|
|
|
|
|
|
*/
|
|
|
|
public void delMaatRelation(Map<Integer, Map<Integer, List<Long>>> idMap) {
|
|
|
|
public void delMaatRelation(Map<Integer, Map<Integer, List<Long>>> idMap) {
|
|
|
|
if (idMap != null && idMap.size() > 0) {
|
|
|
|
if (idMap != null && idMap.size() > 0) {
|
|
|
|
for (Integer redisDBIndex : idMap.keySet()) {
|
|
|
|
for (Integer redisDBIndex : idMap.keySet()) {
|
|
|
|
if (redisDBIndex >= 0 && redisDBIndex <= 15) {
|
|
|
|
if (redisDBIndex >= 0 && redisDBIndex < Configurations.getIntProperty("maxRedisDBIndex", 6)) {
|
|
|
|
// MaatRelation maatRelation =
|
|
|
|
// MaatRelation maatRelation =
|
|
|
|
// CompileGroupRegionRela.getIdRelationMap().get(redisDBIndex);
|
|
|
|
// CompileGroupRegionRela.getIdRelationMap().get(redisDBIndex);
|
|
|
|
Map<Integer, List<Long>> map = idMap.get(redisDBIndex);
|
|
|
|
Map<Integer, List<Long>> map = idMap.get(redisDBIndex);
|
|
|
|
@@ -697,24 +686,4 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void delMaatRelationOld(Map<Integer, Map<Integer, List<Long>>> idMap) {
|
|
|
|
|
|
|
|
if (idMap != null && idMap.size() > 0) {
|
|
|
|
|
|
|
|
for (Integer redisDBIndex : idMap.keySet()) {
|
|
|
|
|
|
|
|
if (redisDBIndex >= 0 && redisDBIndex <= 15) {
|
|
|
|
|
|
|
|
MaatRelation maatRelation = CompileGroupRegionRela.getIdRelationMap().get(redisDBIndex);
|
|
|
|
|
|
|
|
Map<Integer, List<Long>> map = idMap.get(redisDBIndex);
|
|
|
|
|
|
|
|
if (map != null && map.size() > 0) {
|
|
|
|
|
|
|
|
for (Integer service : map.keySet()) {
|
|
|
|
|
|
|
|
List<Long> idList = map.get(service);
|
|
|
|
|
|
|
|
if (idList != null && idList.size() > 0) {
|
|
|
|
|
|
|
|
for (Long compileId : idList) {
|
|
|
|
|
|
|
|
// CompileGroupRegionRela.removKey(maatRelation, compileId);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|