1:修改配置新增或取消时,修改id对应关系为当新增或取消成功后才修改id关系,否则不修改id关系
This commit is contained in:
@@ -88,6 +88,7 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
Map<Integer, List<Map<String, String>>> configMap = new HashMap<Integer, List<Map<String, String>>>();
|
||||
configMap.put(1, listMap);
|
||||
configRedisService.saveUnMaatConfig(configMap);
|
||||
|
||||
} else {
|
||||
Integer service = 100;
|
||||
Map<String, String> map = new HashMap<String, String>();
|
||||
@@ -145,7 +146,10 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
Map<Integer, Map<Integer, List<Long>>> idMap = new HashMap<Integer, Map<Integer, List<Long>>>();
|
||||
idMap.put(redisDB, map);
|
||||
|
||||
configRedisService.delMaatConfig(idMap);
|
||||
boolean delMaatConfig = configRedisService.delMaatConfig(idMap);
|
||||
if (delMaatConfig) {
|
||||
configRedisService.delMaatRelation(idMap);
|
||||
}
|
||||
return "ok";
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
@@ -165,7 +169,9 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
listMap = new ArrayList<MaatConfig>();
|
||||
listMap.add(getMaatConfig(service));
|
||||
configMap.put(2, listMap);
|
||||
configRedisService.saveMaatConfig(configMap);
|
||||
if (configRedisService.saveMaatConfig(configMap)) {
|
||||
configRedisService.addMaatRelation(configMap);
|
||||
}
|
||||
// configRedisService.saveMaatConfig(listMap, service);
|
||||
// new ConfigRedisServiceimpl().GETMaatConfig(listMap);
|
||||
return "ok";
|
||||
@@ -306,7 +312,7 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
checkOpAction(thread, System.currentTimeMillis() - start, opAction, 2);
|
||||
String msg = "";
|
||||
ConfigCompile compile = configSource.getConfigCompileList().get(0);
|
||||
//zdx 20180528改为调用rkg接口取消配置
|
||||
// zdx 20180528改为调用rkg接口取消配置
|
||||
msg = configSourcesService.cancleConfigSources(thread, start, configSource.getConfigCompileList(),
|
||||
configSource.getOpTime(), sb);
|
||||
|
||||
@@ -373,11 +379,12 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置id不能为空",
|
||||
RestBusinessCode.missing_args.getValue());
|
||||
}
|
||||
// if ((configCompile.getActiveSys() != null) || (configCompile.getEffectiveRange() != null
|
||||
// && !configCompile.getEffectiveRange().equals(""))) {
|
||||
// count++;
|
||||
// configSourcesService.setCompileInvalid(configCompile);
|
||||
// }
|
||||
// if ((configCompile.getActiveSys() != null) ||
|
||||
// (configCompile.getEffectiveRange() != null
|
||||
// && !configCompile.getEffectiveRange().equals(""))) {
|
||||
// count++;
|
||||
// configSourcesService.setCompileInvalid(configCompile);
|
||||
// }
|
||||
}
|
||||
if (count > 0) {
|
||||
Thread.sleep(14000);
|
||||
@@ -405,33 +412,34 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置id不能为空",
|
||||
RestBusinessCode.missing_args.getValue());
|
||||
}
|
||||
// if ((configCompile.getActiveSys() != null) || (configCompile.getEffectiveRange() != null
|
||||
// && !configCompile.getEffectiveRange().equals(""))) {
|
||||
// try {
|
||||
// configSourcesService.setCompileValid(configCompile);
|
||||
// } catch (Exception e1) {
|
||||
// String errorCode = "";
|
||||
// String message = e.getMessage();
|
||||
// if (null != message && message.length() > 0) {
|
||||
// int index = message.toUpperCase().indexOf("ORA-");
|
||||
// if (index != -1) {
|
||||
// errorCode = message.substring(index + 4, index + 9);
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// Map<Integer, String> throwExceptionInfo = OracleErrorCodeUtil
|
||||
// .throwExceptionInfo(errorCode);
|
||||
// for (int errorNum : throwExceptionInfo.keySet()) {
|
||||
// if (errorNum == 998) {
|
||||
// thread.setExceptionInfo(e.toString());
|
||||
// } else {
|
||||
// thread.setExceptionInfo(throwExceptionInfo.get(errorNum));
|
||||
// }
|
||||
// throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
||||
// throwExceptionInfo.get(errorNum), errorNum);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// if ((configCompile.getActiveSys() != null) ||
|
||||
// (configCompile.getEffectiveRange() != null
|
||||
// && !configCompile.getEffectiveRange().equals(""))) {
|
||||
// try {
|
||||
// configSourcesService.setCompileValid(configCompile);
|
||||
// } catch (Exception e1) {
|
||||
// String errorCode = "";
|
||||
// String message = e.getMessage();
|
||||
// if (null != message && message.length() > 0) {
|
||||
// int index = message.toUpperCase().indexOf("ORA-");
|
||||
// if (index != -1) {
|
||||
// errorCode = message.substring(index + 4, index + 9);
|
||||
//
|
||||
// }
|
||||
// }
|
||||
// Map<Integer, String> throwExceptionInfo = OracleErrorCodeUtil
|
||||
// .throwExceptionInfo(errorCode);
|
||||
// for (int errorNum : throwExceptionInfo.keySet()) {
|
||||
// if (errorNum == 998) {
|
||||
// thread.setExceptionInfo(e.toString());
|
||||
// } else {
|
||||
// thread.setExceptionInfo(throwExceptionInfo.get(errorNum));
|
||||
// }
|
||||
// throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
||||
// throwExceptionInfo.get(errorNum), errorNum);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -509,19 +517,20 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
Constants.IS_DEBUG ? jsonString : null);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/cfg/v1/commonSources", method = RequestMethod.PUT, produces=org.springframework.http.MediaType.APPLICATION_JSON_VALUE)
|
||||
@RequestMapping(value = "/cfg/v1/commonSources", method = RequestMethod.PUT, produces = org.springframework.http.MediaType.APPLICATION_JSON_VALUE)
|
||||
@ApiOperation(value = "回调配置状态修改", httpMethod = "PUT", response = Map.class, notes = "回调配置状态修改服务")
|
||||
public Map updateCommonConfigSource(@RequestBody String jsonString , HttpServletRequest request,
|
||||
public Map updateCommonConfigSource(@RequestBody String jsonString, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
ConfigSourcesService.setMsgList(new ArrayList<Exception>());// 清除上次记录的日志信息
|
||||
long start = System.currentTimeMillis();
|
||||
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,null);
|
||||
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
|
||||
null);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
|
||||
configSourcesService.saveCommonSources(thread, start, jsonString, sb);
|
||||
|
||||
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
|
||||
"配置数据插入成功" , Constants.IS_DEBUG ? jsonString : null);
|
||||
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "配置数据插入成功",
|
||||
Constants.IS_DEBUG ? jsonString : null);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/cfg/v1/fileUploadSources", method = RequestMethod.POST)
|
||||
@@ -531,36 +540,39 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
HttpServletResponse response) {
|
||||
ConfigSourcesService.setMsgList(new ArrayList<Exception>());// 清除上次记录的日志信息
|
||||
long start = System.currentTimeMillis();
|
||||
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,null);
|
||||
String filePath ="";
|
||||
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
|
||||
null);
|
||||
String filePath = "";
|
||||
try {
|
||||
FileDesc fileDesc = (FileDesc) JSONObject.toBean(JSONObject.fromObject(request.getHeader("File-Desc")),FileDesc.class);
|
||||
if(null==file){
|
||||
FileDesc fileDesc = (FileDesc) JSONObject.toBean(JSONObject.fromObject(request.getHeader("File-Desc")),
|
||||
FileDesc.class);
|
||||
if (null == file) {
|
||||
thread.setExceptionInfo("请选择上传文件到file参数");
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "请选择上传文件到file参数",
|
||||
RestBusinessCode.missing_args.getValue());
|
||||
|
||||
}
|
||||
if (!StringUtil.isEmpty(fileDesc.getChecksum())) {
|
||||
//验证Md5
|
||||
// 验证Md5
|
||||
String md5 = DigestUtils.md5Hex(file.getBytes());
|
||||
System.out.println("----------------------------MD5:'"+md5+"'==='"+fileDesc.getChecksum()+"'");
|
||||
System.out.println("----------------------------MD5:'" + md5 + "'==='" + fileDesc.getChecksum() + "'");
|
||||
if (!md5.equals(fileDesc.getChecksum())) {
|
||||
thread.setExceptionInfo("checksum与文件MD5值不一致");
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "checksum与文件MD5值不一致",
|
||||
RestBusinessCode.config_integrity_error.getValue());
|
||||
}
|
||||
String ext = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1);
|
||||
FastDFSFile fdsfile = new FastDFSFile(file.getBytes(),file.getOriginalFilename(), ext);
|
||||
// NameValuePair[] meta_list = new NameValuePair[5];
|
||||
// meta_list[0] = new NameValuePair("fileName", file.getOriginalFilename());
|
||||
// meta_list[1] = new NameValuePair("fileLength", String.valueOf(file.getSize()));
|
||||
// meta_list[2] = new NameValuePair("fileExt", ext);
|
||||
// meta_list[3] = new NameValuePair("fileAuthor", "rkg");
|
||||
// meta_list[4] = new NameValuePair("fileMd5", md5);
|
||||
FastDFSFile fdsfile = new FastDFSFile(file.getBytes(), file.getOriginalFilename(), ext);
|
||||
// NameValuePair[] meta_list = new NameValuePair[5];
|
||||
// meta_list[0] = new NameValuePair("fileName", file.getOriginalFilename());
|
||||
// meta_list[1] = new NameValuePair("fileLength",
|
||||
// String.valueOf(file.getSize()));
|
||||
// meta_list[2] = new NameValuePair("fileExt", ext);
|
||||
// meta_list[3] = new NameValuePair("fileAuthor", "rkg");
|
||||
// meta_list[4] = new NameValuePair("fileMd5", md5);
|
||||
logger.info("-----------------调用接口上传文件---------------");
|
||||
filePath = FileManager.upload(fdsfile, null);
|
||||
}else{
|
||||
} else {
|
||||
thread.setExceptionInfo("请求头信息中缺少checksum参数");
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "请求头信息中缺少checksum参数",
|
||||
RestBusinessCode.missing_args.getValue());
|
||||
@@ -571,48 +583,49 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
}
|
||||
JSONObject jsonObj = new JSONObject();
|
||||
jsonObj.put("accessUrl", filePath.substring(filePath.indexOf("group")));
|
||||
// jsonObj.put("accessUrl", "filePath");
|
||||
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
|
||||
"文件上传成功" ,jsonObj);
|
||||
// jsonObj.put("accessUrl", "filePath");
|
||||
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "文件上传成功", jsonObj);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/cfg/v1/fileDigestSources", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "文件摘要获取", httpMethod = "POST", response = Map.class, notes = "文件摘要获取")
|
||||
@ApiParam(value = "摘要文件", name = "MultipartFile", required = true)
|
||||
public Map fileDigestSources(MultipartFile file,HttpServletRequest request,
|
||||
HttpServletResponse response){
|
||||
public Map fileDigestSources(MultipartFile file, HttpServletRequest request, HttpServletResponse response) {
|
||||
long start = System.currentTimeMillis();
|
||||
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,file,null);
|
||||
//JSONArray fileArray=new JSONArray();
|
||||
if (file==null) {
|
||||
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
|
||||
file, null);
|
||||
// JSONArray fileArray=new JSONArray();
|
||||
if (file == null) {
|
||||
thread.setExceptionInfo("请上传获取摘要的文件到file");
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "请上传获取摘要的文件到file参数",
|
||||
RestBusinessCode.missing_args.getValue());
|
||||
}
|
||||
JSONObject resultObject = new JSONObject();
|
||||
FileDesc fileDesc = (FileDesc) JSONObject.toBean(JSONObject.fromObject(request.getHeader("File-Desc")),FileDesc.class);
|
||||
FileDesc fileDesc = (FileDesc) JSONObject.toBean(JSONObject.fromObject(request.getHeader("File-Desc")),
|
||||
FileDesc.class);
|
||||
try {
|
||||
if (!StringUtil.isEmpty(fileDesc.getChecksum())) {
|
||||
//验证Md5
|
||||
// 验证Md5
|
||||
String md5 = DigestUtils.md5Hex(file.getBytes());
|
||||
System.out.println("----------------------------MD5:'"+md5+"'==='"+fileDesc.getChecksum()+"'");
|
||||
System.out.println("----------------------------MD5:'" + md5 + "'==='" + fileDesc.getChecksum() + "'");
|
||||
if (!md5.equals(fileDesc.getChecksum())) {
|
||||
thread.setExceptionInfo("checksum与文件MD5值不一致");
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "checksum与文件MD5值不一致",
|
||||
RestBusinessCode.config_integrity_error.getValue());
|
||||
}
|
||||
String ext = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1);
|
||||
FastDFSFile fdsfile = new FastDFSFile(file.getBytes(),file.getOriginalFilename(), ext);
|
||||
FastDFSFile fdsfile = new FastDFSFile(file.getBytes(), file.getOriginalFilename(), ext);
|
||||
// NameValuePair[] meta_list = new NameValuePair[5];
|
||||
// meta_list[0] = new NameValuePair("fileName", file.getOriginalFilename());
|
||||
// meta_list[1] = new NameValuePair("fileLength", String.valueOf(file.getSize()));
|
||||
// meta_list[1] = new NameValuePair("fileLength",
|
||||
// String.valueOf(file.getSize()));
|
||||
// meta_list[2] = new NameValuePair("fileExt", ext);
|
||||
// meta_list[3] = new NameValuePair("fileAuthor", "rkg");
|
||||
// meta_list[4] = new NameValuePair("fileMd5", md5);
|
||||
logger.info("-----------------调用接口上传文件---------------");
|
||||
String filePath = FileManager.upload(fdsfile, null);
|
||||
resultObject.put("path", filePath.substring(filePath.indexOf("group")));
|
||||
}else{
|
||||
} else {
|
||||
thread.setExceptionInfo("请求头信息中缺少checksum参数");
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "请求头信息中缺少checksum参数",
|
||||
RestBusinessCode.missing_args.getValue());
|
||||
@@ -620,12 +633,12 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
|
||||
CommonsMultipartFile filetemp = (CommonsMultipartFile) file;
|
||||
String tempFilePath = filetemp.getStorageDescription().toString();
|
||||
tempFilePath = tempFilePath.substring(tempFilePath.indexOf("[")+1, tempFilePath.indexOf("]"));
|
||||
tempFilePath = tempFilePath.substring(tempFilePath.indexOf("[") + 1, tempFilePath.indexOf("]"));
|
||||
|
||||
String digestStr = configSourcesService.getDigestGen(request.getRealPath("/"),tempFilePath);
|
||||
String digestStr = configSourcesService.getDigestGen(request.getRealPath("/"), tempFilePath);
|
||||
resultObject.put("digest", digestStr);
|
||||
resultObject.put("rawLen", file.getSize());
|
||||
}catch (IOException e) {
|
||||
} catch (IOException e) {
|
||||
// TODO Auto-generated catch block
|
||||
logger.error("文件上传过程中出现异常");
|
||||
thread.setExceptionInfo("文件上传过程中出现异常");
|
||||
@@ -639,8 +652,9 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start, "摘要获取过程中出现异常",
|
||||
RestBusinessCode.unknow_error.getValue());
|
||||
}
|
||||
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "摘要获取成功",resultObject);
|
||||
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "摘要获取成功", resultObject);
|
||||
}
|
||||
|
||||
private boolean isBlank(Date datetime) {
|
||||
if (null != datetime) {
|
||||
return true;
|
||||
|
||||
@@ -15,18 +15,24 @@ import com.nis.domain.restful.MaatConfig;
|
||||
*
|
||||
*/
|
||||
public interface ConfigRedisService {
|
||||
|
||||
/**
|
||||
* 下发非maat配置接口,key是redisDBIndex,value是配置集合
|
||||
* @param configMap
|
||||
* @return 成功返回true,失败返回false或抛出异常
|
||||
*/
|
||||
public void saveUnMaatConfig(Map<Integer, List<Map<String, String>>> configMap);
|
||||
public boolean saveUnMaatConfig(Map<Integer, List<Map<String, String>>> configMap);
|
||||
|
||||
/**
|
||||
* 保存 maat配置接口,key是redisDBIndex,value是配置集合
|
||||
* @param configMap
|
||||
* @return 成功返回true,失败返回false或抛出异常
|
||||
*/
|
||||
public void saveMaatConfig(Map<Integer, List<MaatConfig>> configMap);
|
||||
public boolean saveMaatConfig(Map<Integer, List<MaatConfig>> configMap);
|
||||
/**
|
||||
* 下发配置成功后,需要更新编译,组,域等配置id的对应关系
|
||||
* @param configMap
|
||||
*/
|
||||
public void addMaatRelation(Map<Integer, List<MaatConfig>> configMap);
|
||||
|
||||
/**
|
||||
* 获取指定key的自增长值
|
||||
@@ -38,14 +44,21 @@ public interface ConfigRedisService {
|
||||
/**
|
||||
* 删除非maat类配置,第一个key是redisDBIndex,第二个key是业务类型,value是配置id集合
|
||||
* @param idMap
|
||||
* @return 成功返回true,失败返回false或抛出异常
|
||||
*/
|
||||
public void delUnMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap);
|
||||
public boolean delUnMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap);
|
||||
|
||||
/**
|
||||
* 删除maat类配置,第一个key是redisDBIndex,第二个key是业务类型,value是配置id集合
|
||||
* @param idMap
|
||||
* @return 成功返回true,失败返回false或抛出异常
|
||||
*/
|
||||
public void delMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap);
|
||||
public boolean delMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap);
|
||||
|
||||
/**
|
||||
* 删除maat类配置成功后,需要更新编译,组,域等配置id的对应关系
|
||||
* @param idMap
|
||||
*/
|
||||
public void delMaatRelation(Map<Integer, Map<Integer, List<Long>>> idMap);
|
||||
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@ 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.Exceptions;
|
||||
import com.nis.util.ReadMaatXmlUtil;
|
||||
import com.nis.util.ServiceAndRDBIndexReal;
|
||||
import com.nis.web.service.SpringContextHolder;
|
||||
@@ -32,7 +33,7 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
private static Logger logger = LoggerFactory.getLogger(ConfigRedisServiceimpl.class);
|
||||
|
||||
@Transactional
|
||||
public void saveUnMaatConfig(Map<Integer, List<Map<String, String>>> configMap) {
|
||||
public boolean saveUnMaatConfig(Map<Integer, List<Map<String, String>>> configMap) {
|
||||
if (configMap != null && configMap.size() > 0) {
|
||||
for (Integer redisDBIndex : configMap.keySet()) {
|
||||
if (redisDBIndex >= 0 && redisDBIndex < Configurations.getIntProperty("maxRedisDBIndex", 6)) {
|
||||
@@ -136,10 +137,11 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
||||
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDBIndex,
|
||||
Integer.valueOf(maatVersionStr) + 1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -199,7 +201,7 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void saveMaatConfig(Map<Integer, List<MaatConfig>> configMap) {
|
||||
public boolean saveMaatConfig(Map<Integer, List<MaatConfig>> configMap) {
|
||||
if (configMap != null && configMap.size() > 0) {
|
||||
for (Integer redisDBIndex : configMap.keySet()) {
|
||||
if (redisDBIndex >= 0 && redisDBIndex < Configurations.getIntProperty("maxRedisDBIndex", 6)) {
|
||||
@@ -218,16 +220,19 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(service);
|
||||
setConfig(maatConfig, maatXmlConfig, maatVersion, service, redisTemplate, redisDBIndex);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
||||
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDBIndex,
|
||||
Integer.valueOf(maatVersionStr) + 1);
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
addMaatRelation(configMap);
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -401,7 +406,7 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void delUnMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap) {
|
||||
public boolean delUnMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap) {
|
||||
if (idMap != null && idMap.size() > 0) {
|
||||
for (Integer redisDBIndex : idMap.keySet()) {
|
||||
RedisTemplate<String, String> redisTemplate = SpringContextHolder
|
||||
@@ -500,18 +505,19 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
||||
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDBIndex,
|
||||
Integer.valueOf(maatVersionStr) + 1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void delMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap) {
|
||||
public boolean delMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap) {
|
||||
if (idMap != null && idMap.size() > 0) {
|
||||
for (Integer redisDBIndex : idMap.keySet()) {
|
||||
RedisTemplate<String, String> redisTemplate = SpringContextHolder
|
||||
@@ -525,6 +531,7 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
MaatRelation maatRelation = CompileGroupRegionRela.getIdRelationMap().get(redisDBIndex);
|
||||
if (maatVersionStr != null) {
|
||||
Long maatVersion = Long.valueOf(maatVersionStr) + 1;
|
||||
if (maatRelation != null && redisTemplate != null) {
|
||||
for (Integer service : serviceConfigMap.keySet()) {
|
||||
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(service);
|
||||
removeConfig(serviceConfigMap.get(service), maatXmlConfig, maatVersion, service,
|
||||
@@ -534,13 +541,13 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
|
||||
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDBIndex,
|
||||
Integer.valueOf(maatVersionStr) + 1);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
// 删除配置成功后开始删除id对应关系
|
||||
delMaatRelation(idMap);
|
||||
}
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -595,7 +602,7 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
* @param service
|
||||
* @param redisTemplate
|
||||
*/
|
||||
public void removeCommonConfig(MaatXmlConfig maatXmlConfig, Set<Long> idList, int type, Double maatVersion,
|
||||
private 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) {
|
||||
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
|
||||
@@ -621,10 +628,14 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
|
||||
}
|
||||
String oldKey = keyBF.toString().toUpperCase();
|
||||
maatKey = oldKey.replace("EFFECTIVE_RULE", "OBSOLETE_RULE");
|
||||
if (redisTemplate.hasKey(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映射关系是否正确");
|
||||
}
|
||||
}
|
||||
}
|
||||
for (MaatXmlExpr maatXmlExpr : expressionList) {
|
||||
|
||||
Reference in New Issue
Block a user