1:扩展编译,分组,域配置等的关联关系,以支持分组复用

2:实现为分组复用配置单独添加域配置的功能
3:为单独添加域配置时添加ipClientRangeList(生效范围IP域分组列表)域支持,业务类型37需要该域
This commit is contained in:
RenKaiGe-Office
2018-08-27 09:48:09 +08:00
parent 4391669100
commit a574c207a3
6 changed files with 582 additions and 439 deletions

View File

@@ -9,10 +9,8 @@
package com.nis.domain.restful; package com.nis.domain.restful;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
import java.util.List; import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.wordnik.swagger.annotations.ApiModelProperty; import com.wordnik.swagger.annotations.ApiModelProperty;
/** /**
@@ -24,7 +22,8 @@ import com.wordnik.swagger.annotations.ApiModelProperty;
* @version V1.0 * @version V1.0
*/ */
public class GroupReuse implements Serializable { public class GroupReuse implements Serializable {
private static final long serialVersionUID = 5803814776173252917L;
private static final long serialVersionUID = 1L;
@ApiModelProperty(value = "业务ID", required = true) @ApiModelProperty(value = "业务ID", required = true)
private Integer service; private Integer service;
@@ -38,6 +37,9 @@ public class GroupReuse implements Serializable {
@ApiModelProperty(value = "数值域分组列表", required = true) @ApiModelProperty(value = "数值域分组列表", required = true)
private List<NumRegion> numRegionList; private List<NumRegion> numRegionList;
@ApiModelProperty(value = "生效范围IP域分组列表", required = true)
private List<IpRegion> ipClientRangeList;
/** /**
* @return service * @return service
*/ */
@@ -53,7 +55,6 @@ public class GroupReuse implements Serializable {
this.service = service; this.service = service;
} }
/** /**
* @return strRegionList * @return strRegionList
*/ */
@@ -100,4 +101,12 @@ public class GroupReuse implements Serializable {
this.numRegionList = numRegionList; this.numRegionList = numRegionList;
} }
public List<IpRegion> getIpClientRangeList() {
return ipClientRangeList;
}
public void setIpClientRangeList(List<IpRegion> ipClientRangeList) {
this.ipClientRangeList = ipClientRangeList;
}
} }

View File

