将max_allow_packet参数提取到配置文件中,不用每次从数据库中读取
This commit is contained in:
@@ -70,18 +70,18 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
// }
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void save(List<AsnIpCfg> entitys) {
|
||||
logger.warn("Start to save IP");
|
||||
logger.warn("Start to save IP,size:"+entitys.size());
|
||||
long start=System.currentTimeMillis();
|
||||
int len=0;
|
||||
List<AsnIpCfg> tempList=Lists.newArrayList();
|
||||
Varibles maxPacket=asnIpCfgDao.getVaribles("max_allowed_packet");
|
||||
// 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()) {
|
||||
if((len+tempLen)<Constants.MAX_ALLOWED_PACKET) {
|
||||
tempList.add(asnIpCfg);
|
||||
len+=tempLen;
|
||||
}else {
|
||||
logger.warn("save ip size:"+tempList.size());
|
||||
// logger.warn("save ip size:"+tempList.size());
|
||||
asnIpCfgDao.insertBatch(tempList);
|
||||
tempList.clear();
|
||||
tempList.add(asnIpCfg);
|
||||
@@ -89,7 +89,7 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
}
|
||||
}
|
||||
if(tempList.size()>0) {
|
||||
logger.warn("save ip size:"+tempList.size());
|
||||
// logger.warn("save ip size:"+tempList.size());
|
||||
asnIpCfgDao.insertBatch(tempList);
|
||||
tempList.clear();
|
||||
}
|
||||
@@ -121,7 +121,7 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
List<ConfigGroupInfo> configGroupInfoS=Lists.newArrayList();
|
||||
Date createTime=new Date();
|
||||
int len=0,len1=0;
|
||||
Varibles maxPacket=asnIpCfgDao.getVaribles("max_allowed_packet");
|
||||
// Varibles maxPacket=asnIpCfgDao.getVaribles("max_allowed_packet");
|
||||
for(Entry<Long, Integer> e:asnNoMap.entrySet()) {
|
||||
PolicyGroupInfo info=new PolicyGroupInfo();
|
||||
info.setAsnNo(e.getKey());
|
||||
@@ -133,7 +133,7 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
info.setCreatorId(UserUtils.getUser().getId());
|
||||
info.setCreateTime(createTime);
|
||||
int tempLen=info.toString().getBytes(Charset.forName("UTF-8")).length;
|
||||
if((len+tempLen)<maxPacket.getValue().longValue()) {
|
||||
if((len+tempLen)<Constants.MAX_ALLOWED_PACKET) {
|
||||
policyGroupInfos.add(info);
|
||||
len+=tempLen;
|
||||
}else {
|
||||
@@ -149,7 +149,7 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
group.setGroupType(info.getGroupType());
|
||||
group.setAsnId(info.getAsnNo());
|
||||
int tempLen1=group.toString().getBytes(Charset.forName("UTF-8")).length;
|
||||
if((len1+tempLen1)<maxPacket.getValue().longValue()) {
|
||||
if((len1+tempLen1)<Constants.MAX_ALLOWED_PACKET) {
|
||||
configGroupInfoS.add(group);
|
||||
len1+=tempLen1;
|
||||
}else {
|
||||
@@ -235,13 +235,11 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
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) {
|
||||
@@ -249,6 +247,8 @@ public class AsnIpCfgService extends CrudService<CrudDao<AsnIpCfg>, AsnIpCfg> {
|
||||
}
|
||||
cfgs.clear();
|
||||
toAddRegionAsnIpCfgs.clear();
|
||||
cfgs=null;
|
||||
toAddRegionAsnIpCfgs=null;
|
||||
}
|
||||
/**
|
||||
* 分割IP region分次下发
|
||||
|
||||
Reference in New Issue
Block a user