在本地合并冲突
This commit is contained in:
@@ -6,6 +6,7 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
@@ -15,12 +16,14 @@ import net.sf.json.JSONObject;
|
||||
import org.apache.commons.codec.digest.DigestUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Scope;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.nis.datasource.DynamicJedisDataBase;
|
||||
import com.nis.domain.restful.ConfigCompile;
|
||||
import com.nis.domain.restful.ConfigSource;
|
||||
import com.nis.domain.restful.FileDesc;
|
||||
@@ -37,6 +40,7 @@ import com.nis.web.service.ServicesRequestLogService;
|
||||
import com.nis.web.service.fdfs.FastDFSFile;
|
||||
import com.nis.web.service.fdfs.FileManager;
|
||||
import com.nis.web.service.restful.ConfigRedisService;
|
||||
import com.nis.web.service.restful.ConfigRedisServiceimpl;
|
||||
import com.nis.web.service.restful.ConfigSourcesService;
|
||||
import com.wordnik.swagger.annotations.Api;
|
||||
import com.wordnik.swagger.annotations.ApiOperation;
|
||||
@@ -49,6 +53,7 @@ import com.wordnik.swagger.annotations.ApiParam;
|
||||
* @date 2016年9月5日 下午6:20:33
|
||||
* @version V1.0
|
||||
*/
|
||||
//@Scope("prototype")
|
||||
@RestController
|
||||
@RequestMapping("${servicePath}")
|
||||
@Api(value = "ConfigSourcesController", description = "配置存储服务,包括管控、监测、白名单的控制类")
|
||||
@@ -62,7 +67,7 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
@Autowired
|
||||
ConfigRedisService configRedisService;
|
||||
|
||||
@RequestMapping(value = "/save", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/cfg/v1/save", method = RequestMethod.GET)
|
||||
@ApiOperation(value = "test redis", httpMethod = "GET", response = Map.class, notes = "测试redis事务的crontroller")
|
||||
@ApiParam(value = "test redis", name = "测试redis事务的crontroller", required = true)
|
||||
public String testRedis(Integer type) {
|
||||
@@ -85,7 +90,6 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
configRedisService.saveUnMaatConfig(listMap, service);
|
||||
} else {
|
||||
Integer service = 100;
|
||||
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
long id = configRedisService.getIncrId("seq_compileid");
|
||||
// int id=2;
|
||||
@@ -105,7 +109,7 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
return "false";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/saveMaat", method = RequestMethod.GET)
|
||||
@RequestMapping(value = "/cfg/v1/saveMaat", method = RequestMethod.GET)
|
||||
@ApiOperation(value = "test redis", httpMethod = "GET", response = Map.class, notes = "测试redis事务的crontroller")
|
||||
@ApiParam(value = "test redis", name = "测试redis事务的crontroller", required = true)
|
||||
public String saveMaat(Integer service) {
|
||||
@@ -200,7 +204,6 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
maatConfig.setIpRegionMapList(ipRegionMapList);
|
||||
return maatConfig;
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/cfg/v1/configSources", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "业务配置存储", httpMethod = "POST", response = Map.class, notes = "对有效的配置(封堵|监测|白名单)存储")
|
||||
@ApiParam(value = "业务配置数据源", name = "configSource", required = true)
|
||||
@@ -219,30 +222,7 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
// 验证配置编译数据
|
||||
validateConfigSource(thread, start, configSource);
|
||||
Long benginTime = System.currentTimeMillis();
|
||||
String msg = configSourcesService.saveByJDBCThread(thread, start, configSource.getConfigCompileList(), sb);
|
||||
if (msg.equals("error")) {
|
||||
String errorCode = "";
|
||||
Exception exception = ConfigSourcesService.getMsgList().get(0);
|
||||
String str = exception.getMessage();
|
||||
if (null != str && str.length() > 0) {
|
||||
int index = str.toUpperCase().indexOf("ORA-");
|
||||
if (index != -1) {
|
||||
errorCode = str.substring(index + 4, index + 9);
|
||||
}
|
||||
}
|
||||
Map<Integer, String> throwExceptionInfo = OracleErrorCodeUtil.throwExceptionInfo(errorCode);
|
||||
for (int errorNum : throwExceptionInfo.keySet()) {
|
||||
if (errorNum == 998) {
|
||||
thread.setExceptionInfo(exception.toString());
|
||||
} else {
|
||||
thread.setExceptionInfo(throwExceptionInfo.get(errorNum));
|
||||
}
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
||||
throwExceptionInfo.get(errorNum), errorNum);
|
||||
}
|
||||
}
|
||||
// configSourcesService.insertConfigSourceData(thread, start,
|
||||
// configSource.getConfigCompileList(), sb);
|
||||
configSourcesService.saveMaatConfig(thread, start, configSource.getConfigCompileList(), sb);
|
||||
|
||||
Long endSaveTime = System.currentTimeMillis();
|
||||
Long time = (endSaveTime - benginTime) / 1000;
|
||||
|
||||
@@ -584,9 +584,9 @@ public class ConfigTestController extends BaseRestController {
|
||||
configCompile.setContLabel("0");
|
||||
configCompile.setTaskId(0);
|
||||
configCompile.setGuaranteeId(0);
|
||||
configCompile.setAffAirId(0);
|
||||
configCompile.setTopIcId(0);
|
||||
configCompile.setDoBlackList(0l);
|
||||
configCompile.setAffairId(0);
|
||||
configCompile.setTopicId(0);
|
||||
configCompile.setDoBlacklist(0l);
|
||||
configCompile.setDoLog(0);
|
||||
configCompile.setEffectiveRange("0");
|
||||
configCompile.setConfigPercent(100l);
|
||||
|
||||
@@ -243,9 +243,9 @@ public class SaveConfigTestController extends BaseRestController {
|
||||
configCompile.setContLabel("0");
|
||||
configCompile.setTaskId(0);
|
||||
configCompile.setGuaranteeId(0);
|
||||
configCompile.setAffAirId(0);
|
||||
configCompile.setTopIcId(0);
|
||||
configCompile.setDoBlackList(1l);
|
||||
configCompile.setAffairId(0);
|
||||
configCompile.setTopicId(0);
|
||||
configCompile.setDoBlacklist(1l);
|
||||
configCompile.setDoLog(0);
|
||||
configCompile.setEffectiveRange("0");
|
||||
configCompile.setConfigPercent(100l);
|
||||
|
||||
@@ -1,21 +1,28 @@
|
||||
package com.nis.web.dao.impl;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.data.redis.serializer.StringRedisSerializer;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
import com.nis.web.service.SpringContextHolder;
|
||||
|
||||
@Repository
|
||||
public abstract class BaseRedisDao<K, V> {
|
||||
|
||||
@Autowired
|
||||
protected RedisTemplate<K, V> redisTemplate;
|
||||
|
||||
// public void setRedisTemplate(RedisTemplate<K, V> redisTemplate) {
|
||||
// StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
|
||||
// redisTemplate.setKeySerializer(stringRedisSerializer);
|
||||
// redisTemplate.setValueSerializer(stringRedisSerializer);
|
||||
// this.redisTemplate = redisTemplate;
|
||||
// }
|
||||
|
||||
// public void setRedisTemplate(RedisTemplate<K, V> redisTemplate) {
|
||||
// StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
|
||||
// redisTemplate.setKeySerializer(stringRedisSerializer);
|
||||
// redisTemplate.setValueSerializer(stringRedisSerializer);
|
||||
// this.redisTemplate = redisTemplate;
|
||||
// }
|
||||
protected static void setRedisDataBase(int index, RedisTemplate redisTemplate) {
|
||||
JedisConnectionFactory connectionFactory = SpringContextHolder.getBean("connectionFactory" + index);
|
||||
//connectionFactory.setDatabase(index);
|
||||
redisTemplate.setConnectionFactory(connectionFactory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import com.nis.domain.restful.MaatConfig;
|
||||
public interface ConfigRedisService {
|
||||
/**
|
||||
* 保存非maat配置接口,例如ysp文件样例,ysp标志样例
|
||||
* @param listMap
|
||||
* @param listMap 配置集合,一个map是一个集合
|
||||
* @param service 业务类型
|
||||
*/
|
||||
public void saveUnMaatConfig(List<Map<String, String>> listMap, int service);
|
||||
@@ -35,4 +35,18 @@ public interface ConfigRedisService {
|
||||
* @return
|
||||
*/
|
||||
public Long getIncrId(String key);
|
||||
|
||||
/**
|
||||
* 删除非maat类配置
|
||||
* @param compileIdList 配置id集合
|
||||
* @param service 配置id所属的业务类型
|
||||
*/
|
||||
public void delUnMaatConfig(List<Long> compileIdList, int service);
|
||||
|
||||
/**
|
||||
* 删除maat类配置
|
||||
* @param compileIdList 配置id集合
|
||||
* @param service 配置id所属的业务类型
|
||||
*/
|
||||
public void delMaatConfig(List<Long> compileIdList, int service);
|
||||
}
|
||||
|
||||
@@ -4,23 +4,28 @@ import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import com.nis.datasource.DynamicJedisDataBase;
|
||||
import com.nis.domain.MaatXmlConfig;
|
||||
import com.nis.domain.MaatXmlExpr;
|
||||
import com.nis.domain.MaatXmlSeq;
|
||||
import com.nis.domain.restful.MaatConfig;
|
||||
import com.nis.domain.restful.MaatRelation;
|
||||
import com.nis.listener.CompileGroupRegionRela;
|
||||
import com.nis.util.Configurations;
|
||||
import com.nis.util.ReadMaatXmlUtil;
|
||||
import com.nis.web.dao.impl.BaseRedisDao;
|
||||
|
||||
@Service()
|
||||
public class ConfigRedisServiceimpl extends BaseRedisDao<String, String> implements ConfigRedisService {
|
||||
private static Logger logger = LoggerFactory.getLogger(ConfigRedisServiceimpl.class);
|
||||
|
||||
/**
|
||||
* 第一个key是业务类型,第二个key是type(编译配置,分组配置,域配置)value是表名
|
||||
*/
|
||||
@@ -62,14 +67,26 @@ public class ConfigRedisServiceimpl extends BaseRedisDao<String, String> impleme
|
||||
}
|
||||
}
|
||||
|
||||
@Autowired
|
||||
private OperRedisService operRedisService;
|
||||
public void saveUnMaatConfig2(List<Map<String, String>> listMap, int service) {
|
||||
System.out.println(redisTemplate.getConnectionFactory());
|
||||
setRedisDataBase(2, redisTemplate);
|
||||
System.out.println(redisTemplate.getConnectionFactory());
|
||||
String maatVersion = redisTemplate.opsForValue().get("MAAT_VERSION");
|
||||
System.out.println("maatVersion:" + maatVersion);
|
||||
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
||||
|
||||
}
|
||||
|
||||
@Transactional
|
||||
public void saveUnMaatConfig(List<Map<String, String>> listMap, int service) {
|
||||
if (listMap != null && listMap.size() > 0) {
|
||||
DynamicJedisDataBase.setRedisDataBase(getRedisDBByService(service), redisTemplate);
|
||||
String maatVersionStr = operRedisService.getMaatVersion(getRedisDBByService(service));
|
||||
setRedisDataBase(getRedisDBByService(service), redisTemplate);
|
||||
// String maatVersionStr =
|
||||
// operRedisService.getMaatVersion(getRedisDBByService(service));
|
||||
String maatVersionStr = redisTemplate.opsForValue().get("MAAT_VERSION");
|
||||
if (maatVersionStr == null) {
|
||||
maatVersionStr = "0";
|
||||
}
|
||||
if (maatVersionStr != null) {
|
||||
Long maatVersion = Long.valueOf(maatVersionStr) + 1;
|
||||
for (Map<String, String> map : listMap) {
|
||||
@@ -80,7 +97,7 @@ public class ConfigRedisServiceimpl extends BaseRedisDao<String, String> impleme
|
||||
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
|
||||
String maatKey = "";
|
||||
for (MaatXmlExpr maatXmlExpr : expressionList) {
|
||||
if (16 == maatXmlExpr.getType().intValue()) {
|
||||
if (0 == maatXmlExpr.getType().intValue()) {
|
||||
StringBuffer keyBF = new StringBuffer();
|
||||
String[] keySplit = maatXmlExpr.getKeyExpression().split(";");
|
||||
for (String keyStr : keySplit) {
|
||||
@@ -130,7 +147,7 @@ public class ConfigRedisServiceimpl extends BaseRedisDao<String, String> impleme
|
||||
}
|
||||
List<MaatXmlSeq> seqList = maatXmlConfig.getSequenceList();
|
||||
for (MaatXmlSeq maatXmlSeq : seqList) {
|
||||
// DynamicJedisDataBase.setRedisDataBase(maatXmlSeq.getRedisDB(),
|
||||
// setRedisDataBase(maatXmlSeq.getRedisDB(),
|
||||
// redisTemplate);
|
||||
String seqKey = maatXmlSeq.getSequenceKey();
|
||||
if (!seqKey.toUpperCase().equals("MAAT_VERSION")) {
|
||||
@@ -143,14 +160,15 @@ public class ConfigRedisServiceimpl extends BaseRedisDao<String, String> impleme
|
||||
}
|
||||
}
|
||||
}
|
||||
redisTemplate.boundValueOps("MAAT_VERSION").set(maatVersion + "");
|
||||
|
||||
}
|
||||
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
||||
}
|
||||
}
|
||||
|
||||
public void test() {
|
||||
|
||||
DynamicJedisDataBase.setRedisDataBase(2, redisTemplate);
|
||||
setRedisDataBase(2, redisTemplate);
|
||||
for (int i = 0; i < 10; i++) {
|
||||
redisTemplate.boundZSetOps("1").add("a" + i, i);
|
||||
if (i == 5) {
|
||||
@@ -158,18 +176,18 @@ public class ConfigRedisServiceimpl extends BaseRedisDao<String, String> impleme
|
||||
}
|
||||
}
|
||||
// 切换redis数据库
|
||||
DynamicJedisDataBase.setRedisDataBase(3, redisTemplate);
|
||||
setRedisDataBase(3, redisTemplate);
|
||||
for (int i = 10; i < 20; i++) {
|
||||
redisTemplate.boundZSetOps("1").add("a" + i, i);
|
||||
if (i == 5) {
|
||||
// int a = 1 / 0;
|
||||
}
|
||||
}
|
||||
DynamicJedisDataBase.setRedisDataBase(4, redisTemplate);
|
||||
setRedisDataBase(4, redisTemplate);
|
||||
for (int i = 20; i < 30; i++) {
|
||||
redisTemplate.boundZSetOps("1").add("a" + i, i);
|
||||
if (i == 25) {
|
||||
// int a = 1 / 0;
|
||||
// int a = 1 / 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -177,28 +195,36 @@ public class ConfigRedisServiceimpl extends BaseRedisDao<String, String> impleme
|
||||
@Transactional
|
||||
public void saveMaatConfig(List<MaatConfig> maatConfigList, int service) {
|
||||
if (maatConfigList != null && maatConfigList.size() > 0) {
|
||||
String maatVersionStr = operRedisService.getMaatVersion(getRedisDBByService(service));
|
||||
Integer redisDBIndex = getRedisDBByService(service);
|
||||
setRedisDataBase(redisDBIndex, redisTemplate);
|
||||
String maatVersionStr = redisTemplate.opsForValue().get("MAAT_VERSION");
|
||||
if (maatVersionStr == null) {
|
||||
maatVersionStr = "0";
|
||||
}
|
||||
|
||||
MaatRelation maatRelation = CompileGroupRegionRela.getIdRelationMap().get(redisDBIndex);
|
||||
if (maatVersionStr != null) {
|
||||
Long maatVersion = Long.valueOf(maatVersionStr) + 1;
|
||||
for (MaatConfig maatConfig : maatConfigList) {
|
||||
// Integer service = maatConfig.getService();
|
||||
// if (service != null) {
|
||||
DynamicJedisDataBase.setRedisDataBase(getRedisDBByService(service), redisTemplate);
|
||||
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(service);
|
||||
setConfig(maatConfig, maatXmlConfig, maatVersion, service);
|
||||
// }
|
||||
setConfig(maatConfig, maatXmlConfig, maatVersion, service,maatRelation);
|
||||
}
|
||||
redisTemplate.boundValueOps("MAAT_VERSION").set(maatVersion + "");
|
||||
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setConfig(MaatConfig maatConfig, MaatXmlConfig maatXmlConfig, Long maatVersion, int service) {
|
||||
public void setConfig(MaatConfig maatConfig, MaatXmlConfig maatXmlConfig, Long maatVersion, int service, MaatRelation maatRelation ) {
|
||||
Map<String, String> compileMap = maatConfig.getCompileMap();
|
||||
setCommonConfig(maatXmlConfig, compileMap, 10, maatVersion.doubleValue(), service);// 10代表是编译配置
|
||||
List<Map<String, String>> groupMapList = maatConfig.getGroupMapList();
|
||||
if (groupMapList != null && groupMapList.size() > 0) {
|
||||
for (Map<String, String> map : groupMapList) {
|
||||
map.get("");
|
||||
Map<Long, Set<Long>> groupAndCompileMap = maatRelation.getGroupAndCompileMap();
|
||||
|
||||
|
||||
|
||||
setCommonConfig(maatXmlConfig, map, 11, maatVersion.doubleValue(), service);// 11代表是分组配置
|
||||
}
|
||||
}
|
||||
@@ -238,7 +264,7 @@ public class ConfigRedisServiceimpl extends BaseRedisDao<String, String> impleme
|
||||
setCommonConfig(maatXmlConfig, map, 17, maatVersion.doubleValue(), service);// 17代表是文本相似性域配置
|
||||
}
|
||||
}
|
||||
updateCommonKey(maatXmlConfig);
|
||||
// updateCommonKey(maatXmlConfig);
|
||||
}
|
||||
|
||||
public void setCommonConfig(MaatXmlConfig maatXmlConfig, Map<String, String> map, int type, Double maatVersion,
|
||||
@@ -308,8 +334,6 @@ public class ConfigRedisServiceimpl extends BaseRedisDao<String, String> impleme
|
||||
public void updateCommonKey(MaatXmlConfig maatXmlConfig) {
|
||||
List<MaatXmlSeq> seqList = maatXmlConfig.getSequenceList();
|
||||
for (MaatXmlSeq maatXmlSeq : seqList) {
|
||||
// DynamicJedisDataBase.setRedisDataBase(maatXmlSeq.getRedisDB(),
|
||||
// redisTemplate);
|
||||
String seqKey = maatXmlSeq.getSequenceKey();
|
||||
if (!seqKey.toUpperCase().equals("MAAT_VERSION")) {
|
||||
Integer operation = maatXmlSeq.getOperation();
|
||||
@@ -321,7 +345,10 @@ public class ConfigRedisServiceimpl extends BaseRedisDao<String, String> impleme
|
||||
}
|
||||
|
||||
public Long getIncrId(String key) {
|
||||
DynamicJedisDataBase.setRedisDataBase(2, redisTemplate);
|
||||
//
|
||||
// connectionFactory.setDatabase(0);
|
||||
// redisTemplate.setConnectionFactory(connectionFactory);
|
||||
|
||||
// RedisAtomicLong atomicLong = new RedisAtomicLong(key,
|
||||
// redisTemplate.getConnectionFactory());
|
||||
//
|
||||
@@ -330,6 +357,8 @@ public class ConfigRedisServiceimpl extends BaseRedisDao<String, String> impleme
|
||||
// atomicLong.expire(liveTime, TimeUnit.SECONDS);
|
||||
// }
|
||||
// return id;
|
||||
setRedisDataBase(0, redisTemplate);
|
||||
// System.out.println(redisTemplate.getConnectionFactory());
|
||||
return redisTemplate.boundValueOps(key.toUpperCase()).increment(1l);
|
||||
// return redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
||||
}
|
||||
@@ -367,4 +396,116 @@ public class ConfigRedisServiceimpl extends BaseRedisDao<String, String> impleme
|
||||
getRedisDBByService(80);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void delUnMaatConfig(List<Long> compileIdList, int service) {
|
||||
if (compileIdList != null && compileIdList.size() > 0) {
|
||||
Integer redisDBIndex = getRedisDBByService(service);
|
||||
setRedisDataBase(redisDBIndex, redisTemplate);
|
||||
String maatVersionStr = redisTemplate.opsForValue().get("MAAT_VERSION");
|
||||
if (maatVersionStr == null) {
|
||||
maatVersionStr = "0";
|
||||
}
|
||||
if (maatVersionStr != null) {
|
||||
Long maatVersion = Long.valueOf(maatVersionStr) + 1;
|
||||
for (Long id : compileIdList) {
|
||||
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(service);
|
||||
if (maatXmlConfig != null) {
|
||||
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
|
||||
String maatKey = "";
|
||||
for (MaatXmlExpr maatXmlExpr : expressionList) {
|
||||
if (0 == maatXmlExpr.getType().intValue()) {
|
||||
StringBuffer keyBF = new StringBuffer();
|
||||
String[] keySplit = maatXmlExpr.getKeyExpression().split(";");
|
||||
for (String keyStr : keySplit) {
|
||||
if (!StringUtils.isEmpty(keyStr) && keyStr.toUpperCase().equals("EFFECTIVE_RULE")) {
|
||||
keyStr = "OBSOLETE_RULE";
|
||||
keyBF.append(keyStr.trim());
|
||||
} else if (!StringUtils.isEmpty(keyStr) && keyStr.trim().startsWith("[")) {
|
||||
// keyStr = keyStr.trim().replace("[", "").replace("]", "");
|
||||
keyBF.append(id);
|
||||
} else {
|
||||
keyBF.append(keyStr.trim());
|
||||
}
|
||||
}
|
||||
maatKey = keyBF.toString();
|
||||
String oldKey = maatKey.replace("OBSOLETE_RULE", "EFFECTIVE_RULE");
|
||||
redisTemplate.rename(oldKey.toString().toUpperCase(), keyBF.toString().toUpperCase());
|
||||
break;
|
||||
}
|
||||
// redisTemplate.boundValueOps(keyBF.toString().toUpperCase()).set(valBF.toString());
|
||||
|
||||
}
|
||||
for (MaatXmlExpr maatXmlExpr : expressionList) {
|
||||
if (maatXmlExpr.getKeyExpression().toUpperCase().equals("MAAT_UPDATE_STATUS")) {
|
||||
String zset = maatKey.replace("OBSOLETE_RULE:", "DEL,");
|
||||
redisTemplate.boundZSetOps("MAAT_UPDATE_STATUS").add(zset, maatVersion);
|
||||
} else if (maatXmlExpr.getKeyExpression().toUpperCase().equals("MAAT_RULE_TIMER")) {
|
||||
Double score = 0d;// 界面下发的配置没有超时时间所以这里设置为0
|
||||
redisTemplate.boundZSetOps("MAAT_RULE_TIMER").add(maatKey, score);
|
||||
} else if (maatXmlExpr.getKeyExpression().toUpperCase().equals("MAAT_VERSION_TIMER")) {
|
||||
Long nowTime = new Date().getTime();
|
||||
nowTime = nowTime / 1000l;
|
||||
Double score = nowTime.doubleValue();// 使用redis自带的time,得到当前时间的秒
|
||||
redisTemplate.boundZSetOps("MAAT_VERSION_TIMER").add(maatVersion + "", score);
|
||||
}
|
||||
}
|
||||
List<MaatXmlSeq> seqList = maatXmlConfig.getSequenceList();
|
||||
for (MaatXmlSeq maatXmlSeq : seqList) {
|
||||
// setRedisDataBase(maatXmlSeq.getRedisDB(),
|
||||
// redisTemplate);
|
||||
String seqKey = maatXmlSeq.getSequenceKey();
|
||||
if (!seqKey.toUpperCase().equals("MAAT_VERSION")) {
|
||||
Integer operation = maatXmlSeq.getOperation();
|
||||
if (operation == 1) {
|
||||
redisTemplate.boundValueOps(seqKey.toUpperCase()).increment(1l);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
// redisTemplate.boundValueOps("MAAT_VERSION").set(maatVersion + "");
|
||||
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// @Override
|
||||
public void delMaatConfig(List<Long> compileIdList, int service) {
|
||||
if (compileIdList != null && compileIdList.size() > 0) {
|
||||
Integer redisDBIndex = getRedisDBByService(service);
|
||||
setRedisDataBase(redisDBIndex, redisTemplate);
|
||||
MaatRelation maatRelation = CompileGroupRegionRela.getIdRelationMap().get(redisDBIndex);
|
||||
|
||||
Map<Long, Set<Long>> compileAndGroupMap = maatRelation.getCompileAndGroupMap();
|
||||
Map<Long, Set<Long>> groupAndCompileMap = maatRelation.getGroupAndCompileMap();
|
||||
Map<Long, Set<Long>> groupAndRegionMap = maatRelation.getGroupAndRegionMap();
|
||||
|
||||
}
|
||||
|
||||
//
|
||||
// if (maatConfigList != null && maatConfigList.size() > 0) {
|
||||
// String maatVersionStr =
|
||||
// operRedisService.getMaatVersion(getRedisDBByService(service));
|
||||
// if (maatVersionStr != null) {
|
||||
// Long maatVersion = Long.valueOf(maatVersionStr) + 1;
|
||||
// for (MaatConfig maatConfig : maatConfigList) {
|
||||
// // Integer service = maatConfig.getService();
|
||||
// // if (service != null) {
|
||||
// setRedisDataBase(getRedisDBByService(service),
|
||||
// redisTemplate);
|
||||
// MaatXmlConfig maatXmlConfig =
|
||||
// ReadMaatXmlUtil.getMaatConfigByService(service);
|
||||
// setConfig(maatConfig, maatXmlConfig, maatVersion, service);
|
||||
// // }
|
||||
// }
|
||||
// redisTemplate.boundValueOps("MAAT_VERSION").set(maatVersion + "");
|
||||
// }
|
||||
// }
|
||||
//
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -8,8 +8,8 @@ import com.nis.web.dao.impl.BaseRedisDao;
|
||||
@Service()
|
||||
public class OperRedisService extends BaseRedisDao<String, String> {
|
||||
|
||||
public String getMaatVersion(int redisIndex) {
|
||||
DynamicJedisDataBase.setRedisDataBase(redisIndex, redisTemplate);
|
||||
public String getMaatVersion1(int redisIndex) {
|
||||
//DynamicJedisDataBase.setRedisDataBase(redisIndex, redisTemplate);
|
||||
// RedisAtomicLong atomicLong = new RedisAtomicLong(key,
|
||||
// redisTemplate.getConnectionFactory());
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user