1:添加maat配置取消测试方法
2:优化maat配置新增测试方法 3:在applicationContext-redis.xml中新增没有事务的redistemplate 4:将查询key的值,获取自增长值,判断key是否存在的方法抽取出来使用没有事务的redistemplate操作(在删除配置逻辑中有时候判断key是否存在,获取key的值等时,使用开启事务的redistemplate会返回,查看源码发现在执行以上操作前会先判断是否开启了multi,如果开启直接返回null)
This commit is contained in:
@@ -5,8 +5,6 @@ import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.Charset;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Enumeration;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.servlet.ServletInputStream;
|
||||
import javax.servlet.ServletRequest;
|
||||
|
||||
31
src/main/java/com/nis/util/ExceptionUtil.java
Normal file
31
src/main/java/com/nis/util/ExceptionUtil.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package com.nis.util;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
|
||||
/**
|
||||
* <p>Title: ExceptionUtils.java</p>
|
||||
* <p>Description: 获取异常信息内容</p>
|
||||
* <p>Company: IIE</p>
|
||||
* @author rkg
|
||||
* @date 2018年3月5日
|
||||
*
|
||||
*/
|
||||
|
||||
public class ExceptionUtil {
|
||||
public static String getExceptionMsg(Exception e) {
|
||||
ByteArrayOutputStream out = new ByteArrayOutputStream();
|
||||
PrintStream pout = new PrintStream(out);
|
||||
e.printStackTrace(pout);
|
||||
String msg = new String(out.toByteArray());
|
||||
pout.close();
|
||||
try {
|
||||
out.close();
|
||||
} catch (IOException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
return msg;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -3,12 +3,16 @@
|
||||
*/
|
||||
package com.nis.util;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.Reader;
|
||||
import java.net.URLEncoder;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.Enumeration;
|
||||
@@ -667,7 +671,6 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取文件后缀
|
||||
*
|
||||
@@ -689,10 +692,8 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
|
||||
}
|
||||
|
||||
// 文件下载
|
||||
public static void fileDownload(HttpServletRequest request,
|
||||
HttpServletResponse response,
|
||||
String filename,
|
||||
String filepath) throws IOException{
|
||||
public static void fileDownload(HttpServletRequest request, HttpServletResponse response, String filename,
|
||||
String filepath) throws IOException {
|
||||
FileInputStream in = null;
|
||||
ServletOutputStream out = null;
|
||||
try {
|
||||
@@ -721,44 +722,149 @@ public class FileUtils extends org.apache.commons.io.FileUtils {
|
||||
} finally {
|
||||
if (in != null) {
|
||||
in.close();
|
||||
in=null;
|
||||
in = null;
|
||||
}
|
||||
if (out != null) {
|
||||
out.close();
|
||||
out=null;
|
||||
out = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算文件MD5
|
||||
* @param file
|
||||
* @return
|
||||
*/
|
||||
public static String getFileMD5(File file){
|
||||
if(!file.isFile()){
|
||||
public static String getFileMD5(File file) {
|
||||
if (!file.isFile()) {
|
||||
return "";
|
||||
}
|
||||
String md5 = "";
|
||||
MessageDigest digest=null;
|
||||
FileInputStream in=null;
|
||||
byte[] buffer=new byte[1024];
|
||||
MessageDigest digest = null;
|
||||
FileInputStream in = null;
|
||||
byte[] buffer = new byte[1024];
|
||||
int len;
|
||||
try{
|
||||
digest=MessageDigest.getInstance("MD5");
|
||||
in=new FileInputStream(file);
|
||||
while ((len=in.read(buffer,0,1024)) !=-1) {
|
||||
digest.update(buffer,0,len);
|
||||
try {
|
||||
digest = MessageDigest.getInstance("MD5");
|
||||
in = new FileInputStream(file);
|
||||
while ((len = in.read(buffer, 0, 1024)) != -1) {
|
||||
digest.update(buffer, 0, len);
|
||||
}
|
||||
in.close();
|
||||
}catch(Exception e){
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return "";
|
||||
}
|
||||
byte[] b = digest.digest();
|
||||
for (int i=0; i < b.length; i++) {
|
||||
md5 += Integer.toString( (b[i] & 0xff ) + 0x100, 16).substring(1);//加0x100是因为有的b[i]的十六进制只有1位
|
||||
for (int i = 0; i < b.length; i++) {
|
||||
md5 += Integer.toString((b[i] & 0xff) + 0x100, 16).substring(1);// 加0x100是因为有的b[i]的十六进制只有1位
|
||||
}
|
||||
// BigInteger bigInt=new BigInteger(1,digest.digest());
|
||||
// BigInteger bigInt=new BigInteger(1,digest.digest());
|
||||
return md5;
|
||||
}
|
||||
|
||||
/**
|
||||
* 以字节为单位读取文件,通常用于读取二进制文件,如图片
|
||||
* @param path 文件路径
|
||||
* @return
|
||||
*/
|
||||
public static String readByBytes(String path) {
|
||||
String content = null;
|
||||
try {
|
||||
InputStream inputStream = new FileInputStream(path);
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
int c = 0;
|
||||
byte[] bytes = new byte[1024];
|
||||
while ((c = inputStream.read(bytes)) != -1) {
|
||||
sb.append(new String(bytes, 0, c, "utf-8"));
|
||||
}
|
||||
content = sb.toString();
|
||||
inputStream.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* 以行为单位读取文件,常用语读取面向行的格式化文件
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
public static String readByLines(String path) {
|
||||
String content = null;
|
||||
try {
|
||||
|
||||
BufferedReader bufferedReader = new BufferedReader(
|
||||
new InputStreamReader(new FileInputStream(path), "utf-8"));
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String temp = null;
|
||||
while ((temp = bufferedReader.readLine()) != null) {
|
||||
sb.append(temp);
|
||||
}
|
||||
content = sb.toString();
|
||||
bufferedReader.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* 以字符串为单位读取文件,常用与读取文本文件
|
||||
* @param path
|
||||
* @return
|
||||
*/
|
||||
public static String readByChar(String path) {
|
||||
String content = null;
|
||||
try {
|
||||
Reader reader = new InputStreamReader(new FileInputStream(path), "utf-8");
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
char[] tempChars = null;
|
||||
while ((reader.read(tempChars)) != -1) {
|
||||
sb.append(tempChars);
|
||||
}
|
||||
content = sb.toString();
|
||||
reader.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return content;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把content的内容写到文件中
|
||||
* @param content 内容
|
||||
* @param path 文件路径
|
||||
* @param isAppend 是否追加,true追加,flase是覆盖文件
|
||||
* @return
|
||||
*/
|
||||
public static boolean addStrToFile(String content, String path, boolean isAppend) {
|
||||
FileWriter fw = null;
|
||||
try {
|
||||
fw = new FileWriter(new File(path), isAppend);
|
||||
if (content != null) {
|
||||
fw.write(content);
|
||||
}
|
||||
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
} finally {
|
||||
if (fw != null) {
|
||||
try {
|
||||
fw.flush();
|
||||
fw.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -74,14 +74,14 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
List<Map<String, String>> listMap = new ArrayList<Map<String, String>>();
|
||||
if (type == 1) {
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
Integer service = 98;
|
||||
Integer service = 261;
|
||||
long id = configRedisService.getIncrId("seq_compileid");
|
||||
// int id=2;
|
||||
map.put("cfg_id", id + "");
|
||||
map.put("is_valid", "1");
|
||||
map.put("dst_file", "home");
|
||||
map.put("dst_file_md5", "fasdfdasfsdafdsafadsf");
|
||||
map.put("time_stamp", new Date().getTime() + "");
|
||||
map.put("op_time", new Date().getTime() + "");
|
||||
map.put("level", "20");
|
||||
map.put("file_id", id + "");
|
||||
map.put("service", service + "");
|
||||
@@ -91,7 +91,7 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
configMap.put(1, listMap);
|
||||
configRedisService.saveUnMaatConfig(configMap);
|
||||
} else {
|
||||
Integer service = 100;
|
||||
Integer service = 265;
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
long id = configRedisService.getIncrId("seq_compileid");
|
||||
// int id=2;
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package com.nis.web.controller.restful;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMethod;
|
||||
@@ -20,7 +22,10 @@ import com.nis.domain.restful.IpRegion;
|
||||
import com.nis.domain.restful.NumRegion;
|
||||
import com.nis.domain.restful.StrRegion;
|
||||
import com.nis.util.Configurations;
|
||||
import com.nis.util.ExceptionUtil;
|
||||
import com.nis.util.FileUtils;
|
||||
import com.nis.util.ServiceAndRDBIndexReal;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.service.SaveRequestLogThread;
|
||||
import com.nis.web.service.ServicesRequestLogService;
|
||||
import com.nis.web.service.restful.ConfigRedisService;
|
||||
@@ -34,7 +39,8 @@ import com.wordnik.swagger.annotations.ApiParam;
|
||||
@RequestMapping("${servicePath}")
|
||||
@Api(value = "ConfigSourcesController", description = "测试maat及非maat配置入库,取消功能")
|
||||
public class MaatTestController {
|
||||
private static Logger logger = LoggerFactory.getLogger(MaatTestController.class);
|
||||
// private static Logger logger =
|
||||
// LoggerFactory.getLogger(MaatTestController.class);
|
||||
@Autowired
|
||||
MaatTestServiceimpl maatTestServiceimpl;
|
||||
@Autowired
|
||||
@@ -43,7 +49,108 @@ public class MaatTestController {
|
||||
ConfigSourcesService configSourcesService;
|
||||
@Autowired
|
||||
ServicesRequestLogService servicesRequestLogService;
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
@RequestMapping(value = "/cfg/v1/testDelMaat", method = RequestMethod.GET)
|
||||
@ApiOperation(value = "测试批量删除maat配置", httpMethod = "GET", response = String.class, notes = "测试批量删除maat配置,configId为配置id,多个配置id用逗号分隔")
|
||||
@ApiParam(value = "测试批量删除maat配置", name = "testDelMaat", required = true)
|
||||
public String testDelMaat(@RequestParam(required = true) String configId,
|
||||
@RequestParam(required = true) Integer serviceType) {
|
||||
String[] configArr = null;
|
||||
if (configId.contains(",")) {
|
||||
configArr = configId.split(",");
|
||||
}
|
||||
Map<Integer, List<Long>> compileMap = new HashMap<Integer, List<Long>>();
|
||||
for (String id : configArr) {
|
||||
if (compileMap.containsKey(serviceType)) {
|
||||
compileMap.get(serviceType).add(Long.valueOf(id.trim()));
|
||||
} else {
|
||||
List<Long> idList = new ArrayList<Long>();
|
||||
idList.add(Long.valueOf(id.trim()));
|
||||
compileMap.put(serviceType, idList);
|
||||
}
|
||||
}
|
||||
FileUtils.addStrToFile(sdf.format(new Date()) + "\t" + "开始删除业务类型" + serviceType + "下的配置" + configId + "\n",
|
||||
Configurations.getStringProperty("maatTestLogPath", ""), true);
|
||||
|
||||
Map<Integer, Map<Integer, List<Long>>> restMap = new HashMap<Integer, Map<Integer, List<Long>>>();
|
||||
Iterator<Integer> serviceIterator = compileMap.keySet().iterator();
|
||||
while (serviceIterator.hasNext()) {
|
||||
Integer service = Integer.valueOf(serviceIterator.next().toString());
|
||||
List<Integer> dbIndexList = ServiceAndRDBIndexReal.getRedisDBByService(service);
|
||||
if (!StringUtil.isEmpty(dbIndexList) && dbIndexList.size() > 0) {
|
||||
for (Integer dbIndex : dbIndexList) {
|
||||
if (restMap.containsKey(dbIndex)) {
|
||||
restMap.get(dbIndex).put(service, compileMap.get(service));
|
||||
} else {
|
||||
Map<Integer, List<Long>> map = new HashMap<Integer, List<Long>>();
|
||||
map.put(service, compileMap.get(service));
|
||||
restMap.put(dbIndex, map);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
FileUtils.addStrToFile(sdf.format(new Date()) + "\t" + "获取业务类型" + service + "对应的redisDb失败\n",
|
||||
Configurations.getStringProperty("maatTestLogPath", ""), true);
|
||||
return "error";
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (!configRedisService.delMaatConfig(restMap)) {
|
||||
FileUtils.addStrToFile(
|
||||
sdf.format(new Date()) + "\t" + "删除业务类型" + serviceType + "下的配置" + configId + "失败\n",
|
||||
Configurations.getStringProperty("maatTestLogPath", ""), true);
|
||||
return "error";
|
||||
} else {
|
||||
FileUtils.addStrToFile(
|
||||
sdf.format(new Date()) + "\t" + "删除业务类型" + serviceType + "下的配置" + configId + "成功\n",
|
||||
Configurations.getStringProperty("maatTestLogPath", ""), true);
|
||||
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
FileUtils.addStrToFile(
|
||||
sdf.format(new Date()) + "\t" + "删除业务类型" + serviceType + "下的配置" + configId + "失败,失败原因:"
|
||||
+ ExceptionUtil.getExceptionMsg(e) + "\n",
|
||||
Configurations.getStringProperty("maatTestLogPath", ""), true);
|
||||
|
||||
return "error";
|
||||
}
|
||||
return "ok";
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/cfg/v1/testSaveMaatMore", method = RequestMethod.GET)
|
||||
@ApiOperation(value = "测试批量保存maat配置", httpMethod = "GET", response = String.class, notes = "测试批量保存maat配置,service:需要保存的业务类型,saveCount:保存几条配置")
|
||||
@ApiParam(value = "测试批量保存maat配置", name = "testSaveMaat", required = true)
|
||||
public String testSaveMaatMore(@RequestParam(required = true) Integer service,
|
||||
@RequestParam(required = true) Integer saveCount, Integer forCount) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
for (int a = 0; a < forCount; a++) {
|
||||
long start = System.currentTimeMillis();
|
||||
SaveRequestLogThread thread = new SaveRequestLogThread();
|
||||
StringBuffer sb = new StringBuffer();
|
||||
List<ConfigCompile> configCompileList = new ArrayList<ConfigCompile>();
|
||||
for (int i = 0; i < saveCount; i++) {
|
||||
configCompileList.add(getConfigCompile(service));
|
||||
}
|
||||
// 保存测试配置
|
||||
configSourcesService.saveMaatConfig(thread, start, configCompileList, sb);
|
||||
List<Long> compileIdList = new ArrayList<Long>();
|
||||
for (ConfigCompile configCompile : configCompileList) {
|
||||
compileIdList.add(configCompile.getCompileId());
|
||||
}
|
||||
FileUtils.addStrToFile(
|
||||
sdf.format(new Date()) + "\t" + "业务类型" + service + "添加" + saveCount + "条数据成功,配置id是" + compileIdList
|
||||
+ "\n" + sdf.format(new Date()) + "\t开始验证添加的数据各字段是否正确\n",
|
||||
Configurations.getStringProperty("maatTestLogPath", ""), true);
|
||||
// 验证数据是否在正确
|
||||
maatTestServiceimpl.getKeys(configCompileList);
|
||||
list.add(testDelMaat(compileIdList.toString().replace("[", "").replace("]", ""), service));
|
||||
}
|
||||
return list.toString();
|
||||
// return "http://127.0.0.1:8080/galaxy/service/cfg/v1/testDelMaat?serviceType="
|
||||
// + service + "&configId="
|
||||
// + compileIdList.toString().replace("[", "").replace("]", "");
|
||||
}
|
||||
@RequestMapping(value = "/cfg/v1/testSaveMaat", method = RequestMethod.GET)
|
||||
@ApiOperation(value = "测试批量保存maat配置", httpMethod = "GET", response = String.class, notes = "测试批量保存maat配置,service:需要保存的业务类型,saveCount:保存几条配置")
|
||||
@ApiParam(value = "测试批量保存maat配置", name = "testSaveMaat", required = true)
|
||||
@@ -62,10 +169,14 @@ public class MaatTestController {
|
||||
for (ConfigCompile configCompile : configCompileList) {
|
||||
compileIdList.add(configCompile.getCompileId());
|
||||
}
|
||||
logger.warn("业务类型{}添加{}条数据成功,配置id是{}", service, saveCount, compileIdList);
|
||||
FileUtils.addStrToFile(
|
||||
sdf.format(new Date()) + "\t" + "业务类型" + service + "添加" + saveCount + "条数据成功,配置id是" + compileIdList
|
||||
+ "\n" + sdf.format(new Date()) + "\t开始验证添加的数据各字段是否正确\n",
|
||||
Configurations.getStringProperty("maatTestLogPath", ""), true);
|
||||
// 验证数据是否在正确
|
||||
maatTestServiceimpl.getKeys(configCompileList);
|
||||
return "ok";
|
||||
return "http://127.0.0.1:8080/galaxy/service/cfg/v1/testDelMaat?serviceType=" + service + "&configId="
|
||||
+ compileIdList.toString().replace("[", "").replace("]", "");
|
||||
}
|
||||
|
||||
private ConfigCompile getConfigCompile(Integer service) {
|
||||
|
||||
@@ -1,18 +1,16 @@
|
||||
package com.nis.web.dao.impl;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.data.redis.connection.jedis.JedisConnectionFactory;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
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> {
|
||||
public class BaseRedisDao {
|
||||
private static Logger logger = LoggerFactory.getLogger(BaseRedisDao.class);
|
||||
|
||||
//@Autowired
|
||||
protected RedisTemplate<K, V> redisTemplate1;
|
||||
// @Autowired
|
||||
// protected RedisTemplate<K, V> redisTemplate1;
|
||||
|
||||
// public void setRedisTemplate(RedisTemplate<K, V> redisTemplate) {
|
||||
// StringRedisSerializer stringRedisSerializer = new StringRedisSerializer();
|
||||
@@ -20,9 +18,60 @@ public abstract class BaseRedisDao<K, V> {
|
||||
// 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);
|
||||
// protected static void setRedisDataBase(int index, RedisTemplate
|
||||
// redisTemplate) {
|
||||
// JedisConnectionFactory connectionFactory =
|
||||
// SpringContextHolder.getBean("connectionFactory" + index);
|
||||
// connectionFactory.setDatabase(index);
|
||||
// redisTemplate.setConnectionFactory(connectionFactory);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 利用redis连接对象判断key是否存在,在事务中判断key是否存在时由于判断是否开启了multi(事务需要开启multi),直接返回了null,导致判断key的时候出现了问题
|
||||
* @param index 几号redis库
|
||||
* @param key 需要判断的key
|
||||
* @param redisTemplate RedisTemplate对象
|
||||
* @return
|
||||
*/
|
||||
public static Boolean keyIsExist(int index, String key) {
|
||||
RedisTemplate redisTemplate = SpringContextHolder.getBean("redisTemplateNoTrans" + index);
|
||||
if (redisTemplate != null) {
|
||||
redisTemplate.setEnableTransactionSupport(false);
|
||||
Boolean hasKey = redisTemplate.hasKey(key);
|
||||
if (hasKey == null) {
|
||||
logger.error("判断key是否存在时出现错误");
|
||||
}
|
||||
return hasKey;
|
||||
} else {
|
||||
throw new RuntimeException("从" + index + "号redis库中判断" + key + "是否存在时失败,失败原因:redisTemplate为null请联系开发人员");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取自增长id
|
||||
* @param index
|
||||
* @param key
|
||||
* @return
|
||||
*/
|
||||
public static Long getIncr(int index, String key) {
|
||||
RedisTemplate<String, String> redisTemplate = SpringContextHolder.getBean("redisTemplateNoTrans" + index);
|
||||
if (redisTemplate != null) {
|
||||
redisTemplate.setEnableTransactionSupport(false);
|
||||
Long id = redisTemplate.boundValueOps(key.toUpperCase()).increment(1l);
|
||||
return id;
|
||||
} else {
|
||||
throw new RuntimeException("从" + index + "号redis库中获取" + key + "的自增长值时失败,失败原因:redisTemplate为null请联系开发人员");
|
||||
}
|
||||
}
|
||||
|
||||
public static String getValByKey(int index, String key) {
|
||||
RedisTemplate<String, String> redisTemplate = SpringContextHolder.getBean("redisTemplateNoTrans" + index);
|
||||
if (redisTemplate != null) {
|
||||
redisTemplate.setEnableTransactionSupport(false);
|
||||
return redisTemplate.opsForValue().get(key);
|
||||
} else {
|
||||
throw new RuntimeException("从" + index + "号redis库中获取" + key + "的值时失败,失败原因:redisTemplate为null请联系开发人员");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -18,13 +18,11 @@ import org.springframework.util.StringUtils;
|
||||
import com.nis.domain.MaatXmlConfig;
|
||||
import com.nis.domain.MaatXmlExpr;
|
||||
import com.nis.domain.MaatXmlSeq;
|
||||
import com.nis.domain.restful.CompileAndGroupRelations;
|
||||
import com.nis.domain.restful.GroupAndRegionRelations;
|
||||
import com.nis.domain.restful.MaatConfig;
|
||||
import com.nis.listener.CompileGroupRegionRela;
|
||||
import com.nis.util.Configurations;
|
||||
import com.nis.util.ReadMaatXmlUtil;
|
||||
import com.nis.util.ServiceAndRDBIndexReal;
|
||||
import com.nis.web.dao.impl.BaseRedisDao;
|
||||
import com.nis.web.service.SpringContextHolder;
|
||||
|
||||
@Service()
|
||||
@@ -41,7 +39,7 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
.getBean("redisTemplate" + redisDBIndex);
|
||||
List<Map<String, String>> listMap = configMap.get(redisDBIndex);
|
||||
if (listMap != null && listMap.size() > 0) {
|
||||
String maatVersionStr = redisTemplate.opsForValue().get("MAAT_VERSION");
|
||||
String maatVersionStr = BaseRedisDao.getValByKey(redisDBIndex, "MAAT_VERSION");
|
||||
if (maatVersionStr == null) {
|
||||
maatVersionStr = "0";
|
||||
}
|
||||
@@ -140,7 +138,8 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
if (!seqKey.toUpperCase().equals("MAAT_VERSION")) {
|
||||
Integer operation = maatXmlSeq.getOperation();
|
||||
if (operation == 1) {
|
||||
redisTemplate.boundValueOps(seqKey.toUpperCase()).increment(1l);
|
||||
BaseRedisDao.getIncr(redisDBIndex, seqKey.toUpperCase());
|
||||
// redisTemplate.boundValueOps().increment(1l);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,7 +148,7 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
throw new RuntimeException("无法从maat.xml中获取业务类型" + service + "对应的规则,请检查业务类型是否正确");
|
||||
}
|
||||
}
|
||||
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
||||
BaseRedisDao.getIncr(redisDBIndex, "MAAT_VERSION");
|
||||
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDBIndex,
|
||||
Integer.valueOf(maatVersionStr) + 1);
|
||||
count++;
|
||||
@@ -175,11 +174,12 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
*/
|
||||
private void addMaatRelation(Map<Integer, List<MaatConfig>> configMap) {
|
||||
if (configMap != null && configMap.size() > 0) {
|
||||
for (Integer redisDBIndex : configMap.keySet()) {
|
||||
if (redisDBIndex >= 0 && redisDBIndex < Configurations.getIntProperty("maxRedisDBIndex", 6)) {
|
||||
int idRelaRedisDBIndex = Configurations.getIntProperty("idRelaRedisDBIndex", 15);
|
||||
RedisTemplate<String, String> redisTemplate = SpringContextHolder
|
||||
.getBean("redisTemplate" + idRelaRedisDBIndex);
|
||||
for (Integer redisDBIndex : configMap.keySet()) {
|
||||
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>>();
|
||||
@@ -217,21 +217,20 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
Map<String, List<String>> map = new HashMap<String, List<String>>();
|
||||
int service = maatConfig.getService();
|
||||
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(service);
|
||||
addGroupAndRegionRelations(maatXmlConfig, service, 12, maatConfig.getIpRegionMapList(),
|
||||
redisTemplate, map, redisDBIndex, compileId);
|
||||
addGroupAndRegionRelations(maatXmlConfig, service, 12, maatConfig.getIpRegionMapList(), map,
|
||||
redisDBIndex, compileId);
|
||||
addGroupAndRegionRelations(maatXmlConfig, service, 13, maatConfig.getNumRegionMapList(),
|
||||
redisTemplate, map, redisDBIndex, compileId);
|
||||
map, redisDBIndex, compileId);
|
||||
addGroupAndRegionRelations(maatXmlConfig, service, 14, maatConfig.getStrRegionMapList(),
|
||||
redisTemplate, map, redisDBIndex, compileId);
|
||||
map, redisDBIndex, compileId);
|
||||
addGroupAndRegionRelations(maatXmlConfig, service, 15, maatConfig.getStrStrRegionMapList(),
|
||||
redisTemplate, map, redisDBIndex, compileId);
|
||||
map, redisDBIndex, compileId);
|
||||
addGroupAndRegionRelations(maatXmlConfig, service, 16,
|
||||
maatConfig.getFileDigestRegionMapList(), redisTemplate, map, redisDBIndex,
|
||||
compileId);
|
||||
maatConfig.getFileDigestRegionMapList(), map, redisDBIndex, compileId);
|
||||
addGroupAndRegionRelations(maatXmlConfig, service, 17,
|
||||
maatConfig.getFileLikeRegionMapList(), redisTemplate, map, redisDBIndex, compileId);
|
||||
maatConfig.getFileLikeRegionMapList(), map, redisDBIndex, compileId);
|
||||
addGroupAndRegionRelations(maatXmlConfig, service, 18, maatConfig.getIpClientRangeMapList(),
|
||||
redisTemplate, map, redisDBIndex, compileId);
|
||||
map, redisDBIndex, compileId);
|
||||
|
||||
for (String groupIdStr : map.keySet()) {
|
||||
List<String> list = map.get(groupIdStr);
|
||||
@@ -289,8 +288,8 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
* @param compileAndGroupRelations
|
||||
*/
|
||||
private Map<String, List<String>> addGroupAndRegionRelations(MaatXmlConfig maatXmlConfig, int service, int type,
|
||||
List<Map<String, String>> regionMapList, RedisTemplate<String, String> redisTemplate,
|
||||
Map<String, List<String>> groupAndRegionMap, int redisDBIndex, String compileId) {
|
||||
List<Map<String, String>> regionMapList, Map<String, List<String>> groupAndRegionMap, int redisDBIndex,
|
||||
String compileId) {
|
||||
if (regionMapList != null && regionMapList.size() > 0) {
|
||||
for (Map<String, String> map : regionMapList) {
|
||||
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
|
||||
@@ -341,103 +340,6 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 下发配置成功后,需要更新编译,组,域等配置id的对应关系
|
||||
*/
|
||||
public void addMaatRelationOld(Map<Integer, List<MaatConfig>> configMap) {
|
||||
if (configMap != null && configMap.size() > 0) {
|
||||
for (Integer redisDBIndex : configMap.keySet()) {
|
||||
if (redisDBIndex >= 0 && redisDBIndex < Configurations.getIntProperty("maxRedisDBIndex", 6)) {
|
||||
List<MaatConfig> maatConfigList = configMap.get(redisDBIndex);
|
||||
if (maatConfigList != null && maatConfigList.size() > 0) {
|
||||
for (MaatConfig maatConfig : maatConfigList) {
|
||||
Map<String, String> compileMap = maatConfig.getCompileMap();
|
||||
String cfgIdStr = compileMap.get("compile_id");
|
||||
CompileAndGroupRelations compileAndGroupRelations = new CompileAndGroupRelations();
|
||||
compileAndGroupRelations.setCompileId(Long.valueOf(cfgIdStr));
|
||||
compileAndGroupRelations.setGroupIdList(new ArrayList<GroupAndRegionRelations>());
|
||||
|
||||
int service = maatConfig.getService();
|
||||
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(service);
|
||||
addGroupAndRegionRelationsOld(maatXmlConfig, service, 12, maatConfig.getIpRegionMapList(),
|
||||
compileAndGroupRelations);
|
||||
addGroupAndRegionRelationsOld(maatXmlConfig, service, 13, maatConfig.getNumRegionMapList(),
|
||||
compileAndGroupRelations);
|
||||
addGroupAndRegionRelationsOld(maatXmlConfig, service, 14, maatConfig.getStrRegionMapList(),
|
||||
compileAndGroupRelations);
|
||||
addGroupAndRegionRelationsOld(maatXmlConfig, service, 15,
|
||||
maatConfig.getStrStrRegionMapList(), compileAndGroupRelations);
|
||||
addGroupAndRegionRelationsOld(maatXmlConfig, service, 16,
|
||||
maatConfig.getFileDigestRegionMapList(), compileAndGroupRelations);
|
||||
addGroupAndRegionRelationsOld(maatXmlConfig, service, 17,
|
||||
maatConfig.getFileLikeRegionMapList(), compileAndGroupRelations);
|
||||
addGroupAndRegionRelationsOld(maatXmlConfig, service, 18,
|
||||
maatConfig.getIpClientRangeMapList(), compileAndGroupRelations);
|
||||
|
||||
CompileGroupRegionRela.addIdRelation(redisDBIndex, compileAndGroupRelations);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("redis数据库编号:" + redisDBIndex + "不正确,请检查数据库编号");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("参数不能为空");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 封装组id与域id对应关系并添加到对象中
|
||||
* @param regionMapList
|
||||
* @param compileAndGroupRelations
|
||||
*/
|
||||
private void addGroupAndRegionRelationsOld(MaatXmlConfig maatXmlConfig, int service, int type,
|
||||
List<Map<String, String>> regionMapList, CompileAndGroupRelations compileAndGroupRelations) {
|
||||
if (regionMapList != null && regionMapList.size() > 0 && compileAndGroupRelations != null) {
|
||||
for (Map<String, String> map : regionMapList) {
|
||||
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
|
||||
String maatKey = null;
|
||||
for (MaatXmlExpr maatXmlExpr : expressionList) {
|
||||
if (type == maatXmlExpr.getType().intValue()) {
|
||||
StringBuffer keyBF = new StringBuffer();
|
||||
String[] keySplit = maatXmlExpr.getKeyExpression().split(";");
|
||||
for (String keyStr : keySplit) {
|
||||
if (!StringUtils.isEmpty(keyStr) && keyStr.trim().startsWith("[")) {
|
||||
keyStr = keyStr.trim().replace("[", "").replace("]", "");
|
||||
keyBF.append(map.get(keyStr));
|
||||
} else if (!StringUtils.isEmpty(keyStr) && keyStr.trim().startsWith("{")) {
|
||||
keyStr = keyStr.trim().replace("{", "").replace("}", "");
|
||||
if (keyStr.toLowerCase().contains("table_name")) {
|
||||
String argTableName = map.get("table_name");
|
||||
String maatTableName = ServiceAndRDBIndexReal.getMaatTableName(service, type,
|
||||
argTableName == null ? null : argTableName);
|
||||
if (maatTableName == null) {
|
||||
throw new RuntimeException(
|
||||
"未从业务类型和表对应关系中,找到业务类型:" + service + ",配置类型:" + type + ",对应的真实表名");
|
||||
} else {
|
||||
keyBF.append(maatTableName);
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
keyBF.append(keyStr.trim());
|
||||
}
|
||||
}
|
||||
maatKey = keyBF.toString();
|
||||
break;
|
||||
}
|
||||
}
|
||||
String groupIdStr = map.get("group_id");
|
||||
GroupAndRegionRelations groupAndRegionRelations = new GroupAndRegionRelations();
|
||||
groupAndRegionRelations.setGroupId(Long.valueOf(groupIdStr));
|
||||
groupAndRegionRelations.setRegionId(maatKey);
|
||||
compileAndGroupRelations.getGroupIdList().add(groupAndRegionRelations);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public boolean saveMaatConfig(Map<Integer, List<MaatConfig>> configMap) {
|
||||
@@ -447,7 +349,7 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
if (redisDBIndex >= 0 && redisDBIndex < Configurations.getIntProperty("maxRedisDBIndex", 6)) {
|
||||
RedisTemplate<String, String> redisTemplate = SpringContextHolder
|
||||
.getBean("redisTemplate" + redisDBIndex);
|
||||
String maatVersionStr = redisTemplate.opsForValue().get("MAAT_VERSION");
|
||||
String maatVersionStr = BaseRedisDao.getValByKey(redisDBIndex, "MAAT_VERSION");
|
||||
if (maatVersionStr == null) {
|
||||
maatVersionStr = "0";
|
||||
}
|
||||
@@ -460,7 +362,8 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(service);
|
||||
setConfig(maatConfig, maatXmlConfig, maatVersion, service, redisTemplate, redisDBIndex);
|
||||
}
|
||||
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
||||
BaseRedisDao.getIncr(redisDBIndex, "MAAT_VERSION");
|
||||
// redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
||||
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDBIndex,
|
||||
Integer.valueOf(maatVersionStr) + 1);
|
||||
count++;
|
||||
@@ -682,8 +585,7 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
}
|
||||
|
||||
public Long getIncrId(String key) {
|
||||
RedisTemplate<String, String> redisTemplate = SpringContextHolder.getBean("redisTemplate0");
|
||||
Long id = redisTemplate.boundValueOps(key.toUpperCase()).increment(1l);
|
||||
Long id = BaseRedisDao.getIncr(0, key);
|
||||
logger.info("从0号redis数据库获取{}成功,自增后的值是{}", key, id);
|
||||
return id;
|
||||
}
|
||||
@@ -698,9 +600,10 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
.getBean("redisTemplate" + redisDBIndex);
|
||||
Map<Integer, List<Long>> serviceConfigMap = idMap.get(redisDBIndex);
|
||||
if (serviceConfigMap != null && serviceConfigMap.size() > 0) {
|
||||
String maatVersionStr = redisTemplate.opsForValue().get("MAAT_VERSION");
|
||||
String maatVersionStr = BaseRedisDao.getValByKey(redisDBIndex, "MAAT_VERSION");
|
||||
if (maatVersionStr == null) {
|
||||
maatVersionStr = "0";
|
||||
throw new RuntimeException("从" + redisDBIndex
|
||||
+ "号redis库中获取MAAT_VERSION的值为null,redis中不存在该值,请联系开发人员检查删除逻辑是否正确或redis数据是否出现了异常");
|
||||
}
|
||||
if (maatVersionStr != null) {
|
||||
Long maatVersion = Long.valueOf(maatVersionStr) + 1;
|
||||
@@ -745,7 +648,8 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
}
|
||||
maatKey = keyBF.toString();
|
||||
String oldKey = maatKey.replace("OBSOLETE_RULE", "EFFECTIVE_RULE");
|
||||
if (redisTemplate.hasKey(oldKey.toString().toUpperCase())) {
|
||||
if (BaseRedisDao.keyIsExist(redisDBIndex,
|
||||
oldKey.toString().toUpperCase())) {
|
||||
redisTemplate.rename(oldKey.toString().toUpperCase(),
|
||||
keyBF.toString().toUpperCase());
|
||||
logger.info("向{}号redis数据库修改了一条配置,修改前key是{},修改后key是{}", redisDBIndex,
|
||||
@@ -757,8 +661,6 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
+ "请检查id映射关系是否正确");
|
||||
}
|
||||
}
|
||||
// redisTemplate.boundValueOps(keyBF.toString().toUpperCase()).set(valBF.toString());
|
||||
|
||||
}
|
||||
for (MaatXmlExpr maatXmlExpr : expressionList) {
|
||||
if (maatXmlExpr.getKeyExpression().toUpperCase()
|
||||
@@ -797,7 +699,9 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
if (!seqKey.toUpperCase().equals("MAAT_VERSION")) {
|
||||
Integer operation = maatXmlSeq.getOperation();
|
||||
if (operation == 1) {
|
||||
redisTemplate.boundValueOps(seqKey.toUpperCase()).increment(1l);
|
||||
|
||||
BaseRedisDao.getIncr(redisDBIndex, seqKey.toUpperCase());
|
||||
// redisTemplate.boundValueOps(seqKey.toUpperCase()).increment(1l);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -807,7 +711,8 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
"无法从maat.xml中获取业务类型" + service + "对应的规则,请检查业务类型是否正确");
|
||||
}
|
||||
}
|
||||
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
||||
BaseRedisDao.getIncr(redisDBIndex, "MAAT_VERSION");
|
||||
// redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
||||
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDBIndex,
|
||||
Integer.valueOf(maatVersionStr) + 1);
|
||||
count++;
|
||||
@@ -837,19 +742,16 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
public boolean delMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap) {
|
||||
if (idMap != null && idMap.size() > 0) {
|
||||
int count = 0;
|
||||
for (Integer redisDBIndex : idMap.keySet()) {
|
||||
|
||||
int idRelaRedisDBIndex = Configurations.getIntProperty("idRelaRedisDBIndex", 15);
|
||||
RedisTemplate<String, String> idRredisTemplate = SpringContextHolder
|
||||
.getBean("redisTemplate" + idRelaRedisDBIndex);
|
||||
|
||||
for (Integer redisDBIndex : idMap.keySet()) {
|
||||
RedisTemplate<String, String> redisTemplate = SpringContextHolder
|
||||
.getBean("redisTemplate" + redisDBIndex);
|
||||
Map<Integer, List<Long>> serviceConfigMap = idMap.get(redisDBIndex);
|
||||
if (serviceConfigMap != null && serviceConfigMap.size() > 0) {
|
||||
String maatVersionStr = redisTemplate.opsForValue().get("MAAT_VERSION");
|
||||
String maatVersionStr = BaseRedisDao.getValByKey(redisDBIndex, "MAAT_VERSION");
|
||||
if (maatVersionStr == null) {
|
||||
maatVersionStr = "0";
|
||||
throw new RuntimeException("从" + redisDBIndex
|
||||
+ "号redis库中获取MAAT_VERSION的值为null,redis中不存在该值,请联系开发人员检查删除逻辑是否正确或redis数据是否出现了异常");
|
||||
}
|
||||
// MaatRelation maatRelation =
|
||||
// CompileGroupRegionRela.getIdRelationMap().get(redisDBIndex);
|
||||
@@ -859,10 +761,11 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
for (Integer service : serviceConfigMap.keySet()) {
|
||||
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(service);
|
||||
removeConfig(serviceConfigMap.get(service), maatXmlConfig, maatVersion, service,
|
||||
redisTemplate, redisDBIndex, idRredisTemplate);
|
||||
redisTemplate, redisDBIndex, idRelaRedisDBIndex);
|
||||
|
||||
}
|
||||
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
||||
BaseRedisDao.getIncr(redisDBIndex, "MAAT_VERSION");
|
||||
// redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
||||
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDBIndex,
|
||||
Integer.valueOf(maatVersionStr) + 1);
|
||||
count++;
|
||||
@@ -892,37 +795,55 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
* @param maatRelation id对应关系对象
|
||||
*/
|
||||
private void removeConfig(List<Long> idList, MaatXmlConfig maatXmlConfig, Long maatVersion, int service,
|
||||
RedisTemplate<String, String> redisTemplate, int redisDBIndex,
|
||||
RedisTemplate<String, String> idRredisTemplate) {
|
||||
RedisTemplate<String, String> redisTemplate, int redisDBIndex, int idRelaRedisDBIndex) {
|
||||
|
||||
if (idList != null && idList.size() > 0 && maatXmlConfig != null) {
|
||||
for (Long id : idList) {
|
||||
removeCompileAndGroupConfig(maatXmlConfig, id + "", 10, maatVersion.doubleValue(), service,
|
||||
redisTemplate, redisDBIndex, null);// 10代表是编译配置
|
||||
String compileStr = redisDBIndex + ":COMPILEGROUP:" + id;
|
||||
// 获取当前编译下所有的分组id
|
||||
String groupCompileStrs = idRredisTemplate.opsForValue().get(compileStr);
|
||||
if (groupCompileStrs != null && !groupCompileStrs.equals("")) {
|
||||
String groupCompileStrs = BaseRedisDao.getValByKey(idRelaRedisDBIndex, compileStr);
|
||||
if (groupCompileStrs != null && !groupCompileStrs.trim().equals("")) {
|
||||
String[] split = groupCompileStrs.split(";");
|
||||
for (String groupId : split) {
|
||||
String compileGroupStr = idRredisTemplate.opsForValue().get(groupId);
|
||||
String compileGroupStr = BaseRedisDao.getValByKey(idRelaRedisDBIndex, groupId);
|
||||
if (compileGroupStr != null && !compileGroupStr.trim().equals("")) {
|
||||
String[] compileGroupArr = compileGroupStr.split(";");// 获取组对应的编译id
|
||||
if (compileGroupArr != null && compileGroupArr.length == 1) {// 如果只有一个编译id且与上面的编译id相同则说明未被分组复用,可以将其下的所有域置失效,否则不处理域配置,只把编译,分组关系置为无效
|
||||
for (String compileId : compileGroupArr) {
|
||||
if (compileId.equals(compileStr)) {//
|
||||
String groupRegionKey = groupId.replace("GROUPCOMPILE", "GROUPREGION");
|
||||
String regionStr = idRredisTemplate.opsForValue().get(groupRegionKey);
|
||||
String regionStr = BaseRedisDao.getValByKey(idRelaRedisDBIndex, groupRegionKey);
|
||||
if (regionStr != null && !regionStr.trim().equals("")) {
|
||||
String[] regionKeyArr = regionStr.split(";");
|
||||
if (regionKeyArr != null && regionKeyArr.length > 0) {
|
||||
removeRegionConfig(maatXmlConfig, regionKeyArr, maatVersion.doubleValue(),
|
||||
service, redisTemplate, redisDBIndex);
|
||||
removeRegionConfig(maatXmlConfig, regionKeyArr,
|
||||
maatVersion.doubleValue(), service, redisTemplate,
|
||||
redisDBIndex);
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException(
|
||||
"从" + idRelaRedisDBIndex + "号redis库中获取" + groupRegionKey
|
||||
+ "的值为null,redis中不存在该值,请联系开发人员检查删除逻辑是否正确或redis数据是否出现了异常");
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
removeCompileAndGroupConfig(maatXmlConfig, groupId.replace(redisDBIndex + ":GROUPCOMPILE:", ""),
|
||||
11, maatVersion.doubleValue(), service, redisTemplate, redisDBIndex, id + "");// 11代表是分组配置
|
||||
removeCompileAndGroupConfig(maatXmlConfig,
|
||||
groupId.replace(redisDBIndex + ":GROUPCOMPILE:", ""), 11, maatVersion.doubleValue(),
|
||||
service, redisTemplate, redisDBIndex, id + "");// 11代表是分组配置
|
||||
} else {
|
||||
throw new RuntimeException("从" + idRelaRedisDBIndex + "号redis库中获取" + groupId
|
||||
+ "的值为null,redis中不存在该值,请联系开发人员检查删除逻辑是否正确或redis数据是否出现了异常");
|
||||
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("从" + idRelaRedisDBIndex + "号redis库中获取" + compileStr
|
||||
+ "的值为null,redis中不存在该值,请联系开发人员检查删除逻辑是否正确或redis数据是否出现了异常");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("无法获取内存中记录的id映射关系,无法获取业务类型" + service + "对应的maat规则或传入的配置id有误,请检查!");
|
||||
@@ -972,13 +893,14 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
oldKey += compileId;
|
||||
}
|
||||
maatKey = oldKey.replace("EFFECTIVE_RULE", "OBSOLETE_RULE");
|
||||
if (redisTemplate.hasKey(oldKey)) {
|
||||
if (BaseRedisDao.keyIsExist(redisDBIndex, oldKey)) {
|
||||
redisTemplate.rename(oldKey, maatKey.toUpperCase());
|
||||
logger.info("向{}号redis数据库修改了一条配置,修改前key是{},修改后key是{}", redisDBIndex, oldKey,
|
||||
maatKey.toUpperCase());
|
||||
break;
|
||||
} else {
|
||||
throw new RuntimeException(redisDBIndex + "号redis库中不存在key=" + oldKey + "请检查id映射关系是否正确");
|
||||
throw new RuntimeException(redisDBIndex + "号redis库中不存在key=" + oldKey
|
||||
+ "请检查id映射关系是否正确,或该配置已经被取消,已经被取消的配置不可再次取消,否则将抛出异常");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1023,7 +945,7 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
for (String oldKey : regionArr) {
|
||||
oldKey = oldKey.replace(redisDBIndex + ":", "");
|
||||
maatKey = oldKey.replace("EFFECTIVE_RULE", "OBSOLETE_RULE");
|
||||
if (redisTemplate.hasKey(oldKey)) {
|
||||
if (BaseRedisDao.keyIsExist(redisDBIndex, oldKey)) {
|
||||
redisTemplate.rename(oldKey, maatKey.toUpperCase());
|
||||
logger.info("向{}号redis数据库修改了一条配置,修改前key是{},修改后key是{}", redisDBIndex, oldKey, maatKey.toUpperCase());
|
||||
} else {
|
||||
@@ -1082,12 +1004,16 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
if (idList != null && idList.size() > 0) {
|
||||
for (Long compileId : idList) {
|
||||
String compileStr = redisDBIndex + ":COMPILEGROUP:" + compileId;
|
||||
String groupCompileStr = redisTemplate.opsForValue().get(compileStr);// 根据编译id获取该编译下的分组关系
|
||||
String groupCompileStr = BaseRedisDao.getValByKey(idRelaRedisDBIndex, compileStr);// 根据编译id获取该编译下的分组关系
|
||||
if (groupCompileStr != null && !groupCompileStr.equals("")) {
|
||||
String[] groupCompileStrSplit = groupCompileStr.split(";");// 得到分组关系
|
||||
for (String groupCompile : groupCompileStrSplit) {// 遍历所有分组关系
|
||||
String compileGroupStr = redisTemplate.opsForValue()
|
||||
.get(groupCompile.toUpperCase());// 获取当前分组关系对应的编译信息
|
||||
// String compileGroupStr = redisTemplate.opsForValue()
|
||||
// .get(groupCompile.toUpperCase());// 获取当前分组关系对应的编译信息
|
||||
|
||||
String compileGroupStr = BaseRedisDao.getValByKey(idRelaRedisDBIndex,
|
||||
groupCompile.toUpperCase());// 获取当前分组关系对应的编译信息
|
||||
|
||||
if (compileGroupStr != null && !compileGroupStr.equals("")) {
|
||||
String[] compileGroupStrSplit = compileGroupStr.split(";");
|
||||
if (compileGroupStrSplit != null && compileGroupStrSplit.length == 1
|
||||
@@ -1096,12 +1022,21 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
.equals(compileStr.toUpperCase())) {
|
||||
String groupRegion = groupCompile.replaceAll("GROUPCOMPILE",
|
||||
"GROUPREGION");
|
||||
if (redisTemplate.hasKey(groupRegion)) {
|
||||
if (BaseRedisDao.keyIsExist(idRelaRedisDBIndex, groupRegion)) {
|
||||
redisTemplate.delete(groupRegion);// 删除组对应的域
|
||||
} else {
|
||||
throw new RuntimeException("从" + idRelaRedisDBIndex
|
||||
+ "号redis库中判断"+groupRegion+"组和域关系时不存在,请联系开发人员检查删除逻辑是否正确或redis数据是否出现了异常");
|
||||
|
||||
}
|
||||
|
||||
if (redisTemplate.hasKey(groupCompile.toUpperCase())) {
|
||||
if (BaseRedisDao.keyIsExist(idRelaRedisDBIndex,
|
||||
groupCompile.toUpperCase())) {
|
||||
redisTemplate.delete(groupCompile.toUpperCase());// 删除当前组所对应的编译
|
||||
} else {
|
||||
throw new RuntimeException("从" + idRelaRedisDBIndex
|
||||
+ "号redis库中判断"+groupCompile.toUpperCase()+"组和域关系时不存在,请联系开发人员检查删除逻辑是否正确或redis数据是否出现了异常");
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1121,39 +1056,22 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
redisTemplate.opsForValue().set(groupCompile,
|
||||
sb.substring(0, sb.length() - 1));
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("从" + idRelaRedisDBIndex + "号redis库中获取"
|
||||
+ groupCompile.toUpperCase()
|
||||
+ "的值为null,redis中不存在该值,请联系开发人员检查删除逻辑是否正确或redis数据是否出现了异常");
|
||||
|
||||
}
|
||||
}
|
||||
if (redisTemplate.hasKey(compileStr.toUpperCase())) {
|
||||
if (BaseRedisDao.keyIsExist(idRelaRedisDBIndex, compileStr.toUpperCase())) {
|
||||
redisTemplate.delete(compileStr.toUpperCase());// 删除编译下面所有的组
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("redis数据库编号:" + redisDBIndex + "不正确,请检查数据库编号");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new RuntimeException("参数不能为空");
|
||||
}
|
||||
}
|
||||
throw new RuntimeException("从" + idRelaRedisDBIndex + "号redis库中获取" + compileStr
|
||||
+ "的值为null,redis中不存在该值,请联系开发人员检查删除逻辑是否正确或redis数据是否出现了异常");
|
||||
|
||||
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 < Configurations.getIntProperty("maxRedisDBIndex", 6)) {
|
||||
// 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.delIdRelation(redisDBIndex, compileId);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
package com.nis.web.service.restful;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.data.redis.core.RedisTemplate;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.StringUtils;
|
||||
@@ -19,13 +19,17 @@ import com.nis.domain.restful.IpRegion;
|
||||
import com.nis.domain.restful.NumRegion;
|
||||
import com.nis.domain.restful.StrRegion;
|
||||
import com.nis.util.CamelUnderlineUtil;
|
||||
import com.nis.util.Configurations;
|
||||
import com.nis.util.FileUtils;
|
||||
import com.nis.util.ReadMaatXmlUtil;
|
||||
import com.nis.util.ServiceAndRDBIndexReal;
|
||||
import com.nis.web.service.SpringContextHolder;
|
||||
|
||||
@Service()
|
||||
public class MaatTestServiceimpl {
|
||||
private static Logger logger = LoggerFactory.getLogger(MaatTestServiceimpl.class);
|
||||
// private static Logger logger =
|
||||
// LoggerFactory.getLogger(MaatTestServiceimpl.class);
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
||||
|
||||
public void getKeys(List<ConfigCompile> configCompileList) {
|
||||
if (configCompileList != null && configCompileList.size() > 0) {
|
||||
@@ -106,7 +110,7 @@ public class MaatTestServiceimpl {
|
||||
if (!StringUtils.isEmpty(keyStr)
|
||||
&& keyStr.trim().startsWith("[") & keyStr.toLowerCase().contains("id")) {
|
||||
if (type == 11) {
|
||||
keyBF.append(compileId + "" + id);
|
||||
keyBF.append(id + "" + compileId);
|
||||
} else {
|
||||
keyBF.append(id);
|
||||
}
|
||||
@@ -142,7 +146,11 @@ public class MaatTestServiceimpl {
|
||||
}
|
||||
}
|
||||
if (sysoLog(valArr, valList, obj, redisDb, key)) {
|
||||
logger.warn("编译配置id为{}的配置中,在{}号redis库中key={}的值与实际插入的值相符", compileId, redisDb, key);
|
||||
FileUtils
|
||||
.addStrToFile("\t" +
|
||||
sdf.format(new Date()) + " 编译配置id为" + compileId + "的配置中,在" + redisDb
|
||||
+ "号redis库中key=" + key + "的值与实际插入的值相符\n",
|
||||
Configurations.getStringProperty("maatTestLogPath", ""), true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -155,8 +163,10 @@ public class MaatTestServiceimpl {
|
||||
String beanVal = getFieldValueByFieldName(filedName, obj);
|
||||
String redisVal = valArr[i];
|
||||
if (!beanVal.trim().equals(redisVal.trim())) {
|
||||
logger.warn("{}号redis库中key={}的值第{}位{}的值:{}与实际传的值不一样,实际值是:{}", redisDb, key, i, attrName, redisVal,
|
||||
beanVal);
|
||||
FileUtils.addStrToFile("\t" +
|
||||
sdf.format(new Date()) + " error:" + redisDb + "号redis库中key=" + key + "的值第" + i + "位"
|
||||
+ attrName + "的值:" + redisVal + "与实际传的值不一样,实际值是:{}\n",
|
||||
Configurations.getStringProperty("maatTestLogPath", ""), true);
|
||||
bool = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -99,9 +99,6 @@
|
||||
<property name="enableTransactionSupport" value="true" />
|
||||
</bean>
|
||||
|
||||
|
||||
|
||||
|
||||
<bean id="redisTemplate1" class="org.springframework.data.redis.core.RedisTemplate">
|
||||
<property name="connectionFactory" ref="connectionFactory1" />
|
||||
<!-- 设置key和value的序列化方式,默认使用的是JdkSerializationRedisSerializer,key会被序列化为\xac\xed\x00\x056\x00 -->
|
||||
@@ -113,10 +110,6 @@
|
||||
<property name="enableTransactionSupport" value="true" />
|
||||
</bean>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<bean id="redisTemplate2" class="org.springframework.data.redis.core.RedisTemplate">
|
||||
<property name="connectionFactory" ref="connectionFactory2" />
|
||||
<!-- 设置key和value的序列化方式,默认使用的是JdkSerializationRedisSerializer,key会被序列化为\xac\xed\x00\x056\x00 -->
|
||||
@@ -212,15 +205,6 @@
|
||||
<property name="enableTransactionSupport" value="true" />
|
||||
</bean>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<bean id="redisTemplate15" class="org.springframework.data.redis.core.RedisTemplate">
|
||||
<property name="connectionFactory" ref="connectionFactory15" />
|
||||
<!-- 设置key和value的序列化方式,默认使用的是JdkSerializationRedisSerializer,key会被序列化为\xac\xed\x00\x056\x00 -->
|
||||
@@ -231,4 +215,204 @@
|
||||
<!-- 设置开启事务 -->
|
||||
<property name="enableTransactionSupport" value="true" />
|
||||
</bean>
|
||||
|
||||
|
||||
<!--设置没有事务的redistemplate,用于判断key是否存在 -->
|
||||
|
||||
|
||||
|
||||
<!-- 默认使用数据库0,设置connectionFactory为非单例模式,方便选择redis数据库 -->
|
||||
<bean id="conn0"
|
||||
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
|
||||
p:host-name="${redis.host}" p:port="${redis.port}" p:pool-config-ref="poolConfig"
|
||||
p:database="0" />
|
||||
|
||||
<!-- p:password="" scope="prototype" -->
|
||||
<bean id="conn1"
|
||||
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
|
||||
p:host-name="${redis.host}" p:port="${redis.port}" p:pool-config-ref="poolConfig"
|
||||
p:database="1" />
|
||||
|
||||
<bean id="conn2"
|
||||
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
|
||||
p:host-name="${redis.host}" p:port="${redis.port}" p:pool-config-ref="poolConfig"
|
||||
p:database="2" />
|
||||
|
||||
<!-- p:password="" scope="prototype" -->
|
||||
<bean id="conn3"
|
||||
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
|
||||
p:host-name="${redis.host}" p:port="${redis.port}" p:pool-config-ref="poolConfig"
|
||||
p:database="3" />
|
||||
|
||||
<bean id="conn4"
|
||||
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
|
||||
p:host-name="${redis.host}" p:port="${redis.port}" p:pool-config-ref="poolConfig"
|
||||
p:database="4" />
|
||||
<bean id="conn5"
|
||||
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
|
||||
p:host-name="${redis.host}" p:port="${redis.port}" p:pool-config-ref="poolConfig"
|
||||
p:database="5" />
|
||||
<bean id="conn6"
|
||||
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
|
||||
p:host-name="${redis.host}" p:port="${redis.port}" p:pool-config-ref="poolConfig"
|
||||
p:database="6" />
|
||||
<bean id="conn7"
|
||||
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
|
||||
p:host-name="${redis.host}" p:port="${redis.port}" p:pool-config-ref="poolConfig"
|
||||
p:database="7" />
|
||||
<bean id="conn8"
|
||||
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
|
||||
p:host-name="${redis.host}" p:port="${redis.port}" p:pool-config-ref="poolConfig"
|
||||
p:database="8" />
|
||||
<bean id="conn9"
|
||||
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
|
||||
p:host-name="${redis.host}" p:port="${redis.port}" p:pool-config-ref="poolConfig"
|
||||
p:database="9" />
|
||||
<bean id="conn10"
|
||||
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
|
||||
p:host-name="${redis.host}" p:port="${redis.port}" p:pool-config-ref="poolConfig"
|
||||
p:database="10" />
|
||||
|
||||
<bean id="conn15"
|
||||
class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"
|
||||
p:host-name="${redis.host}" p:port="${redis.port}" p:pool-config-ref="poolConfig"
|
||||
p:database="15" />
|
||||
|
||||
<bean id="redisTemplateNoTrans0" class="org.springframework.data.redis.core.RedisTemplate">
|
||||
<property name="connectionFactory" ref="conn0" />
|
||||
<!-- 设置key和value的序列化方式,默认使用的是JdkSerializationRedisSerializer,key会被序列化为\xac\xed\x00\x056\x00 -->
|
||||
<property name="keySerializer" ref="stringRedisSerializer" />
|
||||
<property name="valueSerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashKeySerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashValueSerializer" ref="stringRedisSerializer" />
|
||||
|
||||
|
||||
</bean>
|
||||
|
||||
<bean id="redisTemplateNoTrans1" class="org.springframework.data.redis.core.RedisTemplate">
|
||||
<property name="connectionFactory" ref="conn1" />
|
||||
<!-- 设置key和value的序列化方式,默认使用的是JdkSerializationRedisSerializer,key会被序列化为\xac\xed\x00\x056\x00 -->
|
||||
<property name="keySerializer" ref="stringRedisSerializer" />
|
||||
<property name="valueSerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashKeySerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashValueSerializer" ref="stringRedisSerializer" />
|
||||
|
||||
|
||||
</bean>
|
||||
|
||||
<bean id="redisTemplateNoTrans2" class="org.springframework.data.redis.core.RedisTemplate">
|
||||
<property name="connectionFactory" ref="conn2" />
|
||||
<!-- 设置key和value的序列化方式,默认使用的是JdkSerializationRedisSerializer,key会被序列化为\xac\xed\x00\x056\x00 -->
|
||||
<property name="keySerializer" ref="stringRedisSerializer" />
|
||||
<property name="valueSerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashKeySerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashValueSerializer" ref="stringRedisSerializer" />
|
||||
|
||||
|
||||
</bean>
|
||||
|
||||
<bean id="redisTemplateNoTrans3" class="org.springframework.data.redis.core.RedisTemplate">
|
||||
<property name="connectionFactory" ref="conn3" />
|
||||
<!-- 设置key和value的序列化方式,默认使用的是JdkSerializationRedisSerializer,key会被序列化为\xac\xed\x00\x056\x00 -->
|
||||
<property name="keySerializer" ref="stringRedisSerializer" />
|
||||
<property name="valueSerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashKeySerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashValueSerializer" ref="stringRedisSerializer" />
|
||||
|
||||
|
||||
</bean>
|
||||
<bean id="redisTemplateNoTrans4" class="org.springframework.data.redis.core.RedisTemplate">
|
||||
<property name="connectionFactory" ref="conn4" />
|
||||
<!-- 设置key和value的序列化方式,默认使用的是JdkSerializationRedisSerializer,key会被序列化为\xac\xed\x00\x056\x00 -->
|
||||
<property name="keySerializer" ref="stringRedisSerializer" />
|
||||
<property name="valueSerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashKeySerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashValueSerializer" ref="stringRedisSerializer" />
|
||||
|
||||
|
||||
</bean>
|
||||
<bean id="redisTemplateNoTrans5" class="org.springframework.data.redis.core.RedisTemplate">
|
||||
<property name="connectionFactory" ref="conn5" />
|
||||
<!-- 设置key和value的序列化方式,默认使用的是JdkSerializationRedisSerializer,key会被序列化为\xac\xed\x00\x056\x00 -->
|
||||
<property name="keySerializer" ref="stringRedisSerializer" />
|
||||
<property name="valueSerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashKeySerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashValueSerializer" ref="stringRedisSerializer" />
|
||||
|
||||
|
||||
</bean>
|
||||
<bean id="redisTemplateNoTrans6" class="org.springframework.data.redis.core.RedisTemplate">
|
||||
<property name="connectionFactory" ref="conn6" />
|
||||
<!-- 设置key和value的序列化方式,默认使用的是JdkSerializationRedisSerializer,key会被序列化为\xac\xed\x00\x056\x00 -->
|
||||
<property name="keySerializer" ref="stringRedisSerializer" />
|
||||
<property name="valueSerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashKeySerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashValueSerializer" ref="stringRedisSerializer" />
|
||||
|
||||
|
||||
</bean>
|
||||
|
||||
|
||||
|
||||
<bean id="redisTemplateNoTrans7" class="org.springframework.data.redis.core.RedisTemplate">
|
||||
<property name="connectionFactory" ref="conn7" />
|
||||
<!-- 设置key和value的序列化方式,默认使用的是JdkSerializationRedisSerializer,key会被序列化为\xac\xed\x00\x056\x00 -->
|
||||
<property name="keySerializer" ref="stringRedisSerializer" />
|
||||
<property name="valueSerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashKeySerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashValueSerializer" ref="stringRedisSerializer" />
|
||||
|
||||
|
||||
</bean>
|
||||
<bean id="redisTemplateNoTrans8" class="org.springframework.data.redis.core.RedisTemplate">
|
||||
<property name="connectionFactory" ref="conn8" />
|
||||
<!-- 设置key和value的序列化方式,默认使用的是JdkSerializationRedisSerializer,key会被序列化为\xac\xed\x00\x056\x00 -->
|
||||
<property name="keySerializer" ref="stringRedisSerializer" />
|
||||
<property name="valueSerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashKeySerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashValueSerializer" ref="stringRedisSerializer" />
|
||||
|
||||
|
||||
</bean>
|
||||
<bean id="redisTemplateNoTrans9" class="org.springframework.data.redis.core.RedisTemplate">
|
||||
<property name="connectionFactory" ref="conn9" />
|
||||
<!-- 设置key和value的序列化方式,默认使用的是JdkSerializationRedisSerializer,key会被序列化为\xac\xed\x00\x056\x00 -->
|
||||
<property name="keySerializer" ref="stringRedisSerializer" />
|
||||
<property name="valueSerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashKeySerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashValueSerializer" ref="stringRedisSerializer" />
|
||||
|
||||
|
||||
</bean>
|
||||
<bean id="redisTemplateNoTrans10" class="org.springframework.data.redis.core.RedisTemplate">
|
||||
<property name="connectionFactory" ref="conn10" />
|
||||
<!-- 设置key和value的序列化方式,默认使用的是JdkSerializationRedisSerializer,key会被序列化为\xac\xed\x00\x056\x00 -->
|
||||
<property name="keySerializer" ref="stringRedisSerializer" />
|
||||
<property name="valueSerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashKeySerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashValueSerializer" ref="stringRedisSerializer" />
|
||||
|
||||
|
||||
</bean>
|
||||
|
||||
<bean id="redisTemplateNoTrans15" class="org.springframework.data.redis.core.RedisTemplate">
|
||||
<property name="connectionFactory" ref="conn15" />
|
||||
<!-- 设置key和value的序列化方式,默认使用的是JdkSerializationRedisSerializer,key会被序列化为\xac\xed\x00\x056\x00 -->
|
||||
<property name="keySerializer" ref="stringRedisSerializer" />
|
||||
<property name="valueSerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashKeySerializer" ref="stringRedisSerializer" />
|
||||
<property name="hashValueSerializer" ref="stringRedisSerializer" />
|
||||
|
||||
|
||||
</bean>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</beans>
|
||||
|
||||
@@ -85,7 +85,7 @@ bonecp.hive.statementsCacheSize=100
|
||||
#####################################################################################################################################
|
||||
#redis.host=10.0.6.228
|
||||
redis.host=10.0.6.249
|
||||
redis.port=6379
|
||||
redis.port=6380
|
||||
redis.pass=
|
||||
redis.maxIdle=5
|
||||
redis.maxTotal=250
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
#Log4j
|
||||
log4j.rootLogger=info,console,file,warnFile
|
||||
log4j.rootLogger=info,console,file
|
||||
# 控制台日志设置
|
||||
log4j.appender.console=org.apache.log4j.ConsoleAppender
|
||||
#log4j.appender.console.Threshold=info
|
||||
log4j.appender.console.Threshold=info
|
||||
log4j.appender.console.layout=org.apache.log4j.PatternLayout
|
||||
log4j.appender.console.layout.ConversionPattern=[%d{yyyy-MM-dd HH\:mm\:ss}] [%-5p] [Thread\:%t] %l %x - <%m>%n
|
||||
|
||||
@@ -16,22 +16,6 @@ log4j.appender.file.DatePattern='.'yyyy-MM-dd
|
||||
log4j.appender.file.layout=org.apache.log4j.PatternLayout
|
||||
#log4j.appender.file.layout.ConversionPattern=%d{HH:mm:ss} %X{ip} [%t] %5p %c{1} %m%n
|
||||
log4j.appender.file.layout.ConversionPattern=[%d{yyyy-MM-dd HH\:mm\:ss}] [%-5p] %X{ip} [Thread\:%t] %l %x - %m%n
|
||||
|
||||
|
||||
# 文件日志设置
|
||||
log4j.appender.warnFile=org.apache.log4j.DailyRollingFileAppender
|
||||
log4j.appender.warnFile.Threshold=warn
|
||||
log4j.appender.warnFile.encoding=UTF-8
|
||||
log4j.appender.warnFile.Append=true
|
||||
log4j.appender.warnFile.file=${nis.root}/WEB-INF/log/warn.log
|
||||
log4j.appender.warnFile.DatePattern='.'yyyy-MM-dd
|
||||
log4j.appender.warnFile.layout=org.apache.log4j.PatternLayout
|
||||
#log4j.appender.file.layout.ConversionPattern=%d{HH:mm:ss} %X{ip} [%t] %5p %c{1} %m%n
|
||||
log4j.appender.warnFile.layout.ConversionPattern=[%d{yyyy-MM-dd HH\:mm\:ss}] [%-5p] %X{ip} [Thread\:%t] %l %x - %m%n
|
||||
|
||||
|
||||
|
||||
|
||||
#MyBatis 配置,com.nis.web.dao是mybatis接口所在包
|
||||
log4j.logger.com.nis.web.dao=debug
|
||||
#bonecp数据源配置
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
xsi:schemaLocation="http://www.w3school.com.cn maat.xsd">
|
||||
|
||||
|
||||
<p:maatType service="261;261;263;264;389;390;391;392">
|
||||
<p:maatType service="261;263;264;389;390;391;392">
|
||||
<p:expressions>
|
||||
<p:keyExpression>EFFECTIVE_RULE;:;{un_maat_table_name};,;[cfg_id]</p:keyExpression>
|
||||
<p:valueExpression>[cfg_id];\t;[is_valid];\t;[dst_file];\t;[dst_file_md5];\t;[op_time];&nbsp;[level];\t;[file_id];\n</p:valueExpression>
|
||||
|
||||
@@ -249,3 +249,5 @@ digest.gen.tool.path=maat-redis/digest_gen
|
||||
maxRedisDBIndex=12
|
||||
##存放编译,分组,域配置id关系的redis数据库编号
|
||||
idRelaRedisDBIndex=15
|
||||
#maat测试程序输出日志的文件目录
|
||||
maatTestLogPath=c:/maat/mmat.log
|
||||
Reference in New Issue
Block a user