在数据入库前校验service是否需要向阀门中额外添加属性,如果额外添加了属性,则验证service对应的redisdb中是否包含阀门,如果不包含给予错误提示
This commit is contained in:
@@ -592,6 +592,12 @@ public enum RestBusinessCode {
|
||||
*/
|
||||
RegionIsNotExist(5002010,"删除分组复用域配置时,无法在关联关系中找到对应的域配置信息,之前该域没有添加过,或者关联关系被损坏请检查"),
|
||||
|
||||
|
||||
/**
|
||||
*配置文件内容有误
|
||||
*/
|
||||
PropertiesIsError(5002011,"配置文件内容有误"),
|
||||
|
||||
/**
|
||||
* 无法从Map中获取配置的属性值
|
||||
*/
|
||||
|
||||
@@ -29,7 +29,7 @@ public class ServiceAndRDBIndexReal {
|
||||
* 记录哪些service可以被分组复用(只有maat类配置可以被分组复用)
|
||||
* Map<Service,Map<regionName,List<tableName>>
|
||||
*/
|
||||
private static Map<Integer,Map<String, List<String>>> serviceGroupReuseMap = new HashMap<Integer, Map<String,List<String>>>();
|
||||
private static Map<Integer, Map<String, List<String>>> serviceGroupReuseMap = new HashMap<Integer, Map<String, List<String>>>();
|
||||
|
||||
/**
|
||||
* 第一个key是业务类型,第二个key是type(编译配置,分组配置,域配置)value是表名
|
||||
@@ -66,26 +66,23 @@ public class ServiceAndRDBIndexReal {
|
||||
if (unMaatService != null && !unMaatService.trim().equals("")) {
|
||||
String[] split = unMaatService.split(";");
|
||||
for (String str : split) {
|
||||
String[] serviceAction = str.split(":");
|
||||
if (serviceAction.length==2) {
|
||||
serviceActionMap.put(Integer.valueOf(serviceAction[0]),
|
||||
Integer.valueOf(serviceAction[1]));
|
||||
}else{
|
||||
serviceActionMap.put(Integer.valueOf(serviceAction[0]),
|
||||
null);
|
||||
}
|
||||
String serviceType = Configurations.getStringProperty(serviceAction[0], "");
|
||||
if (serviceType != null && !serviceType.trim().equals("")) {
|
||||
String[] typeArrs = serviceType.split(";");
|
||||
for (String typeStr : typeArrs) {
|
||||
String[] typeArr = typeStr.split(":");
|
||||
String tableNameArr[] = typeArr[1].split(",");
|
||||
for (String tableName : tableNameArr) {
|
||||
unMaatSercieNameMap.put(Integer.parseInt(serviceAction[0]),
|
||||
tableName.toUpperCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
String[] serviceAction = str.split(":");
|
||||
if (serviceAction.length == 2) {
|
||||
serviceActionMap.put(Integer.valueOf(serviceAction[0]), Integer.valueOf(serviceAction[1]));
|
||||
} else {
|
||||
serviceActionMap.put(Integer.valueOf(serviceAction[0]), null);
|
||||
}
|
||||
String serviceType = Configurations.getStringProperty(serviceAction[0], "");
|
||||
if (serviceType != null && !serviceType.trim().equals("")) {
|
||||
String[] typeArrs = serviceType.split(";");
|
||||
for (String typeStr : typeArrs) {
|
||||
String[] typeArr = typeStr.split(":");
|
||||
String tableNameArr[] = typeArr[1].split(",");
|
||||
for (String tableName : tableNameArr) {
|
||||
unMaatSercieNameMap.put(Integer.parseInt(serviceAction[0]), tableName.toUpperCase());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,17 +158,17 @@ public class ServiceAndRDBIndexReal {
|
||||
if (!StringUtil.isEmpty(serviceRepeatedReal)) {
|
||||
String[] serviceRepeatedRealArr = serviceRepeatedReal.split(";");
|
||||
for (String serviceRepeated : serviceRepeatedRealArr) {
|
||||
String [] serInfos = serviceRepeated.split(":");
|
||||
String [] regionInfos = serInfos[1].split("[|]");
|
||||
String[] serInfos = serviceRepeated.split(":");
|
||||
String[] regionInfos = serInfos[1].split("[|]");
|
||||
for (String regionInfo : regionInfos) {
|
||||
String [] regionTabName = regionInfo.split("@");
|
||||
String [] tableNames = regionTabName[1].split(",");
|
||||
String[] regionTabName = regionInfo.split("@");
|
||||
String[] tableNames = regionTabName[1].split(",");
|
||||
for (String tableName : tableNames) {
|
||||
Integer ser = Integer.valueOf(serInfos[0]);
|
||||
if(serviceGroupReuseMap.containsKey(ser)){
|
||||
if (serviceGroupReuseMap.containsKey(ser)) {
|
||||
serviceGroupReuseMap.get(ser).get(regionTabName[0]).add(tableName);
|
||||
}else{
|
||||
Map<String,List<String>> regTabMap = new HashMap<String, List<String>>();
|
||||
} else {
|
||||
Map<String, List<String>> regTabMap = new HashMap<String, List<String>>();
|
||||
List<String> tabList = new ArrayList<String>();
|
||||
tabList.add(tableName);
|
||||
regTabMap.put(regionTabName[0], tabList);
|
||||
@@ -183,8 +180,6 @@ public class ServiceAndRDBIndexReal {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) {
|
||||
// getUnMaatTable();
|
||||
getMaatTable();
|
||||
@@ -336,10 +331,25 @@ public class ServiceAndRDBIndexReal {
|
||||
if (service != null) {
|
||||
return serviceGroupReuseMap.containsKey(service);
|
||||
} else {
|
||||
throw new ServiceRuntimeException("判断service是否是分组复用时发生了异常,异常原因:service=null", RestBusinessCode.ServiceIsNull.getValue());
|
||||
throw new ServiceRuntimeException("判断service是否是分组复用时发生了异常,异常原因:service=null",
|
||||
RestBusinessCode.ServiceIsNull.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 验证当前service是否是向阀门添加action,service或者userregion等属性
|
||||
* @param service
|
||||
* @return
|
||||
*/
|
||||
public static boolean isAddASU(int service) {
|
||||
boolean isValve = false;
|
||||
Map<String, String[]> map2 = maatToValveMap.get(service);
|
||||
if (map2 != null && map2.size() > 0) {
|
||||
isValve = true;
|
||||
}
|
||||
return isValve;
|
||||
}
|
||||
|
||||
/**
|
||||
* 根据业务类型获取unmaat配置表名
|
||||
* @param service
|
||||
@@ -401,6 +411,7 @@ public class ServiceAndRDBIndexReal {
|
||||
public static void setUnMaatSercieNameMap(Map<Integer, String> unMaatSercieNameMap) {
|
||||
ServiceAndRDBIndexReal.unMaatSercieNameMap = unMaatSercieNameMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the serviceGroupReuseMap
|
||||
*/
|
||||
@@ -416,7 +427,7 @@ public class ServiceAndRDBIndexReal {
|
||||
List<String> list = new ArrayList<String>();
|
||||
list.addAll(map.get(regionName));
|
||||
groupReuseRegionMap.put(regionName, list);
|
||||
}else{
|
||||
} else {
|
||||
groupReuseRegionMap.get(regionName).addAll(map.get(regionName));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -445,6 +445,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
Jedis resource = JedisUtils.getResource(0);
|
||||
Transaction transaction = resource.multi();
|
||||
try {
|
||||
Set<Integer> keySet = configMap.keySet();
|
||||
for (Integer redisDBIndex : configMap.keySet()) {
|
||||
if (redisDBIndex >= 0 && redisDBIndex < Configurations.getIntProperty("maxRedisDBIndex", 6)) {
|
||||
transaction.select(redisDBIndex);
|
||||
@@ -458,6 +459,13 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
if (maatConfigList != null && maatConfigList.size() > 0) {
|
||||
for (MaatConfig maatConfig : maatConfigList) {
|
||||
int service = maatConfig.getService();
|
||||
if (ServiceAndRDBIndexReal.isAddASU(service)) {
|
||||
if (!keySet.contains(TAPREDISDB)) {
|
||||
throw new ServiceRuntimeException("业务类型:" + service + ",需要向阀门" + TAPREDISDB + "号库分发,但是当前只往"
|
||||
+ keySet + "库下发,请检查阀门编号或者当前业务对应的配置文件是否正确",RestBusinessCode.PropertiesIsError.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(service);
|
||||
setConfig(maatConfig, maatXmlConfig, maatVersion, service, transaction,
|
||||
redisDBIndex);
|
||||
|
||||
@@ -52,19 +52,12 @@ public class MaatTestServiceimpl {
|
||||
Integer service = configCompile.getService();
|
||||
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(service);
|
||||
List<Integer> redisDBList = ServiceAndRDBIndexReal.getRedisDBByService(service);
|
||||
|
||||
boolean isValve = false;
|
||||
Map<String, String[]> map2 = ServiceAndRDBIndexReal.getMaatToValveMap().get(service);
|
||||
if (map2 != null && map2.size() > 0) {
|
||||
isValve = true;
|
||||
}
|
||||
if (isValve) {
|
||||
if (ServiceAndRDBIndexReal.isAddASU(service)) {
|
||||
if (!redisDBList.contains(TAPREDISDB)) {
|
||||
throw new RuntimeException("业务类型:" + service + ",需要向阀门" + TAPREDISDB + "号库分发,但是当前只往"
|
||||
+ redisDBList + "库下发,请检查阀门编号或者当前业务对应的配置文件是否正确");
|
||||
}
|
||||
}
|
||||
|
||||
for (Integer redisDB : redisDBList) {
|
||||
getConfigByKey(redisDB, service, configCompile, maatXmlConfig);
|
||||
}
|
||||
|
||||
@@ -281,7 +281,8 @@ unMaatService=3:32;4:96;5:32;25:32;28:32;64;65;261:16;262:16;263:16;264:16;265:1
|
||||
##各业务类型对应的redisdb,业务类型:redisdb,多个业务以“;”分隔,多个db以“,”数量不能超过6个
|
||||
#系统简称对应的redisDBIndex: NTC(12-55):2 MM(256-511):3 PXY(512-767):4 IR(768-1023):5 DK(10241279):6 阀门:7
|
||||
serviceDBIndex=1:2,3,4,6,7;2:2,3,4,6,7;16:2;17:2;18:2;19:2;20:2;21:2;22:2;23:2;24:2;26:2;27:2;30:2;31:2;32:2;33:2,6,7;34:2;35:2,6;36:2,6;37:2;128:2;129:2;130:2;131:2;132:2;133:2;134:2;135:2;136:2;137:2;138:2;139:2;140:2;141:2;142:2;143:2;144:2;145:2,6;146:2;147:2,6;148:2,6;149:2;256:3;257:3;258:3;259:3;260:3;267:3;384:3;385:3;386:3;387:3;388:3;395:3;512:4,7;513:4,2,7;514:4;515:4;517:4;520:4;521:4;528:4;544:4;560:4;576:4;592:4;608:4;750:4;768:5;1024:2,6,7;1025:2,6,7;1026:2,6,7;1027:2,6,7;1028:2,6,7;1029:2,6,7;1030:2,6,7;1031:2,6,7;1040:2,6,7;1041:2,6,7;1042:2,6,7;1152:2,6;3:7;4:7;5:2;25:7;28:7;64:2;65:2;261:8,12;262:9,12;263:10,12;264:11,12;265:3;266:3;268:12;269:12;270:12;389:8,12;390:9,12;391:10,12;392:11,12;393:3;394:3;396:12;397:12;398:12;832:2,4,5,7;
|
||||
|
||||
##阀门配置在redisdb的序号
|
||||
tapRedisDb=7
|
||||
##maat配置入阀门需要将编译中的部分参数写到域配置中,目前最多包含ACTION,SERVICE,USER_REGION三个属性
|
||||
##业务ID:域类型1|域类型2@属性1&属性2&属性3
|
||||
##域类型:IP域 =ipRegion 字符串域=strRegion 增强字符串域=strStrRegion 数值域=numRegion
|
||||
@@ -301,8 +302,7 @@ serviceDBIndex=1:2,3,4,6,7;2:2,3,4,6,7;16:2;17:2;18:2;19:2;20:2;21:2;22:2;23:2;2
|
||||
|
||||
maat2Valve=33:strRegion@ACTION&SERVICE&USER_REGION;35:strRegion@ACTION&SERVICE&USER_REGION;36:strRegion@ACTION&SERVICE&USER_REGION;145:strRegion@ACTION&SERVICE&USER_REGION;147:strRegion@ACTION&SERVICE&USER_REGION;148:strRegion@ACTION&SERVICE&USER_REGION;512:ipRegion@ACTION&SERVICE;513:strRegion@ACTION&SERVICE&USER_REGION;1024:strRegion|strStrRegion@USER_REGION;1026:strRegion|strStrRegion@USER_REGION;1027:strRegion|strStrRegion@USER_REGION;1028:ipRegion@USER_REGION;1029:strStrRegion@USER_REGION;1030:numRegion@USER_REGION;1031:strStrRegion@USER_REGION;1040:strRegion@ACTION&SERVICE&USER_REGION;1041:strRegion@ACTION&SERVICE&USER_REGION;1042:strRegion@ACTION&SERVICE&USER_REGION;1056:strRegion@ACTION&SERVICE&USER_REGION;1057:ipRegion@ACTION&SERVICE&USER_REGION;1058:strRegion@ACTION&SERVICE&USER_REGION;1059:strRegion@ACTION&SERVICE&USER_REGION;1060:strRegion@ACTION&SERVICE&USER_REGION
|
||||
|
||||
##阀门配置在redisdb的序号
|
||||
tapRedisDb=5
|
||||
|
||||
##记录哪些service可以被分组复用(只有maat类配置可以被分组复用)
|
||||
#业务ID:域类型1@表名,表名|域类型2@表名;业务ID:域类型1@表名,表名|域类型2@表名
|
||||
##域类型:IP域 =ipRegion 字符串域=strRegion 数值域=numRegion
|
||||
|
||||
@@ -10,11 +10,11 @@ fastdfs.http_secret_key = FastDFS1234567890
|
||||
fastdfs.http_tracker_http_port = 80
|
||||
|
||||
#元辰鑫内网
|
||||
#fastdfs.tracker_servers = 10.0.6.249:22122
|
||||
#fastDfsHttpAddr= 10.0.6.249
|
||||
fastdfs.tracker_servers = 10.0.6.249:22122
|
||||
fastDfsHttpAddr= 10.0.6.249
|
||||
#元辰鑫外网
|
||||
fastdfs.tracker_servers = 192.168.10.205:22122
|
||||
fastDfsHttpAddr=192.168.10.205
|
||||
#fastdfs.tracker_servers=192.168.10.205:22122
|
||||
#fastDfsHttpAddr=192.168.10.205
|
||||
#亦庄演示环境
|
||||
#fastdfs.tracker_servers = 10.3.34.1:22122
|
||||
#fastDfsHttpAddr = 10.3.34.1
|
||||
@@ -7,8 +7,8 @@ http.secret_key = FastDFS1234567890
|
||||
|
||||
|
||||
#元辰鑫内网
|
||||
#tracker_server = 10.0.6.249:22122
|
||||
tracker_server=10.0.6.249:22122
|
||||
#元辰鑫外网
|
||||
tracker_server = 192.168.10.205:22122
|
||||
#tracker_server=192.168.10.205:22122
|
||||
#亦庄演示环境
|
||||
#tracker_server = 10.3.34.1:22122
|
||||
#tracker_server=10.3.34.1:22122
|
||||
|
||||
Reference in New Issue
Block a user