(1)index 跟子配置保存放到service同一个事务中
(2)修复是否下发选项隐藏导致的空指针异常
This commit is contained in:
@@ -319,65 +319,7 @@ public class AppCfgService extends BaseService {
|
||||
}
|
||||
}
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void savePolicyList(List<AppPolicyCfg> appPolicyCfgs){
|
||||
for (AppPolicyCfg appPolicyCfg : appPolicyCfgs) {
|
||||
appCfgDao.insertAppPolicyCfg(appPolicyCfg);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* 同一个app下的ip批量保存
|
||||
* @param cfgs
|
||||
* @param specificServiceCfg
|
||||
* @throws Exception
|
||||
*/
|
||||
@Transactional(readOnly = false, rollbackFor = RuntimeException.class)
|
||||
public void saveAppIpCfg(List<BaseIpCfg> cfgs,SpecificServiceCfg specificServiceCfg){
|
||||
logger.warn("Start to save IP");
|
||||
long start=System.currentTimeMillis();
|
||||
ConfigGroupInfo configGroupInfo=configGroupInfoDao.getConfigGroupInfoByGroupId(specificServiceCfg.getGroupId());
|
||||
if(configGroupInfo==null) {//一般特定服务的组号是新增之后就有的,不会进入这一步。
|
||||
Integer groupId = ConfigServiceUtil.getId(2, 1).get(0);
|
||||
Integer compileId=ConfigServiceUtil.getId(1, 1).get(0);
|
||||
specificServiceCfg.setGroupId(groupId);
|
||||
configGroupInfo = new ConfigGroupInfo();
|
||||
configGroupInfo.setGroupId(specificServiceCfg.getGroupId());
|
||||
configGroupInfo.setGroupName(specificServiceCfg.getSpecServiceName());
|
||||
configGroupInfo.setIsIssued(0);
|
||||
configGroupInfo.setGroupType(1);
|
||||
configGroupInfo.setCompileId(compileId);
|
||||
configGroupInfoDao.insertConfigGroupInfo(configGroupInfo);
|
||||
//更新group_id
|
||||
specificServiceCfg.setOpTime(new Date());
|
||||
specificServiceCfgDao.update(specificServiceCfg);
|
||||
}
|
||||
Integer compileId = configGroupInfo.getCompileId();
|
||||
// Varibles maxPacket=asnIpCfgDao.getVaribles("max_allowed_packet");
|
||||
List<AppIpCfg> tempList=Lists.newArrayList();
|
||||
int len=0;
|
||||
for(BaseIpCfg cfg:cfgs) {
|
||||
AppIpCfg entity=new AppIpCfg();
|
||||
BeanUtils.copyProperties(cfg, entity);
|
||||
entity.setCompileId(compileId);
|
||||
int tempLen=entity.toString().getBytes(Charset.forName("UTF-8")).length;
|
||||
if((len+tempLen)<Constants.MAX_ALLOWED_PACKET) {
|
||||
tempList.add(entity);
|
||||
len+=tempLen;
|
||||
}else {
|
||||
appCfgDao.insertAppIpCfgBatch(tempList);
|
||||
tempList.clear();
|
||||
tempList.add(entity);
|
||||
len=tempLen;
|
||||
}
|
||||
}
|
||||
if(tempList.size()>0) {
|
||||
logger.warn("save ip size:"+tempList.size());
|
||||
appCfgDao.insertAppIpCfgBatch(tempList);
|
||||
tempList.clear();
|
||||
}
|
||||
long end=System.currentTimeMillis();
|
||||
logger.warn("Save IP finish,cost:"+(end-start));
|
||||
}
|
||||
|
||||
@Transactional(readOnly = false, rollbackFor = RuntimeException.class)
|
||||
public void saveOrUpdateAppIpCfg(AppIpCfg entity) throws Exception {
|
||||
// 设置区域运营商信息
|
||||
@@ -2128,51 +2070,4 @@ public class AppCfgService extends BaseService {
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入配置时数据批量入库
|
||||
* @param listPage
|
||||
*/
|
||||
public void saveAppDomainCfgBatch(List<BaseStringCfg<?>> data) {
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
try{
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
for(int index = 0; index < data.size();index++){
|
||||
BaseStringCfg<?> entity = data.get(index);
|
||||
AppDomainCfg cfg=new AppDomainCfg();
|
||||
BeanUtils.copyProperties(entity, cfg);
|
||||
((AppCfgDao) batchSqlSession.getMapper(AppCfgDao.class)).insertAppDomainCfgBatch(cfg);
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入配置时数据批量入库
|
||||
* @param listPage
|
||||
*/
|
||||
public void saveAppHttpCfgBatch(List<ComplexkeywordCfg> data) {
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
try{
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
for(int index = 0; index < data.size();index++){
|
||||
ComplexkeywordCfg entity = data.get(index);
|
||||
AppHttpCfg cfg=new AppHttpCfg();
|
||||
BeanUtils.copyProperties(entity, cfg);
|
||||
((AppCfgDao) batchSqlSession.getMapper(AppCfgDao.class)).insertAppHttpCfgBatch(cfg);
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,30 +66,6 @@ public class DdosCfgService extends BaseService{
|
||||
return ddosCfgDao.getDdosIpCfg(cfgId);
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void saveDdosIpCfg(List<BaseIpCfg> ipPortCfgs) {
|
||||
List<DdosIpCfg> ddosIpCfgS=Lists.newArrayList(ipPortCfgs.size());
|
||||
for(BaseIpCfg cfg:ipPortCfgs) {
|
||||
DdosIpCfg ddosIpCfg=new DdosIpCfg();
|
||||
BeanUtils.copyProperties(cfg, ddosIpCfg);
|
||||
ddosIpCfgS.add(ddosIpCfg);
|
||||
}
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
try{
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
for(int index = 0; index < ddosIpCfgS.size();index++){
|
||||
DdosIpCfg ddosIpCfg = ddosIpCfgS.get(index);
|
||||
//如果insert加入了select last_insert_id,会拖慢6~7倍以上的效率
|
||||
((DdosCfgDao) batchSqlSession.getMapper(DdosCfgDao.class)).insert(ddosIpCfg);
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void saveOrUpdate(DdosIpCfg entity){
|
||||
Date createTime=new Date();
|
||||
//设置区域运营商信息
|
||||
|
||||
@@ -51,30 +51,6 @@ public class DnsIpCfgService extends BaseService{
|
||||
return dnsIpCfgDao.getDnsIpCfg(cfgId);
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void saveDnsIpCfg(List<BaseIpCfg> cfgs) {
|
||||
List<DnsIpCfg> dnsIpCfgs=Lists.newArrayList(cfgs.size());
|
||||
for(BaseIpCfg cfg:cfgs) {
|
||||
DnsIpCfg _cfg=new DnsIpCfg();
|
||||
BeanUtils.copyProperties(cfg, _cfg);
|
||||
dnsIpCfgs.add(_cfg);
|
||||
}
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
try{
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
for(int index = 0; index < dnsIpCfgs.size();index++){
|
||||
DnsIpCfg dnsIpCfg = dnsIpCfgs.get(index);
|
||||
//如果insert加入了select last_insert_id,会拖慢6~7倍以上的效率
|
||||
((DnsIpCfgDao) batchSqlSession.getMapper(DnsIpCfgDao.class)).insert(dnsIpCfg);
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void saveOrUpdate(DnsIpCfg entity){
|
||||
Date createTime=new Date();
|
||||
//设置区域运营商信息
|
||||
|
||||
@@ -193,28 +193,6 @@ 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;
|
||||
try{
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
for(int index = 0; index < data.size();index++){
|
||||
DnsResStrategy cfg = data.get(index);
|
||||
((DnsResStrategyDao) batchSqlSession.getMapper(DnsResStrategyDao.class)).insert(cfg);
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -112,23 +112,6 @@ public class IpCfgService extends CrudService<IpCfgDao,BaseIpCfg> {
|
||||
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void saveCfgIndexOf(List<CfgIndexInfo> cfgIndexInfos){
|
||||
SqlSessionFactory sqlSessionFactory=SpringContextHolder.getBean(SqlSessionFactory.class);
|
||||
SqlSession batchSqlSession = null;
|
||||
try{
|
||||
batchSqlSession = sqlSessionFactory.openSession(ExecutorType.BATCH, false);
|
||||
for(int index = 0; index < cfgIndexInfos.size();index++){
|
||||
CfgIndexInfo cfgIndexInfo = cfgIndexInfos.get(index);
|
||||
((IpCfgDao) batchSqlSession.getMapper(IpCfgDao.class)).saveCfgIndexForBatch(cfgIndexInfo);
|
||||
}
|
||||
batchSqlSession.commit();
|
||||
}finally {
|
||||
if(batchSqlSession != null){
|
||||
batchSqlSession.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
@Transactional(readOnly=false,rollbackFor=RuntimeException.class)
|
||||
public void saveIpCfg(CfgIndexInfo entity){
|
||||
//设置区域运营商信息
|
||||
setAreaEffectiveIds(entity);
|
||||
|
||||
@@ -11,7 +11,6 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import com.nis.domain.FunctionRegionDict;
|
||||
import com.nis.domain.Page;
|
||||
import com.nis.domain.configuration.AreaIpCfg;
|
||||
import com.nis.domain.configuration.BaseStringCfg;
|
||||
@@ -26,14 +25,13 @@ import com.nis.domain.configuration.IpPortCfg;
|
||||
import com.nis.domain.configuration.NtcSubscribeIdCfg;
|
||||
import com.nis.domain.configuration.SslKeywordCfg;
|
||||
import com.nis.domain.maat.MaatCfg;
|
||||
import com.nis.domain.maat.MaatCfg.NumBoundaryCfg;
|
||||
import com.nis.domain.maat.ToMaatBean;
|
||||
import com.nis.domain.maat.ToMaatResult;
|
||||
import com.nis.domain.maat.MaatCfg.DigestCfg;
|
||||
import com.nis.domain.maat.MaatCfg.GroupCfg;
|
||||
import com.nis.domain.maat.MaatCfg.IpCfg;
|
||||
import com.nis.domain.maat.MaatCfg.NumBoundaryCfg;
|
||||
import com.nis.domain.maat.MaatCfg.StringCfg;
|
||||
import com.nis.domain.specific.ConfigGroupInfo;
|
||||
import com.nis.domain.maat.ToMaatBean;
|
||||
import com.nis.domain.maat.ToMaatResult;
|
||||
import com.nis.exceptions.MaatConvertException;
|
||||
import com.nis.util.ConfigServiceUtil;
|
||||
import com.nis.util.Constants;
|
||||
|
||||
Reference in New Issue
Block a user