@@ -538,6 +538,11 @@ public enum RestBusinessCode {
*/ */
ExistsKeyFailed(5002008,"判断key是否存在失败"), ExistsKeyFailed(5002008,"判断key是否存在失败"),
/**
* 当前service不允许单独添加域配置
*/
ServiceNotAllowAddReion(5002009,"当前service不允许单独添加域配置"),
/** /**
* 无法从Map中获取配置的属性值 * 无法从Map中获取配置的属性值
*/ */

View File

@@ -31,6 +31,7 @@ import com.nis.domain.restful.StrRegion;
import com.nis.util.Configurations; import com.nis.util.Configurations;
import com.nis.util.ExceptionUtil; import com.nis.util.ExceptionUtil;
import com.nis.util.FileUtils; import com.nis.util.FileUtils;
import com.nis.util.JsonMapper;
import com.nis.util.ReadCommSourceXmlUtil; import com.nis.util.ReadCommSourceXmlUtil;
import com.nis.util.ServiceAndRDBIndexReal; import com.nis.util.ServiceAndRDBIndexReal;
import com.nis.util.StringUtil; import com.nis.util.StringUtil;
@@ -151,6 +152,8 @@ public class MaatTestController {
for (int i = 0; i < saveCount; i++) { for (int i = 0; i < saveCount; i++) {
configCompileList.add(getConfigCompile(ser)); configCompileList.add(getConfigCompile(ser));
} }
String jsonString = JsonMapper.toJsonString(configCompileList);
System.out.println(jsonString);
// 保存测试配置 // 保存测试配置
configSourcesService.saveMaatConfig(thread, start, configCompileList, sb); configSourcesService.saveMaatConfig(thread, start, configCompileList, sb);
for (ConfigCompile configCompile : configCompileList) { for (ConfigCompile configCompile : configCompileList) {
@@ -175,6 +178,8 @@ public class MaatTestController {
for (int i = 0; i < saveCount; i++) { for (int i = 0; i < saveCount; i++) {
configCompileList.add(getConfigCompile(service)); configCompileList.add(getConfigCompile(service));
} }
String jsonString = JsonMapper.toJsonString(configCompileList);
System.out.println(jsonString);
// 保存测试配置 // 保存测试配置
configSourcesService.saveMaatConfig(thread, start, configCompileList, sb); configSourcesService.saveMaatConfig(thread, start, configCompileList, sb);
for (ConfigCompile configCompile : configCompileList) { for (ConfigCompile configCompile : configCompileList) {
@@ -188,7 +193,8 @@ public class MaatTestController {
maatTestServiceimpl.getMaatKeys(configCompileList); maatTestServiceimpl.getMaatKeys(configCompileList);
map.put(service, "http://127.0.0.1:8080/galaxy/service/test/cfg/v1/testDelMaat?serviceType=" map.put(service, "http://127.0.0.1:8080/galaxy/service/test/cfg/v1/testDelMaat?serviceType="
+ service + "&configId=" + compileIdList.toString().replace("[", "").replace("]", "")); + service + "&configId=" + compileIdList.toString().replace("[", "").replace("]", ""));
if(!testDelMaat(compileIdList.toString().replace("[", "").replace("]", ""), service).equals("ok")) { if (!testDelMaat(compileIdList.toString().replace("[", "").replace("]", ""), service)
.equals("ok")) {
map.put(-4, "del config error"); map.put(-4, "del config error");
} }
} else { } else {
@@ -594,7 +600,7 @@ public class MaatTestController {
// 验证数据是否在正确 // 验证数据是否在正确
maatTestServiceimpl.getUnMaatKeys(jsonStr, service); maatTestServiceimpl.getUnMaatKeys(jsonStr, service);
// 删除配置 // 删除配置
if(!testDelUnMaat(compileIdList.toString().replace("[", "").replace("]", ""), service).equals("ok")){ if (!testDelUnMaat(compileIdList.toString().replace("[", "").replace("]", ""), service).equals("ok")) {
map.put(-4, "del unmaat error"); map.put(-4, "del unmaat error");
} }
} }

View File

@@ -213,7 +213,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
Map<String, List<String>> compileAndGroupMap = new HashMap<String, List<String>>(); Map<String, List<String>> compileAndGroupMap = new HashMap<String, List<String>>();
Map<String, List<String>> groupAndCompileMap = new HashMap<String, List<String>>(); Map<String, List<String>> groupAndCompileMap = new HashMap<String, List<String>>();
for (MaatConfig maatConfig : maatConfigList) { for (MaatConfig maatConfig : maatConfigList) {
String compileId = maatConfig.getCompileMap().get("compile_id"); // String compileId = maatConfig.getCompileMap().get("compile_id");
List<Map<String, String>> groupMapList = maatConfig.getGroupMapList(); List<Map<String, String>> groupMapList = maatConfig.getGroupMapList();
if (groupMapList != null && groupMapList.size() > 0) { if (groupMapList != null && groupMapList.size() > 0) {
for (Map<String, String> map : groupMapList) { for (Map<String, String> map : groupMapList) {
@@ -244,38 +244,11 @@ public class ConfigJedisServiceimpl 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(), map, addGroupRegionReal(maatConfig, transaction, redisDBSetStr, idRelaRedisDBIndex);
redisDBIndex, compileId, redisDBSetStr);
addGroupAndRegionRelations(maatXmlConfig, service, 13, maatConfig.getNumRegionMapList(),
map, redisDBIndex, compileId, redisDBSetStr);
addGroupAndRegionRelations(maatXmlConfig, service, 14, maatConfig.getStrRegionMapList(),
map, redisDBIndex, compileId, redisDBSetStr);
addGroupAndRegionRelations(maatXmlConfig, service, 15, maatConfig.getStrStrRegionMapList(),
map, redisDBIndex, compileId, redisDBSetStr);
addGroupAndRegionRelations(maatXmlConfig, service, 16,
maatConfig.getFileDigestRegionMapList(), map, redisDBIndex, compileId,
redisDBSetStr);
addGroupAndRegionRelations(maatXmlConfig, service, 17,
maatConfig.getFileLikeRegionMapList(), map, redisDBIndex, compileId, redisDBSetStr);
addGroupAndRegionRelations(maatXmlConfig, service, 18, maatConfig.getIpClientRangeMapList(),
map, redisDBIndex, compileId, redisDBSetStr);
for (String groupIdStr : map.keySet()) {
List<String> list = map.get(groupIdStr);
StringBuffer sb = new StringBuffer();
if (list != null && list.size() > 0) {
for (String regionIdStr : list) {
sb.append(regionIdStr);
sb.append(";");
}
}
transaction.set(groupIdStr, sb.substring(0, sb.length() - 1));// 保存分组id和域id的关系(每个域配置,只会属于一个组)
}
} }
for (String compile : compileAndGroupMap.keySet()) { for (String compile : compileAndGroupMap.keySet()) {
List<String> list = compileAndGroupMap.get(compile); List<String> list = compileAndGroupMap.get(compile);
StringBuffer sb = new StringBuffer(); StringBuffer sb = new StringBuffer();
@@ -441,8 +414,8 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
* @param compileAndGroupRelations * @param compileAndGroupRelations
*/ */
private Map<String, List<String>> addGroupAndRegionRelations(MaatXmlConfig maatXmlConfig, int service, int type, private Map<String, List<String>> addGroupAndRegionRelations(MaatXmlConfig maatXmlConfig, int service, int type,
List<Map<String, String>> regionMapList, Map<String, List<String>> groupAndRegionMap, int redisDBIndex, List<Map<String, String>> regionMapList, Map<String, List<String>> groupAndRegionMap,
String compileId, String redisDBSetStr) { String redisDBSetStr) {
if (regionMapList != null && regionMapList.size() > 0) { if (regionMapList != null && regionMapList.size() > 0) {
for (Map<String, String> map : regionMapList) { for (Map<String, String> map : regionMapList) {
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList(); List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
@@ -596,59 +569,10 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
"无法从参数中获取" + redisDBIndex + "号redis库,业务类型为:" + service + "的分组配置信息,请检查配置参数是否正确", "无法从参数中获取" + redisDBIndex + "号redis库,业务类型为:" + service + "的分组配置信息,请检查配置参数是否正确",
RestBusinessCode.NotFoundGroupInfo.getValue()); RestBusinessCode.NotFoundGroupInfo.getValue());
} }
/**
List<Map<String, String>> ipRegionMapList = maatConfig.getIpRegionMapList(); * 保存域配置信息
if (ipRegionMapList != null && ipRegionMapList.size() > 0) { */
for (Map<String, String> map : ipRegionMapList) { addRegion(maatConfig, maatXmlConfig, maatVersion, service, transaction, redisDBIndex);
setCommonConfig(maatXmlConfig, map, 12, maatVersion.doubleValue(), service, transaction, redisDBIndex,
null);// 12代表是ip类域配置
}
}
List<Map<String, String>> numRegionMapList = maatConfig.getNumRegionMapList();
if (numRegionMapList != null && numRegionMapList.size() > 0) {
for (Map<String, String> map : numRegionMapList) {
setCommonConfig(maatXmlConfig, map, 13, maatVersion.doubleValue(), service, transaction, redisDBIndex,
null);// 13代表是数值类配置
}
}
List<Map<String, String>> strRegionMapList = maatConfig.getStrRegionMapList();
if (strRegionMapList != null && strRegionMapList.size() > 0) {
for (Map<String, String> map : strRegionMapList) {
setCommonConfig(maatXmlConfig, map, 14, maatVersion.doubleValue(), service, transaction, redisDBIndex,
null);// 14代表是字符串类域配置
}
}
List<Map<String, String>> strStrRegionMapList = maatConfig.getStrStrRegionMapList();
if (strStrRegionMapList != null && strStrRegionMapList.size() > 0) {
for (Map<String, String> map : strStrRegionMapList) {
setCommonConfig(maatXmlConfig, map, 15, maatVersion.doubleValue(), service, transaction, redisDBIndex,
null);// 15代表是增强字符串类域配置
}
}
List<Map<String, String>> fileDigestRegionMapList = maatConfig.getFileDigestRegionMapList();
if (fileDigestRegionMapList != null && fileDigestRegionMapList.size() > 0) {
for (Map<String, String> map : fileDigestRegionMapList) {
setCommonConfig(maatXmlConfig, map, 16, maatVersion.doubleValue(), service, transaction, redisDBIndex,
null);// 16代表是文件摘要类域配置
}
}
List<Map<String, String>> fileLikeRegionMapList = maatConfig.getFileLikeRegionMapList();
if (fileLikeRegionMapList != null && fileLikeRegionMapList.size() > 0) {
for (Map<String, String> map : fileLikeRegionMapList) {
setCommonConfig(maatXmlConfig, map, 17, maatVersion.doubleValue(), service, transaction, redisDBIndex,
null);// 17代表是文本相似性域配置
}
}
List<Map<String, String>> ipclientList = maatConfig.getIpClientRangeMapList();
if (ipclientList != null && ipclientList.size() > 0) {
for (Map<String, String> map : ipclientList) {
setCommonConfig(maatXmlConfig, map, 18, maatVersion.doubleValue(), service, transaction, redisDBIndex,
null);// 18代表是区域ip域配置
}
}
// updateCommonKey(maatXmlConfig);
} }
/** /**
@@ -661,7 +585,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
* @param redisTemplate * @param redisTemplate
* @param redisDBIndex * @param redisDBIndex
*/ */
public void setCommonConfig(MaatXmlConfig maatXmlConfig, Map<String, String> map, int type, Double maatVersion, private void setCommonConfig(MaatXmlConfig maatXmlConfig, Map<String, String> map, int type, Double maatVersion,
int service, Transaction transaction, Integer redisDBIndex, String compileId) { int service, Transaction transaction, Integer redisDBIndex, String compileId) {
if (maatXmlConfig != null && map != null && map.size() > 0) { if (maatXmlConfig != null && map != null && map.size() > 0) {
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList(); List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
@@ -756,6 +680,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
valBF.append(valStr.trim()); valBF.append(valStr.trim());
} }
} }
transaction.select(redisDBIndex);
maatKey = keyBF.toString(); maatKey = keyBF.toString();
transaction.set(maatKey.toUpperCase(), valBF.toString()); transaction.set(maatKey.toUpperCase(), valBF.toString());
logger.info("向{}号redis数据库添加了一条配置,key是{},value是{}", redisDBIndex, maatKey.toUpperCase(), logger.info("向{}号redis数据库添加了一条配置,key是{},value是{}", redisDBIndex, maatKey.toUpperCase(),
@@ -1064,7 +989,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
} }
break; break;
} }
if (delMaatRelation(idMap, transaction) && delStatisticsReal(idMap, transaction)) { if (removeMaatRelation(idMap, transaction) && removeStatisticsReal(idMap, transaction)) {
transaction.exec(); transaction.exec();
return true; return true;
} else { } else {
@@ -1340,7 +1265,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
* 编译配置用于实时统计 * 编译配置用于实时统计
* 取消分类性质,标签等信息 * 取消分类性质,标签等信息
*/ */
private boolean delStatisticsReal(Map<Integer, Map<Integer, List<Long>>> idMap, Transaction transaction) { private boolean removeStatisticsReal(Map<Integer, Map<Integer, List<Long>>> idMap, Transaction transaction) {
if (idMap != null && idMap.size() > 0) { if (idMap != null && idMap.size() > 0) {
int redisStatisticsRealDBIndex = Configurations.getIntProperty("redisStatisticsRealDBIndex", 14); int redisStatisticsRealDBIndex = Configurations.getIntProperty("redisStatisticsRealDBIndex", 14);
transaction.select(redisStatisticsRealDBIndex); transaction.select(redisStatisticsRealDBIndex);
@@ -1414,7 +1339,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
* 删除配置成功后,需要更新编译,组,域等配置id的对应关系 * 删除配置成功后,需要更新编译,组,域等配置id的对应关系
* @param idMap * @param idMap
*/ */
private boolean delMaatRelation(Map<Integer, Map<Integer, List<Long>>> idMap, Transaction transaction) { private boolean removeMaatRelation(Map<Integer, Map<Integer, List<Long>>> idMap, Transaction transaction) {
if (idMap != null && idMap.size() > 0) { if (idMap != null && idMap.size() > 0) {
int idRelaRedisDBIndex = Configurations.getIntProperty("idRelaRedisDBIndex", 15); int idRelaRedisDBIndex = Configurations.getIntProperty("idRelaRedisDBIndex", 15);
transaction.select(idRelaRedisDBIndex); transaction.select(idRelaRedisDBIndex);
@@ -1516,4 +1441,351 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
RestBusinessCode.ConfigInfoMapIsNull.getValue()); RestBusinessCode.ConfigInfoMapIsNull.getValue());
} }
} }
@Override
public boolean saveGroupReuseConfig(Map<Integer, List<MaatConfig>> configMap) {
Jedis resource = JedisUtils.getResource(0);
Transaction transaction = resource.multi();
try {
Set<Integer> keySet = configMap.keySet();// 所有的redisdb
String redisDBSetStr = "-" + keySet.toString().replace("[", "").replace("]", "");
int idRelaRedisDBIndex = Configurations.getIntProperty("idRelaRedisDBIndex", 15);
for (Integer redisDb : keySet) {
List<MaatConfig> list = configMap.get(redisDb);
if (list != null && list.size() > 0) {
transaction.select(redisDb);
String maatVersionStr = JedisUtils.get("MAAT_VERSION", redisDb);
if (maatVersionStr == null) {
maatVersionStr = "0";
}
if (maatVersionStr != null) {
Long maatVersion = Long.valueOf(maatVersionStr) + 1;
for (MaatConfig maatConfig : list) {
Integer service = maatConfig.getService();
if (ServiceAndRDBIndexReal.serviceIsReuse(service)) {
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(service);
addRegion(maatConfig, maatXmlConfig, maatVersion, service, transaction, redisDb);
/**
* 添加组和域的关联关系信息
*/
addGroupRegionReal(maatConfig, transaction, redisDBSetStr, idRelaRedisDBIndex);
} else {
throw new ServiceRuntimeException(
"service=" + service + "不是分组复用的配置,不可单独添加域配置,请检查service是否正确",
RestBusinessCode.ServiceNotAllowAddReion.getValue());
}
}
transaction.select(redisDb);
transaction.incrBy("MAAT_VERSION", 1l);
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDb,
Integer.valueOf(maatVersionStr) + 1);
}
} else {
throw new ServiceRuntimeException("" + redisDb + "号redis库中添加分组复用域配置时,未发现对应的配置信息,请检查配置参数是否正确",
RestBusinessCode.ConfigSourceIsNull.getValue());
}
}
transaction.exec();
return true;
} catch (JedisConnectionException e) {
String error = "连接redis异常,保存maat类配置失败" + e.getMessage();
logger.error(error);
throw new ServiceRuntimeException(error, RestBusinessCode.CannotConnectionRedis.getValue());
} catch (Exception e) {
transaction.discard();
String error = "保存maat类配置发生了异常" + e.getMessage();
logger.error(error);
throw new ServiceRuntimeException(error, RestBusinessCode.SaveDataInError.getValue());
} finally {
// 释放连接到连接池
JedisUtils.returnResource(resource);
}
}
/**
* 添加分组和域的关联关系
* @param maatConfig
* @param transaction
* @param redisDBIndex
* @param redisDBSetStr
* @param idRelaRedisDBIndex
*/
private void addGroupRegionReal(MaatConfig maatConfig, Transaction transaction, String redisDBSetStr,
int idRelaRedisDBIndex) {
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(), map, redisDBSetStr);
addGroupAndRegionRelations(maatXmlConfig, service, 13, maatConfig.getNumRegionMapList(), map, redisDBSetStr);
addGroupAndRegionRelations(maatXmlConfig, service, 14, maatConfig.getStrRegionMapList(), map, redisDBSetStr);
addGroupAndRegionRelations(maatXmlConfig, service, 15, maatConfig.getStrStrRegionMapList(), map, redisDBSetStr);
addGroupAndRegionRelations(maatXmlConfig, service, 16, maatConfig.getFileDigestRegionMapList(), map,
redisDBSetStr);
addGroupAndRegionRelations(maatXmlConfig, service, 17, maatConfig.getFileLikeRegionMapList(), map,
redisDBSetStr);
addGroupAndRegionRelations(maatXmlConfig, service, 18, maatConfig.getIpClientRangeMapList(), map,
redisDBSetStr);
for (String groupIdStr : map.keySet()) {
List<String> list = map.get(groupIdStr);
StringBuffer sb = new StringBuffer();
if (list != null && list.size() > 0) {
for (String regionIdStr : list) {
sb.append(regionIdStr);
sb.append(";");
}
}
transaction.select(idRelaRedisDBIndex);// 选择关联关系库
if (JedisUtils.exists(groupIdStr.toUpperCase(),
idRelaRedisDBIndex)) {
transaction.append(groupIdStr,";"+sb.substring(0, sb.length() - 1));
}else {
transaction.set(groupIdStr, sb.substring(0, sb.length() - 1));// 保存分组id和域id的关系(每个域配置,只会属于一个组)
}
}
}
/**
* 保存域配置信息,供分组复用单独添加域和普通maat配置添加域
* @param maatConfig 配置信息
* @param maatXmlConfig 配置的表达式
* @param maatVersion 版本号
* @param service 业务类型
* @param transaction redis连接
* @param redisDBIndex redis编号
*/
private void addRegion(MaatConfig maatConfig, MaatXmlConfig maatXmlConfig, Long maatVersion, int service,
Transaction transaction, Integer redisDBIndex) {
int count = 0;// 计算下所有的域是不是都没有值,如果没有值则给出提示
List<Map<String, String>> ipRegionMapList = maatConfig.getIpRegionMapList();
if (ipRegionMapList != null && ipRegionMapList.size() > 0) {
count += ipRegionMapList.size();
for (Map<String, String> map : ipRegionMapList) {
setCommonConfig(maatXmlConfig, map, 12, maatVersion.doubleValue(), service, transaction, redisDBIndex,
null);// 12代表是ip类域配置
}
}
List<Map<String, String>> numRegionMapList = maatConfig.getNumRegionMapList();
if (numRegionMapList != null && numRegionMapList.size() > 0) {
count += numRegionMapList.size();
for (Map<String, String> map : numRegionMapList) {
setCommonConfig(maatXmlConfig, map, 13, maatVersion.doubleValue(), service, transaction, redisDBIndex,
null);// 13代表是数值类配置
}
}
List<Map<String, String>> strRegionMapList = maatConfig.getStrRegionMapList();
if (strRegionMapList != null && strRegionMapList.size() > 0) {
count += strRegionMapList.size();
for (Map<String, String> map : strRegionMapList) {
setCommonConfig(maatXmlConfig, map, 14, maatVersion.doubleValue(), service, transaction, redisDBIndex,
null);// 14代表是字符串类域配置
}
}
List<Map<String, String>> strStrRegionMapList = maatConfig.getStrStrRegionMapList();
if (strStrRegionMapList != null && strStrRegionMapList.size() > 0) {
count += strStrRegionMapList.size();
for (Map<String, String> map : strStrRegionMapList) {
setCommonConfig(maatXmlConfig, map, 15, maatVersion.doubleValue(), service, transaction, redisDBIndex,
null);// 15代表是增强字符串类域配置
}
}
List<Map<String, String>> fileDigestRegionMapList = maatConfig.getFileDigestRegionMapList();
if (fileDigestRegionMapList != null && fileDigestRegionMapList.size() > 0) {
count += fileDigestRegionMapList.size();
for (Map<String, String> map : fileDigestRegionMapList) {
setCommonConfig(maatXmlConfig, map, 16, maatVersion.doubleValue(), service, transaction, redisDBIndex,
null);// 16代表是文件摘要类域配置
}
}
List<Map<String, String>> fileLikeRegionMapList = maatConfig.getFileLikeRegionMapList();
if (fileLikeRegionMapList != null && fileLikeRegionMapList.size() > 0) {
count += fileLikeRegionMapList.size();
for (Map<String, String> map : fileLikeRegionMapList) {
setCommonConfig(maatXmlConfig, map, 17, maatVersion.doubleValue(), service, transaction, redisDBIndex,
null);// 17代表是文本相似性域配置
}
}
List<Map<String, String>> ipclientList = maatConfig.getIpClientRangeMapList();
if (ipclientList != null && ipclientList.size() > 0) {
count += ipclientList.size();
for (Map<String, String> map : ipclientList) {
setCommonConfig(maatXmlConfig, map, 18, maatVersion.doubleValue(), service, transaction, redisDBIndex,
null);// 18代表是区域ip域配置
}
}
if (count == 0) {
throw new ServiceRuntimeException("添加分组复用域配置时,所有的域配置都为空,请检查配置参数是否正确",
RestBusinessCode.ConfigSourceIsNull.getValue());
}
}
@Override
public boolean delGroupReuseConfig(Map<Integer, List<MaatConfig>> configMap) {
Jedis resource = JedisUtils.getResource(0);
Transaction transaction = resource.multi();
try {
Set<Integer> keySet = configMap.keySet();// 所有的redisdb
int idRelaRedisDBIndex = Configurations.getIntProperty("idRelaRedisDBIndex", 15);
for (Integer service : keySet) {
List<MaatConfig> list = configMap.get(service);
if (list != null && list.size() > 0) {
for (MaatConfig maatConfig : list) {
if (ServiceAndRDBIndexReal.serviceIsReuse(service)) {
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(service);
removeRegion(maatConfig, maatXmlConfig, service, transaction,idRelaRedisDBIndex);
} else {
throw new ServiceRuntimeException(
"service=" + service + "不是分组复用的配置,不可单独删除域配置,请检查service是否正确",
RestBusinessCode.ServiceNotAllowAddReion.getValue());
}
}
}
}
transaction.exec();
return true;
} catch (JedisConnectionException e) {
String error = "连接redis异常,保存maat类配置失败" + e.getMessage();
logger.error(error);
throw new ServiceRuntimeException(error, RestBusinessCode.CannotConnectionRedis.getValue());
} catch (Exception e) {
transaction.discard();
String error = "保存maat类配置发生了异常" + e.getMessage();
logger.error(error);
throw new ServiceRuntimeException(error, RestBusinessCode.SaveDataInError.getValue());
} finally {
// 释放连接到连接池
JedisUtils.returnResource(resource);
}
}
private void removeRegion(MaatConfig maatConfig, MaatXmlConfig maatXmlConfig, int service, Transaction transaction,
Integer idRelaRedisDBIndex) {
// String maatVersionStr = JedisUtils.get("MAAT_VERSION", redisDBIndex);
// if (maatVersionStr == null) {
// maatVersionStr = "0";
// }
// if (maatVersionStr != null) {
// Long maatVersion = Long.valueOf(maatVersionStr) + 1;
// List<Map<String, String>> ipRegionMapList = maatConfig.getIpRegionMapList();
// if (ipRegionMapList != null && ipRegionMapList.size() > 0) {
// for (Map<String, String> map : ipRegionMapList) {
// String groupId = "GROUPREGION" + getGroupId(maatXmlConfig, map, 12, service);// 12代表是ip类域配置
// removeReion(groupId, maatXmlConfig, service, redisDBIndex, idRelaRedisDBIndex, maatVersion,
// transaction);
// }
// }
// List<Map<String, String>> numRegionMapList = maatConfig.getNumRegionMapList();
// if (numRegionMapList != null && numRegionMapList.size() > 0) {
// for (Map<String, String> map : numRegionMapList) {
// String groupId = "GROUPREGION" + getGroupId(maatXmlConfig, map, 13, service);// 13代表是数值类配置
// removeReion(groupId, maatXmlConfig, service, redisDBIndex, idRelaRedisDBIndex, maatVersion,
// transaction);
//
// }
// }
// List<Map<String, String>> strRegionMapList = maatConfig.getStrRegionMapList();
// if (strRegionMapList != null && strRegionMapList.size() > 0) {
// for (Map<String, String> map : strRegionMapList) {
// String groupId = "GROUPREGION" + getGroupId(maatXmlConfig, map, 14, service);// 14代表是字符串类域配置
// removeReion(groupId, maatXmlConfig, service, redisDBIndex, idRelaRedisDBIndex, maatVersion,
// transaction);
// }
// }
// List<Map<String, String>> strStrRegionMapList = maatConfig.getStrStrRegionMapList();
// if (strStrRegionMapList != null && strStrRegionMapList.size() > 0) {
// for (Map<String, String> map : strStrRegionMapList) {
// String groupId = "GROUPREGION" + getGroupId(maatXmlConfig, map, 15, service);// 15代表是增强字符串类域配置
// removeReion(groupId, maatXmlConfig, service, redisDBIndex, idRelaRedisDBIndex, maatVersion,
// transaction);
// }
// }
// List<Map<String, String>> fileDigestRegionMapList = maatConfig.getFileDigestRegionMapList();
// if (fileDigestRegionMapList != null && fileDigestRegionMapList.size() > 0) {
// for (Map<String, String> map : fileDigestRegionMapList) {
// String groupId = "GROUPREGION" + getGroupId(maatXmlConfig, map, 16, service);// 16代表是文件摘要类域配置
// removeReion(groupId, maatXmlConfig, service, redisDBIndex, idRelaRedisDBIndex, maatVersion,
// transaction);
// }
// }
// List<Map<String, String>> fileLikeRegionMapList = maatConfig.getFileLikeRegionMapList();
// if (fileLikeRegionMapList != null && fileLikeRegionMapList.size() > 0) {
// for (Map<String, String> map : fileLikeRegionMapList) {
// String groupId = "GROUPREGION" + getGroupId(maatXmlConfig, map, 17, service);// 17代表是文本相似性域配置
// removeReion(groupId, maatXmlConfig, service, redisDBIndex, idRelaRedisDBIndex, maatVersion,
// transaction);
// }
// }
// List<Map<String, String>> ipclientList = maatConfig.getIpClientRangeMapList();
// if (ipclientList != null && ipclientList.size() > 0) {
// for (Map<String, String> map : ipclientList) {
// String groupId = "GROUPREGION" + getGroupId(maatXmlConfig, map, 18, service);// 18代表是区域ip域配置
// removeReion(groupId, maatXmlConfig, service, redisDBIndex, idRelaRedisDBIndex, maatVersion,
// transaction);
// }
// }
// }
}
private void removeReion(String groupId, MaatXmlConfig maatXmlConfig, int service, int redisDBIndex,
int idRelaRedisDBIndex, Long maatVersion, Transaction transaction) {
String groupRegionKey = groupId.replace("GROUPCOMPILE", "GROUPREGION");// groupregion里面value是region的信息,key是group的信息,所以可以直接将GROUPCOMPILE替换为GROUPREGION
String regionStr = getRealInfo(JedisUtils.get(groupRegionKey, idRelaRedisDBIndex));
if (regionStr != null && !regionStr.trim().equals("")) {
String[] regionKeyArr = regionStr.split(";");
if (regionKeyArr != null && regionKeyArr.length > 0) {
// 根据分组与域关联关系找到对应域配置然后删除(重命名)
removeRegionConfig(maatXmlConfig, regionKeyArr, maatVersion.doubleValue(), service, transaction,
redisDBIndex);
}
} else {
throw new ServiceRuntimeException(
"" + idRelaRedisDBIndex + "号redis库中无法获取MAAT配置分组与域的关联关系key为" + groupRegionKey,
RestBusinessCode.KeyNotExistsInRedis.getValue());
}
}
/**
* 根据域配置map获取groupId
* @param maatXmlConfig
* @param map
* @param type
* @param maatVersion
* @param service
* @param transaction
* @param redisDBIndex
* @param compileId
* @return
*/
private String getGroupId(MaatXmlConfig maatXmlConfig, Map<String, String> map, int type, int service) {
if (maatXmlConfig != null && map != null && map.size() > 0) {
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
for (MaatXmlExpr maatXmlExpr : expressionList) {
if (type == maatXmlExpr.getType().intValue()) {
String[] valSplit = maatXmlExpr.getValueExpression().split(";");
for (String valStr : valSplit) {
if (valStr.equals("group_id")) {
return map.get(valStr);
}
}
}
}
throw new ServiceRuntimeException("删除分组复用域配置时,service=" + service + ",未发现对应的分组id,请检查配置参数是否正确",
RestBusinessCode.ConfigSourceIsNull.getValue());
} else {
if (maatXmlConfig == null) {
throw new ServiceRuntimeException(
"无法从applicationConfig-maatRedis.xml配置文件中,获取service为" + service + "对应的规则,请检查业务类型是否正确",
RestBusinessCode.NotFoundRedisRule.getValue());
} else {
throw new ServiceRuntimeException("向redis库中添加配置时,未发现对应的配置信息,请检查配置参数是否正确",
RestBusinessCode.ConfigSourceIsNull.getValue());
}
}
}
} }

View File

@@ -28,11 +28,13 @@ public interface ConfigRedisService {
* @return 成功返回true,失败返回false或抛出异常 * @return 成功返回true,失败返回false或抛出异常
*/ */
public boolean saveMaatConfig(Map<Integer, List<MaatConfig>> configMap); public boolean saveMaatConfig(Map<Integer, List<MaatConfig>> configMap);
/** /**
* 下发配置成功后,需要更新编译,组,域等配置id的对应关系 * 分组复用域配置新增接口,key是redisDBIndex,value是配置集合
* @param configMap * @param configMap
* @return 成功返回true,失败返回false或抛出异常
*/ */
//public void addMaatRelation(Map<Integer, List<MaatConfig>> configMap); public boolean saveGroupReuseConfig(Map<Integer, List<MaatConfig>> configMap);
/** /**
* 获取指定key的自增长值 * 获取指定key的自增长值
@@ -47,7 +49,7 @@ public interface ConfigRedisService {
* @param isInvalid 是否将配置置为无效 * @param isInvalid 是否将配置置为无效
* @return 成功返回true,失败返回false或抛出异常 * @return 成功返回true,失败返回false或抛出异常
*/ */
public boolean delUnMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap,boolean isInvalid); public boolean delUnMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap, boolean isInvalid);
/** /**
* 删除maat类配置,第一个key是redisDBIndex,第二个key是业务类型,value是配置id集合 * 删除maat类配置,第一个key是redisDBIndex,第二个key是业务类型,value是配置id集合
@@ -57,9 +59,10 @@ public interface ConfigRedisService {
public boolean delMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap); public boolean delMaatConfig(Map<Integer, Map<Integer, List<Long>>> idMap);
/** /**
* 删除maat类配置成功后,需要更新编译,组,域等配置id的对应关系 * 删除分组复用的域配置
* @param idMap * @param maatMap key是service
* @return
*/ */
//public void delMaatRelation(Map<Integer, Map<Integer, List<Long>>> idMap); public boolean delGroupReuseConfig(Map<Integer, List<MaatConfig>> configMap);
} }

View File

@@ -72,12 +72,10 @@ public class ConfigSourcesService extends BaseService {
* @return * @return
* @throws Exception * @throws Exception
*/ */
public static boolean isStrStrongRegion(String tableName, Integer service) public static boolean isStrStrongRegion(String tableName, Integer service) throws Exception {
throws Exception {
if (null != tableName && !tableName.equals("")) { if (null != tableName && !tableName.equals("")) {
List<String> tableList = new ArrayList<String>(); List<String> tableList = new ArrayList<String>();
Map<Integer, List<String>> sercieNameMap = ServiceAndRDBIndexReal Map<Integer, List<String>> sercieNameMap = ServiceAndRDBIndexReal.getSercieNameMap().get(service);
.getSercieNameMap().get(service);
if (sercieNameMap != null && sercieNameMap.size() > 0) { if (sercieNameMap != null && sercieNameMap.size() > 0) {
for (Integer type : sercieNameMap.keySet()) { for (Integer type : sercieNameMap.keySet()) {
// 12代表是ip类域配置,13代表是数值类配置,14代表是字符串类域配置,15代表是增强字符串类域配置, // 12代表是ip类域配置,13代表是数值类配置,14代表是字符串类域配置,15代表是增强字符串类域配置,
@@ -121,30 +119,25 @@ public class ConfigSourcesService extends BaseService {
* @param sb * @param sb
* @return * @return
*/ */
public void saveMaatConfig(AuditLogThread thread, long start, public void saveMaatConfig(AuditLogThread thread, long start, List<ConfigCompile> configCompileList,
List<ConfigCompile> configCompileList, StringBuffer sb) StringBuffer sb) throws Exception {
throws Exception {
Map<Integer, List<MaatConfig>> maatMap = new HashMap<Integer, List<MaatConfig>>(); Map<Integer, List<MaatConfig>> maatMap = new HashMap<Integer, List<MaatConfig>>();
Map<Integer, List<MaatConfig>> configMap = new HashMap<Integer, List<MaatConfig>>(); Map<Integer, List<MaatConfig>> configMap = new HashMap<Integer, List<MaatConfig>>();
for (ConfigCompile configCompile : configCompileList) { for (ConfigCompile configCompile : configCompileList) {
Integer service = Integer.valueOf(configCompile.getService() Integer service = Integer.valueOf(configCompile.getService().toString());
.toString());
MaatConfig maatConfig = new MaatConfig(); MaatConfig maatConfig = new MaatConfig();
CompileVal.compileIsOk(configCompile, false, sb); CompileVal.compileIsOk(configCompile, false, sb);
maatConfig.setService(service); maatConfig.setService(service);
// 编译 // 编译
maatConfig.setCompileMap(convertObjectToMap(configCompile, maatConfig.setCompileMap(convertObjectToMap(configCompile, ConfigCompile.class));
ConfigCompile.class));
// 分组 // 分组
List<Map<String, String>> dstMaplList = null; List<Map<String, String>> dstMaplList = null;
if (!StringUtil.isEmpty(configCompile.getGroupRelationList())) { if (!StringUtil.isEmpty(configCompile.getGroupRelationList())) {
dstMaplList = new ArrayList<Map<String, String>>(); dstMaplList = new ArrayList<Map<String, String>>();
for (ConfigGroupRelation group : configCompile for (ConfigGroupRelation group : configCompile.getGroupRelationList()) {
.getGroupRelationList()) { dstMaplList.add(convertObjectToMap(group, ConfigGroupRelation.class));
dstMaplList.add(convertObjectToMap(group,
ConfigGroupRelation.class));
} }
} }
maatConfig.setGroupMapList(dstMaplList); maatConfig.setGroupMapList(dstMaplList);
@@ -155,14 +148,12 @@ public class ConfigSourcesService extends BaseService {
dstMaplList = new ArrayList<Map<String, String>>(); dstMaplList = new ArrayList<Map<String, String>>();
for (StrRegion region : configCompile.getStrRegionList()) { for (StrRegion region : configCompile.getStrRegionList()) {
if (StringUtil.isEmpty(region.getDistrict())) { if (StringUtil.isEmpty(region.getDistrict())) {
dstMaplList.add(convertObjectToMap(region, dstMaplList.add(convertObjectToMap(region, StrRegion.class));
StrRegion.class));
} else { } else {
if (StringUtil.isEmpty(strongMapList)) { if (StringUtil.isEmpty(strongMapList)) {
strongMapList = new ArrayList<Map<String, String>>(); strongMapList = new ArrayList<Map<String, String>>();
} }
strongMapList.add(convertObjectToMap(region, strongMapList.add(convertObjectToMap(region, StrRegion.class));
StrRegion.class));
} }
} }
} }
@@ -176,8 +167,7 @@ public class ConfigSourcesService extends BaseService {
if (!StringUtil.isEmpty(configCompile.getNumRegionList())) { if (!StringUtil.isEmpty(configCompile.getNumRegionList())) {
dstMaplList = new ArrayList<Map<String, String>>(); dstMaplList = new ArrayList<Map<String, String>>();
for (NumRegion region : configCompile.getNumRegionList()) { for (NumRegion region : configCompile.getNumRegionList()) {
dstMaplList dstMaplList.add(convertObjectToMap(region, NumRegion.class));
.add(convertObjectToMap(region, NumRegion.class));
} }
} }
maatConfig.setNumRegionMapList(dstMaplList); maatConfig.setNumRegionMapList(dstMaplList);
@@ -197,8 +187,7 @@ public class ConfigSourcesService extends BaseService {
if (!StringUtil.isEmpty(configCompile.getDigestRegionList())) { if (!StringUtil.isEmpty(configCompile.getDigestRegionList())) {
dstMaplList = new ArrayList<Map<String, String>>(); dstMaplList = new ArrayList<Map<String, String>>();
for (DigestRegion region : configCompile.getDigestRegionList()) { for (DigestRegion region : configCompile.getDigestRegionList()) {
dstMaplList.add(convertObjectToMap(region, dstMaplList.add(convertObjectToMap(region, DigestRegion.class));
DigestRegion.class));
} }
} }
@@ -232,74 +221,53 @@ public class ConfigSourcesService extends BaseService {
Iterator serviceIterator = maatMap.keySet().iterator(); Iterator serviceIterator = maatMap.keySet().iterator();
while (serviceIterator.hasNext()) { while (serviceIterator.hasNext()) {
Integer service = Integer Integer service = Integer.valueOf(serviceIterator.next().toString());
.valueOf(serviceIterator.next().toString()); List<Integer> dbIndexList = ServiceAndRDBIndexReal.getRedisDBByService(service);
List<Integer> dbIndexList = ServiceAndRDBIndexReal
.getRedisDBByService(service);
if (!StringUtil.isEmpty(dbIndexList) && dbIndexList.size() > 0) { if (!StringUtil.isEmpty(dbIndexList) && dbIndexList.size() > 0) {
for (Integer dbIndex : dbIndexList) { for (Integer dbIndex : dbIndexList) {
// 分发到阀门有些业务需要添加编译属性到域配置 // 分发到阀门有些业务需要添加编译属性到域配置
List<MaatConfig> newMaatConfigList = new ArrayList<MaatConfig>(); List<MaatConfig> newMaatConfigList = new ArrayList<MaatConfig>();
newMaatConfigList.addAll(maatMap.get(service)); newMaatConfigList.addAll(maatMap.get(service));
if (dbIndex.intValue() == ServiceAndRDBIndexReal if (dbIndex.intValue() == ServiceAndRDBIndexReal.getValveDBIndex().intValue()) {
.getValveDBIndex().intValue()) { Map<Integer, Map<String, String[]>> maatToValueMap = ServiceAndRDBIndexReal.getMaatToValveMap();
Map<Integer, Map<String, String[]>> maatToValueMap = ServiceAndRDBIndexReal
.getMaatToValveMap();
if (maatToValueMap.containsKey(service)) { if (maatToValueMap.containsKey(service)) {
Map<String, String[]> regionAndFiledMap = maatToValueMap Map<String, String[]> regionAndFiledMap = maatToValueMap.get(service);
.get(service);
for (int i = 0; i < newMaatConfigList.size(); i++) { for (int i = 0; i < newMaatConfigList.size(); i++) {
MaatConfig maatConfig = newMaatConfigList MaatConfig maatConfig = newMaatConfigList.get(i);
.get(i);
MaatConfig newMaatConfig = (MaatConfig) JsonMapper MaatConfig newMaatConfig = (MaatConfig) JsonMapper
.fromJsonString(JsonMapper .fromJsonString(JsonMapper.toJsonString(maatConfig), MaatConfig.class);
.toJsonString(maatConfig), Iterator iterator = regionAndFiledMap.keySet().iterator();
MaatConfig.class);
Iterator iterator = regionAndFiledMap.keySet()
.iterator();
while (iterator.hasNext()) { while (iterator.hasNext()) {
String regionName = iterator.next() String regionName = iterator.next().toString();
.toString();
PropertyDescriptor pd; PropertyDescriptor pd;
try { try {
pd = new PropertyDescriptor(regionName pd = new PropertyDescriptor(regionName + "MapList", MaatConfig.class);
+ "MapList", MaatConfig.class);
Method method = pd.getReadMethod(); Method method = pd.getReadMethod();
Object object = method Object object = method.invoke(newMaatConfig);
.invoke(newMaatConfig);
if (object != null) { if (object != null) {
List<Map<String, String>> listMaps = new ArrayList<Map<String, String>>(); List<Map<String, String>> listMaps = new ArrayList<Map<String, String>>();
listMaps.addAll((List<Map<String, String>>) object); listMaps.addAll((List<Map<String, String>>) object);
String[] fields = regionAndFiledMap String[] fields = regionAndFiledMap.get(regionName);
.get(regionName);
for (String fieldName : fields) { for (String fieldName : fields) {
String value = newMaatConfig String value = newMaatConfig.getCompileMap()
.getCompileMap() .get(fieldName.toLowerCase());
.get(fieldName
.toLowerCase());
if (!StringUtil.isEmpty(value)) { if (!StringUtil.isEmpty(value)) {
for (Map<String, String> map : listMaps) { for (Map<String, String> map : listMaps) {
map.put(fieldName map.put(fieldName.toLowerCase(), value);
.toLowerCase(),
value);
} }
} }
} }
method = pd.getWriteMethod(); method = pd.getWriteMethod();
method.invoke(newMaatConfig, method.invoke(newMaatConfig, listMaps);
listMaps);
} }
newMaatConfigList.set(i, newMaatConfig); newMaatConfigList.set(i, newMaatConfig);
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
throw new RestServiceException( throw new RestServiceException("未找到域列表,请检查配置文件中域类型是否正确!:" + e.getMessage(),
"未找到域列表,请检查配置文件中域类型是否正确!:" RestBusinessCode.service_runtime_error.getValue());
+ e.getMessage(),
RestBusinessCode.service_runtime_error
.getValue());
} }
} }
@@ -317,8 +285,7 @@ public class ConfigSourcesService extends BaseService {
} }
} else { } else {
throw new ServiceRuntimeException( throw new ServiceRuntimeException(RestBusinessCode.ServiceNoFoundDBIndex.getErrorReason(),
RestBusinessCode.ServiceNoFoundDBIndex.getErrorReason(),
RestBusinessCode.ServiceNoFoundDBIndex.getValue()); RestBusinessCode.ServiceNoFoundDBIndex.getValue());
} }
} }
@@ -326,15 +293,13 @@ public class ConfigSourcesService extends BaseService {
configRedisService.saveMaatConfig(configMap); configRedisService.saveMaatConfig(configMap);
} }
private Map<String, String> convertObjectToMap(Object obj, Class clazz) private Map<String, String> convertObjectToMap(Object obj, Class clazz) throws Exception {
throws Exception {
Map<String, String> dstMap = new HashMap<String, String>(); Map<String, String> dstMap = new HashMap<String, String>();
Field[] fields = obj.getClass().getDeclaredFields(); Field[] fields = obj.getClass().getDeclaredFields();
for (Field field : fields) { for (Field field : fields) {
if ("serialVersionUID".equals(field.getName())) if ("serialVersionUID".equals(field.getName()))
continue; continue;
String dstName = CamelUnderlineUtil.camelToUnderline(field String dstName = CamelUnderlineUtil.camelToUnderline(field.getName());
.getName());
PropertyDescriptor pd; PropertyDescriptor pd;
pd = new PropertyDescriptor(field.getName(), clazz); pd = new PropertyDescriptor(field.getName(), clazz);
Method method = pd.getReadMethod(); Method method = pd.getReadMethod();
@@ -345,15 +310,13 @@ public class ConfigSourcesService extends BaseService {
if (dstObject instanceof ArrayList) { if (dstObject instanceof ArrayList) {
dstObject = ""; dstObject = "";
} }
dstMap.put(dstName, dstMap.put(dstName, StringUtil.isEmpty(dstObject) ? "" : dstObject.toString());
StringUtil.isEmpty(dstObject) ? "" : dstObject.toString());
} }
return dstMap; return dstMap;
} }
public void updateConfigSources(AuditLogThread thread, long start, public void updateConfigSources(AuditLogThread thread, long start, List<ConfigCompile> compileList, Date opTime,
List<ConfigCompile> compileList, Date opTime, StringBuffer sb) StringBuffer sb) throws Exception {
throws Exception {
Map<Integer, List<Long>> compileMap = new HashMap<Integer, List<Long>>(); Map<Integer, List<Long>> compileMap = new HashMap<Integer, List<Long>>();
if (null != compileList && compileList.size() > 0) { if (null != compileList && compileList.size() > 0) {
for (ConfigCompile config : compileList) { for (ConfigCompile config : compileList) {
@@ -364,8 +327,7 @@ public class ConfigSourcesService extends BaseService {
// compileAllList.add(config); // compileAllList.add(config);
if (compileMap.containsKey(config.getService())) { if (compileMap.containsKey(config.getService())) {
compileMap.get(config.getService()).add( compileMap.get(config.getService()).add(config.getCompileId());
config.getCompileId());
} else { } else {
List<Long> idList = new ArrayList<Long>(); List<Long> idList = new ArrayList<Long>();
idList.add(config.getCompileId()); idList.add(config.getCompileId());
@@ -374,22 +336,18 @@ public class ConfigSourcesService extends BaseService {
} }
} else { } else {
throw new RestServiceException("编译配置不能为空" + sb.toString(), throw new RestServiceException("编译配置不能为空" + sb.toString(), RestBusinessCode.CompileIsNull.getValue());
RestBusinessCode.CompileIsNull.getValue());
} }
// Map<DBIndex,Map<Service,List<CompileId>> // Map<DBIndex,Map<Service,List<CompileId>>
Map<Integer, Map<Integer, List<Long>>> restMap = new HashMap<Integer, Map<Integer, List<Long>>>(); Map<Integer, Map<Integer, List<Long>>> restMap = new HashMap<Integer, Map<Integer, List<Long>>>();
Iterator serviceIterator = compileMap.keySet().iterator(); Iterator serviceIterator = compileMap.keySet().iterator();
while (serviceIterator.hasNext()) { while (serviceIterator.hasNext()) {
Integer service = Integer Integer service = Integer.valueOf(serviceIterator.next().toString());
.valueOf(serviceIterator.next().toString()); List<Integer> dbIndexList = ServiceAndRDBIndexReal.getRedisDBByService(service);
List<Integer> dbIndexList = ServiceAndRDBIndexReal
.getRedisDBByService(service);
if (!StringUtil.isEmpty(dbIndexList) && dbIndexList.size() > 0) { if (!StringUtil.isEmpty(dbIndexList) && dbIndexList.size() > 0) {
for (Integer dbIndex : dbIndexList) { for (Integer dbIndex : dbIndexList) {
if (restMap.containsKey(dbIndex)) { if (restMap.containsKey(dbIndex)) {
restMap.get(dbIndex).put(service, restMap.get(dbIndex).put(service, compileMap.get(service));
compileMap.get(service));
} else { } else {
Map<Integer, List<Long>> map = new HashMap<Integer, List<Long>>(); Map<Integer, List<Long>> map = new HashMap<Integer, List<Long>>();
map.put(service, compileMap.get(service)); map.put(service, compileMap.get(service));
@@ -397,8 +355,7 @@ public class ConfigSourcesService extends BaseService {
} }
} }
} else { } else {
ServiceRuntimeException e = new ServiceRuntimeException( ServiceRuntimeException e = new ServiceRuntimeException("service值为" + service + ",与写入数据库序号映射关系不存在",
"service值为" + service + ",与写入数据库序号映射关系不存在",
RestBusinessCode.ServiceNoFoundDBIndex.getValue()); RestBusinessCode.ServiceNoFoundDBIndex.getValue());
} }
} }
@@ -422,58 +379,47 @@ public class ConfigSourcesService extends BaseService {
* @param config * @param config
* @return * @return
*/ */
private void checkCompileOptForUpdate(ConfigCompile config) private void checkCompileOptForUpdate(ConfigCompile config) throws Exception {
throws Exception {
if (StringUtil.isEmpty(config.getCompileId())) { if (StringUtil.isEmpty(config.getCompileId())) {
throw new RestServiceException( throw new RestServiceException(RestBusinessCode.CompileIdIsNull.getErrorReason(),
RestBusinessCode.CompileIdIsNull.getErrorReason(),
RestBusinessCode.CompileIdIsNull.getValue()); RestBusinessCode.CompileIdIsNull.getValue());
} }
if (StringUtil.isEmpty(config.getService())) { if (StringUtil.isEmpty(config.getService())) {
throw new RestServiceException( throw new RestServiceException(RestBusinessCode.ServiceIsNull.getErrorReason(),
RestBusinessCode.ServiceIsNull.getErrorReason(),
RestBusinessCode.ServiceIsNull.getValue()); RestBusinessCode.ServiceIsNull.getValue());
} }
if (StringUtil.isEmpty(config.getIsValid())) { if (StringUtil.isEmpty(config.getIsValid())) {
throw new RestServiceException("编译配置id为" + config.getCompileId() throw new RestServiceException("编译配置id为" + config.getCompileId() + "的IsValid字段不能为空",
+ "的IsValid字段不能为空",
RestBusinessCode.IsValidIsNull.getValue()); RestBusinessCode.IsValidIsNull.getValue());
} }
if (config.getIsValid() != 0) { if (config.getIsValid() != 0) {
throw new RestServiceException("编译配置id为" + config.getCompileId() throw new RestServiceException("编译配置id为" + config.getCompileId() + "的配置在修改时不能为有效",
+ "的配置在修改时不能为有效", RestBusinessCode.IsValidIsF.getValue()); RestBusinessCode.IsValidIsF.getValue());
} }
} }
public void saveCommonSources(AuditLogThread thread, long start, public void saveCommonSources(AuditLogThread thread, long start, String jsonString) throws Exception {
String jsonString) throws Exception {
JsonArray jsonObjectList = null; JsonArray jsonObjectList = null;
try { try {
jsonObjectList = new JsonParser().parse(jsonString) jsonObjectList = new JsonParser().parse(jsonString).getAsJsonArray();
.getAsJsonArray();
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
throw new RestServiceException( throw new RestServiceException(RestBusinessCode.CBParamFormateError.getErrorReason() + "," + e.getMessage(),
RestBusinessCode.CBParamFormateError.getErrorReason() + ","
+ e.getMessage(),
RestBusinessCode.CBParamFormateError.getValue()); RestBusinessCode.CBParamFormateError.getValue());
} }
Map<Integer, List<Map<String, String>>> dstMaps = new HashMap<Integer, List<Map<String, String>>>(); Map<Integer, List<Map<String, String>>> dstMaps = new HashMap<Integer, List<Map<String, String>>>();
for (int i = 0; i < jsonObjectList.size(); i++) { for (int i = 0; i < jsonObjectList.size(); i++) {
JsonObject jsonObj = (JsonObject) jsonObjectList.get(i); JsonObject jsonObj = (JsonObject) jsonObjectList.get(i);
Map<String, Object> srcMap = JSONObject.fromObject(JSONObject Map<String, Object> srcMap = JSONObject.fromObject(JSONObject.fromObject((jsonObj.toString())));
.fromObject((jsonObj.toString())));
if (srcMap.containsKey("service")) { if (srcMap.containsKey("service")) {
Map<String, String> dstMap = new HashMap<String, String>(); Map<String, String> dstMap = new HashMap<String, String>();
List<CommonSourceFieldCfg> commonSourceFieldCfgList = ReadCommSourceXmlUtil List<CommonSourceFieldCfg> commonSourceFieldCfgList = ReadCommSourceXmlUtil
.getCommonSourceCfgByService(srcMap.get("service") .getCommonSourceCfgByService(srcMap.get("service").toString().trim());
.toString().trim());
if (StringUtil.isEmpty(commonSourceFieldCfgList)) { if (StringUtil.isEmpty(commonSourceFieldCfgList)) {
throw new RestServiceException( throw new RestServiceException(
RestBusinessCode.ServiceIsWrong.getErrorReason() RestBusinessCode.ServiceIsWrong.getErrorReason() + ",请检查service配置是否正确",
+ ",请检查service配置是否正确",
RestBusinessCode.ServiceIsWrong.getValue()); RestBusinessCode.ServiceIsWrong.getValue());
} }
// 获取IP类型 // 获取IP类型
@@ -482,41 +428,28 @@ public class ConfigSourcesService extends BaseService {
for (CommonSourceFieldCfg commonSourceFieldCfg : commonSourceFieldCfgList) { for (CommonSourceFieldCfg commonSourceFieldCfg : commonSourceFieldCfgList) {
if (commonSourceFieldCfg.getDstName().equals("addr_type")) { if (commonSourceFieldCfg.getDstName().equals("addr_type")) {
String dstVal = srcMap.get( String dstVal = srcMap.get(commonSourceFieldCfg.getSrcName()).toString();
commonSourceFieldCfg.getSrcName()).toString();
ipTypeName = commonSourceFieldCfg.getSrcName(); ipTypeName = commonSourceFieldCfg.getSrcName();
// regexp 特殊格式正则验证 // regexp 特殊格式正则验证
Boolean valFlag = true; Boolean valFlag = true;
if (!StringUtil.isEmpty(commonSourceFieldCfg if (!StringUtil.isEmpty(commonSourceFieldCfg.getRegexp())) {
.getRegexp())) { Pattern pattern = Pattern.compile(commonSourceFieldCfg.getRegexp());
Pattern pattern = Pattern
.compile(commonSourceFieldCfg.getRegexp());
Matcher matcher = pattern.matcher(dstVal); Matcher matcher = pattern.matcher(dstVal);
valFlag = valFlag & matcher.matches(); valFlag = valFlag & matcher.matches();
} }
if (!valFlag) { if (!valFlag) {
throw new RestServiceException( throw new RestServiceException(RestBusinessCode.IpTypeIsWrong.getErrorReason(),
RestBusinessCode.IpTypeIsWrong
.getErrorReason(),
RestBusinessCode.IpTypeIsWrong.getValue()); RestBusinessCode.IpTypeIsWrong.getValue());
} }
ipType = Integer.parseInt(dstVal); ipType = Integer.parseInt(dstVal);
} }
// 验证service与action是否匹配 // 验证service与action是否匹配
if (commonSourceFieldCfg.getDstName().equals("action")) { if (commonSourceFieldCfg.getDstName().equals("action")) {
String dstVal = srcMap String dstVal = srcMap.get(commonSourceFieldCfg.getSrcName()).toString().trim();
.get(commonSourceFieldCfg.getSrcName()) if (Integer.valueOf(dstVal).compareTo(ServiceAndRDBIndexReal
.toString().trim(); .getActionByService(Integer.valueOf(srcMap.get("service").toString().trim()))) != 0) {
if (Integer.valueOf(dstVal).compareTo( throw new RestServiceException(RestBusinessCode.ServiceUnmatchAction.getErrorReason(),
ServiceAndRDBIndexReal RestBusinessCode.ServiceUnmatchAction.getValue());
.getActionByService(Integer
.valueOf(srcMap.get("service")
.toString().trim()))) != 0) {
throw new RestServiceException(
RestBusinessCode.ServiceUnmatchAction
.getErrorReason(),
RestBusinessCode.ServiceUnmatchAction
.getValue());
} }
} }
} }
@@ -526,47 +459,33 @@ public class ConfigSourcesService extends BaseService {
for (CommonSourceFieldCfg commonSourceFieldCfg : commonSourceFieldCfgList) { for (CommonSourceFieldCfg commonSourceFieldCfg : commonSourceFieldCfgList) {
// 是否必填 // 是否必填
if (commonSourceFieldCfg.getIsRequired() if (commonSourceFieldCfg.getIsRequired()
&& !srcMap.containsKey(commonSourceFieldCfg && !srcMap.containsKey(commonSourceFieldCfg.getSrcName())) {
.getSrcName())) { throw new RestServiceException(commonSourceFieldCfg.getSrcName() + "参数不能为空",
throw new RestServiceException(
commonSourceFieldCfg.getSrcName() + "参数不能为空",
RestBusinessCode.FieldIsNull.getValue()); RestBusinessCode.FieldIsNull.getValue());
} }
// 字段类型 String Number Date Ip Port // 字段类型 String Number Date Ip Port
String dstStr = StringUtil.isEmpty(srcMap String dstStr = StringUtil.isEmpty(srcMap.get(commonSourceFieldCfg.getSrcName()))
.get(commonSourceFieldCfg.getSrcName())) ? commonSourceFieldCfg ? commonSourceFieldCfg.getDefaultVal()
.getDefaultVal() : srcMap.get( : srcMap.get(commonSourceFieldCfg.getSrcName()).toString();
commonSourceFieldCfg.getSrcName()).toString(); if (!StringUtil.isEmpty(dstStr) && dstStr.startsWith("[") && dstStr.endsWith("]")) {
if (!StringUtil.isEmpty(dstStr) && dstStr.startsWith("[") dstStr = srcMap.get(dstStr.substring(1, dstStr.length() - 1)).toString();
&& dstStr.endsWith("]")) {
dstStr = srcMap.get(
dstStr.substring(1, dstStr.length() - 1))
.toString();
} }
if ("dstFile".equals(commonSourceFieldCfg.getSrcName())) { if ("dstFile".equals(commonSourceFieldCfg.getSrcName())) {
if ("dst_file" if ("dst_file".equals(commonSourceFieldCfg.getDstName())) {
.equals(commonSourceFieldCfg.getDstName())) {
String maatTableName = ServiceAndRDBIndexReal String maatTableName = ServiceAndRDBIndexReal
.getUnMaatTableName(Integer.valueOf(srcMap .getUnMaatTableName(Integer.valueOf(srcMap.get("service").toString().trim()));
.get("service").toString().trim())); String dstPath = Constants.MM_SAMPLE_DST_PATH.replace("{tableType}",
String dstPath = Constants.MM_SAMPLE_DST_PATH maatTableName.substring(maatTableName.lastIndexOf("_") + 1));
.replace("{tableType}", maatTableName dstStr = dstPath.replace("{fileName}", dstStr.substring(dstStr.lastIndexOf("/") + 1));
.substring(maatTableName } else if ("file_id".equals(commonSourceFieldCfg.getDstName())) {
.lastIndexOf("_") + 1));
dstStr = dstPath.replace("{fileName}", dstStr
.substring(dstStr.lastIndexOf("/") + 1));
} else if ("file_id".equals(commonSourceFieldCfg
.getDstName())) {
dstStr = dstStr.substring(dstStr.indexOf("group")); dstStr = dstStr.substring(dstStr.indexOf("group"));
} }
} }
switch (commonSourceFieldCfg.getFieldType()) { switch (commonSourceFieldCfg.getFieldType()) {
case "Number": case "Number":
if (!StringUtil.isNumeric(dstStr)) { if (!StringUtil.isNumeric(dstStr)) {
throw new RestServiceException( throw new RestServiceException(commonSourceFieldCfg.getSrcName() + "参数不能格式不正确,必需是数值型",
commonSourceFieldCfg.getSrcName()
+ "参数不能格式不正确,必需是数值型",
RestBusinessCode.MastNumberic.getValue()); RestBusinessCode.MastNumberic.getValue());
} }
break; break;
@@ -580,9 +499,7 @@ public class ConfigSourcesService extends BaseService {
dstStr = date.getTime() + "000"; dstStr = date.getTime() + "000";
} catch (ParseException e) { } catch (ParseException e) {
// TODO Auto-generated catch block // TODO Auto-generated catch block
throw new RestServiceException( throw new RestServiceException(commonSourceFieldCfg.getSrcName() + "参数格式不正确或不是规范的日期串",
commonSourceFieldCfg.getSrcName()
+ "参数格式不正确或不是规范的日期串",
RestBusinessCode.MastDate.getValue()); RestBusinessCode.MastDate.getValue());
} }
break; break;
@@ -598,16 +515,13 @@ public class ConfigSourcesService extends BaseService {
} }
if (!BasicProvingUtil.isIpOrIpMask(dstStr, valAddrType)) { if (!BasicProvingUtil.isIpOrIpMask(dstStr, valAddrType)) {
throw new RestServiceException( throw new RestServiceException(
commonSourceFieldCfg.getSrcName() commonSourceFieldCfg.getSrcName() + "参数格式不正确或与" + ipTypeName + "不一致",
+ "参数格式不正确或与" + ipTypeName + "不一致",
RestBusinessCode.IpIsUnMatchType.getValue()); RestBusinessCode.IpIsUnMatchType.getValue());
} }
break; break;
case "Port": case "Port":
if (!BasicProvingUtil.isPortOrPortMask(dstStr)) { if (!BasicProvingUtil.isPortOrPortMask(dstStr)) {
throw new RestServiceException( throw new RestServiceException(commonSourceFieldCfg.getSrcName() + "参数不能格式不正确不是合法的Port",
commonSourceFieldCfg.getSrcName()
+ "参数不能格式不正确不是合法的Port",
RestBusinessCode.PortIsNotVal.getValue()); RestBusinessCode.PortIsNotVal.getValue());
} }
break; break;
@@ -615,73 +529,55 @@ public class ConfigSourcesService extends BaseService {
} }
// range取值范围验证 // range取值范围验证
if (!StringUtil.isEmpty(commonSourceFieldCfg.getRange())) { if (!StringUtil.isEmpty(commonSourceFieldCfg.getRange())) {
String[] range = commonSourceFieldCfg.getRange().split( String[] range = commonSourceFieldCfg.getRange().split("-");
"-");
Boolean flag = false; Boolean flag = false;
if (range.length == 2) { if (range.length == 2) {
if (!(Long.valueOf(range[0]).compareTo( if (!(Long.valueOf(range[0]).compareTo(Long.valueOf(dstStr)) <= 0
Long.valueOf(dstStr)) <= 0 && Long.valueOf( && Long.valueOf(range[1]).compareTo(Long.valueOf(dstStr)) >= 0)) {
range[1]).compareTo(Long.valueOf(dstStr)) >= 0)) {
flag = true; flag = true;
} }
} else if (commonSourceFieldCfg.getRange().startsWith( } else if (commonSourceFieldCfg.getRange().startsWith("-")) {// 只有最大值限制
"-")) {// 只有最大值限制 if (Long.valueOf(range[0]).compareTo(Long.valueOf(dstStr)) <= 0) {
if (Long.valueOf(range[0]).compareTo(
Long.valueOf(dstStr)) <= 0) {
flag = true; flag = true;
} }
} else if (commonSourceFieldCfg.getRange() } else if (commonSourceFieldCfg.getRange().endsWith("-")) {// 只有最小值限制
.endsWith("-")) {// 只有最小值限制 if (Long.valueOf(range[0]).compareTo(Long.valueOf(dstStr)) >= 0) {
if (Long.valueOf(range[0]).compareTo(
Long.valueOf(dstStr)) >= 0) {
flag = true; flag = true;
} }
} }
if (flag) { if (flag) {
throw new RestServiceException( throw new RestServiceException(commonSourceFieldCfg.getSrcName() + "参数不在有效范围("
commonSourceFieldCfg.getSrcName() + commonSourceFieldCfg.getRange() + ")",
+ "参数不在有效范围(" RestBusinessCode.ValueInWrongRange.getValue());
+ commonSourceFieldCfg.getRange()
+ ")",
RestBusinessCode.ValueInWrongRange
.getValue());
} }
} }
// regexp 特殊格式正则验证 // regexp 特殊格式正则验证
Boolean valFlag = true; Boolean valFlag = true;
if (!StringUtil.isEmpty(commonSourceFieldCfg.getRegexp())) { if (!StringUtil.isEmpty(commonSourceFieldCfg.getRegexp())) {
Pattern pattern = Pattern.compile(commonSourceFieldCfg Pattern pattern = Pattern.compile(commonSourceFieldCfg.getRegexp());
.getRegexp());
Matcher matcher = pattern.matcher(dstStr); Matcher matcher = pattern.matcher(dstStr);
valFlag = valFlag & matcher.matches(); valFlag = valFlag & matcher.matches();
} }
if (valFlag) { if (valFlag) {
dstMap.put(commonSourceFieldCfg.getDstName(), dstStr); dstMap.put(commonSourceFieldCfg.getDstName(), dstStr);
} else { } else {
throw new RestServiceException( throw new RestServiceException(commonSourceFieldCfg.getSrcName() + "参数格式与正则("
commonSourceFieldCfg.getSrcName() + "参数格式与正则(" + commonSourceFieldCfg.getRegexp() + ")不匹配",
+ commonSourceFieldCfg.getRegexp()
+ ")不匹配",
RestBusinessCode.ValueInWrongRegexp.getValue()); RestBusinessCode.ValueInWrongRegexp.getValue());
} }
} }
if (StringUtil.isEmpty(dstMaps.get(Integer.valueOf(srcMap.get( if (StringUtil.isEmpty(dstMaps.get(Integer.valueOf(srcMap.get("service").toString())))) {
"service").toString())))) {
List<Map<String, String>> list = new ArrayList<Map<String, String>>(); List<Map<String, String>> list = new ArrayList<Map<String, String>>();
list.add(dstMap); list.add(dstMap);
dstMaps.put( dstMaps.put(Integer.valueOf(srcMap.get("service").toString()), list);
Integer.valueOf(srcMap.get("service").toString()),
list);
} else { } else {
List<Map<String, String>> list = dstMaps.get(Integer List<Map<String, String>> list = dstMaps.get(Integer.valueOf(srcMap.get("service").toString()));
.valueOf(srcMap.get("service").toString()));
list.add(dstMap); list.add(dstMap);
} }
} else { } else {
throw new RestServiceException("service参数不能为空", throw new RestServiceException("service参数不能为空", RestBusinessCode.ServiceIsNull.getValue());
RestBusinessCode.ServiceIsNull.getValue());
} }
} }
logger.info("------------------调用非maat配置新增接口-------------------"); logger.info("------------------调用非maat配置新增接口-------------------");
@@ -689,10 +585,8 @@ public class ConfigSourcesService extends BaseService {
Map<Integer, List<Map<String, String>>> configMap = new HashMap<Integer, List<Map<String, String>>>(); Map<Integer, List<Map<String, String>>> configMap = new HashMap<Integer, List<Map<String, String>>>();
Iterator serviceIterator = dstMaps.keySet().iterator(); Iterator serviceIterator = dstMaps.keySet().iterator();
while (serviceIterator.hasNext()) { while (serviceIterator.hasNext()) {
Integer service = Integer Integer service = Integer.valueOf(serviceIterator.next().toString());
.valueOf(serviceIterator.next().toString()); List<Integer> dbIndexList = ServiceAndRDBIndexReal.getRedisDBByService(service);
List<Integer> dbIndexList = ServiceAndRDBIndexReal
.getRedisDBByService(service);
if (!StringUtil.isEmpty(dbIndexList) && dbIndexList.size() > 0) { if (!StringUtil.isEmpty(dbIndexList) && dbIndexList.size() > 0) {
for (Integer dbIndex : dbIndexList) { for (Integer dbIndex : dbIndexList) {
if (configMap.containsKey(dbIndex)) { if (configMap.containsKey(dbIndex)) {
@@ -724,17 +618,14 @@ public class ConfigSourcesService extends BaseService {
* @param sb * @param sb
* @throws Exception * @throws Exception
*/ */
public void updateCommonSources(AuditLogThread thread, long start, public void updateCommonSources(AuditLogThread thread, long start, String jsonString, Date opTime, StringBuffer sb)
String jsonString, Date opTime, StringBuffer sb) throws Exception { throws Exception {
JsonArray jsonObjectList = null; JsonArray jsonObjectList = null;
try { try {
jsonObjectList = new JsonParser().parse(jsonString) jsonObjectList = new JsonParser().parse(jsonString).getAsJsonArray();
.getAsJsonArray();
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
throw new RestServiceException( throw new RestServiceException(RestBusinessCode.CBParamFormateError.getErrorReason() + "," + e.getMessage(),
RestBusinessCode.CBParamFormateError.getErrorReason() + ","
+ e.getMessage(),
RestBusinessCode.CBParamFormateError.getValue()); RestBusinessCode.CBParamFormateError.getValue());
} }
// <service,cfgIdList> // <service,cfgIdList>
@@ -743,15 +634,12 @@ public class ConfigSourcesService extends BaseService {
Map<String, String> validIdMap = new HashMap<String, String>(); Map<String, String> validIdMap = new HashMap<String, String>();
for (int i = 0; i < jsonObjectList.size(); i++) { for (int i = 0; i < jsonObjectList.size(); i++) {
JsonObject jsonObj = (JsonObject) jsonObjectList.get(i); JsonObject jsonObj = (JsonObject) jsonObjectList.get(i);
Map<String, Object> srcMap = JSONObject.fromObject(JSONObject Map<String, Object> srcMap = JSONObject.fromObject(JSONObject.fromObject((jsonObj.toString())));
.fromObject((jsonObj.toString())));
checkOptForUpdate(srcMap); checkOptForUpdate(srcMap);
validIdMap.put(srcMap.get("isValid").toString(), validIdMap.put(srcMap.get("isValid").toString(), srcMap.get("isValid").toString());
srcMap.get("isValid").toString());
Integer service = Integer.valueOf(srcMap.get("service").toString()); Integer service = Integer.valueOf(srcMap.get("service").toString());
List<CommonSourceFieldCfg> list = ReadCommSourceXmlUtil List<CommonSourceFieldCfg> list = ReadCommSourceXmlUtil.getCommonSourceCfgByService(service + "");
.getCommonSourceCfgByService(service + "");
String srcName = "cfgId"; String srcName = "cfgId";
for (CommonSourceFieldCfg commonSourceFieldCfg : list) { for (CommonSourceFieldCfg commonSourceFieldCfg : list) {
if (commonSourceFieldCfg.getIsCfgId()) { if (commonSourceFieldCfg.getIsCfgId()) {
@@ -769,17 +657,14 @@ public class ConfigSourcesService extends BaseService {
} }
if (validIdMap.size() > 1) { if (validIdMap.size() > 1) {
throw new RestServiceException( throw new RestServiceException(RestBusinessCode.IsValidNonUniq.getErrorReason(),
RestBusinessCode.IsValidNonUniq.getErrorReason(),
RestBusinessCode.IsValidNonUniq.getValue()); RestBusinessCode.IsValidNonUniq.getValue());
} }
Map<Integer, Map<Integer, List<Long>>> restMap = new HashMap<Integer, Map<Integer, List<Long>>>(); Map<Integer, Map<Integer, List<Long>>> restMap = new HashMap<Integer, Map<Integer, List<Long>>>();
Iterator serviceIterator = cfgMap.keySet().iterator(); Iterator serviceIterator = cfgMap.keySet().iterator();
while (serviceIterator.hasNext()) { while (serviceIterator.hasNext()) {
Integer service = Integer Integer service = Integer.valueOf(serviceIterator.next().toString());
.valueOf(serviceIterator.next().toString()); List<Integer> dbIndexList = ServiceAndRDBIndexReal.getRedisDBByService(service);
List<Integer> dbIndexList = ServiceAndRDBIndexReal
.getRedisDBByService(service);
if (!StringUtil.isEmpty(dbIndexList) && dbIndexList.size() > 0) { if (!StringUtil.isEmpty(dbIndexList) && dbIndexList.size() > 0) {
for (Integer dbIndex : dbIndexList) { for (Integer dbIndex : dbIndexList) {
if (restMap.containsKey(dbIndex)) { if (restMap.containsKey(dbIndex)) {
@@ -797,8 +682,7 @@ public class ConfigSourcesService extends BaseService {
} }
try { try {
// 停用时isInvalid=true,启用时isInvalid = false // 停用时isInvalid=true,启用时isInvalid = false
configRedisService.delUnMaatConfig(restMap, configRedisService.delUnMaatConfig(restMap, validIdMap.containsKey("0") ? true : false);
validIdMap.containsKey("0") ? true : false);
} catch (Exception e) { } catch (Exception e) {
// TODO: handle exception // TODO: handle exception
throw e; throw e;
@@ -820,16 +704,13 @@ public class ConfigSourcesService extends BaseService {
Object isValid = srcMap.get("isValid"); Object isValid = srcMap.get("isValid");
if (StringUtil.isEmpty(service)) { if (StringUtil.isEmpty(service)) {
throw new RestServiceException( throw new RestServiceException(RestBusinessCode.ServiceIsNull.getErrorReason(),
RestBusinessCode.ServiceIsNull.getErrorReason(),
RestBusinessCode.ServiceIsNull.getValue()); RestBusinessCode.ServiceIsNull.getValue());
} else if (!StringUtil.isNumeric(service.toString())) { } else if (!StringUtil.isNumeric(service.toString())) {
throw new RestServiceException("service字段格式不正确," throw new RestServiceException("service字段格式不正确," + RestBusinessCode.MastNumberic.getErrorReason(),
+ RestBusinessCode.MastNumberic.getErrorReason(),
RestBusinessCode.MastNumberic.getValue()); RestBusinessCode.MastNumberic.getValue());
} }
List<CommonSourceFieldCfg> list = ReadCommSourceXmlUtil List<CommonSourceFieldCfg> list = ReadCommSourceXmlUtil.getCommonSourceCfgByService(service + "");
.getCommonSourceCfgByService(service + "");
String srcName = "cfgId"; String srcName = "cfgId";
for (CommonSourceFieldCfg commonSourceFieldCfg : list) { for (CommonSourceFieldCfg commonSourceFieldCfg : list) {
if (commonSourceFieldCfg.getIsCfgId()) { if (commonSourceFieldCfg.getIsCfgId()) {
@@ -838,22 +719,18 @@ public class ConfigSourcesService extends BaseService {
} }
Object cfgId = srcMap.get(srcName); Object cfgId = srcMap.get(srcName);
if (StringUtil.isEmpty(cfgId)) { if (StringUtil.isEmpty(cfgId)) {
throw new RestServiceException( throw new RestServiceException(RestBusinessCode.CfgIdIsNull.getErrorReason(),
RestBusinessCode.CfgIdIsNull.getErrorReason(),
RestBusinessCode.CfgIdIsNull.getValue()); RestBusinessCode.CfgIdIsNull.getValue());
} else if (!StringUtil.isNumeric(cfgId.toString())) { } else if (!StringUtil.isNumeric(cfgId.toString())) {
throw new RestServiceException("cfgId字段格式不正确," throw new RestServiceException("cfgId字段格式不正确," + RestBusinessCode.MastNumberic.getErrorReason(),
+ RestBusinessCode.MastNumberic.getErrorReason(),
RestBusinessCode.MastNumberic.getValue()); RestBusinessCode.MastNumberic.getValue());
} }
if (StringUtil.isEmpty(isValid)) { if (StringUtil.isEmpty(isValid)) {
throw new RestServiceException("配置id为" + srcMap.get("cfgId") throw new RestServiceException("配置id为" + srcMap.get("cfgId") + "的isValid字段不能为空",
+ "的isValid字段不能为空",
RestBusinessCode.IsValidIsNull.getValue()); RestBusinessCode.IsValidIsNull.getValue());
} else { } else {
if (!StringUtil.isNumeric(service.toString())) { if (!StringUtil.isNumeric(service.toString())) {
throw new RestServiceException( throw new RestServiceException(RestBusinessCode.IsValidInWrongRange.getErrorReason(),
RestBusinessCode.IsValidInWrongRange.getErrorReason(),
RestBusinessCode.IsValidInWrongRange.getValue()); RestBusinessCode.IsValidInWrongRange.getValue());
} }
// 配置取消改为状态更新(停/启用) // 配置取消改为状态更新(停/启用)
@@ -874,8 +751,7 @@ public class ConfigSourcesService extends BaseService {
* @return * @return
* @throws Exception * @throws Exception
*/ */
public String getDigestGen(String realPath, String filePath) public String getDigestGen(String realPath, String filePath) throws Exception {
throws Exception {
logger.info("----------------开始获取摘要getDigestGen"); logger.info("----------------开始获取摘要getDigestGen");
String content = ""; String content = "";
String digestGenToolPath = Constants.DIGEST_GEN_TOOL_PATH; String digestGenToolPath = Constants.DIGEST_GEN_TOOL_PATH;
@@ -897,8 +773,7 @@ public class ConfigSourcesService extends BaseService {
} }
// System.out.println("-------------------->>"+content); // System.out.println("-------------------->>"+content);
String[] digestGenReslt = content.split(" "); String[] digestGenReslt = content.split(" ");
if (digestGenReslt.length >= 4 if (digestGenReslt.length >= 4 && !StringUtil.isEmpty(digestGenReslt[3])) {
&& !StringUtil.isEmpty(digestGenReslt[3])) {
return digestGenReslt[3]; return digestGenReslt[3];
} }
return null; return null;
@@ -915,13 +790,13 @@ public class ConfigSourcesService extends BaseService {
* @param sb * @param sb
* @return * @return
*/ */
public void addGroupReuseSources(AuditLogThread thread, long start, public void addGroupReuseSources(AuditLogThread thread, long start, List<GroupReuse> groupReuseList,
List<GroupReuse> groupReuseList, StringBuffer sb) throws Exception { StringBuffer sb) throws Exception {
// Map<service,List<maat配置>> 存放解析后输入数据 // Map<service,List<maat配置>> 存放解析后输入数据
Map<Integer, List<MaatConfig>> maatMap = new HashMap<Integer, List<MaatConfig>>(); Map<Integer, List<MaatConfig>> maatMap = new HashMap<Integer, List<MaatConfig>>();
// Map<service,List<maat配置>> 存放多分发的数据 // Map<service,List<maat配置>> 存放多分发的数据
Map<Integer, List<MaatConfig>> configMap = new HashMap<Integer, List<MaatConfig>>(); Map<Integer, List<MaatConfig>> configMap = new HashMap<Integer, List<MaatConfig>>();
//验证 // 验证
GroupReuseVal.valGroupReuse(groupReuseList, false); GroupReuseVal.valGroupReuse(groupReuseList, false);
for (GroupReuse groupReuse : groupReuseList) { for (GroupReuse groupReuse : groupReuseList) {
@@ -935,14 +810,12 @@ public class ConfigSourcesService extends BaseService {
dstMaplList = new ArrayList<Map<String, String>>(); dstMaplList = new ArrayList<Map<String, String>>();
for (StrRegion region : groupReuse.getStrRegionList()) { for (StrRegion region : groupReuse.getStrRegionList()) {
if (StringUtil.isEmpty(region.getDistrict())) { if (StringUtil.isEmpty(region.getDistrict())) {
dstMaplList.add(convertObjectToMap(region, dstMaplList.add(convertObjectToMap(region, StrRegion.class));
StrRegion.class));
} else { } else {
if (StringUtil.isEmpty(strongMapList)) { if (StringUtil.isEmpty(strongMapList)) {
strongMapList = new ArrayList<Map<String, String>>(); strongMapList = new ArrayList<Map<String, String>>();
} }
strongMapList.add(convertObjectToMap(region, strongMapList.add(convertObjectToMap(region, StrRegion.class));
StrRegion.class));
} }
} }
} }
@@ -956,8 +829,7 @@ public class ConfigSourcesService extends BaseService {
if (!StringUtil.isEmpty(groupReuse.getNumRegionList())) { if (!StringUtil.isEmpty(groupReuse.getNumRegionList())) {
dstMaplList = new ArrayList<Map<String, String>>(); dstMaplList = new ArrayList<Map<String, String>>();
for (NumRegion region : groupReuse.getNumRegionList()) { for (NumRegion region : groupReuse.getNumRegionList()) {
dstMaplList dstMaplList.add(convertObjectToMap(region, NumRegion.class));
.add(convertObjectToMap(region, NumRegion.class));
} }
} }
maatConfig.setNumRegionMapList(dstMaplList); maatConfig.setNumRegionMapList(dstMaplList);
@@ -972,6 +844,15 @@ public class ConfigSourcesService extends BaseService {
} }
maatConfig.setIpRegionMapList(dstMaplList); maatConfig.setIpRegionMapList(dstMaplList);
// 生效范围IP域
dstMaplList = null;
if (!StringUtil.isEmpty(groupReuse.getIpClientRangeList())) {
dstMaplList = new ArrayList<Map<String, String>>();
for (IpRegion region : groupReuse.getIpClientRangeList()) {
dstMaplList.add(convertObjectToMap(region, IpRegion.class));
}
}
maatConfig.setIpClientRangeMapList(dstMaplList);
if (maatMap.containsKey(service)) { if (maatMap.containsKey(service)) {
maatMap.get(service).add(maatConfig); maatMap.get(service).add(maatConfig);
} else { } else {
@@ -985,10 +866,8 @@ public class ConfigSourcesService extends BaseService {
// 根据service分发到各系统 // 根据service分发到各系统
Iterator serviceIterator = maatMap.keySet().iterator(); Iterator serviceIterator = maatMap.keySet().iterator();
while (serviceIterator.hasNext()) { while (serviceIterator.hasNext()) {
Integer service = Integer Integer service = Integer.valueOf(serviceIterator.next().toString());
.valueOf(serviceIterator.next().toString()); List<Integer> dbIndexList = ServiceAndRDBIndexReal.getRedisDBByService(service);
List<Integer> dbIndexList = ServiceAndRDBIndexReal
.getRedisDBByService(service);
if (!StringUtil.isEmpty(dbIndexList) && dbIndexList.size() > 0) { if (!StringUtil.isEmpty(dbIndexList) && dbIndexList.size() > 0) {
for (Integer dbIndex : dbIndexList) { for (Integer dbIndex : dbIndexList) {
List<MaatConfig> newMaatConfigList = new ArrayList<MaatConfig>(); List<MaatConfig> newMaatConfigList = new ArrayList<MaatConfig>();
@@ -1003,13 +882,12 @@ public class ConfigSourcesService extends BaseService {
} }
} else { } else {
throw new ServiceRuntimeException( throw new ServiceRuntimeException(RestBusinessCode.ServiceNoFoundDBIndex.getErrorReason(),
RestBusinessCode.ServiceNoFoundDBIndex.getErrorReason(),
RestBusinessCode.ServiceNoFoundDBIndex.getValue()); RestBusinessCode.ServiceNoFoundDBIndex.getValue());
} }
} }
logger.info("---------------调用Redis 分组复用配置新增接口---------------------"); logger.info("---------------调用Redis 分组复用配置新增接口---------------------");
// configRedisService.addGroupReuseConfig(configMap); configRedisService.saveGroupReuseConfig(configMap);
} }
/** /**
@@ -1024,15 +902,14 @@ public class ConfigSourcesService extends BaseService {
* @param sb * @param sb
* @throws Exception * @throws Exception
*/ */
public void deleteGroupReuseSources(AuditLogThread thread, long start, public void deleteGroupReuseSources(AuditLogThread thread, long start, List<GroupReuse> groupReuseList, Date opTime,
List<GroupReuse> groupReuseList, Date opTime, StringBuffer sb) StringBuffer sb) throws Exception {
throws Exception { // 按service分类
//按service分类
Map<Integer, List<MaatConfig>> maatMap = new HashMap<Integer, List<MaatConfig>>(); Map<Integer, List<MaatConfig>> maatMap = new HashMap<Integer, List<MaatConfig>>();
GroupReuseVal.valGroupReuse(groupReuseList, false); GroupReuseVal.valGroupReuse(groupReuseList, false);
for (GroupReuse groupReuse : groupReuseList) { for (GroupReuse groupReuse : groupReuseList) {
//验证格式 // 验证格式
checkGroupReuseForUpdate(groupReuse); checkGroupReuseForUpdate(groupReuse);
Integer service = groupReuse.getService(); Integer service = groupReuse.getService();
@@ -1045,14 +922,12 @@ public class ConfigSourcesService extends BaseService {
dstMaplList = new ArrayList<Map<String, String>>(); dstMaplList = new ArrayList<Map<String, String>>();
for (StrRegion region : groupReuse.getStrRegionList()) { for (StrRegion region : groupReuse.getStrRegionList()) {
if (StringUtil.isEmpty(region.getDistrict())) { if (StringUtil.isEmpty(region.getDistrict())) {
dstMaplList.add(convertObjectToMap(region, dstMaplList.add(convertObjectToMap(region, StrRegion.class));
StrRegion.class));
} else { } else {
if (StringUtil.isEmpty(strongMapList)) { if (StringUtil.isEmpty(strongMapList)) {
strongMapList = new ArrayList<Map<String, String>>(); strongMapList = new ArrayList<Map<String, String>>();
} }
strongMapList.add(convertObjectToMap(region, strongMapList.add(convertObjectToMap(region, StrRegion.class));
StrRegion.class));
} }
} }
} }
@@ -1066,8 +941,7 @@ public class ConfigSourcesService extends BaseService {
if (!StringUtil.isEmpty(groupReuse.getNumRegionList())) { if (!StringUtil.isEmpty(groupReuse.getNumRegionList())) {
dstMaplList = new ArrayList<Map<String, String>>(); dstMaplList = new ArrayList<Map<String, String>>();
for (NumRegion region : groupReuse.getNumRegionList()) { for (NumRegion region : groupReuse.getNumRegionList()) {
dstMaplList dstMaplList.add(convertObjectToMap(region, NumRegion.class));
.add(convertObjectToMap(region, NumRegion.class));
} }
} }
maatConfig.setNumRegionMapList(dstMaplList); maatConfig.setNumRegionMapList(dstMaplList);
@@ -1092,10 +966,10 @@ public class ConfigSourcesService extends BaseService {
} }
logger.info("调用接口删除Redis中分组复用的域配置接口"); logger.info("调用接口删除Redis中分组复用的域配置接口");
// 所有的都删除成功返回true // 所有的都删除成功返回true
// if (!configRedisService.delMaatConfig(maatMap)) { if (!configRedisService.delGroupReuseConfig(maatMap)) {
// throw new ServiceRuntimeException("删除分组利用域配置时出现异常,具体原因不详,请联系管理员", throw new ServiceRuntimeException("删除分组利用域配置时出现异常,具体原因不详,请联系管理员",
// RestBusinessCode.service_runtime_error.getValue()); RestBusinessCode.service_runtime_error.getValue());
// } }
} }
/** /**
@@ -1106,48 +980,36 @@ public class ConfigSourcesService extends BaseService {
* @param config * @param config
* @return * @return
*/ */
private void checkGroupReuseForUpdate(GroupReuse config) private void checkGroupReuseForUpdate(GroupReuse config) throws Exception {
throws Exception {
if (StringUtil.isEmpty(config.getService())) { if (StringUtil.isEmpty(config.getService())) {
throw new RestServiceException( throw new RestServiceException(RestBusinessCode.ServiceIsNull.getErrorReason(),
RestBusinessCode.ServiceIsNull.getErrorReason(),
RestBusinessCode.ServiceIsNull.getValue()); RestBusinessCode.ServiceIsNull.getValue());
} }
if (!ServiceAndRDBIndexReal.serviceIsReuse(config.getService())) { if (!ServiceAndRDBIndexReal.serviceIsReuse(config.getService())) {
throw new RestServiceException("server为空或" + config.getService() throw new RestServiceException("server为空或" + config.getService() + "或不属于分组复用的业务类型",
+ "或不属于分组复用的业务类型",
RestBusinessCode.ServiceIsNullOrNotReuse.getValue()); RestBusinessCode.ServiceIsNullOrNotReuse.getValue());
} }
Boolean hasRegionFlag = false; Boolean hasRegionFlag = false;
Map<String, List<String>> regTabNameMap = ServiceAndRDBIndexReal Map<String, List<String>> regTabNameMap = ServiceAndRDBIndexReal.getServiceGroupReuseMap(config.getService());
.getServiceGroupReuseMap(config.getService()); if (regTabNameMap.containsKey("numRegion") && !StringUtil.isEmpty(config.getNumRegionList())
if (regTabNameMap.containsKey("numRegion")
&& !StringUtil.isEmpty(config.getNumRegionList())
&& config.getNumRegionList().size() > 0) { && config.getNumRegionList().size() > 0) {
hasRegionFlag = true; hasRegionFlag = true;
List<NumRegion> numRegionList = config.getNumRegionList(); List<NumRegion> numRegionList = config.getNumRegionList();
for (NumRegion numRegion : numRegionList) { for (NumRegion numRegion : numRegionList) {
if (!StringUtil.isEmpty(numRegion.getTableName()) if (!StringUtil.isEmpty(numRegion.getTableName())
&& !CompileVal.type2TableNameIsOk(config.getService(), && !CompileVal.type2TableNameIsOk(config.getService(), numRegion.getTableName())) {
numRegion.getTableName())) { throw new RestServiceException("service为" + config.getService() + "的配置中numRegionList中的regionId为"
throw new RestServiceException("service为" + config.getService() + numRegion.getRegionId() + "的域配置tableName与业务类型不一致",
+ "的配置中numRegionList中的regionId为" RestBusinessCode.TableNameUnmatchService.getValue());
+ numRegion.getRegionId()
+ "的域配置tableName与业务类型不一致",
RestBusinessCode.TableNameUnmatchService
.getValue());
} }
if (numRegion.getIsValid() != 0) { if (numRegion.getIsValid() != 0) {
throw new RestServiceException("service为" + config.getService() throw new RestServiceException("service为" + config.getService() + "的配置中numRegionList中的regionId为"
+ "的配置中numRegionList中的regionId为" + numRegion.getRegionId() + "的域配置在修改时不能为有效", RestBusinessCode.IsValidIsF.getValue());
+ numRegion.getRegionId() + "的域配置在修改时不能为有效",
RestBusinessCode.IsValidIsF.getValue());
} }
} }
} else if (regTabNameMap.containsKey("strRegion") } else if (regTabNameMap.containsKey("strRegion") && !StringUtil.isEmpty(config.getStrRegionList())
&& !StringUtil.isEmpty(config.getStrRegionList())
&& config.getStrRegionList().size() > 0) { && config.getStrRegionList().size() > 0) {
hasRegionFlag = true; hasRegionFlag = true;
List<StrRegion> strRegionList = config.getStrRegionList(); List<StrRegion> strRegionList = config.getStrRegionList();
@@ -1156,54 +1018,40 @@ public class ConfigSourcesService extends BaseService {
// !regionGroupIdList.contains(strRegion.getGroupId())) // !regionGroupIdList.contains(strRegion.getGroupId()))
// { // {
if (!StringUtil.isEmpty(strRegion.getTableName()) if (!StringUtil.isEmpty(strRegion.getTableName())
&& !CompileVal.type2TableNameIsOk(config.getService(), && !CompileVal.type2TableNameIsOk(config.getService(), strRegion.getTableName())) {
strRegion.getTableName())) { throw new RestServiceException("配置id为" + config.getService() + "的配置中strRegionList中的regionId为"
throw new RestServiceException("配置id为" + config.getService() + strRegion.getRegionId() + "的域配置tableName与业务类型不一致",
+ "的配置中strRegionList中的regionId为" RestBusinessCode.TableNameUnmatchService.getValue());
+ strRegion.getRegionId()
+ "的域配置tableName与业务类型不一致",
RestBusinessCode.TableNameUnmatchService
.getValue());
} }
if (strRegion.getIsValid() != 0) { if (strRegion.getIsValid() != 0) {
throw new RestServiceException("配置id为" + config.getService() throw new RestServiceException("配置id为" + config.getService() + "的配置中strRegionList中的regionId为"
+ "的配置中strRegionList中的regionId为" + strRegion.getRegionId() + "的域配置在修改时不能为有效", RestBusinessCode.IsValidIsF.getValue());
+ strRegion.getRegionId() + "的域配置在修改时不能为有效",
RestBusinessCode.IsValidIsF.getValue());
} }
} }
} else if (regTabNameMap.containsKey("ipRegion") } else if (regTabNameMap.containsKey("ipRegion") && !StringUtil.isEmpty(config.getIpRegionList())
&& !StringUtil.isEmpty(config.getIpRegionList())
&& config.getIpRegionList().size() > 0) { && config.getIpRegionList().size() > 0) {
hasRegionFlag = true; hasRegionFlag = true;
List<IpRegion> ipRegionList = config.getIpRegionList(); List<IpRegion> ipRegionList = config.getIpRegionList();
for (IpRegion ipRegion : ipRegionList) { for (IpRegion ipRegion : ipRegionList) {
if (!StringUtil.isEmpty(ipRegion.getTableName()) if (!StringUtil.isEmpty(ipRegion.getTableName())
&& !CompileVal.type2TableNameIsOk(config.getService(), && !CompileVal.type2TableNameIsOk(config.getService(), ipRegion.getTableName())) {
ipRegion.getTableName())) { throw new RestServiceException("配置id为" + config.getService() + "的配置中ipRegionList中的regionId为"
throw new RestServiceException("配置id为" + config.getService() + ipRegion.getRegionId() + "的域配置tableName与业务类型不一致",
+ "的配置中ipRegionList中的regionId为" RestBusinessCode.TableNameUnmatchService.getValue());
+ ipRegion.getRegionId()
+ "的域配置tableName与业务类型不一致",
RestBusinessCode.TableNameUnmatchService
.getValue());
} }
if (null == ipRegion.getIsValid() || ipRegion if (null == ipRegion.getIsValid() || ipRegion.getIsValid() != 0) {
.getIsValid() != 0) { throw new RestServiceException("service为" + config.getService() + "的配置中ipRegionList中的regionId为"
throw new RestServiceException("service为" + config.getService() + ipRegion.getRegionId() + "的域配置在修改时不能为有效", RestBusinessCode.IsValidIsF.getValue());
+ "的配置中ipRegionList中的regionId为"
+ ipRegion.getRegionId() + "的域配置在修改时不能为有效",
RestBusinessCode.IsValidIsF.getValue());
} }
} }
} }
if (hasRegionFlag) { if (hasRegionFlag) {
// 所有的域类型都不包括,可能是配置文件配错了 // 所有的域类型都不包括,可能是配置文件配错了
throw new ServiceRuntimeException("service为" + config.getService() + "" throw new ServiceRuntimeException(
+ RestBusinessCode.ReuseRegionIsNull.getErrorReason(), "service为" + config.getService() + "" + RestBusinessCode.ReuseRegionIsNull.getErrorReason(),
RestBusinessCode.ReuseRegionIsNull.getValue()); RestBusinessCode.ReuseRegionIsNull.getValue());
} }
} }