(1)导入日志加入时间打印
(2)线程池等待sleep时间调整为10ms
This commit is contained in:
@@ -104,6 +104,8 @@ public class ConfigServiceUtil {
|
||||
* @return
|
||||
*/
|
||||
public static List<Integer> getId(int type,int num) throws MaatConvertException {
|
||||
logger.warn("get ids start");
|
||||
long start=System.currentTimeMillis();
|
||||
String result = null;
|
||||
String url = "";
|
||||
List<Integer> list = new ArrayList();
|
||||
@@ -140,6 +142,8 @@ public class ConfigServiceUtil {
|
||||
}else{
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
long end=System.currentTimeMillis();
|
||||
logger.warn("get ids finish,cost:"+(end-start));
|
||||
return list;
|
||||
}
|
||||
/**
|
||||
@@ -355,6 +359,8 @@ public class ConfigServiceUtil {
|
||||
* @throws MaatConvertException
|
||||
*/
|
||||
public static ToMaatResult postGroupReuseSources(String params) throws MaatConvertException{
|
||||
logger.warn("postGroupReuseSources start");
|
||||
long start=System.currentTimeMillis();
|
||||
String result = null;
|
||||
ToMaatResult bean = null;
|
||||
String url = Constants.SERVICE_URL+Constants.GROUP_REUSE_SOURCES;
|
||||
@@ -373,6 +379,8 @@ public class ConfigServiceUtil {
|
||||
}else{
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+response.readEntity(String.class));
|
||||
}
|
||||
long end=System.currentTimeMillis();
|
||||
logger.warn("postGroupReuseSources end,cost:"+(end-start));
|
||||
return bean;
|
||||
}
|
||||
/**
|
||||
|
||||
@@ -733,4 +733,5 @@ public final class Constants {
|
||||
//IP复用maat json中的ip region单次send 最大个数
|
||||
public static final Integer MAAT_JSON_SEND_SIZE=Configurations.getIntProperty("maat_json_send_size", 1000);
|
||||
public static final Integer MULITY_THREAD_SIZE=Configurations.getIntProperty("mulity_thread_size", 5);
|
||||
public static final Integer SAVE_AND_DEL_THREAD_SIZE=Configurations.getIntProperty("save_and_del_thread_size", 5);
|
||||
}
|
||||
|
||||
136
src/main/java/com/nis/util/excel/thread/DeleteAsnIpTread.java
Normal file
136
src/main/java/com/nis/util/excel/thread/DeleteAsnIpTread.java
Normal file
@@ -0,0 +1,136 @@
|
||||
package com.nis.util.excel.thread;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ArrayBlockingQueue;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
||||
|
||||
import com.beust.jcommander.internal.Lists;
|
||||
import com.nis.domain.basics.AsnIpCfg;
|
||||
import com.nis.domain.specific.ConfigGroupInfo;
|
||||
import com.nis.util.AsnCacheUtils;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.web.dao.basics.AsnIpCfgDao;
|
||||
import com.nis.web.dao.specific.ConfigGroupInfoDao;
|
||||
import com.nis.web.service.SpringContextHolder;
|
||||
import com.nis.web.service.basics.AsnIpCfgService;
|
||||
|
||||
public class DeleteAsnIpTread implements Callable<Throwable> {
|
||||
private BlockingQueue<Long> asnNos;
|
||||
private ConfigGroupInfoDao configGroupInfoDao;
|
||||
private AsnIpCfgDao asnIpCfgDao;
|
||||
public DeleteAsnIpTread(BlockingQueue<Long> asnNos) {
|
||||
this.asnNos=asnNos;
|
||||
this.configGroupInfoDao=SpringContextHolder.getBean(ConfigGroupInfoDao.class);
|
||||
this.asnIpCfgDao=SpringContextHolder.getBean(AsnIpCfgDao.class);
|
||||
}
|
||||
@Override
|
||||
public Throwable call() throws Exception {
|
||||
// TODO Auto-generated method stub
|
||||
List<Long> asnNoList=Lists.newArrayList();
|
||||
List<Long> asnIds=Lists.newArrayList();
|
||||
DataSourceTransactionManager transactionManager=(DataSourceTransactionManager)SpringContextHolder.getBean("transactionManager");
|
||||
LinkedBlockingQueue<AsnIpCfg> toDelAndSendAsnIpCfgs=new LinkedBlockingQueue<AsnIpCfg>();
|
||||
while(!asnNos.isEmpty()) {
|
||||
asnNos.drainTo(asnNoList,5);
|
||||
for(Long asnNo:asnNoList) {
|
||||
ConfigGroupInfo configGroupInfo=AsnCacheUtils.get(asnNo);
|
||||
if(configGroupInfo==null) {
|
||||
configGroupInfo=configGroupInfoDao.getInfoByAsnNo(asnNo);
|
||||
}
|
||||
if(configGroupInfo.getIsIssued()==1) {//已下发
|
||||
List<AsnIpCfg> _toDelAsnIpCfgs=asnIpCfgDao.getByAsnNo(configGroupInfo.getAsnId());
|
||||
toDelAndSendAsnIpCfgs.addAll(_toDelAsnIpCfgs);
|
||||
}else {
|
||||
asnIds.add(asnNo);
|
||||
}
|
||||
|
||||
}
|
||||
if(asnIds.size()>0) {
|
||||
this.deleteByAsnNo(asnIds);
|
||||
}
|
||||
if(!toDelAndSendAsnIpCfgs.isEmpty()) {
|
||||
Integer size = toDelAndSendAsnIpCfgs.size();
|
||||
int pointsDataLimit = Constants.MAAT_JSON_SEND_SIZE;//限制条数
|
||||
List<AsnIpCfg> listPage=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
|
||||
while(!toDelAndSendAsnIpCfgs.isEmpty()) {
|
||||
//开启一个新事物
|
||||
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
|
||||
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务,这样会比较安全些。
|
||||
TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
|
||||
try {
|
||||
toDelAndSendAsnIpCfgs.drainTo(listPage, Constants.MAAT_JSON_SEND_SIZE);
|
||||
StringBuilder sb=new StringBuilder();
|
||||
for(AsnIpCfg ip:listPage) {
|
||||
sb.append(ip.getCfgId());
|
||||
sb.append(",");
|
||||
}
|
||||
sb.deleteCharAt(sb.toString().lastIndexOf(","));
|
||||
asnIpCfgDao.delete(sb.toString());
|
||||
new AsnIpCfgService().asnIPRegionSendToMaat(listPage, Constants.VALID_NO);
|
||||
transactionManager.commit(status);
|
||||
listPage.clear();
|
||||
} catch (Throwable e) {
|
||||
// TODO: handle exception
|
||||
transactionManager.rollback(status);
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
}
|
||||
asnNoList.clear();
|
||||
asnIds.clear();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
public void deleteByAsnNo(List<Long> asnNoList) {
|
||||
int pointsDataLimit = 1000;//限制条数
|
||||
Integer size = asnNoList.size();
|
||||
if(pointsDataLimit<size){
|
||||
int part = size/pointsDataLimit;//分批数
|
||||
for (int i = 0; i < part; i++) {
|
||||
List<Long> listPage = asnNoList.subList(0, pointsDataLimit);
|
||||
StringBuilder asnNoStr=new StringBuilder();
|
||||
for(Long asnNo:asnNoList) {
|
||||
asnNoStr.append(asnNo);
|
||||
asnNoStr.append(",");
|
||||
}
|
||||
int result=0;
|
||||
do {
|
||||
result=asnIpCfgDao.deleteByAsnGroup(asnNoStr.toString().substring(0,asnNoStr.toString().length()-1));
|
||||
}while(result>0);
|
||||
//剔除
|
||||
asnNoList.subList(0, pointsDataLimit).clear();
|
||||
}
|
||||
if(!asnNoList.isEmpty()){
|
||||
StringBuilder asnNoStr=new StringBuilder();
|
||||
for(Long asnNo:asnNoList) {
|
||||
asnNoStr.append(asnNo);
|
||||
asnNoStr.append(",");
|
||||
}
|
||||
int result=0;
|
||||
do {
|
||||
result=asnIpCfgDao.deleteByAsnGroup(asnNoStr.toString().substring(0,asnNoStr.toString().length()-1));
|
||||
}while(result>0);
|
||||
asnNoList.clear();
|
||||
}
|
||||
}else {
|
||||
StringBuilder asnNoStr=new StringBuilder();
|
||||
for(Long asnNo:asnNoList) {
|
||||
asnNoStr.append(asnNo);
|
||||
asnNoStr.append(",");
|
||||
}
|
||||
int result=0;
|
||||
do {
|
||||
result=asnIpCfgDao.deleteByAsnGroup(asnNoStr.toString().substring(0,asnNoStr.toString().length()-1));
|
||||
}while(result>0);
|
||||
asnNoList.clear();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
201
src/main/java/com/nis/util/excel/thread/SaveAsnIpThread.java
Normal file
201
src/main/java/com/nis/util/excel/thread/SaveAsnIpThread.java
Normal file
@@ -0,0 +1,201 @@
|
||||
package com.nis.util.excel.thread;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
import java.util.concurrent.Callable;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
|
||||
import org.springframework.transaction.TransactionDefinition;
|
||||
import org.springframework.transaction.TransactionStatus;
|
||||
import org.springframework.transaction.support.DefaultTransactionDefinition;
|
||||
|
||||
import com.beust.jcommander.internal.Lists;
|
||||
import com.nis.domain.FunctionRegionDict;
|
||||
import com.nis.domain.FunctionServiceDict;
|
||||
import com.nis.domain.basics.AsnIpCfg;
|
||||
import com.nis.domain.basics.Varibles;
|
||||
import com.nis.domain.configuration.BaseIpCfg;
|
||||
import com.nis.domain.specific.ConfigGroupInfo;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.AsnCacheUtils;
|
||||
import com.nis.util.ConfigServiceUtil;
|
||||
import com.nis.util.Constants;
|
||||
import com.nis.util.StringUtil;
|
||||
import com.nis.web.dao.basics.AsnIpCfgDao;
|
||||
import com.nis.web.dao.specific.ConfigGroupInfoDao;
|
||||
import com.nis.web.security.UserUtils;
|
||||
import com.nis.web.service.SpringContextHolder;
|
||||
import com.nis.web.service.basics.AsnIpCfgService;
|
||||
|
||||
public class SaveAsnIpThread implements Callable<Throwable>{
|
||||
private Logger logger=LoggerFactory.getLogger(getClass());
|
||||
private BlockingQueue<BaseIpCfg> ipPortCfgs;
|
||||
private FunctionServiceDict serviceDict;
|
||||
private FunctionRegionDict regionDict;
|
||||
private Map<Long,Boolean> fullMap;
|
||||
private List<Map<Long,Integer>> asnNoMaps;
|
||||
private Integer requestId;
|
||||
private AsnIpCfgDao asnIpCfgDao;
|
||||
private ConfigGroupInfoDao configGroupInfoDao;
|
||||
// private AsnIpCfgService asnIpCfgService;
|
||||
public SaveAsnIpThread(FunctionServiceDict serviceDict,FunctionRegionDict regionDict,Integer requestId,BlockingQueue<BaseIpCfg> ipPortCfgs) {
|
||||
this.serviceDict=serviceDict;
|
||||
this.regionDict=regionDict;
|
||||
this.ipPortCfgs=ipPortCfgs;
|
||||
this.requestId=requestId;
|
||||
this.asnIpCfgDao=SpringContextHolder.getBean(AsnIpCfgDao.class);
|
||||
this.configGroupInfoDao=SpringContextHolder.getBean(ConfigGroupInfoDao.class);
|
||||
}
|
||||
@Override
|
||||
public Throwable call() {
|
||||
// TODO Auto-generated method stub
|
||||
try {
|
||||
|
||||
DataSourceTransactionManager transactionManager=(DataSourceTransactionManager)SpringContextHolder.getBean("transactionManager");
|
||||
|
||||
List<AsnIpCfg> asnIpCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
|
||||
List<BaseIpCfg> _ipPortCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
|
||||
while(!ipPortCfgs.isEmpty()) {
|
||||
//开启一个新事物
|
||||
DefaultTransactionDefinition def = new DefaultTransactionDefinition();
|
||||
def.setPropagationBehavior(TransactionDefinition.PROPAGATION_REQUIRES_NEW); // 事物隔离级别,开启新事务,这样会比较安全些。
|
||||
TransactionStatus status = transactionManager.getTransaction(def); // 获得事务状态
|
||||
try {
|
||||
Date date=new Date();
|
||||
int size=ipPortCfgs.drainTo(_ipPortCfgs,Constants.MAAT_JSON_SEND_SIZE);
|
||||
List<Integer> regionIds=Lists.newArrayList();
|
||||
if(_ipPortCfgs.size()>0) {
|
||||
try {
|
||||
regionIds = ConfigServiceUtil.getId(3,_ipPortCfgs.size());
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.info("获取域ID出错");
|
||||
throw new MaatConvertException("<spring:message code=\"request_service_failed\"/>:"+e.getMessage());
|
||||
}
|
||||
int ind=0;
|
||||
for (BaseIpCfg cfg : _ipPortCfgs) {
|
||||
AsnIpCfg _cfg=new AsnIpCfg();
|
||||
BeanUtils.copyProperties(cfg, _cfg,new String[] {"cfgId"});
|
||||
_cfg.setTableName(AsnIpCfg.getTablename());
|
||||
_cfg.setAction(0);
|
||||
_cfg.setCfgRegionCode(regionDict.getConfigRegionCode());
|
||||
_cfg.setCfgType(regionDict.getConfigRegionValue());
|
||||
_cfg.setCreateTime(date);
|
||||
_cfg.setCreatorId(UserUtils.getUser().getId());
|
||||
_cfg.setDoLog(1);
|
||||
_cfg.setFunctionId(regionDict.getFunctionId());
|
||||
_cfg.setIsAudit(0);
|
||||
if(fullMap.get(Long.parseLong(_cfg.getUserRegion1()))) {
|
||||
_cfg.setIsValid(Constants.VALID_YES);
|
||||
}else {
|
||||
_cfg.setIsValid(Constants.VALID_NO);
|
||||
}
|
||||
_cfg.setIsAreaEffective(0);
|
||||
_cfg.setAttribute("0");
|
||||
_cfg.setClassify("0");
|
||||
_cfg.setLable("0");
|
||||
_cfg.setRequestId(StringUtil.isEmpty(requestId) ? 0 : requestId);
|
||||
_cfg.setServiceId(0);
|
||||
//设置region id
|
||||
if(regionIds!=null&®ionIds.size()==_ipPortCfgs.size()) {
|
||||
_cfg.setRegionId(regionIds.get(ind));
|
||||
}
|
||||
//设置group id
|
||||
if(asnNoMaps.get(0).containsKey(Long.parseLong(_cfg.getUserRegion1()))) {
|
||||
_cfg.setAsnIpGroup(asnNoMaps.get(0).get(Long.parseLong(_cfg.getUserRegion1())));
|
||||
}else if(asnNoMaps.get(1).containsKey(Long.parseLong(_cfg.getUserRegion1()))) {
|
||||
_cfg.setAsnIpGroup(asnNoMaps.get(1).get(Long.parseLong(_cfg.getUserRegion1())));
|
||||
}else {
|
||||
// ConfigGroupInfo info=asnIpCfgService.getConfigGroupInfoByAsnNo(Long.parseLong(_cfg.getUserRegion1()));
|
||||
ConfigGroupInfo info=AsnCacheUtils.get(Long.parseLong(_cfg.getUserRegion1()));
|
||||
if(info==null) {
|
||||
info=configGroupInfoDao.getInfoByAsnNo(Long.parseLong(_cfg.getUserRegion1()));
|
||||
}
|
||||
_cfg.setAsnIpGroup(info.getGroupId());
|
||||
}
|
||||
asnIpCfgs.add(_cfg);
|
||||
ind++;
|
||||
}
|
||||
this.saveAsnIpBatch(asnIpCfgs);
|
||||
}
|
||||
transactionManager.commit(status);
|
||||
}catch (Throwable e) {
|
||||
transactionManager.rollback(status);
|
||||
// TODO: handle exception
|
||||
throw e;
|
||||
}
|
||||
_ipPortCfgs.clear();
|
||||
asnIpCfgs.clear();
|
||||
}
|
||||
}catch (Exception e) {
|
||||
// TODO: handle exception
|
||||
return e;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
public Map<Long, Boolean> getFullMap() {
|
||||
return fullMap;
|
||||
}
|
||||
public void setFullMap(Map<Long, Boolean> fullMap) {
|
||||
this.fullMap = fullMap;
|
||||
}
|
||||
public List<Map<Long, Integer>> getAsnNoMaps() {
|
||||
return asnNoMaps;
|
||||
}
|
||||
public void setAsnNoMaps(List<Map<Long, Integer>> asnNoMaps) {
|
||||
this.asnNoMaps = asnNoMaps;
|
||||
}
|
||||
public void saveAsnIpBatch(List<AsnIpCfg> cfgs){
|
||||
//需要通过新增域接口新增的ip集合
|
||||
List<AsnIpCfg> toAddRegionAsnIpCfgs=Lists.newArrayList();
|
||||
long start=System.currentTimeMillis();
|
||||
for(AsnIpCfg cfg:cfgs) {
|
||||
if(Constants.VALID_YES==cfg.getIsValid().intValue()) {
|
||||
toAddRegionAsnIpCfgs.add(cfg);
|
||||
}
|
||||
}
|
||||
long end=System.currentTimeMillis();
|
||||
this.save(cfgs);
|
||||
// splitAndSend(toAddRegionAsnIpCfgs,Constants.VALID_YES);
|
||||
if(toAddRegionAsnIpCfgs.size()>0) {
|
||||
new AsnIpCfgService().asnIPRegionSendToMaat(toAddRegionAsnIpCfgs,Constants.VALID_YES);
|
||||
}
|
||||
cfgs.clear();
|
||||
toAddRegionAsnIpCfgs.clear();
|
||||
}
|
||||
public void save(List<AsnIpCfg> entitys) {
|
||||
logger.warn("Start to save IP");
|
||||
long start=System.currentTimeMillis();
|
||||
int len=0;
|
||||
List<AsnIpCfg> tempList=Lists.newArrayList();
|
||||
Varibles maxPacket=asnIpCfgDao.getVaribles("max_allowed_packet");
|
||||
for(AsnIpCfg asnIpCfg:entitys) {
|
||||
int tempLen=asnIpCfg.toString().getBytes(Charset.forName("UTF-8")).length;
|
||||
if((len+tempLen)<maxPacket.getValue().longValue()) {
|
||||
tempList.add(asnIpCfg);
|
||||
len+=tempLen;
|
||||
}else {
|
||||
logger.warn("save ip size:"+tempList.size());
|
||||
asnIpCfgDao.insertBatch(tempList);
|
||||
tempList.clear();
|
||||
tempList.add(asnIpCfg);
|
||||
len=tempLen;
|
||||
}
|
||||
}
|
||||
if(tempList.size()>0) {
|
||||
logger.warn("save ip size:"+tempList.size());
|
||||
asnIpCfgDao.insertBatch(tempList);
|
||||
tempList.clear();
|
||||
}
|
||||
// entitys.clear();
|
||||
long end=System.currentTimeMillis();
|
||||
logger.warn("Save IP finish,cost:"+(end-start));
|
||||
}
|
||||
}
|
||||
@@ -92,7 +92,6 @@ import com.nis.util.excel.thread.CheckDnsResStrategyFormatThread;
|
||||
import com.nis.util.excel.thread.CheckIpFormatThread;
|
||||
import com.nis.util.excel.thread.CheckStringFormatThread;
|
||||
import com.nis.web.dao.configuration.IpCfgDao;
|
||||
import com.nis.web.dao.configuration.WebsiteCfgDao;
|
||||
import com.nis.web.security.UserUtils;
|
||||
import com.nis.web.service.ArchiveServcie;
|
||||
import com.nis.web.service.AreaService;
|
||||
@@ -875,7 +874,7 @@ public class BaseController {
|
||||
service.shutdown();
|
||||
while(!service.isTerminated()) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
Thread.sleep(10);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
@@ -914,7 +913,7 @@ public class BaseController {
|
||||
service.shutdown();
|
||||
while(!service.isTerminated()) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
Thread.sleep(10);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
@@ -953,7 +952,7 @@ public class BaseController {
|
||||
service.shutdown();
|
||||
while(!service.isTerminated()) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
Thread.sleep(10);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
@@ -992,7 +991,7 @@ public class BaseController {
|
||||
service.shutdown();
|
||||
while(!service.isTerminated()) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
Thread.sleep(10);
|
||||
} catch (InterruptedException e) {
|
||||
// TODO Auto-generated catch block
|
||||
e.printStackTrace();
|
||||
@@ -1172,6 +1171,7 @@ public class BaseController {
|
||||
.getFunctionRegionDict(Integer.parseInt(regionDictIds.split(",")[i]));
|
||||
//加载模板
|
||||
loadTemplate(ei,regionDict, serviceDict);
|
||||
//------------------------------------check format start----------------------------
|
||||
if (regionDict.getRegionType().equals(1)) {// IP
|
||||
if (regionDict.getFunctionId().equals(5)) {
|
||||
if (serviceDict!=null&&serviceDict.getAction().equals(64)) {
|
||||
@@ -1244,6 +1244,7 @@ public class BaseController {
|
||||
if(ei.getUploadFile()!=null&&ei.getUploadFile().exists()) {
|
||||
ei.getUploadFile().delete();
|
||||
}
|
||||
//------------------------------------check format end----------------------------
|
||||
Date date = new Date();
|
||||
String specServiceId = request.getParameter("appId");
|
||||
String behaviorId = request.getParameter("behaviorId");
|
||||
@@ -1286,7 +1287,33 @@ public class BaseController {
|
||||
asnIpCfgService.processGroup(asnNoMaps.get(0));
|
||||
//全量下发,删除asnNo对应的已有的IP
|
||||
if(isImportAll.get(0).getItemCode().equals("1")) {
|
||||
logger.warn("Delete and send ip reuse regions start");
|
||||
long _start=System.currentTimeMillis();
|
||||
asnIpCfgService.deleteIps(asnNoMaps.get(1));
|
||||
// List<Future<Throwable>> list=Lists.newArrayList();
|
||||
// ExecutorService service=Executors.newFixedThreadPool(Constants.SAVE_AND_DEL_THREAD_SIZE);
|
||||
// BlockingQueue<Long> queue=new ArrayBlockingQueue<>(asnNoMaps.get(1).size());
|
||||
// queue.addAll(asnNoMaps.get(1).keySet());
|
||||
// for(int j=0;j<Constants.SAVE_AND_DEL_THREAD_SIZE;j++) {
|
||||
// DeleteAsnIpTread t=new DeleteAsnIpTread(queue);
|
||||
// list.add(service.submit(t));
|
||||
// }
|
||||
// service.shutdown();
|
||||
// while(!service.isTerminated()) {
|
||||
// Thread.sleep(10);
|
||||
// }
|
||||
// for(Future<Throwable> e:list) {
|
||||
// if(e.get()!=null) {
|
||||
// try {
|
||||
// throw e.get();
|
||||
// } catch (Throwable e1) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e1.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
long _end=System.currentTimeMillis();
|
||||
logger.warn("Delete and send ip reuse regions end,cost:"+(_end-_start));
|
||||
}
|
||||
Map<Long,Boolean> fullMap=Maps.newConcurrentMap();
|
||||
for(Long asnNo:asnNoMaps.get(0).keySet()) {
|
||||
@@ -1299,6 +1326,28 @@ public class BaseController {
|
||||
}
|
||||
fullMap.put(asnNo, info.getIsIssued().intValue()==1);
|
||||
}
|
||||
// List<Future<Throwable>> list=Lists.newArrayList();
|
||||
// ExecutorService service=Executors.newFixedThreadPool(Constants.SAVE_AND_DEL_THREAD_SIZE);
|
||||
// for(int j=0;j<Constants.SAVE_AND_DEL_THREAD_SIZE;j++) {
|
||||
// SaveAsnIpThread t=new SaveAsnIpThread(serviceDict, regionDict, requestId, ipPortCfgs);
|
||||
// t.setAsnNoMaps(asnNoMaps);
|
||||
// t.setFullMap(fullMap);
|
||||
// list.add(service.submit(t));
|
||||
// }
|
||||
// service.shutdown();
|
||||
// while(!service.isTerminated()) {
|
||||
// Thread.sleep(10);
|
||||
// }
|
||||
// for(Future<Throwable> e:list) {
|
||||
// if(e.get()!=null) {
|
||||
// try {
|
||||
// throw e.get();
|
||||
// } catch (Throwable e1) {
|
||||
// // TODO Auto-generated catch block
|
||||
// e1.printStackTrace();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
List<AsnIpCfg> asnIpCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
|
||||
List<BaseIpCfg> _ipPortCfgs=Lists.newArrayList(Constants.MAAT_JSON_SEND_SIZE);
|
||||
while(!ipPortCfgs.isEmpty()) {
|
||||
@@ -1345,7 +1394,6 @@ public class BaseController {
|
||||
}else if(asnNoMaps.get(1).containsKey(Long.parseLong(_cfg.getUserRegion1()))) {
|
||||
_cfg.setAsnIpGroup(asnNoMaps.get(1).get(Long.parseLong(_cfg.getUserRegion1())));
|
||||
}else {
|
||||
// ConfigGroupInfo info=asnIpCfgService.getConfigGroupInfoByAsnNo(Long.parseLong(_cfg.getUserRegion1()));
|
||||
ConfigGroupInfo info=AsnCacheUtils.get(Long.parseLong(_cfg.getUserRegion1()));
|
||||
if(info==null) {
|
||||
info=asnIpCfgService.getConfigGroupInfoByAsnNo(Long.parseLong(_cfg.getUserRegion1()));
|
||||
|
||||
@@ -42,14 +42,14 @@ public class AsnIpController extends BaseController{
|
||||
,RedirectAttributes redirectAttributes){
|
||||
Page<AsnIpCfg> page = asnIpCfgService.findPage(new Page<AsnIpCfg>(request, response,"r"), entity);
|
||||
model.addAttribute("page", page);
|
||||
initPageCondition(model);
|
||||
// initPageCondition(model);
|
||||
List<FunctionRegionDict> regionList = DictUtils.getFunctionRegionDictList(entity.getFunctionId());
|
||||
model.addAttribute("regionList", regionList);
|
||||
List<FunctionServiceDict> serviceList = DictUtils.getFunctionServiceDictList(entity.getFunctionId());
|
||||
model.addAttribute("serviceList", serviceList);
|
||||
|
||||
List<PolicyGroupInfo> policyGroups=policyGroupInfoService.findPolicyGroupInfosByType(4);
|
||||
model.addAttribute("policyGroups", policyGroups);
|
||||
// List<PolicyGroupInfo> policyGroups=policyGroupInfoService.findPolicyGroupInfosByType(4);
|
||||
// model.addAttribute("policyGroups", policyGroups);
|
||||
return "/basics/asnIpCfgList";
|
||||
}
|
||||
@RequestMapping(value = {"/addForm"})
|
||||
|
||||
@@ -244,7 +244,9 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
long end=System.currentTimeMillis();
|
||||
this.save(cfgs);
|
||||
// splitAndSend(toAddRegionAsnIpCfgs,Constants.VALID_YES);
|
||||
if(toAddRegionAsnIpCfgs.size()>0) {
|
||||
asnIPRegionSendToMaat(toAddRegionAsnIpCfgs,Constants.VALID_YES);
|
||||
}
|
||||
cfgs.clear();
|
||||
toAddRegionAsnIpCfgs.clear();
|
||||
}
|
||||
@@ -286,6 +288,8 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
* @param asnIpCfgs
|
||||
*/
|
||||
public void asnIPRegionSendToMaat(List<AsnIpCfg> asnIpCfgs,Integer valid) {
|
||||
logger.warn("asnIPRegionSendToMaat start");
|
||||
long start=System.currentTimeMillis();
|
||||
GroupReuseAddBean maatBean = new GroupReuseAddBean();
|
||||
List<GroupReuseCfg> groupReuseList=new ArrayList<>();
|
||||
GroupReuseCfg groupReuseCfg=new GroupReuseCfg();
|
||||
@@ -326,6 +330,8 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
ToMaatResult result = ConfigServiceUtil.put(json,3);
|
||||
logger.info("asn ip复用域删除配置响应信息:"+result.getMsg());
|
||||
}
|
||||
long end=System.currentTimeMillis();
|
||||
logger.warn("asnIPRegionSendToMaat finish,cost:"+(end-start));
|
||||
}
|
||||
/**
|
||||
* 批量保存asn PolicyGroupInfo
|
||||
|
||||
@@ -197,6 +197,7 @@ public class DnsResStrategyService extends BaseService{
|
||||
* 导入配置时数据批量入库
|
||||
* @param data
|
||||
*/
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void saveDnsResStrategyCfgBatch(List<DnsResStrategy> data) {
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
|
||||
@@ -550,3 +550,4 @@ mulity_thread_size=5
|
||||
ntcRadiusReport=ntcRadiusReport
|
||||
ntcCollectVoipLog=ntcCollectVoipLogs
|
||||
ntcKeywordsUrlLog=ntcKeywordsUrlLogs
|
||||
save_and_del_thread_size=5
|
||||
Reference in New Issue
Block a user