(1)导入日志加入时间打印

(2)线程池等待sleep时间调整为10ms
This commit is contained in:
wangxin
2018-11-18 17:44:58 +08:00
parent 85123852b0
commit 97882ad05f
9 changed files with 413 additions and 11 deletions

View File

@@ -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()));

View File

@@ -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"})

View File

@@ -244,7 +244,9 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
long end=System.currentTimeMillis();
this.save(cfgs);
// splitAndSend(toAddRegionAsnIpCfgs,Constants.VALID_YES);
asnIPRegionSendToMaat(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

View File

@@ -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;