1:修改配置下发及停启用接口的逻辑
2:完成公共组域配置新增和修改功能
This commit is contained in:
@@ -15,28 +15,22 @@ import com.wordnik.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
*
|
||||
* @ClassName:RegionRepeat
|
||||
* @ClassName:CommonGroup
|
||||
* @Description:TODO(这里用一句话描述这个类的作用)
|
||||
* @author (zdx)
|
||||
* @date 2018年8月22日 下午6:57:42
|
||||
* @version V1.0
|
||||
*/
|
||||
public class GroupReuse implements Serializable {
|
||||
public class CommonGroup implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
// ASN-IP阻断和监测不用传service和ipregion.userRegion字段,当是app协议ip业务时需要传入ipregion.userRegion字段
|
||||
// @ApiModelProperty(value = "业务ID", required = true)
|
||||
// private Integer service;
|
||||
|
||||
@ApiModelProperty(value = "字符串域分组列表", access = "", required = true)
|
||||
private List<StrRegion> strRegionList;
|
||||
|
||||
@ApiModelProperty(value = "IP域分组列表", required = true)
|
||||
private List<IpRegion> ipRegionList;
|
||||
|
||||
@ApiModelProperty(value = "数值域分组列表", required = true)
|
||||
private List<NumRegion> numRegionList;
|
||||
|
||||
/**
|
||||
* @return strRegionList
|
||||
*/
|
||||
@@ -17,103 +17,96 @@ import com.nis.util.JsonDateDeserializer;
|
||||
import com.nis.util.JsonDateSerializer;
|
||||
|
||||
/**
|
||||
* @ClassName:RegionRepeatSource
|
||||
* CommonGroupSource
|
||||
*
|
||||
* @Description:TODO(这里用一句话描述这个类的作用)
|
||||
* @author (zdx)
|
||||
* @date 2018年8月22日 下午7:03:36
|
||||
* @version V1.0
|
||||
*/
|
||||
public class GroupReuseSource extends ConfigCommonSource{
|
||||
|
||||
private static final long serialVersionUID = -7543263486915343526L;
|
||||
public class CommonGroupSource extends ConfigCommonSource {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
private static final String DEFAULT_VERSION = "1.0";
|
||||
private List<GroupReuse> groupReuseList; //分组复用域配置列表
|
||||
/**
|
||||
* @Title:
|
||||
* @Description: TODO
|
||||
* @param
|
||||
*/
|
||||
public GroupReuseSource() {
|
||||
private List<CommonGroup> commonGroupList; // 公共组新增域配置列表
|
||||
|
||||
/**
|
||||
* @Title:
|
||||
* @Description: TODO
|
||||
* @param
|
||||
*/
|
||||
public CommonGroupSource() {
|
||||
this.version = DEFAULT_VERSION;
|
||||
}
|
||||
|
||||
public GroupReuseSource(String Version) {
|
||||
|
||||
public CommonGroupSource(String Version) {
|
||||
this.version = Version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return version
|
||||
*/
|
||||
/**
|
||||
* @return version
|
||||
*/
|
||||
public String getVersion() {
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param version 要设置的 version
|
||||
*/
|
||||
/**
|
||||
* @param version 要设置的 version
|
||||
*/
|
||||
public void setVersion(String version) {
|
||||
this.version = version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return operator
|
||||
*/
|
||||
/**
|
||||
* @return operator
|
||||
*/
|
||||
public String getOperator() {
|
||||
return operator;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param operator 要设置的 operator
|
||||
*/
|
||||
/**
|
||||
* @param operator 要设置的 operator
|
||||
*/
|
||||
public void setOperator(String operator) {
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @return opTime
|
||||
*/
|
||||
@JsonSerialize(using=JsonDateSerializer.class)
|
||||
/**
|
||||
* @return opTime
|
||||
*/
|
||||
@JsonSerialize(using = JsonDateSerializer.class)
|
||||
public Date getOpTime() {
|
||||
return opTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param opTime 要设置的 opTime
|
||||
*/
|
||||
@JsonDeserialize(using=JsonDateDeserializer.class)
|
||||
/**
|
||||
* @param opTime 要设置的 opTime
|
||||
*/
|
||||
@JsonDeserialize(using = JsonDateDeserializer.class)
|
||||
public void setOpTime(Date opTime) {
|
||||
this.opTime = opTime;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @return opAction
|
||||
*/
|
||||
/**
|
||||
* @return opAction
|
||||
*/
|
||||
public Integer getOpAction() {
|
||||
return opAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param opAction 要设置的 opAction
|
||||
*/
|
||||
/**
|
||||
* @param opAction 要设置的 opAction
|
||||
*/
|
||||
public void setOpAction(Integer opAction) {
|
||||
this.opAction = opAction;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the groupReuseList
|
||||
*/
|
||||
public List<GroupReuse> getGroupReuseList() {
|
||||
return groupReuseList;
|
||||
public List<CommonGroup> getCommonGroupList() {
|
||||
return commonGroupList;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param groupReuseList the groupReuseList to set
|
||||
*/
|
||||
public void setGroupReuseList(List<GroupReuse> groupReuseList) {
|
||||
this.groupReuseList = groupReuseList;
|
||||
|
||||
public void setCommonGroupList(List<CommonGroup> commonGroupList) {
|
||||
this.commonGroupList = commonGroupList;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,89 +0,0 @@
|
||||
/**
|
||||
* @Title: DfConfigCompile.java
|
||||
* @Package com.nis.domain.restful
|
||||
* @Description: TODO(用一句话描述该文件做什么)
|
||||
* @author (darnell)
|
||||
* @date 2016年8月29日 下午9:36:28
|
||||
* @version V1.0
|
||||
*/
|
||||
package com.nis.domain.restful;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.nis.util.JsonDateDeserializer;
|
||||
import com.wordnik.swagger.annotations.ApiModelProperty;
|
||||
|
||||
/**
|
||||
* @ClassName: ConfigCompileStartStop
|
||||
* @Description: TODO(这里用一句话描述这个类的作用)
|
||||
* @author (rkg)
|
||||
* @date 2018年12月22日 下午4:36:28
|
||||
* @version V1.0
|
||||
*/
|
||||
public class ConfigCompileStartStop implements Serializable {
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 546753235262247839L;
|
||||
@ApiModelProperty(value = "配置ID", required = true)
|
||||
private Long compileId;
|
||||
@ApiModelProperty(value = "有效标志", required = true)
|
||||
private Integer isValid;
|
||||
@ApiModelProperty(value = "业务类型", required = true)
|
||||
private Integer service;
|
||||
@ApiModelProperty(value = "操作时间", required = true)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date opTime;
|
||||
|
||||
public Long getCompileId() {
|
||||
return compileId;
|
||||
}
|
||||
|
||||
public void setCompileId(Long compileId) {
|
||||
this.compileId = compileId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return isValid
|
||||
*/
|
||||
public Integer getIsValid() {
|
||||
return isValid;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param isValid 要设置的 isValid
|
||||
*/
|
||||
public void setIsValid(Integer isValid) {
|
||||
this.isValid = isValid;
|
||||
}
|
||||
|
||||
|
||||
public Integer getService() {
|
||||
return service;
|
||||
}
|
||||
|
||||
public void setService(Integer service) {
|
||||
this.service = service;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return opTime
|
||||
*/
|
||||
@JsonDeserialize(using = JsonDateDeserializer.class)
|
||||
public Date getOpTime() {
|
||||
return opTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param opTime 要设置的 opTime
|
||||
*/
|
||||
@JsonDeserialize(using = JsonDateDeserializer.class)
|
||||
public void setOpTime(Date opTime) {
|
||||
this.opTime = opTime;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,499 +0,0 @@
|
||||
package com.nis.util;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import com.nis.domain.restful.GroupReuse;
|
||||
import com.nis.domain.restful.IpRegion;
|
||||
import com.nis.domain.restful.NumRegion;
|
||||
import com.nis.domain.restful.StrRegion;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.RestServiceException;
|
||||
import com.nis.restful.ServiceRuntimeException;
|
||||
import com.nis.web.service.restful.ConfigSourcesService;
|
||||
import com.zdjizhi.utils.StringUtil;
|
||||
|
||||
public class GroupReuseVal {
|
||||
|
||||
public static void valGroupReuse(List<GroupReuse> groupReuseList,
|
||||
Boolean isUpdate) throws Exception {
|
||||
for (GroupReuse groupReuse : groupReuseList) {
|
||||
Map<String, List<String>> groupReuseRegionMap = ServiceAndRDBIndexReal
|
||||
.getGroupReuseRegionMap();
|
||||
// 验证各类型域配置
|
||||
Boolean hasRegionFlag = false;
|
||||
if (groupReuseRegionMap.containsKey("numRegion")
|
||||
&& !StringUtil.isEmpty(groupReuse.getNumRegionList())
|
||||
&& groupReuse.getNumRegionList().size() > 0) {
|
||||
hasRegionFlag = true;
|
||||
List<NumRegion> numRegionList = groupReuse.getNumRegionList();
|
||||
for (NumRegion numRegion : numRegionList) {
|
||||
if (!StringUtil.isEmpty(numRegion.getTableName())
|
||||
&& !groupReuseRegionMap.get("numRegion").contains(numRegion.getTableName())) {
|
||||
throw new RestServiceException("numRegionList中的regionId为"
|
||||
+ numRegion.getRegionId()
|
||||
+ "的域配置tableName不是分组复用的域表",
|
||||
RestBusinessCode.TableNameUnReuse
|
||||
.getValue());
|
||||
}
|
||||
if (!isUpdate && numRegion.getIsValid() != 1) {
|
||||
throw new RestServiceException("numRegionList中的regionId为"
|
||||
+ numRegion.getRegionId() + "的域配置在添加时不能为无效",
|
||||
RestBusinessCode.IsValidIsT.getValue());
|
||||
}
|
||||
if (isUpdate && numRegion.getIsValid() != 0) {
|
||||
throw new RestServiceException("numRegionList中的regionId为"
|
||||
+ numRegion.getRegionId() + "的域配置在修改时不能为有效",
|
||||
RestBusinessCode.IsValidIsF.getValue());
|
||||
}
|
||||
|
||||
if (!isUpdate && Constants.BASE_VALIDATE) {
|
||||
valNumRegion(numRegion);
|
||||
}
|
||||
if (!isUpdate && Constants.SERVICE_VALIDATE) {
|
||||
serviceNumRegionVal(numRegion);
|
||||
}
|
||||
}
|
||||
} else if (groupReuseRegionMap.containsKey("strRegion")
|
||||
&& !StringUtil.isEmpty(groupReuse.getStrRegionList())
|
||||
&& groupReuse.getStrRegionList().size() > 0) {
|
||||
hasRegionFlag = true;
|
||||
List<StrRegion> strRegionList = groupReuse.getStrRegionList();
|
||||
for (StrRegion strRegion : strRegionList) {
|
||||
// if (groupReuse.getIsValid() != 0 &&
|
||||
// !regionGroupIdList.contains(strRegion.getGroupId()))
|
||||
// {
|
||||
|
||||
if (!StringUtil.isEmpty(strRegion.getTableName())
|
||||
&& !groupReuseRegionMap.get("strRegion").contains(strRegion.getTableName())) {
|
||||
throw new RestServiceException("strRegionList中的regionId为"
|
||||
+ strRegion.getRegionId()
|
||||
+ "的域配置tableName不是分组复用的域表",
|
||||
RestBusinessCode.TableNameUnReuse
|
||||
.getValue());
|
||||
}
|
||||
if (!isUpdate && strRegion.getIsValid() != 1) {
|
||||
throw new RestServiceException("strRegionList中的regionId为"
|
||||
+ strRegion.getRegionId() + "的域配置在添加时不能为无效",
|
||||
RestBusinessCode.IsValidIsT.getValue());
|
||||
}
|
||||
if (isUpdate && strRegion.getIsValid() != 0) {
|
||||
throw new RestServiceException("strRegionList中的regionId为"
|
||||
+ strRegion.getRegionId() + "的域配置在修改时不能为有效",
|
||||
RestBusinessCode.IsValidIsF.getValue());
|
||||
}
|
||||
|
||||
if (!isUpdate && Constants.BASE_VALIDATE) {
|
||||
valStrRegion(strRegion);
|
||||
}
|
||||
if (!isUpdate && Constants.SERVICE_VALIDATE) {
|
||||
serviceStrRegionVal(strRegion);
|
||||
}
|
||||
}
|
||||
} else if (groupReuseRegionMap.containsKey("ipRegion")
|
||||
&& !StringUtil.isEmpty(groupReuse.getIpRegionList())
|
||||
&& groupReuse.getIpRegionList().size() > 0) {
|
||||
hasRegionFlag = true;
|
||||
List<IpRegion> ipRegionList = groupReuse.getIpRegionList();
|
||||
for (IpRegion ipRegion : ipRegionList) {
|
||||
// if (groupReuse.getIsValid() != 0 &&
|
||||
// !regionGroupIdList.contains(ipRegion.getGroupId())) {
|
||||
// if (!StringUtil.isEmpty(groupReuse.getService())) {
|
||||
// if (groupReuse.getService().intValue()!=1028) {
|
||||
// throw new RestServiceException("ipRegionList中的regionId为"
|
||||
// + ipRegion.getRegionId()
|
||||
// + "的域配置的service只能为空或1028",
|
||||
// RestBusinessCode.ReUseServiceRange
|
||||
// .getValue());
|
||||
// }
|
||||
if (StringUtil.isEmpty(ipRegion.getUserRegion())) {
|
||||
throw new RestServiceException("ipRegionList中的regionId为"
|
||||
+ ipRegion.getRegionId()
|
||||
+ "的域配置需要下发到阀门,userRegion不能为空",
|
||||
RestBusinessCode.ReUseUserRegionIsNull
|
||||
.getValue());
|
||||
}
|
||||
// }
|
||||
|
||||
if (!StringUtil.isEmpty(ipRegion.getTableName())
|
||||
&& !groupReuseRegionMap.get("ipRegion").contains(ipRegion.getTableName())) {
|
||||
throw new RestServiceException("ipRegionList中的regionId为"
|
||||
+ ipRegion.getRegionId()
|
||||
+ "的域配置tableName不是分组复用的域表",
|
||||
RestBusinessCode.TableNameUnReuse
|
||||
.getValue());
|
||||
}
|
||||
|
||||
if (!isUpdate
|
||||
&& (null == ipRegion.getIsValid() || ipRegion
|
||||
.getIsValid() != 1)) {
|
||||
throw new RestServiceException("ipRegionList中的regionId为"
|
||||
+ ipRegion.getRegionId() + "的域配置在添加时不能为无效",
|
||||
RestBusinessCode.IsValidIsT.getValue());
|
||||
}
|
||||
if (isUpdate
|
||||
&& (null == ipRegion.getIsValid() || ipRegion
|
||||
.getIsValid() != 0)) {
|
||||
throw new RestServiceException("ipRegionList中的regionId为"
|
||||
+ ipRegion.getRegionId() + "的域配置在修改时不能为有效",
|
||||
RestBusinessCode.IsValidIsF.getValue());
|
||||
}
|
||||
|
||||
if (!isUpdate && Constants.BASE_VALIDATE) {
|
||||
valIpRegion(ipRegion);
|
||||
}
|
||||
|
||||
if (!isUpdate && Constants.SERVICE_VALIDATE) {
|
||||
serviceIpRegionVal(ipRegion);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!hasRegionFlag) {
|
||||
// 所有的域类型都不包括,可能是配置文件配错了
|
||||
throw new ServiceRuntimeException(RestBusinessCode.ReuseRegionIsNull.getErrorReason(),
|
||||
RestBusinessCode.ReuseRegionIsNull.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void valIpRegion(IpRegion ipRegion) {
|
||||
Long regionId = ipRegion.getRegionId();
|
||||
if (null == regionId) {
|
||||
throw new RestServiceException("ipRegionList中的regionId不能为空",
|
||||
RestBusinessCode.RegionIdIsNull.getValue());
|
||||
}
|
||||
if (null == ipRegion.getGroupId()) {
|
||||
throw new RestServiceException("ipRegionList中id为" + regionId + "的配置groupId不能为空",
|
||||
RestBusinessCode.RegionsGroupIdIsNull.getValue());
|
||||
}
|
||||
if (null == ipRegion.getAddrType()) {
|
||||
throw new RestServiceException("ipRegionList中id为" + regionId + "的配置addrType不能为空",
|
||||
RestBusinessCode.AddrTypeIsNull.getValue());
|
||||
}
|
||||
if (null == ipRegion.getSrcIp() || ipRegion.getSrcIp().equals("")) {
|
||||
throw new RestServiceException("ipRegionList中id为" + regionId + "的配置srcIp不能为空",
|
||||
RestBusinessCode.SrcIpIsNull.getValue());
|
||||
}
|
||||
|
||||
if (null == ipRegion.getMaskSrcIp()
|
||||
|| ipRegion.getMaskSrcIp().equals("")) {
|
||||
throw new RestServiceException("ipRegionList中id为" + regionId + "的配置maskSrcIp不能为空",
|
||||
RestBusinessCode.MaskSrcIpIsNull.getValue());
|
||||
}
|
||||
if (null == ipRegion.getSrcPort() || ipRegion.getSrcPort().equals("")) {
|
||||
throw new RestServiceException("ipRegionList中id为" + regionId + "的配置srcPort不能为空",
|
||||
RestBusinessCode.SrcPortIsNull.getValue());
|
||||
}
|
||||
if (null == ipRegion.getMaskSrcPort()
|
||||
|| ipRegion.getMaskSrcPort().equals("")) {
|
||||
throw new RestServiceException("ipRegionList中id为" + regionId + "的配置maskSrcPort不能为空",
|
||||
RestBusinessCode.MaskSrcPortIsNull.getValue());
|
||||
}
|
||||
if (null == ipRegion.getDstIp() || ipRegion.getDstIp().equals("")) {
|
||||
throw new RestServiceException("ipRegionList中id为" + regionId + "的配置dstIp不能为空",
|
||||
RestBusinessCode.DstIpIsNull.getValue());
|
||||
}
|
||||
if (null == ipRegion.getMaskDstIp()
|
||||
|| ipRegion.getMaskDstIp().equals("")) {
|
||||
throw new RestServiceException("ipRegionList中id为" + regionId + "的配置maskDstIp不能为空",
|
||||
RestBusinessCode.MaskDstIpIsNull.getValue());
|
||||
}
|
||||
if (null == ipRegion.getDstPort() || ipRegion.getDstPort().equals("")) {
|
||||
throw new RestServiceException("ipRegionList中id为" + regionId + "的配置dstPort不能为空",
|
||||
RestBusinessCode.DstPortIsNull.getValue());
|
||||
}
|
||||
if (null == ipRegion.getMaskDstPort()
|
||||
|| ipRegion.getMaskDstPort().equals("")) {
|
||||
throw new RestServiceException("ipRegionList中id为" + regionId + "的配置maskDstPort不能为空",
|
||||
RestBusinessCode.MaskDstPortIsNull.getValue());
|
||||
}
|
||||
if (null == ipRegion.getProtocol()) {
|
||||
throw new RestServiceException("ipRegionList中id为" + regionId + "的配置protocol不能为空",
|
||||
RestBusinessCode.ProtocolIsNull.getValue());
|
||||
}
|
||||
if (null == ipRegion.getDirection()) {
|
||||
throw new RestServiceException("ipRegionList中id为" + regionId + "的配置direction不能为空",
|
||||
RestBusinessCode.DirectionIsNull.getValue());
|
||||
}
|
||||
if (null == ipRegion.getIsValid()) {
|
||||
throw new RestServiceException("ipRegionList中id为" + regionId + "的配置isValid不能为空",
|
||||
RestBusinessCode.IsValidIsNull.getValue());
|
||||
}
|
||||
if (null == ipRegion.getOpTime()) {
|
||||
throw new RestServiceException("ipRegionList中id为" + regionId + "的配置opTime不能为空",
|
||||
RestBusinessCode.OpTimeIsNull.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public static void valNumRegion(NumRegion numRegion)
|
||||
throws Exception {
|
||||
Long regionId = numRegion.getRegionId();
|
||||
if (null == regionId) {
|
||||
throw new RestServiceException("数值类域配置的regionId不能为空",
|
||||
RestBusinessCode.RegionIdIsNull.getValue());
|
||||
}
|
||||
if (null == numRegion.getGroupId()) {
|
||||
throw new RestServiceException("数值类域配置id为" + regionId + "的配置groupId不能为空",
|
||||
RestBusinessCode.RegionsGroupIdIsNull.getValue());
|
||||
}
|
||||
if (null == numRegion.getLowBoundary()) {
|
||||
throw new RestServiceException("数值类域配置id为" + regionId + "的配置lowBoundary不能为空",
|
||||
RestBusinessCode.LowBoundaryIsNull.getValue());
|
||||
}
|
||||
if (null == numRegion.getUpBoundary()) {
|
||||
throw new RestServiceException("数值类域配置id为" + regionId + "的配置upBoundary不能为空",
|
||||
RestBusinessCode.UpBoundaryIsNull.getValue());
|
||||
}
|
||||
if (null == numRegion.getOpTime()) {
|
||||
throw new RestServiceException("数值类域配置中id为" + regionId + "的配置opTime不能为空",
|
||||
RestBusinessCode.OpTimeIsNull.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public static void valStrRegion(StrRegion strRegion) throws Exception {
|
||||
Long regionId = strRegion.getRegionId();
|
||||
if (null == regionId) {
|
||||
throw new RestServiceException("strRegionList中regionId不能为空",
|
||||
RestBusinessCode.RegionIdIsNull.getValue());
|
||||
}
|
||||
if (null == strRegion.getGroupId()) {
|
||||
throw new RestServiceException("strRegionList中id为" + regionId + "的配置groupId不能为空",
|
||||
RestBusinessCode.RegionsGroupIdIsNull.getValue());
|
||||
}
|
||||
|
||||
if (null == strRegion.getKeywords()
|
||||
|| strRegion.getKeywords().equals("")) {
|
||||
throw new RestServiceException("strRegionList中id为" + regionId + "的配置keywords不能为空",
|
||||
RestBusinessCode.KeywordsIsNull.getValue());
|
||||
}
|
||||
|
||||
if (null == strRegion.getExprType()) {
|
||||
throw new RestServiceException("strRegionList中id为" + regionId + "的配置exprType不能为空",
|
||||
RestBusinessCode.ExprTypeIsNull.getValue());
|
||||
}
|
||||
|
||||
if (null == strRegion.getMatchMethod()) {
|
||||
throw new RestServiceException("strRegionList中id为" + regionId + "的配置matchMethod不能为空",
|
||||
RestBusinessCode.MatchMethodIsNull.getValue());
|
||||
}
|
||||
if (null == strRegion.getIsHexbin()) {
|
||||
throw new RestServiceException("strRegionList中id为" + regionId + "的配置isHexbin不能为空",
|
||||
RestBusinessCode.MatchMethodIsNull.getValue());
|
||||
}
|
||||
if (null == strRegion.getOpTime()) {
|
||||
throw new RestServiceException("strRegionList中id为" + regionId + "的配置opTime不能为空",
|
||||
RestBusinessCode.OpTimeIsNull.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static void validateIpAndMask(IpRegion ipRegion) throws Exception {
|
||||
// 源IP信息和目的IP信息格式s为IPV4或IPV6
|
||||
if (ipRegion.getAddrType().intValue() == 4
|
||||
|| ipRegion.getAddrType().intValue() == 6) {
|
||||
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getSrcIp(),
|
||||
ipRegion.getAddrType())) {
|
||||
throw new RestServiceException("ipRegionList中regionId为" + ipRegion.getRegionId()
|
||||
+ "的域配置srcIp的格式不正确或与addrType不一致",
|
||||
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||
}
|
||||
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getMaskSrcIp(),
|
||||
ipRegion.getAddrType())) {
|
||||
throw new RestServiceException("ipRegionList中regionId为" + ipRegion.getRegionId()
|
||||
+ "的域配置maskSrcIp的格式不正确或与addrType不一致",
|
||||
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||
}
|
||||
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getDstIp(),
|
||||
ipRegion.getAddrType())) {
|
||||
throw new RestServiceException("ipRegionList中regionId为" + ipRegion.getRegionId()
|
||||
+ "的域配置dstIp的格式不正确或与addrType不一致",
|
||||
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||
}
|
||||
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getMaskDstIp(),
|
||||
ipRegion.getAddrType())) {
|
||||
throw new RestServiceException("ipRegionList中regionId为" + ipRegion.getRegionId()
|
||||
+ "的域配置maskDstIp的格式不正确或与addrType不一致",
|
||||
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||
}
|
||||
} else if (ipRegion.getAddrType().intValue() == 46) {// 4OVER6:源IP信息格式为IPV4、目的IP信息格式IPV6
|
||||
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getSrcIp(), 4)) {
|
||||
throw new RestServiceException("ipRegionList中regionId为" + ipRegion.getRegionId()
|
||||
+ "的域配置srcIp的格式不正确或与addrType不一致",
|
||||
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||
}
|
||||
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getMaskSrcIp(), 4)) {
|
||||
throw new RestServiceException("ipRegionList中regionId为" + ipRegion.getRegionId()
|
||||
+ "的域配置maskSrcIp的格式不正确或与addrType不一致",
|
||||
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||
}
|
||||
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getDstIp(), 6)) {
|
||||
throw new RestServiceException("ipRegionList中regionId为" + ipRegion.getRegionId()
|
||||
+ "的域配置dstIp的格式不正确或与addrType不一致",
|
||||
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||
}
|
||||
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getMaskDstIp(), 6)) {
|
||||
throw new RestServiceException("ipRegionList中regionId为" + ipRegion.getRegionId()
|
||||
+ "的域配置maskDstIp的格式不正确或与addrType不一致",
|
||||
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||
}
|
||||
} else if (ipRegion.getAddrType().intValue() == 64) {// 6OVER4:源IP信息格式为IPV6、目的IP信息格式IPV4
|
||||
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getSrcIp(), 6)) {
|
||||
throw new RestServiceException("ipRegionList中regionId为" + ipRegion.getRegionId()
|
||||
+ "的域配置srcIp的格式不正确或与addrType不一致",
|
||||
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||
}
|
||||
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getMaskSrcIp(), 6)) {
|
||||
throw new RestServiceException("ipRegionList中regionId为" + ipRegion.getRegionId()
|
||||
+ "的域配置maskSrcIp的格式不正确或与addrType不一致",
|
||||
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||
}
|
||||
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getDstIp(), 4)) {
|
||||
throw new RestServiceException("ipRegionList中regionId为" + ipRegion.getRegionId()
|
||||
+ "的域配置dstIp的格式不正确或与addrType不一致",
|
||||
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||
}
|
||||
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getMaskDstIp(), 4)) {
|
||||
throw new RestServiceException("ipRegionList中regionId为" + ipRegion.getRegionId()
|
||||
+ "的域配置maskDstIp的格式不正确或与addrType不一致",
|
||||
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||
}
|
||||
} else if (ipRegion.getAddrType().intValue() == 10) {// all:符合IP格式即可
|
||||
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getSrcIp(), null)) {
|
||||
throw new RestServiceException("ipRegionList中regionId为" + ipRegion.getRegionId()
|
||||
+ "的域配置srcIp的格式不正确或与addrType不一致",
|
||||
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||
}
|
||||
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getMaskSrcIp(), null)) {
|
||||
throw new RestServiceException("ipRegionList中regionId为" + ipRegion.getRegionId()
|
||||
+ "的域配置maskSrcIp的格式不正确或与addrType不一致",
|
||||
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||
}
|
||||
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getDstIp(), null)) {
|
||||
throw new RestServiceException("ipRegionList中regionId为" + ipRegion.getRegionId()
|
||||
+ "的域配置dstIp的格式不正确或与addrType不一致",
|
||||
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||
}
|
||||
if (!BasicProvingUtil.isIpOrIpMask(ipRegion.getMaskDstIp(), null)) {
|
||||
throw new RestServiceException("ipRegionList中中regionId为" + ipRegion.getRegionId()
|
||||
+ "的域配置maskDstIp的格式不正确或与addrType不一致",
|
||||
RestBusinessCode.IPUnMatchAddrType.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void serviceIpRegionVal(IpRegion ipRegion) throws Exception {
|
||||
|
||||
int addrType = ipRegion.getAddrType().intValue();
|
||||
if (!(addrType == 4|| addrType == 6 || addrType == 46|| addrType == 64 || addrType ==10)) {
|
||||
throw new RestServiceException("ipRegionList中regionId为" + ipRegion.getRegionId()
|
||||
+ "的域配置addrType的值只能为4(IPV4)、6(IPV6)、46(4OVER6隧道)、64(6OVER4隧道)、10(全部)",
|
||||
RestBusinessCode.AddrTypeIsWrongRange.getValue());
|
||||
}
|
||||
|
||||
validateIpAndMask(ipRegion);
|
||||
|
||||
if (!BasicProvingUtil.isPortOrPortMask(ipRegion.getSrcPort())) {
|
||||
throw new RestServiceException("ipRegionList中regionId为" + ipRegion.getRegionId()
|
||||
+ "的域配置srcPort的格式不正确",
|
||||
RestBusinessCode.PortIsNotVal.getValue());
|
||||
}
|
||||
|
||||
if (!BasicProvingUtil.isPortOrPortMask(ipRegion.getMaskSrcPort())) {
|
||||
throw new RestServiceException("ipRegionList中regionId为" + ipRegion.getRegionId()
|
||||
+ "的域配置maskSrcPort的格式不正确",
|
||||
RestBusinessCode.PortIsNotVal.getValue());
|
||||
}
|
||||
if (!BasicProvingUtil.isPortOrPortMask(ipRegion.getDstPort())) {
|
||||
throw new RestServiceException("ipRegionList中regionId为" + ipRegion.getRegionId()
|
||||
+ "的域配置dstPort的格式不正确",
|
||||
RestBusinessCode.PortIsNotVal.getValue());
|
||||
}
|
||||
|
||||
if (!BasicProvingUtil.isPortOrPortMask(ipRegion.getMaskDstPort())) {
|
||||
// if (!BasicProvingUtil.isIntType(ipRegion.getMaskDstPort())) {
|
||||
throw new RestServiceException("ipRegionList中regionId为" + ipRegion.getRegionId()
|
||||
+ "的域配置maskDstPort的格式不正确",
|
||||
RestBusinessCode.PortIsNotVal.getValue());
|
||||
}
|
||||
|
||||
if (ipRegion.getSrcIp().equals(ipRegion.getDstIp())) {
|
||||
throw new RestServiceException("ipRegionList中regionId为" + ipRegion.getRegionId()
|
||||
+ "的域配置srcIp和dstIp不能相同",
|
||||
RestBusinessCode.SrcIpEQDstIp.getValue());
|
||||
}
|
||||
if (ipRegion.getDirection() != 1 && ipRegion.getDirection() != 0) {
|
||||
throw new RestServiceException("ipRegionList中regionId为" + ipRegion.getRegionId()
|
||||
+ "的域配置direction的值不正确,只能是0或1",
|
||||
RestBusinessCode.DirectionIsWrongRange.getValue());
|
||||
}
|
||||
|
||||
// zdx protocol验证?
|
||||
// if (ipRegion.getTableName().toLowerCase().equals("dj_ip_port")) {
|
||||
// if (ipRegion.getProtocol() < 0 || ipRegion.getProtocol() > 255) {
|
||||
// return "service为" + service + "的配置中"+listName+"中regionId为" +
|
||||
// ipRegion.getRegionId()
|
||||
// + "的域配置tableName为dj_ip_port时,protocol的取值范围只能是0-255";
|
||||
// }
|
||||
// } else {
|
||||
// if (ipRegion.getProtocol() != 0) {
|
||||
// return "service为" + service + "的配置中"+listName+"中regionId为" +
|
||||
// ipRegion.getRegionId() + "的域配置tableName为"
|
||||
// + ipRegion.getTableName() + "时,protocol的值只能是0";
|
||||
// }
|
||||
//
|
||||
// }
|
||||
}
|
||||
|
||||
public static void serviceNumRegionVal(NumRegion numRegion)
|
||||
throws Exception {
|
||||
Long lowBoundary = numRegion.getLowBoundary();
|
||||
Long upBoundary = numRegion.getUpBoundary();
|
||||
if (lowBoundary <= upBoundary) {
|
||||
if (lowBoundary > 4294967295l || lowBoundary < 0l) {
|
||||
throw new RestServiceException("numRegionList中regionId为"
|
||||
+ numRegion.getRegionId()
|
||||
+ "的域配置lowBoundary的值不能大于2的32次方减一(4294967295)或者小于0",
|
||||
RestBusinessCode.LowBoundaryIsWrongRange.getValue());
|
||||
}
|
||||
if (upBoundary > 4294967295l || upBoundary < 0l) {
|
||||
throw new RestServiceException("numRegionList中regionId为"
|
||||
+ numRegion.getRegionId()
|
||||
+ "的域配置upBoundary的值不能大于2的32次方减一(4294967295)或者小于0",
|
||||
RestBusinessCode.UpBoundaryIsWrongRange.getValue());
|
||||
}
|
||||
} else {
|
||||
throw new RestServiceException("numRegionList中regionId为" + numRegion.getRegionId()
|
||||
+ "的域配置lowBoundary的值大于upBoundary,应该是小于或等于",
|
||||
RestBusinessCode.LowBoundaryGTUpBoundary.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
public static void serviceStrRegionVal(StrRegion strRegion) throws Exception {
|
||||
|
||||
Integer exprType = strRegion.getExprType();
|
||||
Integer matchMethod = strRegion.getMatchMethod();
|
||||
Integer isHexbin = strRegion.getIsHexbin();
|
||||
if (exprType != 0 && exprType != 1) {
|
||||
throw new RestServiceException("strRegionList中regionId为" + strRegion.getRegionId()
|
||||
+ "的域配置exprType的值只能是0(无表达式)或者1(与表达式)",
|
||||
RestBusinessCode.ExprTypeIsWrongRange.getValue());
|
||||
}
|
||||
if (matchMethod != 0 && matchMethod != 1 && matchMethod != 2
|
||||
&& matchMethod != 3) {
|
||||
throw new RestServiceException("strRegionList中regionId为" + strRegion.getRegionId()
|
||||
+ "的域配置matchMethod的值只能是0(子串匹配),1(右匹配),2(左匹配),3(完全匹配)",
|
||||
RestBusinessCode.MatchMethodIsWrongRange.getValue());
|
||||
}
|
||||
|
||||
if (isHexbin != 0 && isHexbin != 1 && isHexbin != 2) {
|
||||
throw new RestServiceException("strRegionList中regionId为"
|
||||
+ strRegion.getRegionId()
|
||||
+ "的域配置isHexbin的值只能是0(大小写不敏感,且非HEX)或者1(HEX)或者2(大小写敏感,且非HEX)",
|
||||
RestBusinessCode.IsHexbinIsWrongRange.getValue());
|
||||
}
|
||||
// strRegProhibitConfigWord(strRegion,service);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -417,10 +417,6 @@ public class ServiceAndRDBIndexReal {
|
||||
public static void setMaatToValveMap(Map<Integer, Map<String, String[]>> maatToValveMap) {
|
||||
ServiceAndRDBIndexReal.maatToValveMap = maatToValveMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static Map<Integer, Map<String, String[]>> getMaatToWebFocusMap() {
|
||||
return maatToWebFocusMap;
|
||||
@@ -430,8 +426,6 @@ public class ServiceAndRDBIndexReal {
|
||||
ServiceAndRDBIndexReal.maatToWebFocusMap = maatToWebFocusMap;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static Map<Integer, String> getUnMaatSercieNameMap() {
|
||||
return unMaatSercieNameMap;
|
||||
}
|
||||
@@ -439,27 +433,4 @@ public class ServiceAndRDBIndexReal {
|
||||
public static void setUnMaatSercieNameMap(Map<Integer, String> unMaatSercieNameMap) {
|
||||
ServiceAndRDBIndexReal.unMaatSercieNameMap = unMaatSercieNameMap;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the serviceGroupReuseMap
|
||||
*/
|
||||
public static Map<String, List<String>> getGroupReuseRegionMap() {
|
||||
Map<String, List<String>> groupReuseRegionMap = new HashMap<String, List<String>>();
|
||||
Iterator iterator = serviceGroupReuseMap.keySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map<String, List<String>> map = serviceGroupReuseMap.get(Integer.valueOf(iterator.next().toString()));
|
||||
Iterator mapIterator = map.keySet().iterator();
|
||||
while (mapIterator.hasNext()) {
|
||||
String regionName = mapIterator.next().toString();
|
||||
if (!groupReuseRegionMap.containsKey(regionName)) {
|
||||
List<String> list = new ArrayList<String>();
|
||||
list.addAll(map.get(regionName));
|
||||
groupReuseRegionMap.put(regionName, list);
|
||||
} else {
|
||||
groupReuseRegionMap.get(regionName).addAll(map.get(regionName));
|
||||
}
|
||||
}
|
||||
}
|
||||
return groupReuseRegionMap;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,10 +21,9 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import com.nis.domain.restful.ConfigCompile;
|
||||
import com.nis.domain.restful.ConfigSource;
|
||||
import com.nis.domain.restful.ConfigSourceStartStop;
|
||||
import com.nis.domain.restful.FileDesc;
|
||||
import com.nis.domain.restful.GroupReuse;
|
||||
import com.nis.domain.restful.GroupReuseSource;
|
||||
import com.nis.domain.restful.CommonGroup;
|
||||
import com.nis.domain.restful.CommonGroupSource;
|
||||
import com.nis.restful.RestBusinessCode;
|
||||
import com.nis.restful.RestServiceException;
|
||||
import com.nis.restful.ServiceRuntimeException;
|
||||
@@ -473,46 +472,45 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "摘要获取成功", resultObject);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/cfg/v1/groupReuseSources", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "分组复用域配置新增接口", httpMethod = "POST", response = Map.class, notes = "接收分组复用域配置,增加到对应的分组中")
|
||||
@ApiParam(value = "分组复用域配置对象", name = "groupReuseSource", required = true)
|
||||
public Map addGroupReuseSources(@RequestBody GroupReuseSource groupReuseSource, HttpServletRequest request,
|
||||
@RequestMapping(value = "/cfg/v1/addRegionToCommonGroup", method = RequestMethod.POST)
|
||||
@ApiOperation(value = "公共组域配置新增接口", httpMethod = "POST", response = Map.class, notes = "接收公共组新增的域配置,增加到对应的分组中")
|
||||
@ApiParam(value = "公关组对象", name = "commonGroupSource", required = true)
|
||||
public Map addRegionToCommonGroup(@RequestBody CommonGroupSource commonGroupSource, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
|
||||
groupReuseSource);
|
||||
commonGroupSource);
|
||||
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String requestId = UUID.randomUUID().toString();
|
||||
try {
|
||||
if (getLock(requestId)) {
|
||||
if (null != groupReuseSource && null != groupReuseSource.getGroupReuseList()
|
||||
&& groupReuseSource.getGroupReuseList().size() > 0) {
|
||||
checkOpAction(thread, System.currentTimeMillis() - start, groupReuseSource.getOpAction(),
|
||||
if (null != commonGroupSource && null != commonGroupSource.getCommonGroupList()
|
||||
&& commonGroupSource.getCommonGroupList().size() > 0) {
|
||||
checkOpAction(thread, System.currentTimeMillis() - start, commonGroupSource.getOpAction(),
|
||||
Constants.OPACTION_POST);
|
||||
// 验证配置编译数据
|
||||
validateGroupReuseSource(thread, start, groupReuseSource);
|
||||
configSourcesService.addGroupReuseSources(thread, start, groupReuseSource.getGroupReuseList(), sb);
|
||||
validateCommonGroupSource(thread, start, commonGroupSource);
|
||||
configSourcesService.updateRegionToCommonGroup(thread, start,
|
||||
commonGroupSource.getCommonGroupList(), sb, true);
|
||||
} else {
|
||||
throw new RestServiceException("Maat规则不能为空", RestBusinessCode.ConfigSourceIsNull.getValue());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
thread.setExceptionInfo("Maat 分组复用规则存储异常:" + ExceptionUtil.getExceptionMsg(e));
|
||||
logger.error("Maat 分组复用规则存储异常:" + ExceptionUtil.getExceptionMsg(e));
|
||||
String errorTitle = "MAAT公共组新增域配置异常:";
|
||||
thread.setExceptionInfo(errorTitle + ExceptionUtil.getExceptionMsg(e));
|
||||
logger.error(errorTitle + ExceptionUtil.getExceptionMsg(e));
|
||||
if (e instanceof RestServiceException) {
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
||||
"Maat 分组复用规则存储异常:" + ExceptionUtil.getExceptionMsg(e),
|
||||
((RestServiceException) e).getErrorCode());
|
||||
errorTitle + ExceptionUtil.getExceptionMsg(e), ((RestServiceException) e).getErrorCode());
|
||||
} else if (e instanceof ServiceRuntimeException) {
|
||||
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
||||
"Maat 分组复用规则存储异常:" + ExceptionUtil.getExceptionMsg(e),
|
||||
((ServiceRuntimeException) e).getErrorCode());
|
||||
errorTitle + ExceptionUtil.getExceptionMsg(e), ((ServiceRuntimeException) e).getErrorCode());
|
||||
} else {
|
||||
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
||||
"Maat 分组复用规则存储异常:" + ExceptionUtil.getExceptionMsg(e),
|
||||
errorTitle + ExceptionUtil.getExceptionMsg(e),
|
||||
RestBusinessCode.service_runtime_error.getValue());
|
||||
}
|
||||
|
||||
@@ -521,30 +519,30 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
}
|
||||
|
||||
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
|
||||
"Maat分组复用规则添加成功" + sb.toString(), Constants.IS_DEBUG ? groupReuseSource : null);
|
||||
"MAAT公共组新增域配置成功" + sb.toString(), Constants.IS_DEBUG ? commonGroupSource : null);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/cfg/v1/groupReuseSources", method = RequestMethod.PUT)
|
||||
@ApiOperation(value = "分组复用域配置删除接口", httpMethod = "PUT", response = Map.class, notes = "接收分组复用域配置,并从对应分组中删除")
|
||||
@ApiParam(value = "分组复用域配置对象", name = "groupReuseSource", required = true)
|
||||
public Map delGroupReuseSources(@RequestBody GroupReuseSource groupReuseSource, HttpServletRequest request,
|
||||
@RequestMapping(value = "/cfg/v1/updateRegionToCommonGroup", method = RequestMethod.PUT)
|
||||
@ApiOperation(value = "MAAT公共组修改域配置接口", httpMethod = "PUT", response = Map.class, notes = "界面在删除公共组中的域或者修改公共组中的域时,需要将该组下所有的域下发过来,后台会删除老的域,并将新的域添加到该组下")
|
||||
@ApiParam(value = "公共组对象", name = "commonGroupSource", required = true)
|
||||
public Map updateRegionToCommonGroup(@RequestBody CommonGroupSource commonGroupSource, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
long start = System.currentTimeMillis();
|
||||
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request,
|
||||
groupReuseSource);
|
||||
commonGroupSource);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String requestId = UUID.randomUUID().toString();
|
||||
try {
|
||||
if (getLock(requestId)) {
|
||||
if (null == groupReuseSource.getOpTime()) {
|
||||
groupReuseSource.setOpTime(new Date());
|
||||
if (null == commonGroupSource.getOpTime()) {
|
||||
commonGroupSource.setOpTime(new Date());
|
||||
}
|
||||
if (null != groupReuseSource && null != groupReuseSource.getGroupReuseList()
|
||||
&& groupReuseSource.getGroupReuseList().size() > 0) {
|
||||
int opAction = groupReuseSource.getOpAction();
|
||||
if (null != commonGroupSource && null != commonGroupSource.getCommonGroupList()
|
||||
&& commonGroupSource.getCommonGroupList().size() > 0) {
|
||||
int opAction = commonGroupSource.getOpAction();
|
||||
checkOpAction(thread, System.currentTimeMillis() - start, opAction, 2);
|
||||
configSourcesService.deleteGroupReuseSources(thread, start, groupReuseSource.getGroupReuseList(),
|
||||
groupReuseSource.getOpTime(), sb);
|
||||
configSourcesService.updateRegionToCommonGroup(thread, start,
|
||||
commonGroupSource.getCommonGroupList(), sb, false);
|
||||
|
||||
} else {
|
||||
throw new RestServiceException("分组复用信息不能为空" + sb.toString(),
|
||||
@@ -552,20 +550,18 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
thread.setExceptionInfo("MAAT规则状态更新时出现异常:" + ExceptionUtil.getExceptionMsg(e));
|
||||
logger.error("删除MAAT规则分组复用域配置时出现异常:" + ExceptionUtil.getExceptionMsg(e));
|
||||
String errorTitle = "MAAT公共组修改域配置时出现异常:";
|
||||
thread.setExceptionInfo(errorTitle + ExceptionUtil.getExceptionMsg(e));
|
||||
logger.error(errorTitle + ExceptionUtil.getExceptionMsg(e));
|
||||
if (e instanceof RestServiceException) {
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
||||
"删除MAAT规则分组复用域配置时出现异常:" + ExceptionUtil.getExceptionMsg(e),
|
||||
((RestServiceException) e).getErrorCode());
|
||||
errorTitle + ExceptionUtil.getExceptionMsg(e), ((RestServiceException) e).getErrorCode());
|
||||
} else if (e instanceof ServiceRuntimeException) {
|
||||
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
||||
"删除MAAT规则分组复用域配置时出现异常:" + ExceptionUtil.getExceptionMsg(e),
|
||||
((ServiceRuntimeException) e).getErrorCode());
|
||||
errorTitle + ExceptionUtil.getExceptionMsg(e), ((ServiceRuntimeException) e).getErrorCode());
|
||||
} else {
|
||||
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
||||
"删除MAAT规则分组复用域配置时出现异常:" + ExceptionUtil.getExceptionMsg(e),
|
||||
errorTitle + ExceptionUtil.getExceptionMsg(e),
|
||||
RestBusinessCode.service_runtime_error.getValue());
|
||||
}
|
||||
} finally {
|
||||
@@ -573,7 +569,57 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
}
|
||||
|
||||
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
|
||||
"MAAT规则分组复用域配置删除成功" + sb.toString(), Constants.IS_DEBUG ? groupReuseSource : null);
|
||||
"MAAT公共组修改域配置成功" + sb.toString(), Constants.IS_DEBUG ? commonGroupSource : null);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/cfg/v1/delCommonGroup", method = RequestMethod.PUT)
|
||||
@ApiOperation(value = "MAAT公共组修改域配置接口", httpMethod = "PUT", response = Map.class, notes = "界面在删除公共组中的域或者修改公共组中的域时,需要将该组下所有的域下发过来,后台会删除老的域,并将新的域添加到该组下")
|
||||
@ApiParam(value = "公共组对象", name = "commonGroupSource", required = true)
|
||||
public Map delCommonGroup(@RequestBody CommonGroupSource commonGroupSource, HttpServletRequest request,
|
||||
HttpServletResponse response) {
|
||||
long start = System.currentTimeMillis();
|
||||
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request,
|
||||
commonGroupSource);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
String requestId = UUID.randomUUID().toString();
|
||||
try {
|
||||
if (getLock(requestId)) {
|
||||
if (null == commonGroupSource.getOpTime()) {
|
||||
commonGroupSource.setOpTime(new Date());
|
||||
}
|
||||
if (null != commonGroupSource && null != commonGroupSource.getCommonGroupList()
|
||||
&& commonGroupSource.getCommonGroupList().size() > 0) {
|
||||
int opAction = commonGroupSource.getOpAction();
|
||||
checkOpAction(thread, System.currentTimeMillis() - start, opAction, 2);
|
||||
// configSourcesService.deleteGroupReuseSources(thread, start, commonGroupSource.getCommonGroupList(),
|
||||
// commonGroupSource.getOpTime(), sb);
|
||||
|
||||
} else {
|
||||
throw new RestServiceException("分组复用信息不能为空" + sb.toString(),
|
||||
RestBusinessCode.ConfigSourceIsNull.getValue());
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
String errorTitle = "MAAT公共组修改域配置时出现异常:";
|
||||
thread.setExceptionInfo(errorTitle + ExceptionUtil.getExceptionMsg(e));
|
||||
logger.error(errorTitle + ExceptionUtil.getExceptionMsg(e));
|
||||
if (e instanceof RestServiceException) {
|
||||
throw new RestServiceException(thread, System.currentTimeMillis() - start,
|
||||
errorTitle + ExceptionUtil.getExceptionMsg(e), ((RestServiceException) e).getErrorCode());
|
||||
} else if (e instanceof ServiceRuntimeException) {
|
||||
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
||||
errorTitle + ExceptionUtil.getExceptionMsg(e), ((ServiceRuntimeException) e).getErrorCode());
|
||||
} else {
|
||||
throw new ServiceRuntimeException(thread, System.currentTimeMillis() - start,
|
||||
errorTitle + ExceptionUtil.getExceptionMsg(e),
|
||||
RestBusinessCode.service_runtime_error.getValue());
|
||||
}
|
||||
} finally {
|
||||
deblocking(requestId);
|
||||
}
|
||||
|
||||
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
|
||||
"MAAT公共组修改域配置成功" + sb.toString(), Constants.IS_DEBUG ? commonGroupSource : null);
|
||||
}
|
||||
|
||||
@RequestMapping(value = "/cfg/v1/getAllKVByCompileId", method = RequestMethod.GET)
|
||||
@@ -597,10 +643,10 @@ public class ConfigSourcesController extends BaseRestController {
|
||||
"根据配置id获取对应的编译,组,域等信息成功", map);
|
||||
}
|
||||
|
||||
private void validateGroupReuseSource(AuditLogThread thread, long start, GroupReuseSource groupReuseSource) {
|
||||
private void validateCommonGroupSource(AuditLogThread thread, long start, CommonGroupSource groupReuseSource) {
|
||||
String errorInfo = "";
|
||||
|
||||
List<GroupReuse> groupReuseSourceList = groupReuseSource.getGroupReuseList();
|
||||
List<CommonGroup> groupReuseSourceList = groupReuseSource.getCommonGroupList();
|
||||
|
||||
if (StringUtils.isEmpty(groupReuseSource.getOperator())) {
|
||||
errorInfo = "get operator is Empty";
|
||||
|
||||
@@ -179,7 +179,8 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
/**
|
||||
* 下发配置时,需要记录编译,组,域等配置id的对应关系,以便于在取消配置时可以根据配置id查找对应的编译,分组,域的关系
|
||||
*/
|
||||
private void addMaatRelation(Map<Integer, List<MaatConfig>> configMap, Transaction transaction) {
|
||||
private void addMaatRelation(Map<Integer, List<MaatConfig>> configMap, Transaction transaction,
|
||||
List<Long> commonGroupIdList) {
|
||||
if (configMap != null && configMap.size() > 0) {
|
||||
int idRelaRedisDBIndex = Configurations.getIntProperty("idRelaRedisDBIndex", 15);
|
||||
transaction.select(idRelaRedisDBIndex);
|
||||
@@ -221,7 +222,8 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
/**
|
||||
* 添加组和域的关联关系信息
|
||||
*/
|
||||
addGroupRegionReal(maatConfig, transaction, redisDBSetStr, idRelaRedisDBIndex);
|
||||
addGroupRegionReal(maatConfig, transaction, redisDBSetStr, idRelaRedisDBIndex,
|
||||
commonGroupIdList);
|
||||
}
|
||||
for (String compile : compileAndGroupMap.keySet()) {
|
||||
List<String> list = compileAndGroupMap.get(compile);
|
||||
@@ -385,9 +387,9 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
* @param regionMapList
|
||||
* @param compileAndGroupRelations
|
||||
*/
|
||||
private Map<String, List<String>> addGroupAndRegionRelations(MaatXmlConfig maatXmlConfig, int service, int type,
|
||||
List<Map<String, String>> regionMapList, Map<String, List<String>> groupAndRegionMap,
|
||||
String redisDBSetStr) {
|
||||
private Map<String, Set<String>> addGroupAndRegionRelations(MaatXmlConfig maatXmlConfig, int service, int type,
|
||||
List<Map<String, String>> regionMapList, Map<String, Set<String>> groupAndRegionMap, String redisDBSetStr,
|
||||
List<Long> commonGroupIdList) {
|
||||
if (regionMapList != null && regionMapList.size() > 0) {
|
||||
for (Map<String, String> map : regionMapList) {
|
||||
List<MaatXmlExpr> expressionList = maatXmlConfig.getExpressionList();
|
||||
@@ -424,14 +426,22 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
break;
|
||||
}
|
||||
}
|
||||
String groupIdStr = "GROUPREGION:" + map.get("group_id");// groupregion里面value是region的信息,key是group的信息
|
||||
// commonGroupIdList
|
||||
Long groupId = Long.parseLong(map.get("group_id"));
|
||||
|
||||
String groupIdStr = "GROUPREGION:" + groupId;// groupregion里面value是region的信息,key是group的信息
|
||||
if (commonGroupIdList.contains(groupId)) {
|
||||
groupIdStr = "COMMONGROUPREGION:" + groupId;
|
||||
}
|
||||
|
||||
if (groupAndRegionMap.containsKey(groupIdStr.toUpperCase())) {
|
||||
groupAndRegionMap.get(groupIdStr.toUpperCase()).add(maatKey.toUpperCase() + redisDBSetStr);
|
||||
} else {
|
||||
List<String> list = new ArrayList<String>();
|
||||
Set<String> list = new HashSet<String>();
|
||||
list.add(maatKey.toUpperCase() + redisDBSetStr);
|
||||
groupAndRegionMap.put(groupIdStr.toUpperCase(), list);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return groupAndRegionMap;
|
||||
@@ -471,10 +481,19 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
setConfig(maatConfig, maatXmlConfig, maatVersion, service, transaction,
|
||||
redisDBIndex, commonGroupIdList);
|
||||
}
|
||||
if (commonGroupIdList != null && commonGroupIdList.size() > 0) {
|
||||
for (String db : Constants.COMMONGROUPDBARR) {
|
||||
transaction.select(Integer.parseInt(db));
|
||||
transaction.incrBy("MAAT_VERSION", 1l);
|
||||
logger.info("向{}号redis数据库更新了MAAT_VERSION", Integer.parseInt(db));
|
||||
}
|
||||
} else {
|
||||
transaction.select(redisDBIndex);
|
||||
transaction.incrBy("MAAT_VERSION", 1l);
|
||||
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDBIndex,
|
||||
Integer.valueOf(maatVersionStr) + 1);
|
||||
}
|
||||
|
||||
transaction.incrBy("MAAT_VERSION", 1l);
|
||||
logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDBIndex,
|
||||
Integer.valueOf(maatVersionStr) + 1);
|
||||
count++;
|
||||
} else {
|
||||
throw new ServiceRuntimeException(
|
||||
@@ -488,7 +507,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
}
|
||||
}
|
||||
if (count == configMap.size()) {
|
||||
addMaatRelation(configMap, transaction);
|
||||
addMaatRelation(configMap, transaction, commonGroupIdList);
|
||||
addStatisticsReal(configMap, transaction);
|
||||
transaction.exec();
|
||||
return true;
|
||||
@@ -1082,6 +1101,9 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
private void removeConfig(Long id, MaatXmlConfig maatXmlConfig, Double maatVersion, int service,
|
||||
Transaction transaction, int redisDBIndex, int idRelaRedisDBIndex, boolean isStart,
|
||||
List<Long> keepGroupId) {
|
||||
|
||||
Map<String, Boolean> groupIsCommonMap = new HashMap<>();
|
||||
|
||||
if (maatXmlConfig != null) {
|
||||
Map<String, String> keyMap = new HashMap<>();
|
||||
// 删除(重命名)编译配置
|
||||
@@ -1110,9 +1132,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
} else {
|
||||
groupCompileAndDBStrs = keyMap.get(groupId);
|
||||
}
|
||||
|
||||
String groupIdReal = groupId.replace("GROUPCOMPILE:", "");
|
||||
|
||||
String[] compileGroupArr = org.apache.commons.lang.StringUtils
|
||||
.split(groupCompileAndDBStrs, ";");// 获取组对应的编译id,示例:
|
||||
// ;COMPILEGROUP:24070-2, 5
|
||||
@@ -1120,49 +1140,68 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
if (groupAndCompileStr != null && !groupAndCompileStr.trim().equals("")) {
|
||||
String compileId = getRegionInfo(groupAndCompileStr);// COMPILEGROUP:24070
|
||||
if (compileId != null && !compileId.trim().equals("")) {
|
||||
|
||||
if (isStart || (keepGroupId != null && keepGroupId.size() > 0
|
||||
&& !keepGroupId.contains(Long.parseLong(groupIdReal)))) {// 如果是修改为生效则置为生效,如果是失效如果包含保留的group,则不将域置为失效,否则将域置为失效,否
|
||||
// if (!ServiceAndRDBIndexReal.serviceIsReuse(service)) {// 如果当前业务不允许被分组复用(普通的maat类配置),则可以将域置为失效,否则不将域置为失效
|
||||
// 如果只有一个编译id且与上面的编译id相同则说明未被分组复用,可以将其下的所有域置失效,否则不处理域配置,只把编译,分组关系置为无效
|
||||
if (compileId.equals(compileStr)) {//
|
||||
String groupRegionKey = groupId.replace("GROUPCOMPILE",
|
||||
"GROUPREGION");// groupregion里面value是region的信息,key是group的信息,所以可以直接将GROUPCOMPILE替换为GROUPREGION
|
||||
String regionStrs = null;
|
||||
if (!keyMap.containsKey(groupRegionKey)) {
|
||||
regionStrs = JedisUtils.get(groupRegionKey,
|
||||
idRelaRedisDBIndex);
|
||||
keyMap.put(groupRegionKey, regionStrs);
|
||||
} else {
|
||||
regionStrs = keyMap.get(groupRegionKey);
|
||||
}
|
||||
if (regionStrs != null && !regionStrs.trim().equals("")) {
|
||||
String[] regionStrArr = regionStrs.split(";");
|
||||
for (String str : regionStrArr) {
|
||||
if (str != null && !str.trim().equals("")) {
|
||||
boolean isCommonGroup = false;
|
||||
if (isStart) {
|
||||
String commonGroupRegionKey = groupId
|
||||
.replace("GROUPCOMPILE", "COMMONGROUPREGION");// groupregion里面value是region的信息,key是group的信息,所以可以直接将GROUPCOMPILE替换为GROUPREGION
|
||||
if (!groupIsCommonMap.containsKey(commonGroupRegionKey)) {
|
||||
boolean exist = JedisUtils.exists(commonGroupRegionKey,
|
||||
idRelaRedisDBIndex);
|
||||
groupIsCommonMap.put(commonGroupRegionKey, exist);
|
||||
if (exist) {
|
||||
isCommonGroup = true;
|
||||
}
|
||||
|
||||
String regionStr = getRegionInfo(str);
|
||||
if (regionStr != null
|
||||
&& !regionStr.trim().equals("")) {
|
||||
String[] regionKeyArr = regionStr.split(";");
|
||||
if (regionKeyArr != null
|
||||
&& regionKeyArr.length > 0) {
|
||||
// 根据分组与域关联关系找到对应域配置然后删除(重命名)
|
||||
removeRegionConfig(maatXmlConfig,
|
||||
regionKeyArr, maatVersion, service,
|
||||
transaction, redisDBIndex, isStart);
|
||||
} else {
|
||||
isCommonGroup = groupIsCommonMap
|
||||
.get(commonGroupRegionKey);
|
||||
}
|
||||
}
|
||||
if (!isCommonGroup) {// 如果是公共组则不进行操作,因为公共组本来就是有效的
|
||||
String regionStrs = null;
|
||||
if (!keyMap.containsKey(groupRegionKey)) {
|
||||
regionStrs = JedisUtils.get(groupRegionKey,
|
||||
idRelaRedisDBIndex);
|
||||
keyMap.put(groupRegionKey, regionStrs);
|
||||
} else {
|
||||
regionStrs = keyMap.get(groupRegionKey);
|
||||
}
|
||||
if (regionStrs != null && !regionStrs.trim().equals("")) {
|
||||
String[] regionStrArr = regionStrs.split(";");
|
||||
for (String str : regionStrArr) {
|
||||
if (str != null && !str.trim().equals("")) {
|
||||
|
||||
String regionStr = getRegionInfo(str);
|
||||
if (regionStr != null
|
||||
&& !regionStr.trim().equals("")) {
|
||||
String[] regionKeyArr = regionStr
|
||||
.split(";");
|
||||
if (regionKeyArr != null
|
||||
&& regionKeyArr.length > 0) {
|
||||
// 根据分组与域关联关系找到对应域配置然后删除(重命名)
|
||||
removeRegionConfig(maatXmlConfig,
|
||||
regionKeyArr, maatVersion,
|
||||
service, transaction,
|
||||
redisDBIndex, isStart);
|
||||
}
|
||||
} else {
|
||||
throw new ServiceRuntimeException("从"
|
||||
+ idRelaRedisDBIndex
|
||||
+ "号redis库中无法获取MAAT配置分组与域的关联关系,key为"
|
||||
+ groupRegionKey,
|
||||
RestBusinessCode.KeyNotExistsInRedis
|
||||
.getValue());
|
||||
}
|
||||
} else {
|
||||
throw new ServiceRuntimeException("从"
|
||||
+ idRelaRedisDBIndex
|
||||
+ "号redis库中无法获取MAAT配置分组与域的关联关系,key为"
|
||||
+ groupRegionKey,
|
||||
RestBusinessCode.KeyNotExistsInRedis
|
||||
.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// }
|
||||
}
|
||||
}
|
||||
// 根据分组与编译关联关系找到对应分组配置然后删除(重命名)
|
||||
@@ -1426,16 +1465,38 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
.split(compileGroupStr, ";");
|
||||
// 被分组复用的业务,不能将域置为失效,其分组关系也不置为失效
|
||||
|
||||
// if (!ServiceAndRDBIndexReal.serviceIsReuse(service)) {// 如果当前业务不允许被分组复用(普通的maat类配置),则可以将域置为失效,否则不将域置为失效
|
||||
|
||||
if (compileGroupStrSplit[0].toUpperCase()
|
||||
.equals(compileStr.toUpperCase())) {
|
||||
String groupRegion = groupCompile.replace("GROUPCOMPILE",
|
||||
"GROUPREGION");// groupregion里面value是region的信息,key是group的信息,所以可以直接将GROUPCOMPILE替换为GROUPREGION
|
||||
// String commonGroupRegion = groupCompile.replace("GROUPCOMPILE",
|
||||
// "COMMONGROUPREGION");// groupregion里面value是region的信息,key是group的信息,所以可以直接将GROUPCOMPILE替换为GROUPREGION
|
||||
|
||||
String groupRegionVal = JedisUtils.get(groupRegion,
|
||||
idRelaRedisDBIndex);
|
||||
|
||||
if (groupRegionVal == null
|
||||
|| groupRegionVal.trim().equals("")) {// 如果从普通的组中无法获,取则尝试下获取公共组
|
||||
|
||||
groupRegion = groupCompile.replace("GROUPCOMPILE",
|
||||
"COMMONGROUPREGION");
|
||||
|
||||
groupRegionVal = JedisUtils.get(groupRegion,
|
||||
idRelaRedisDBIndex);
|
||||
break;
|
||||
}
|
||||
if (groupRegionVal == null
|
||||
|| groupRegionVal.trim().equals("")) {// 如果普通的组和公共组都无法获取则给出错误提示
|
||||
throw new ServiceRuntimeException("从" + idRelaRedisDBIndex
|
||||
+ "号redis库中无法获取"
|
||||
+ groupCompile.replace("GROUPCOMPILE",
|
||||
"COMMONGROUPREGION")
|
||||
+ "和"
|
||||
+ groupCompile.replace("GROUPCOMPILE",
|
||||
"GROUPREGION")
|
||||
+ ",请检查groupid是否正确,或联系开发人员检查删除redis数据是否被人为删除了",
|
||||
RestBusinessCode.KeyNotExistsInRedis.getValue());
|
||||
}
|
||||
try {
|
||||
// 为了提高效率,不判断了,如果报错直接捕捉异常处理
|
||||
// 删除分组与域的关联关系
|
||||
@@ -1675,11 +1736,161 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
}
|
||||
}
|
||||
|
||||
private void addTmpReion(List<Map<String, String>> regionMapList, MaatXmlExpr maatXmlExpr, Transaction transaction,
|
||||
int type, int tmpStorageReuseRegionDB, int idRelaRedisDBIndex, List<MaatXmlExpr> expressionList,
|
||||
private void addReionToCommonGroup(List<Map<String, String>> regionMapList, MaatXmlExpr maatXmlExpr,
|
||||
Transaction transaction, int type, int idRelaRedisDBIndex, List<MaatXmlExpr> expressionList, boolean isAdd)
|
||||
throws Exception {
|
||||
Set<Long> groupIdSet = new HashSet<>();
|
||||
Map<Integer, Double> dbVersionMap = new HashMap<>();// 记录所有redisdb的maatversion,避免每次查询影响性能
|
||||
if (regionMapList != null && regionMapList.size() > 0) {
|
||||
String[] keySplit = maatXmlExpr.getKeyExpression().split(";");
|
||||
|
||||
for (Map<String, String> map : regionMapList) {
|
||||
String maatKey = null;
|
||||
StringBuffer keyBF = new StringBuffer();
|
||||
for (String keyStr : keySplit) {
|
||||
if (!StringUtils.isEmpty(keyStr) && keyStr.trim().startsWith("[")) {
|
||||
keyStr = keyStr.trim().replace("[", "").replace("]", "");
|
||||
String keyVal = map.get(keyStr);
|
||||
if (keyVal != null && !keyVal.equals("")) {
|
||||
keyBF.append(keyVal);
|
||||
} else {
|
||||
throw new ServiceRuntimeException("未从map中获取到" + keyStr + "的值,请检查数据或配置文件是否正确",
|
||||
RestBusinessCode.NotFoundValueByKey.getValue());
|
||||
}
|
||||
} else if (!StringUtils.isEmpty(keyStr) && keyStr.trim().startsWith("{")) {
|
||||
keyStr = keyStr.trim().replace("{", "").replace("}", "");
|
||||
if (keyStr.toLowerCase().contains("table_name")) {
|
||||
String argTableName = map.get("table_name");
|
||||
if (argTableName == null) {
|
||||
throw new ServiceRuntimeException("添加分组复用域配置时,必须要传入表名,请检查参数,配置类型:" + type + ",对应的真实表名",
|
||||
RestBusinessCode.NotFoundTableName.getValue());
|
||||
} else {
|
||||
keyBF.append(argTableName);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
keyBF.append(keyStr.trim());
|
||||
}
|
||||
}
|
||||
String groupId = null;
|
||||
StringBuffer valBF = new StringBuffer();
|
||||
String[] valSplit = maatXmlExpr.getValueExpression().split(";");
|
||||
for (String valStr : valSplit) {
|
||||
if (!StringUtils.isEmpty(valStr) && valStr.trim().startsWith("[")) {
|
||||
valStr = valStr.trim().replace("[", "").replace("]", "");
|
||||
if (valStr.toLowerCase().equals("op_time") && type == 12) {
|
||||
String user_region = map.get("user_region");
|
||||
valBF.append(user_region + "\t");
|
||||
}
|
||||
String val = map.get(valStr);
|
||||
if (val != null) {
|
||||
valBF.append(val);
|
||||
if (valStr.equals("group_id")) {
|
||||
groupId = val;
|
||||
}
|
||||
} else {
|
||||
// 所有在maat.xml中配置的属性都不可以为空
|
||||
throw new ServiceRuntimeException("未从map中获取到" + valStr + "的值,无法拼接redisValue,请检查数据或配置文件是否正确",
|
||||
RestBusinessCode.NotFoundValueByKey.getValue());
|
||||
}
|
||||
} else if (valStr.equals(" ")) {
|
||||
valBF.append(" ");
|
||||
} else if (valStr.equals("\\t")) {// xml中是字符串的\t这里判断的时候需要转义为\\t,但是添加的时候需要添加\t不是\\t
|
||||
valBF.append("\t");
|
||||
} else if (valStr.equals("\\n")) {
|
||||
valBF.append("\n");
|
||||
} else {
|
||||
valBF.append(valStr.trim());
|
||||
}
|
||||
}
|
||||
|
||||
for (String db : Constants.COMMONGROUPDBARR) {
|
||||
// 将域配置下发到每个db中,并更新MAAT_UPDATE_STATUS等信息
|
||||
int everyDb = Integer.parseInt(db);
|
||||
transaction.select(everyDb);
|
||||
maatKey = keyBF.toString();
|
||||
transaction.set(maatKey.toUpperCase(), valBF.toString());
|
||||
logger.info("向{}号redis数据库添加了一条配置,key是{},value是{}", everyDb, maatKey.toUpperCase(),
|
||||
valBF.toString());
|
||||
|
||||
Double maatVersion = null;
|
||||
if (!dbVersionMap.containsKey(everyDb)) {
|
||||
String maatVersionStr = JedisUtils.get("MAAT_VERSION", everyDb);
|
||||
if (maatVersionStr == null) {
|
||||
maatVersionStr = "0";
|
||||
}
|
||||
maatVersion = Double.valueOf(maatVersionStr) + 1D;
|
||||
dbVersionMap.put(everyDb, maatVersion);
|
||||
} else {
|
||||
maatVersion = dbVersionMap.get(everyDb);
|
||||
}
|
||||
updateMaatInfo(expressionList, maatKey, transaction, maatVersion, everyDb, false);
|
||||
}
|
||||
groupIdSet.add(Long.parseLong(groupId));
|
||||
String groupRegionStr = "COMMONGROUPREGION:" + groupId;
|
||||
transaction.select(idRelaRedisDBIndex);
|
||||
if (!isAdd) {
|
||||
transaction.del(groupRegionStr);
|
||||
}
|
||||
// 更新组与域的关系
|
||||
transaction.append(groupRegionStr, ";" + maatKey.toUpperCase() + "-" + Constants.COMMONGROUPDBARR[0]);// redisdb随便写一个即可,实际每个库都下发了
|
||||
|
||||
}
|
||||
if (!isAdd) {
|
||||
|
||||
Map<String, String> keyMap = new HashMap<>();// 记录15号库中的COMPILEGROUP,GROUPCOMPILE,避免每次去redis中查询,影响性能
|
||||
for (Long groupId : groupIdSet) {
|
||||
String groupRegionStr = "COMMONGROUPREGION:" + groupId;
|
||||
String regionVal = null;
|
||||
if (!keyMap.containsKey(groupRegionStr)) {
|
||||
regionVal = JedisUtils.get(groupRegionStr, idRelaRedisDBIndex);
|
||||
keyMap.put(groupRegionStr, regionVal);
|
||||
} else {
|
||||
regionVal = keyMap.get(groupRegionStr);
|
||||
}
|
||||
|
||||
String[] commonsplit = org.apache.commons.lang.StringUtils.split(regionVal, ";");
|
||||
for (String regionKey : commonsplit) {
|
||||
String maatKey = regionKey.substring(0, regionKey.indexOf("-"));
|
||||
for (String db : Constants.COMMONGROUPDBARR) {
|
||||
int everyDb = Integer.parseInt(db);
|
||||
transaction.select(everyDb);
|
||||
String obsoleteKey = maatKey.replace("EFFECTIVE_RULE", "OBSOLETE_RULE");
|
||||
transaction.rename(maatKey, obsoleteKey);
|
||||
Double maatVersion = dbVersionMap.get(everyDb);
|
||||
updateMaatInfo(expressionList, obsoleteKey, transaction, maatVersion, everyDb, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// for (String db : Constants.COMMONGROUPDBARR) {
|
||||
// int everyDb = Integer.parseInt(db);
|
||||
// transaction.select(everyDb);
|
||||
// for (String commonGroupKey : keyMap.keySet()) {
|
||||
// String[] commonsplit = org.apache.commons.lang.StringUtils.split(keyMap.get(commonGroupKey),
|
||||
// ";");
|
||||
// for (String regionKey : commonsplit) {
|
||||
// String maatKey = regionKey.substring(0, regionKey.indexOf("-"));
|
||||
// try {
|
||||
// transaction.del(maatKey);
|
||||
// } catch (Exception e) {
|
||||
// logger.error("公共组:{}中的域配置:{}在{}号db中找不到,请联系开发人员检查业务逻辑是否正确,失败原因:{}", commonGroupKey,
|
||||
// maatKey, everyDb, ExceptionUtil.getExceptionMsg(e));
|
||||
// }
|
||||
// Double maatVersion = dbVersionMap.get(everyDb);
|
||||
// updateMaatInfo(expressionList, maatKey, transaction, maatVersion, everyDb, false);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addTmpReionold(List<Map<String, String>> regionMapList, MaatXmlExpr maatXmlExpr,
|
||||
Transaction transaction, int type, int idRelaRedisDBIndex, List<MaatXmlExpr> expressionList,
|
||||
Set<Integer> redisDB) throws Exception {
|
||||
Map<String, String> keyMap = new HashMap<>();
|
||||
Map<Integer, Double> dbVersionMap = new HashMap<>();
|
||||
Map<String, String> keyMap = new HashMap<>();// 记录15号库中的COMPILEGROUP,GROUPCOMPILE,避免每次去redis中查询,影响性能
|
||||
Map<Integer, Double> dbVersionMap = new HashMap<>();// 记录每个redisdb中的maat_version,避免每次去redis中查询,影响性能
|
||||
if (regionMapList != null && regionMapList.size() > 0) {
|
||||
String[] keySplit = maatXmlExpr.getKeyExpression().split(";");
|
||||
for (Map<String, String> map : regionMapList) {
|
||||
@@ -1742,11 +1953,13 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
}
|
||||
}
|
||||
|
||||
transaction.select(tmpStorageReuseRegionDB);
|
||||
maatKey = keyBF.toString();
|
||||
transaction.set(maatKey.toUpperCase(), valBF.toString());
|
||||
logger.info("向{}号redis数据库添加了一条配置,key是{},value是{}", tmpStorageReuseRegionDB, maatKey.toUpperCase(),
|
||||
valBF.toString());
|
||||
//
|
||||
//
|
||||
// transaction.select(tmpStorageReuseRegionDB);
|
||||
// maatKey = keyBF.toString();
|
||||
// transaction.set(maatKey.toUpperCase(), valBF.toString());
|
||||
// logger.info("向{}号redis数据库添加了一条配置,key是{},value是{}", tmpStorageReuseRegionDB, maatKey.toUpperCase(),
|
||||
// valBF.toString());
|
||||
|
||||
String groupIdStr = "GROUPCOMPILE:" + groupId;
|
||||
String groupCompileVal = null;
|
||||
@@ -1806,19 +2019,13 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 单独添加域时,先判断下当前组是否被使用了(是否有对应的编译),如果被使用了则分发到所有编译在的redisdb里,
|
||||
* 如果没有被使用则先存储在临时库里面,后面下发编译时使用到了该分组再把该分组下的所有域复制到编译下面
|
||||
*/
|
||||
@Override
|
||||
public boolean updateGroupRegion(List<MaatConfig> configList) {
|
||||
public boolean updateGroupRegion(List<MaatConfig> configList, boolean isAdd) {
|
||||
Jedis resource = JedisUtils.getResource(0);
|
||||
Transaction transaction = resource.multi();
|
||||
try {
|
||||
if (configList != null && configList.size() > 0) {
|
||||
int tmpStorageReuseRegionDB = Configurations.getIntProperty("tmpStorageReuseRegionDB", 15);
|
||||
int idRelaRedisDBIndex = Configurations.getIntProperty("idRelaRedisDBIndex", 15);
|
||||
transaction.select(tmpStorageReuseRegionDB);
|
||||
MaatXmlConfig maatXmlConfig = ReadMaatXmlUtil.getMaatConfigByService(37);// maat类配置的表达式都一样,这里因为没有service所以就随便取了一个
|
||||
MaatXmlExpr maatXmlExpr12 = null;
|
||||
MaatXmlExpr maatXmlExpr13 = null;
|
||||
@@ -1836,19 +2043,19 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
}
|
||||
}
|
||||
}
|
||||
Set<Integer> redisDB = new HashSet<Integer>();
|
||||
|
||||
for (MaatConfig maatConfig : configList) {
|
||||
addTmpReion(maatConfig.getIpRegionMapList(), maatXmlExpr12, transaction, 12,
|
||||
tmpStorageReuseRegionDB, idRelaRedisDBIndex, expressionList, redisDB);
|
||||
addTmpReion(maatConfig.getNumRegionMapList(), maatXmlExpr13, transaction, 13,
|
||||
tmpStorageReuseRegionDB, idRelaRedisDBIndex, expressionList, redisDB);
|
||||
addTmpReion(maatConfig.getStrRegionMapList(), maatXmlExpr14, transaction, 14,
|
||||
tmpStorageReuseRegionDB, idRelaRedisDBIndex, expressionList, redisDB);
|
||||
addReionToCommonGroup(maatConfig.getIpRegionMapList(), maatXmlExpr12, transaction, 12,
|
||||
idRelaRedisDBIndex, expressionList, isAdd);
|
||||
addReionToCommonGroup(maatConfig.getNumRegionMapList(), maatXmlExpr13, transaction, 13,
|
||||
idRelaRedisDBIndex, expressionList, isAdd);
|
||||
addReionToCommonGroup(maatConfig.getStrRegionMapList(), maatXmlExpr14, transaction, 14,
|
||||
idRelaRedisDBIndex, expressionList, isAdd);
|
||||
}
|
||||
for (Integer redisDb : redisDB) {
|
||||
transaction.select(redisDb);
|
||||
for (String db : Constants.COMMONGROUPDBARR) {
|
||||
transaction.select(Integer.parseInt(db));
|
||||
transaction.incrBy("MAAT_VERSION", 1l);
|
||||
logger.info("向{}号redis数据库更新了MAAT_VERSION", redisDb);
|
||||
logger.info("向{}号redis数据库更新了MAAT_VERSION", Integer.parseInt(db));
|
||||
// logger.info("向{}号redis数据库更新了MAAT_VERSION,更新后版本是{}", redisDb, maatVersion);
|
||||
}
|
||||
|
||||
@@ -1885,23 +2092,27 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
* @param idRelaRedisDBIndex
|
||||
*/
|
||||
private void addGroupRegionReal(MaatConfig maatConfig, Transaction transaction, String redisDBSetStr,
|
||||
int idRelaRedisDBIndex) {
|
||||
Map<String, List<String>> map = new HashMap<String, List<String>>();
|
||||
int idRelaRedisDBIndex, List<Long> commonGroupIdList) {
|
||||
Map<String, Set<String>> map = new HashMap<String, Set<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, 12, maatConfig.getIpRegionMapList(), map, redisDBSetStr,
|
||||
commonGroupIdList);
|
||||
addGroupAndRegionRelations(maatXmlConfig, service, 13, maatConfig.getNumRegionMapList(), map, redisDBSetStr,
|
||||
commonGroupIdList);
|
||||
addGroupAndRegionRelations(maatXmlConfig, service, 14, maatConfig.getStrRegionMapList(), map, redisDBSetStr,
|
||||
commonGroupIdList);
|
||||
addGroupAndRegionRelations(maatXmlConfig, service, 15, maatConfig.getStrStrRegionMapList(), map, redisDBSetStr,
|
||||
commonGroupIdList);
|
||||
addGroupAndRegionRelations(maatXmlConfig, service, 16, maatConfig.getFileDigestRegionMapList(), map,
|
||||
redisDBSetStr);
|
||||
redisDBSetStr, commonGroupIdList);
|
||||
addGroupAndRegionRelations(maatXmlConfig, service, 17, maatConfig.getFileLikeRegionMapList(), map,
|
||||
redisDBSetStr);
|
||||
addGroupAndRegionRelations(maatXmlConfig, service, 18, maatConfig.getIpClientRangeMapList(), map,
|
||||
redisDBSetStr);
|
||||
redisDBSetStr, commonGroupIdList);
|
||||
addGroupAndRegionRelations(maatXmlConfig, service, 18, maatConfig.getIpClientRangeMapList(), map, redisDBSetStr,
|
||||
commonGroupIdList);
|
||||
|
||||
for (String groupIdStr : map.keySet()) {
|
||||
List<String> list = map.get(groupIdStr);
|
||||
Set<String> list = map.get(groupIdStr);
|
||||
StringBuffer sb = new StringBuffer();
|
||||
if (list != null && list.size() > 0) {
|
||||
for (String regionIdStr : list) {
|
||||
@@ -1931,6 +2142,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
// Boolean serviceIsReuse = ServiceAndRDBIndexReal.serviceIsReuse(service);
|
||||
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) {
|
||||
@@ -2042,6 +2254,7 @@ public class ConfigJedisServiceimpl implements ConfigRedisService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// if (count == 0 && isReuseSaveRegion) {
|
||||
// throw new ServiceRuntimeException("添加分组复用域配置时,所有的域配置都为空,请检查配置参数是否正确",
|
||||
// RestBusinessCode.ConfigSourceIsNull.getValue());
|
||||
|
||||
@@ -40,13 +40,17 @@ public interface ConfigRedisService {
|
||||
public boolean saveMaatConfig(Map<Integer, List<MaatConfig>> configMap,List<Long> commonGroupIdList);
|
||||
|
||||
/**
|
||||
* 该接口用途:界面对某个组下面的域配置进行修改,因为界面没有保存regionid,所以无法准确的去修改某个域配置,因此界面每次都会传过来该组下所有的region,后台根据groupid先将老的region删除,然后在将新的region添加到对应的redisdb中
|
||||
* ,value是配置集合
|
||||
*接口 说明;
|
||||
* 1:界面单独向某个公共组下添加域。
|
||||
* 2:对某个公共组下面的域配置进行修改,因为界面没有保存regionid,所以无法准确的去修改某个域配置,
|
||||
* 因此界面每次都会传过来该组下所有的region,后台根据groupid先将老的region删除,然后在将新的region添加到对应的redisdb中
|
||||
*
|
||||
* @param configList
|
||||
*
|
||||
* @param configList 配置集合
|
||||
* @param isAdd 标志是否是新增域,而不是修改域,修改域需要先删除老配置
|
||||
* @return 成功返回true,失败返回false或抛出异常
|
||||
*/
|
||||
public boolean updateGroupRegion(List<MaatConfig> configList);
|
||||
public boolean updateGroupRegion(List<MaatConfig> configList,boolean isAdd);
|
||||
|
||||
/**
|
||||
* 获取指定key的自增长值
|
||||
|
||||
@@ -22,11 +22,11 @@ import org.springframework.stereotype.Service;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.google.gson.JsonParser;
|
||||
import com.nis.domain.restful.CommonGroup;
|
||||
import com.nis.domain.restful.CommonSourceFieldCfg;
|
||||
import com.nis.domain.restful.ConfigCompile;
|
||||
import com.nis.domain.restful.ConfigGroupRelation;
|
||||
import com.nis.domain.restful.DigestRegion;
|
||||
import com.nis.domain.restful.GroupReuse;
|
||||
import com.nis.domain.restful.IpRegion;
|
||||
import com.nis.domain.restful.MaatConfig;
|
||||
import com.nis.domain.restful.NumRegion;
|
||||
@@ -38,7 +38,6 @@ import com.nis.util.BasicProvingUtil;
|
||||
import com.nis.util.CamelUnderlineUtil;
|
||||
import com.nis.util.CompileVal;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.GroupReuseVal;
|
||||
import com.nis.util.JsonMapper;
|
||||
import com.nis.util.ReadCommSourceXmlUtil;
|
||||
import com.nis.util.ServiceAndRDBIndexReal;
|
||||
@@ -356,7 +355,7 @@ public class ConfigSourcesService extends BaseService {
|
||||
Map<String, String> validIdMap = new HashMap<String, String>();
|
||||
// 在将配置置为失效时,记录需要保留的groupid(哪些组及组下的域不用置为失效)
|
||||
Map<Long, List<Long>> compileGroupMap = new HashMap<Long, List<Long>>();
|
||||
//需要置失效的配置,key是业务类型,value是配置id集合
|
||||
// 需要置失效的配置,key是业务类型,value是配置id集合
|
||||
Map<Integer, List<Long>> compileMap = new HashMap<Integer, List<Long>>();
|
||||
if (null != compileList && compileList.size() > 0) {
|
||||
for (ConfigCompile config : compileList) {
|
||||
@@ -832,7 +831,7 @@ public class ConfigSourcesService extends BaseService {
|
||||
|
||||
/**
|
||||
*
|
||||
* @Description:增加分组复用域配置
|
||||
* @Description:解析界面传过来的公共组数据,校验数据格式,并转化数据格式传到下一层
|
||||
* @author (zdx)
|
||||
* @date 2018年5月25日 下午3:49:46
|
||||
* @param thread
|
||||
@@ -841,13 +840,13 @@ public class ConfigSourcesService extends BaseService {
|
||||
* @param sb
|
||||
* @return
|
||||
*/
|
||||
public void addGroupReuseSources(AuditLogThread thread, long start, List<GroupReuse> groupReuseList,
|
||||
StringBuffer sb) throws Exception {
|
||||
public void updateRegionToCommonGroup(AuditLogThread thread, long start, List<CommonGroup> groupReuseList,
|
||||
StringBuffer sb, boolean isAdd) throws Exception {
|
||||
List<MaatConfig> list = new ArrayList<MaatConfig>();
|
||||
// 验证
|
||||
GroupReuseVal.valGroupReuse(groupReuseList, false);
|
||||
// GroupReuseVal.valGroupReuse(groupReuseList, false);
|
||||
|
||||
for (GroupReuse groupReuse : groupReuseList) {
|
||||
for (CommonGroup groupReuse : groupReuseList) {
|
||||
MaatConfig maatConfig = new MaatConfig();
|
||||
List<Map<String, String>> dstMapList = null;
|
||||
// 字符串域
|
||||
@@ -913,9 +912,12 @@ public class ConfigSourcesService extends BaseService {
|
||||
}
|
||||
|
||||
// 调用接口入redis
|
||||
logger.info("---------------调用Redis 分组复用配置新增接口---------------------");
|
||||
configRedisService.updateGroupRegion(list);
|
||||
// configRedisService.saveGroupReuseConfigByPipeLine(list);
|
||||
logger.info("---------------调用Redis 公共组修改接口---------------------");
|
||||
if (isAdd) {
|
||||
configRedisService.updateGroupRegion(list, true);
|
||||
} else {
|
||||
configRedisService.updateGroupRegion(list, false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -930,14 +932,14 @@ public class ConfigSourcesService extends BaseService {
|
||||
* @param sb
|
||||
* @throws Exception
|
||||
*/
|
||||
public void deleteGroupReuseSources(AuditLogThread thread, long start, List<GroupReuse> groupReuseList, Date opTime,
|
||||
StringBuffer sb) throws Exception {
|
||||
public void deleteGroupReuseSources(AuditLogThread thread, long start, List<CommonGroup> groupReuseList,
|
||||
Date opTime, StringBuffer sb) throws Exception {
|
||||
// Map<groupId,List<"tableName,regionId">
|
||||
Map<Long, List<String>> reuseMap = new HashMap<Long, List<String>>();
|
||||
|
||||
for (GroupReuse groupReuse : groupReuseList) {
|
||||
for (CommonGroup groupReuse : groupReuseList) {
|
||||
// 验证格式
|
||||
checkGroupReuseForUpdate(groupReuse);
|
||||
// checkGroupReuseForUpdate(groupReuse);
|
||||
|
||||
// 字符串域
|
||||
if (!StringUtil.isEmpty(groupReuse.getStrRegionList())) {
|
||||
@@ -989,77 +991,4 @@ public class ConfigSourcesService extends BaseService {
|
||||
RestBusinessCode.service_runtime_error.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @Description:验证service+regionId+isValid+tableName
|
||||
* @author (zdx)
|
||||
* @date 2017年8月16日 上午11:48:46
|
||||
* @param config
|
||||
* @return
|
||||
*/
|
||||
private void checkGroupReuseForUpdate(GroupReuse config) throws Exception {
|
||||
|
||||
Boolean hasRegionFlag = false;
|
||||
Map<String, List<String>> groupReuseRegionMap = ServiceAndRDBIndexReal.getGroupReuseRegionMap();
|
||||
if (groupReuseRegionMap.containsKey("numRegion") && !StringUtil.isEmpty(config.getNumRegionList())
|
||||
&& config.getNumRegionList().size() > 0) {
|
||||
hasRegionFlag = true;
|
||||
List<NumRegion> numRegionList = config.getNumRegionList();
|
||||
for (NumRegion numRegion : numRegionList) {
|
||||
if (StringUtil.isEmpty(numRegion.getTableName())
|
||||
|| !groupReuseRegionMap.get("numRegion").contains(numRegion.getTableName())) {
|
||||
throw new RestServiceException(
|
||||
"numRegionList中的regionId为" + numRegion.getRegionId() + "的域配置tableName为空或不是分组复用的域表",
|
||||
RestBusinessCode.TableNameUnReuse.getValue());
|
||||
}
|
||||
if (numRegion.getIsValid() != 0) {
|
||||
throw new RestServiceException(
|
||||
"numRegionList中的regionId为" + numRegion.getRegionId() + "的域配置在修改时不能为有效",
|
||||
RestBusinessCode.IsValidIsF.getValue());
|
||||
}
|
||||
}
|
||||
} else if (groupReuseRegionMap.containsKey("strRegion") && !StringUtil.isEmpty(config.getStrRegionList())
|
||||
&& config.getStrRegionList().size() > 0) {
|
||||
hasRegionFlag = true;
|
||||
List<StrRegion> strRegionList = config.getStrRegionList();
|
||||
for (StrRegion strRegion : strRegionList) {
|
||||
if (StringUtil.isEmpty(strRegion.getTableName())
|
||||
|| !groupReuseRegionMap.get("strRegion").contains(strRegion.getTableName())) {
|
||||
throw new RestServiceException(
|
||||
"strRegionList中的regionId为" + strRegion.getRegionId() + "的域配置tableName为空或不是分组复用的域表",
|
||||
RestBusinessCode.TableNameUnReuse.getValue());
|
||||
}
|
||||
if (strRegion.getIsValid() != 0) {
|
||||
throw new RestServiceException(
|
||||
"strRegionList中的regionId为" + strRegion.getRegionId() + "的域配置在修改时不能为有效",
|
||||
RestBusinessCode.IsValidIsF.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
} else if (groupReuseRegionMap.containsKey("ipRegion") && !StringUtil.isEmpty(config.getIpRegionList())
|
||||
&& config.getIpRegionList().size() > 0) {
|
||||
hasRegionFlag = true;
|
||||
List<IpRegion> ipRegionList = config.getIpRegionList();
|
||||
for (IpRegion ipRegion : ipRegionList) {
|
||||
|
||||
if (StringUtil.isEmpty(ipRegion.getTableName())
|
||||
|| !groupReuseRegionMap.get("ipRegion").contains(ipRegion.getTableName())) {
|
||||
throw new RestServiceException(
|
||||
"ipRegionList中的regionId为" + ipRegion.getRegionId() + "的域配置tableName为空或不是分组复用的域表",
|
||||
RestBusinessCode.TableNameUnReuse.getValue());
|
||||
}
|
||||
if (null == ipRegion.getIsValid() || ipRegion.getIsValid() != 0) {
|
||||
throw new RestServiceException("ipRegionList中的regionId为" + ipRegion.getRegionId() + "的域配置在修改时不能为有效",
|
||||
RestBusinessCode.IsValidIsF.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!hasRegionFlag) {
|
||||
// 所有的域类型都不包括,可能是配置文件配错了
|
||||
throw new ServiceRuntimeException(RestBusinessCode.ReuseRegionIsNull.getErrorReason(),
|
||||
RestBusinessCode.ReuseRegionIsNull.getValue());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -189,8 +189,6 @@ digest.gen.tool.path=maat-redis/digest_gen
|
||||
maxRedisDBIndex=16
|
||||
##存放编译,分组,域配置id关系的redis数据库编号
|
||||
idRelaRedisDBIndex=15
|
||||
#存储分组复用域配置的redisdb
|
||||
tmpStorageReuseRegionDB=15
|
||||
|
||||
##实时统计(编译配置)数据表达式
|
||||
redisStatisticsReal=[COMPILE_ID];\t;[SERVICE];\t;[ACTION];\t;[CONT_TYPE];\t;[ATTR_TYPE];\t;[CONT_LABEL];\t;[TASK_ID];\t;[AFFAIR_ID];\t;[DO_BLACKLIST];\t;[DO_LOG];\t;[EFFECTIVE_RANGE];\t;[START_TIME];\t;[END_TIME];\t;[USER_REGION];\t;[IS_VALID];\t;[GROUP_NUM];\t;[FATHER_CFG_ID];\t;[OP_TIME]
|
||||
|
||||
Reference in New Issue
Block a user