ASN IP 导入并下发功能
This commit is contained in:
@@ -1537,7 +1537,8 @@ public class BaseController {
|
||||
}else if(regionDict.getFunctionId().equals(214)) { // IpSpoofing
|
||||
BlockingQueue<IpSpoofingTemplate> list = ei.getDataList(IpSpoofingTemplate.class );
|
||||
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict,null,null, list);
|
||||
}else if(regionDict.getFunctionId().equals(405)) { // APP IP
|
||||
}else if(regionDict.getFunctionId().equals(405) || regionDict.getFunctionId().equals(563) || regionDict.getFunctionId().equals(565)
|
||||
|| regionDict.getFunctionId().equals(566)) { // APP Feature IP
|
||||
BlockingQueue<IpAllNotDoLogTemplate> list = ei.getDataList(IpAllNotDoLogTemplate.class );
|
||||
ipPortCfgs=this.checkIpCfgMulity(errTip,serviceDict, regionDict,null,null, list);
|
||||
}else {
|
||||
@@ -1605,6 +1606,9 @@ public class BaseController {
|
||||
} else if(regionDict.getFunctionId().equals(563)){// APP Payload
|
||||
BlockingQueue<AppPayloadTemplate> list = ei.getDataList(AppPayloadTemplate.class);
|
||||
appComplexFeatureCfgs = this.checkAppComplexFeatureStringCfgMulity(errTip,serviceDict, regionDict, list);
|
||||
} else if(regionDict.getFunctionId().equals(565) || regionDict.getFunctionId().equals(564) || regionDict.getFunctionId().equals(566)){// APP Feature StrPlus
|
||||
BlockingQueue<ComplexStringAllNotDoLogTemplate> list = ei.getDataList(ComplexStringAllNotDoLogTemplate.class);
|
||||
complexkeywordCfgs = this.checkComplexStringCfgMulity(errTip,serviceDict, regionDict, list);
|
||||
} else {
|
||||
BlockingQueue<ComplexStringAllTemplate> list = ei.getDataList(ComplexStringAllTemplate.class
|
||||
);
|
||||
@@ -1654,13 +1658,22 @@ public class BaseController {
|
||||
//处理config_group_info和asn_group_info
|
||||
asnIpCfgService.processGroup(serviceDict,asnNoMaps,asnOrgList,isSend,isImportAll.get(0).getItemCode());
|
||||
//每次批量之后需要更新已下发的组
|
||||
asnNoMaps.get(3).clear();
|
||||
if(isImportAll.get(0).getItemCode().equals("1")){
|
||||
asnNoMaps.get(3).clear();
|
||||
}
|
||||
//处理asn ip
|
||||
List<BaseIpCfg> _ipPortCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
|
||||
List<AsnIpCfg> asnIpCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
|
||||
int index=0;
|
||||
//未下发过的组织下asn ip信息
|
||||
Map<Long,List<AsnIpCfg>> newAsnIpMap=Maps.newConcurrentMap();
|
||||
int newAsnIpIndex=0;
|
||||
//下发过的组织下asn ip信息
|
||||
Map<Long,List<AsnIpCfg>> oldAsnIpMap=Maps.newConcurrentMap();
|
||||
int oldAsnIpIndex=0;
|
||||
while(!ipPortCfgs.isEmpty()) {
|
||||
ipPortCfgs.drainTo(_ipPortCfgs, Constants.MAAT_JSON_SEND_SIZE);
|
||||
asnIpCfgService.processAsnIp(serviceDict,regionDict,_ipPortCfgs,asnNoMaps,isSend,isImportAll.get(0).getItemCode(),requestId, attribute, classify);
|
||||
/*List<Integer> regionIds=Lists.newArrayList();
|
||||
List<Integer> regionIds=Lists.newArrayList();
|
||||
try {
|
||||
regionIds = ConfigServiceUtil.getId(3,_ipPortCfgs.size());
|
||||
} catch (Exception e) {
|
||||
@@ -1668,60 +1681,109 @@ public class BaseController {
|
||||
logger.info("获取域ID出错");
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
||||
}
|
||||
int ind=0;
|
||||
index=0;
|
||||
for (BaseIpCfg cfg : _ipPortCfgs) {
|
||||
AsnIpCfg _cfg=new AsnIpCfg();
|
||||
BeanUtils.copyProperties(cfg, _cfg,new String[] {"cfgId"});
|
||||
_cfg.setTableName(AsnIpCfg.getTablename());
|
||||
_cfg.setAction(serviceDict==null?0:serviceDict.getAction());
|
||||
_cfg.setCfgRegionCode(regionDict.getConfigRegionCode());
|
||||
_cfg.setCfgType(regionDict.getConfigRegionValue());
|
||||
_cfg.setCreateTime(date);
|
||||
_cfg.setCreatorId(UserUtils.getUser().getId());
|
||||
_cfg.setDoLog(2);
|
||||
_cfg.setFunctionId(regionDict.getFunctionId());
|
||||
AsnIpCfg asnIpCfg=new AsnIpCfg();
|
||||
BeanUtils.copyProperties(cfg, asnIpCfg,new String[] {"cfgId"});
|
||||
asnIpCfg.setTableName(AsnIpCfg.getTablename());
|
||||
asnIpCfg.setAction(serviceDict==null?0:serviceDict.getAction());
|
||||
asnIpCfg.setCfgRegionCode(regionDict.getConfigRegionCode());
|
||||
asnIpCfg.setCfgType(regionDict.getConfigRegionValue());
|
||||
asnIpCfg.setCreateTime(date);
|
||||
asnIpCfg.setCreatorId(UserUtils.getUser().getId());
|
||||
asnIpCfg.setDoLog(2);
|
||||
asnIpCfg.setFunctionId(regionDict.getFunctionId());
|
||||
if(isSend.equals("1")) {
|
||||
_cfg.setIsAudit(Constants.AUDIT_YES);
|
||||
_cfg.setIsValid(Constants.VALID_YES);
|
||||
_cfg.setAuditorId(UserUtils.getUser().getId());
|
||||
_cfg.setAuditTime(date);
|
||||
asnIpCfg.setIsAudit(Constants.AUDIT_YES);
|
||||
asnIpCfg.setIsValid(Constants.VALID_YES);
|
||||
asnIpCfg.setAuditorId(UserUtils.getUser().getId());
|
||||
asnIpCfg.setAuditTime(date);
|
||||
|
||||
}else {
|
||||
_cfg.setIsAudit(Constants.AUDIT_NOT_YET);
|
||||
_cfg.setIsValid(Constants.VALID_NO);
|
||||
}
|
||||
_cfg.setIsAreaEffective(0);
|
||||
_cfg.setLable("0");
|
||||
_cfg.setRequestId(StringUtil.isEmpty(requestId) ? 0 : requestId);
|
||||
_cfg.setAttribute(attribute);
|
||||
_cfg.setClassify(classify);
|
||||
// _cfg.setServiceId(0);
|
||||
_cfg.setServiceId(serviceDict==null?0:serviceDict.getServiceId());
|
||||
//设置region id
|
||||
if(regionIds!=null&®ionIds.size()==_ipPortCfgs.size()) {
|
||||
_cfg.setRegionId(regionIds.get(ind));
|
||||
asnIpCfg.setIsAudit(Constants.AUDIT_NOT_YET);
|
||||
asnIpCfg.setIsValid(Constants.VALID_NO);
|
||||
}
|
||||
asnIpCfg.setIsAreaEffective(0);
|
||||
asnIpCfg.setLable("0");
|
||||
asnIpCfg.setRequestId(StringUtil.isEmpty(requestId) ? 0 : requestId);
|
||||
asnIpCfg.setAttribute(attribute);
|
||||
asnIpCfg.setClassify(classify);
|
||||
asnIpCfg.setServiceId(serviceDict==null?0:serviceDict.getServiceId());
|
||||
asnIpCfg.setRegionId(regionIds.get(index));
|
||||
//设置group id,compileId
|
||||
if(asnNoMaps.get(0).containsKey(Long.parseLong(_cfg.getUserRegion1()))) {
|
||||
_cfg.setAsnIpGroup(asnNoMaps.get(0).get(Long.parseLong(_cfg.getUserRegion1())).getGroupId());
|
||||
_cfg.setCompileId(asnNoMaps.get(0).get(Long.parseLong(_cfg.getUserRegion1())).getCompileId());
|
||||
}else if(asnNoMaps.get(1).containsKey(Long.parseLong(_cfg.getUserRegion1()))) {
|
||||
_cfg.setAsnIpGroup(asnNoMaps.get(1).get(Long.parseLong(_cfg.getUserRegion1())).getGroupId());
|
||||
_cfg.setCompileId(asnNoMaps.get(1).get(Long.parseLong(_cfg.getUserRegion1())).getCompileId());
|
||||
}else {
|
||||
//AsnGroupInfo info=AsnCacheUtils.get(Long.parseLong(_cfg.getUserRegion1()));
|
||||
AsnGroupInfo info=asnGroupInfos.get(Long.parseLong(_cfg.getUserRegion1()));
|
||||
if(info!=null) {
|
||||
_cfg.setAsnIpGroup(info.getGroupId());
|
||||
_cfg.setCompileId(info.getCompileId());
|
||||
asnIpCfg.setAsnIpGroup(asnNoMaps.get(2).get(Long.parseLong(asnIpCfg.getUserRegion1())).getGroupId());
|
||||
asnIpCfg.setCompileId(asnNoMaps.get(2).get(Long.parseLong(asnIpCfg.getUserRegion1())).getCompileId());
|
||||
if(isSend.equals("1")) {
|
||||
//已下发
|
||||
if(asnNoMaps.get(3).keySet().contains(Long.valueOf(asnIpCfg.getUserRegion1()))){
|
||||
//groupId已经在了
|
||||
if(oldAsnIpMap.keySet().contains(Long.valueOf(asnIpCfg.getAsnIpGroup()))){
|
||||
oldAsnIpMap.get(Long.valueOf(asnIpCfg.getAsnIpGroup())).add(asnIpCfg);
|
||||
oldAsnIpIndex++;
|
||||
}else{
|
||||
List list=new ArrayList<>();
|
||||
list.add(asnIpCfg);
|
||||
oldAsnIpMap.put(Long.valueOf(asnIpCfg.getAsnIpGroup()), list);
|
||||
oldAsnIpIndex++;
|
||||
}
|
||||
}else{//未下发
|
||||
//groupId已经在了
|
||||
if(newAsnIpMap.keySet().contains(Long.valueOf(asnIpCfg.getAsnIpGroup()))){
|
||||
newAsnIpMap.get(Long.valueOf(asnIpCfg.getAsnIpGroup())).add(asnIpCfg);
|
||||
newAsnIpIndex++;
|
||||
}else{
|
||||
List list=new ArrayList<>();
|
||||
list.add(asnIpCfg);
|
||||
newAsnIpMap.put(Long.valueOf(asnIpCfg.getAsnIpGroup()), list);
|
||||
newAsnIpIndex++;
|
||||
}
|
||||
}
|
||||
/**********************新的asn ip达到最大量后发送一次***********************/
|
||||
//未下发过的asnGroup
|
||||
if(newAsnIpIndex==Constants.MAAT_JSON_SEND_SIZE){
|
||||
asnIpCfgService.auditAsnIp(newAsnIpMap,asnNoMaps,"maat",newAsnIpIndex);
|
||||
newAsnIpMap.clear();
|
||||
newAsnIpIndex=0;
|
||||
}
|
||||
/**********************新的asn ip达到最大量后发送一次***********************/
|
||||
//已下发过的asnGroup
|
||||
if(oldAsnIpIndex==Constants.MAAT_JSON_SEND_SIZE){
|
||||
asnIpCfgService.auditAsnIp(oldAsnIpMap,asnNoMaps,"common",oldAsnIpIndex);
|
||||
oldAsnIpMap.clear();
|
||||
oldAsnIpIndex=0;
|
||||
}
|
||||
|
||||
}else{
|
||||
asnIpCfgs.add(asnIpCfg);
|
||||
}
|
||||
asnIpCfgs.add(_cfg);
|
||||
ind++;
|
||||
//仅仅需要保存的数
|
||||
if(asnIpCfgs.size()==Constants.MAAT_JSON_SEND_SIZE){
|
||||
asnIpCfgService.saveAsnIp(asnIpCfgs);
|
||||
asnIpCfgs.clear();
|
||||
}
|
||||
index++;
|
||||
|
||||
}
|
||||
if(isSend.equals("1")) {
|
||||
//未下发过的asnGroup
|
||||
if(!newAsnIpMap.isEmpty()){
|
||||
asnIpCfgService.auditAsnIp(newAsnIpMap,asnNoMaps,"maat",newAsnIpIndex);
|
||||
newAsnIpMap.clear();
|
||||
newAsnIpIndex=0;
|
||||
}
|
||||
//已下发过的asnGroup
|
||||
if(!oldAsnIpMap.isEmpty()){
|
||||
asnIpCfgService.auditAsnIp(oldAsnIpMap,asnNoMaps,"common",oldAsnIpIndex);
|
||||
oldAsnIpMap.clear();
|
||||
oldAsnIpIndex=0;
|
||||
}
|
||||
}
|
||||
//仅仅需要保存的数
|
||||
if(!StringUtil.isEmpty(asnIpCfgs)){
|
||||
asnIpCfgService.saveAsnIp(asnIpCfgs);
|
||||
asnIpCfgs.clear();
|
||||
}
|
||||
ipCfgService.saveAndSend(regionDict, serviceDict, specificServiceCfg, asnIpCfgs, cfgIndexInfos, appPolicyCfgs,appFeatureIndexs,asnNoMaps,isSend.equals("1"));*/
|
||||
_ipPortCfgs.clear();
|
||||
/*asnIpCfgs.clear();*/
|
||||
}
|
||||
}else if(regionDict.getFunctionId().intValue()==214) { // IpSpoofing
|
||||
List<BaseIpCfg> _ipPortCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
|
||||
@@ -2470,7 +2532,8 @@ public class BaseController {
|
||||
ei.loadInitParams(IpWhitelistTemplate.class, msgProp, regionDict, serviceDict);
|
||||
} else if(regionDict.getFunctionId().equals(214)) { // IpSpoofing
|
||||
ei.loadInitParams(IpSpoofingTemplate.class, msgProp, regionDict, serviceDict);
|
||||
} else if(regionDict.getFunctionId().equals(405)) { // APP IP
|
||||
} else if(regionDict.getFunctionId().equals(405) || regionDict.getFunctionId().equals(563) || regionDict.getFunctionId().equals(565)
|
||||
|| regionDict.getFunctionId().equals(566)) { // APP Feature IP
|
||||
ei.loadInitParams(IpAllNotDoLogTemplate.class, msgProp, regionDict, serviceDict);
|
||||
} else {
|
||||
ei.loadInitParams(IpAllTemplate.class, msgProp, regionDict, serviceDict);
|
||||
@@ -2516,6 +2579,8 @@ public class BaseController {
|
||||
ei.loadInitParams(ComplexStringAllNotDoLogTemplate.class, this.getMsgProp(), regionDict, serviceDict);
|
||||
}else if(regionDict.getFunctionId().equals(563)) {// APP Payload
|
||||
ei.loadInitParams(AppPayloadTemplate.class, this.getMsgProp(), regionDict, serviceDict);
|
||||
}else if(regionDict.getFunctionId().equals(565) || regionDict.getFunctionId().equals(564) || regionDict.getFunctionId().equals(566)){// APP Feature StrPlus
|
||||
ei.loadInitParams(ComplexStringAllNotDoLogTemplate.class, this.getMsgProp(), regionDict, serviceDict);
|
||||
} else {
|
||||
ei.loadInitParams(ComplexStringAllTemplate.class, msgProp, regionDict, serviceDict);
|
||||
}
|
||||
|
||||
@@ -2138,6 +2138,7 @@ public abstract class BaseService {
|
||||
long start=System.currentTimeMillis();
|
||||
ConfigGroupInfo configGroupInfo=configGroupInfoDao.getConfigGroupInfoByGroupId(specificServiceCfg.getGroupId());
|
||||
if(configGroupInfo==null) {//一般特定服务的组号是新增之后就有的,不会进入这一步。
|
||||
Date date = new Date();
|
||||
Integer groupId = ConfigServiceUtil.getId(2, 1).get(0);
|
||||
Integer compileId=ConfigServiceUtil.getId(1, 1).get(0);
|
||||
specificServiceCfg.setGroupId(groupId);
|
||||
@@ -2147,9 +2148,10 @@ public abstract class BaseService {
|
||||
configGroupInfo.setIsIssued(0);
|
||||
configGroupInfo.setGroupType(1);
|
||||
configGroupInfo.setCompileId(compileId);
|
||||
configGroupInfo.setInsertTime(date);
|
||||
configGroupInfoDao.insertConfigGroupInfo(configGroupInfo);
|
||||
//更新group_id
|
||||
specificServiceCfg.setOpTime(new Date());
|
||||
specificServiceCfg.setOpTime(date);
|
||||
specificServiceCfgDao.update(specificServiceCfg);
|
||||
}
|
||||
Integer compileId = configGroupInfo.getCompileId();
|
||||
@@ -2931,7 +2933,8 @@ public abstract class BaseService {
|
||||
}
|
||||
//调用服务接口下发配置
|
||||
ToMaatResult result =ConfigServiceUtil.auditCommonGroupRegionSources(json,action);
|
||||
logger.info("asn ip复用域 "+action+" 配置响应信息:"+result.getMsg());
|
||||
//logger.info("asn ip复用域 "+action+" 配置响应信息:"+result.getMsg());
|
||||
logger.info("asn ip复用域 "+action+" 配置响应信息:");
|
||||
}else {
|
||||
maatBean.setOpAction(action);
|
||||
//调用服务接口下发配置数据
|
||||
@@ -2944,7 +2947,8 @@ public abstract class BaseService {
|
||||
}
|
||||
//调用服务接口下发配置
|
||||
ToMaatResult result = ConfigServiceUtil.auditCommonGroupRegionSources(json,3);
|
||||
logger.info("asn ip复用域删除配置响应信息:"+result.getMsg());
|
||||
logger.info("asn ip复用域删除配置响应信息:");
|
||||
//logger.info("asn ip复用域删除配置响应信息:"+result.getMsg());
|
||||
}
|
||||
long end=System.currentTimeMillis();
|
||||
logger.warn("asnIPRegionSendToMaat finish,cost:"+(end-start));
|
||||
|
||||
@@ -172,123 +172,145 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
auditAllAsnRegionCfg(entity,auditAsnGroupList,null);
|
||||
}*/
|
||||
}
|
||||
/**
|
||||
*
|
||||
* @param asnNoMaps 所有asn的信息
|
||||
* @param configGroupInfos asn组织的数据库信息
|
||||
* @param asnOrgMap asn和组织的关系
|
||||
* @param isImportAll 是否导入全量
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void processAsnIp(FunctionServiceDict service,FunctionRegionDict regionDict,List<BaseIpCfg> ipCfgList,List<Map<Long, AsnGroupInfo>> asnNoMaps,String isSend,String isImportAll,Integer requestId, String attribute, String classify){
|
||||
logger.warn("Start to save asn ip size:"+ipCfgList.size());
|
||||
public void saveAsnIp(List<AsnIpCfg> asnIpCfgs){
|
||||
logger.warn("Start to only save asn ip size:"+asnIpCfgs.size());
|
||||
long start=System.currentTimeMillis();
|
||||
//List<AsnIpCfg> asnIpCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
|
||||
Date date=new Date();
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
int index=0;
|
||||
Map<Long,AsnGroupInfo> auditInfo=new HashMap<>();
|
||||
//存储未下发的asno及asnIP
|
||||
Map<Integer,List<AsnIpCfg>> noAuditGroupIds=new HashMap<>();
|
||||
//存储已下发的asnno
|
||||
Map<Integer,List<AsnIpCfg>> auditGroupIds=new HashMap<>();
|
||||
//本次未下发的组信息
|
||||
List<AsnGroupInfo> noAuditGroupList=new ArrayList<AsnGroupInfo>();
|
||||
Long asno=0l;
|
||||
try{
|
||||
List<Integer> regionIds=ConfigServiceUtil.getId(3, ipCfgList.size());
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
for (BaseIpCfg cfg : ipCfgList) {
|
||||
AsnIpCfg asnIpCfg=new AsnIpCfg();
|
||||
BeanUtils.copyProperties(cfg, asnIpCfg,new String[] {"cfgId"});
|
||||
asnIpCfg.setTableName(AsnIpCfg.getTablename());
|
||||
asnIpCfg.setAction(service==null?0:service.getAction());
|
||||
asnIpCfg.setCfgRegionCode(regionDict.getConfigRegionCode());
|
||||
asnIpCfg.setCfgType(regionDict.getConfigRegionValue());
|
||||
asnIpCfg.setCreateTime(date);
|
||||
asnIpCfg.setCreatorId(UserUtils.getUser().getId());
|
||||
asnIpCfg.setDoLog(2);
|
||||
asnIpCfg.setFunctionId(regionDict.getFunctionId());
|
||||
if(isSend.equals("1")) {
|
||||
asnIpCfg.setIsAudit(Constants.AUDIT_YES);
|
||||
asnIpCfg.setIsValid(Constants.VALID_YES);
|
||||
asnIpCfg.setAuditorId(UserUtils.getUser().getId());
|
||||
asnIpCfg.setAuditTime(date);
|
||||
|
||||
}else {
|
||||
asnIpCfg.setIsAudit(Constants.AUDIT_NOT_YET);
|
||||
asnIpCfg.setIsValid(Constants.VALID_NO);
|
||||
if(!StringUtil.isEmpty(asnIpCfgs)){
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
for (AsnIpCfg cfg : asnIpCfgs) {
|
||||
((AsnIpCfgDao) batchSqlSession.getMapper(AsnIpCfgDao.class)).insert(cfg);
|
||||
}
|
||||
asnIpCfg.setIsAreaEffective(0);
|
||||
asnIpCfg.setLable("0");
|
||||
asnIpCfg.setRequestId(StringUtil.isEmpty(requestId) ? 0 : requestId);
|
||||
asnIpCfg.setAttribute(attribute);
|
||||
asnIpCfg.setClassify(classify);
|
||||
asnIpCfg.setServiceId(service==null?0:service.getServiceId());
|
||||
asnIpCfg.setRegionId(regionIds.get(index));
|
||||
asno=Long.parseLong(asnIpCfg.getUserRegion1());
|
||||
//设置group id,compileId
|
||||
asnIpCfg.setAsnIpGroup(asnNoMaps.get(2).get(Long.parseLong(asnIpCfg.getUserRegion1())).getGroupId());
|
||||
asnIpCfg.setCompileId(asnNoMaps.get(2).get(Long.parseLong(asnIpCfg.getUserRegion1())).getCompileId());
|
||||
/*if(isSend.equals("1")) {
|
||||
//判断组是否已下发
|
||||
if(asnNoMaps.get(3).keySet().contains(asno)){
|
||||
|
||||
}else{
|
||||
asnNoMaps.get(3).put(asno, asnNoMaps.get(2).get(asno));
|
||||
}
|
||||
}*/
|
||||
|
||||
((AsnIpCfgDao) batchSqlSession.getMapper(AsnIpCfgDao.class)).insert(asnIpCfg);
|
||||
index++;
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
batchSqlSession.commit();
|
||||
}
|
||||
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
//6、配置取消所有编译[编译取消,编译下的所有group和region都会取消(已和服务端确认)]
|
||||
/*if(!StringUtil.isEmpty(deleteAsnCompile)){
|
||||
long startAudit=System.currentTimeMillis();
|
||||
ToMaatBean maatBean = new ToMaatBean();
|
||||
MaatCfg maatCfg = new MaatCfg();
|
||||
List<MaatCfg> configCompileList = new ArrayList();
|
||||
List<GroupCfg> groupRelationList = new ArrayList();
|
||||
List<IpCfg> ipRegionList = new ArrayList();
|
||||
List<StringCfg> strRegionList = new ArrayList();
|
||||
List<NumBoundaryCfg> numRegionList = new ArrayList();
|
||||
List<DigestCfg> digestRegionList = new ArrayList();
|
||||
List<IpCfg> areaIpRegionList = new ArrayList();
|
||||
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(600);
|
||||
Integer serviceId=0;
|
||||
serviceId=serviceList.get(0).getServiceId();
|
||||
for(Entry<Long, AsnGroupInfo> e:deleteAsnCompile.entrySet()) {
|
||||
maatCfg.setCompileId(e.getValue().getCompileId());
|
||||
maatCfg.setServiceId(serviceId);
|
||||
maatCfg.setIsValid(0);//无效
|
||||
configCompileList.add(maatCfg);
|
||||
}
|
||||
maatBean.setConfigCompileList(configCompileList);
|
||||
maatBean.setAuditTime(createTime);
|
||||
long end=System.currentTimeMillis();
|
||||
logger.warn("end only save asn ip finish,cost:"+(end-start));
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void auditAsnIp(Map<Long, List<AsnIpCfg>> auditAsnIp,List<Map<Long, AsnGroupInfo>> asnNoMaps,String auditType,int auditSize){
|
||||
logger.warn("Start to audit and save asn ip size:"+auditSize);
|
||||
long start=System.currentTimeMillis();
|
||||
Date date=new Date();
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
Long asno=0l;
|
||||
List<Long> groupIds=Lists.newArrayList(auditAsnIp.size());
|
||||
List<AsnIpCfg> auditList=new ArrayList<>();
|
||||
ToMaatBean maatBean = new ToMaatBean();
|
||||
List<MaatCfg> configCompileList = new ArrayList();
|
||||
try{
|
||||
if(!auditAsnIp.isEmpty()){
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
//maat结构配置
|
||||
if(auditType.equals("maat")){
|
||||
//maat参数
|
||||
List<StringCfg> strRegionList = new ArrayList();
|
||||
List<NumBoundaryCfg> numRegionList = new ArrayList();
|
||||
List<DigestCfg> digestRegionList = new ArrayList();
|
||||
List<IpCfg> areaIpRegionList = new ArrayList();
|
||||
|
||||
for (Entry<Long, List<AsnIpCfg>> e:auditAsnIp.entrySet()) {
|
||||
List<GroupCfg> groupRelationList = Lists.newArrayList();
|
||||
List<IpCfg> ipRegionList = new ArrayList();
|
||||
|
||||
//分组信息
|
||||
GroupCfg groupCfg=new GroupCfg();
|
||||
groupCfg.setAuditTime(e.getValue().get(0).getAuditTime());
|
||||
groupCfg.setCompileId(e.getValue().get(0).getCompileId());
|
||||
groupCfg.setGroupId(e.getValue().get(0).getAsnIpGroup());
|
||||
groupCfg.setIsCommonGroup(1);
|
||||
groupCfg.setIsValid(e.getValue().get(0).getIsValid());
|
||||
|
||||
groupRelationList.add(groupCfg);
|
||||
|
||||
//域信息
|
||||
ipRegionList.addAll(groupReuseCfgAddRemoveConvert(e.getValue(),Constants.VALID_YES,Integer.parseInt(e.getKey()+"")));
|
||||
|
||||
MaatCfg maatCfg = new MaatCfg();
|
||||
maatCfg.initDefaultValue();
|
||||
BeanUtils.copyProperties(e.getValue().get(0), maatCfg);
|
||||
maatCfg.setAction(e.getValue().get(0).getAction());
|
||||
maatCfg.setAuditTime(e.getValue().get(0).getAuditTime());
|
||||
maatCfg.setStrRegionList(strRegionList);
|
||||
maatCfg.setNumRegionList(numRegionList);
|
||||
maatCfg.setDigestRegionList(digestRegionList);
|
||||
maatCfg.setGroupRelationList(groupRelationList);
|
||||
maatCfg.setAreaIpRegionList(areaIpRegionList);
|
||||
maatCfg.setIpRegionList(ipRegionList);
|
||||
maatCfg.setIsValid(e.getValue().get(0).getIsValid());
|
||||
maatCfg.setCompileId(e.getValue().get(0).getCompileId());
|
||||
// 设置ASN自定义域
|
||||
String userRegion = Constants.ASN_REGION_KEY+"=" +Constants.ASN_KEY+ e.getValue().get(0).getUserRegion1();
|
||||
maatCfg.setUserRegion(userRegion);
|
||||
maatCfg.setGroupNum(groupRelationList.size());
|
||||
configCompileList.add(maatCfg);
|
||||
|
||||
groupIds.add(e.getKey());
|
||||
for (AsnIpCfg cfg : e.getValue()) {
|
||||
((AsnIpCfgDao) batchSqlSession.getMapper(AsnIpCfgDao.class)).insert(cfg);
|
||||
}
|
||||
//组第一次下发,需要更新已下发过的组中
|
||||
asnNoMaps.get(3).put(Long.valueOf(e.getValue().get(0).getUserRegion1()), asnNoMaps.get(2).get(Long.valueOf(e.getValue().get(0).getUserRegion1())));
|
||||
}
|
||||
|
||||
}else{
|
||||
//复用接口
|
||||
for (Entry<Long, List<AsnIpCfg>> e:auditAsnIp.entrySet()) {
|
||||
groupIds.add(e.getKey());
|
||||
for (AsnIpCfg cfg : e.getValue()) {
|
||||
((AsnIpCfgDao) batchSqlSession.getMapper(AsnIpCfgDao.class)).insert(cfg);
|
||||
}
|
||||
auditList.addAll(e.getValue());
|
||||
}
|
||||
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
}
|
||||
//第一次走maat配置的下发,需要将asn组修改为有效
|
||||
if(auditType.equals("maat") && !StringUtil.isEmpty(groupIds)){
|
||||
asnGroupInfoDao.updateIsUsedAndIsValid(groupIds, null, 1);
|
||||
}
|
||||
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
logger.warn("Start to audit asn ip ");
|
||||
long startAudit=System.currentTimeMillis();
|
||||
if(auditType.equals("maat")){
|
||||
maatBean.setConfigCompileList(configCompileList);
|
||||
maatBean.setAuditTime(new Date());
|
||||
maatBean.setCreatorName(UserUtils.getUser().getName());
|
||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||
maatBean.setOpAction(Constants.UPDATE_ACTION);
|
||||
//调用服务接口取消配置
|
||||
maatBean.setOpAction(Constants.INSERT_ACTION);
|
||||
//调用服务接口下发配置数据
|
||||
String json=gsonToJson(maatBean);
|
||||
logger.info("ASN IP 业务的编译配置全部失效参数:"+json);
|
||||
long auditEnd=System.currentTimeMillis();
|
||||
logger.warn("Cancle all ASN compile finish,cost:"+(auditEnd-startAudit));
|
||||
ToMaatResult result = ConfigServiceUtil.put(json,1);
|
||||
logger.info("ASN IP所有编译取消返回结果:"+result.getMsg());
|
||||
long resultEnd=System.currentTimeMillis();
|
||||
logger.warn("Cancle all ASN compile finish,cost:"+(resultEnd-auditEnd));
|
||||
}*/
|
||||
//logger.info("asn ip maat结构配置下发配置参数:"+json);
|
||||
logger.info("asn ip maat结构配置下发配置参数:");
|
||||
//调用服务接口下发配置
|
||||
ToMaatResult result = ConfigServiceUtil.postMaatCfg(json);
|
||||
//logger.info("asn ip maat结构配置下发响应信息:"+result.getMsg());
|
||||
logger.info("asn ip maat结构配置下发响应信息:");
|
||||
}else{
|
||||
if(!StringUtil.isEmpty(auditList)){
|
||||
asnIPRegionSendToMaat(auditList, 1, Constants.OPACTION_POST);
|
||||
}
|
||||
}
|
||||
long endAutit=System.currentTimeMillis();
|
||||
logger.warn("End to audit asn ip finish,cost:"+(endAutit-startAudit));
|
||||
|
||||
long end=System.currentTimeMillis();
|
||||
logger.warn("Save asn ip finish,cost:"+(end-start));
|
||||
logger.warn("end audit and save asn ip finish,cost:"+(end-start));
|
||||
}
|
||||
/**
|
||||
*
|
||||
@@ -358,7 +380,7 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
}
|
||||
}
|
||||
|
||||
//4、遍历保存所有的asn_group_info
|
||||
//5、遍历保存所有的asn_group_info
|
||||
if(!asnNoMaps.isEmpty()){
|
||||
Map<Long, AsnGroupInfo> newAsnGroup =asnNoMaps.get(0); //【0】 新的asn group info
|
||||
Map<Long, AsnGroupInfo> oldAsnGroup =asnNoMaps.get(1); //【1】 旧的asn group info
|
||||
|
||||
Reference in New Issue
Block a user