配置全量下发代码提公共方法
This commit is contained in:
@@ -62,15 +62,6 @@ import com.nis.web.service.BaseService;
|
|||||||
public class ConfigSynchronizationService extends BaseService{
|
public class ConfigSynchronizationService extends BaseService{
|
||||||
@Autowired
|
@Autowired
|
||||||
protected ConfigSynchronizationDao configSynchronizationDao;
|
protected ConfigSynchronizationDao configSynchronizationDao;
|
||||||
private ToMaatBean maatBean;
|
|
||||||
private MaatCfg maatCfg;
|
|
||||||
private List<MaatCfg> configCompileList;
|
|
||||||
private List<GroupCfg> groupRelationList;
|
|
||||||
private List<IpCfg> ipRegionList;
|
|
||||||
private List<StringCfg> strRegionList;
|
|
||||||
private List<NumBoundaryCfg> numRegionList;
|
|
||||||
private List<DigestCfg> digestRegionList;
|
|
||||||
private List<IpCfg> areaIpRegionList;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 配置全量更新下发
|
* 配置全量更新下发
|
||||||
@@ -139,6 +130,51 @@ public class ConfigSynchronizationService extends BaseService{
|
|||||||
|
|
||||||
boolean hasData = true;
|
boolean hasData = true;
|
||||||
while(hasData){
|
while(hasData){
|
||||||
|
entity.setPage(page);
|
||||||
|
List<CfgIndexInfo> list = configSynchronizationDao.getCfgIndexList(entity);
|
||||||
|
if(!StringUtil.isEmpty(list)){
|
||||||
|
hasData=auditNtcMaatData(cfgList,userRegionList,page,entity,list,hasData,isUpdateCfg);
|
||||||
|
if(hasData) {
|
||||||
|
page.setPageNo(page.getNext());
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
hasData = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* MAAT配置批量下发
|
||||||
|
* @param cfgList
|
||||||
|
* @param userRegionList
|
||||||
|
* @param page
|
||||||
|
* @param entity
|
||||||
|
* @param list
|
||||||
|
* @param hasData
|
||||||
|
* @param isUpdateCfg 业务配置全部生效时需同步更新库表配置状态
|
||||||
|
* @return
|
||||||
|
* @throws NoSuchFieldException
|
||||||
|
* @throws SecurityException
|
||||||
|
* @throws IllegalArgumentException
|
||||||
|
* @throws IllegalAccessException
|
||||||
|
*/
|
||||||
|
public boolean auditNtcMaatData(List<Map<String,Object>> cfgList,
|
||||||
|
List<Map<String,Object>> userRegionList,
|
||||||
|
Page page,
|
||||||
|
BaseCfg entity,
|
||||||
|
List<CfgIndexInfo> list,
|
||||||
|
boolean hasData,
|
||||||
|
boolean isUpdateCfg)throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException{
|
||||||
|
ToMaatBean maatBean;
|
||||||
|
MaatCfg maatCfg;
|
||||||
|
List<MaatCfg> configCompileList;
|
||||||
|
List<GroupCfg> groupRelationList;
|
||||||
|
List<IpCfg> ipRegionList;
|
||||||
|
List<StringCfg> strRegionList;
|
||||||
|
List<NumBoundaryCfg> numRegionList;
|
||||||
|
List<DigestCfg> digestRegionList;
|
||||||
|
List<IpCfg> areaIpRegionList;
|
||||||
|
|
||||||
|
|
||||||
List<IpPortCfg> ipList = new ArrayList();
|
List<IpPortCfg> ipList = new ArrayList();
|
||||||
List<BaseStringCfg> strList = new ArrayList();
|
List<BaseStringCfg> strList = new ArrayList();
|
||||||
List<ComplexkeywordCfg> complexStrList = new ArrayList();
|
List<ComplexkeywordCfg> complexStrList = new ArrayList();
|
||||||
@@ -146,9 +182,6 @@ public class ConfigSynchronizationService extends BaseService{
|
|||||||
List<FileDigestCfg> fileList = new ArrayList();
|
List<FileDigestCfg> fileList = new ArrayList();
|
||||||
maatBean = new ToMaatBean();
|
maatBean = new ToMaatBean();
|
||||||
configCompileList = new ArrayList();
|
configCompileList = new ArrayList();
|
||||||
entity.setPage(page);
|
|
||||||
List<CfgIndexInfo> list = configSynchronizationDao.getCfgIndexList(entity);
|
|
||||||
if(!StringUtil.isEmpty(list)){
|
|
||||||
List<Integer> compileIds = new ArrayList();
|
List<Integer> compileIds = new ArrayList();
|
||||||
for(CfgIndexInfo cfg:list){
|
for(CfgIndexInfo cfg:list){
|
||||||
compileIds.add(cfg.getCompileId());
|
compileIds.add(cfg.getCompileId());
|
||||||
@@ -325,8 +358,6 @@ public class ConfigSynchronizationService extends BaseService{
|
|||||||
page.setList(list);
|
page.setList(list);
|
||||||
if(page.isLastPage()){
|
if(page.isLastPage()){
|
||||||
hasData = false;
|
hasData = false;
|
||||||
}else{
|
|
||||||
page.setPageNo(page.getNext());
|
|
||||||
}
|
}
|
||||||
if(!StringUtil.isEmpty(configCompileList.size())){
|
if(!StringUtil.isEmpty(configCompileList.size())){
|
||||||
maatBean.setConfigCompileList(configCompileList);
|
maatBean.setConfigCompileList(configCompileList);
|
||||||
@@ -335,15 +366,10 @@ public class ConfigSynchronizationService extends BaseService{
|
|||||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||||
maatBean.setOpAction(Constants.INSERT_ACTION);
|
maatBean.setOpAction(Constants.INSERT_ACTION);
|
||||||
String json=gsonToJson(maatBean);
|
String json=gsonToJson(maatBean);
|
||||||
// System.out.println(json);
|
|
||||||
|
|
||||||
//调用服务接口配置全量更新
|
//调用服务接口配置全量更新
|
||||||
ToMaatResult result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,(hasData?null:"FINISHED"));
|
ToMaatResult result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,(hasData?null:"FINISHED"));
|
||||||
}
|
}
|
||||||
}else{
|
return hasData;
|
||||||
hasData = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -362,12 +388,57 @@ public class ConfigSynchronizationService extends BaseService{
|
|||||||
|
|
||||||
boolean hasData = true;
|
boolean hasData = true;
|
||||||
while(hasData){
|
while(hasData){
|
||||||
List<IpPortCfg> ipList = new ArrayList();
|
|
||||||
maatBean = new ToMaatBean();
|
|
||||||
configCompileList = new ArrayList();
|
|
||||||
entity.setPage(page);
|
entity.setPage(page);
|
||||||
List<DdosIpCfg> list = configSynchronizationDao.getDdosIpCfgList(entity);
|
List<DdosIpCfg> list = configSynchronizationDao.getDdosIpCfgList(entity);
|
||||||
if(!StringUtil.isEmpty(list)){
|
if(!StringUtil.isEmpty(list)){
|
||||||
|
hasData=auditDdosMaatData(cfgList,userRegionList,
|
||||||
|
page,entity,list,hasData,isUpdateCfg);
|
||||||
|
if(hasData) {
|
||||||
|
page.setPageNo(page.getNext());
|
||||||
|
}
|
||||||
|
}else{
|
||||||
|
hasData = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ddos配置批量下发
|
||||||
|
* @param cfgList
|
||||||
|
* @param userRegionList
|
||||||
|
* @param page
|
||||||
|
* @param entity
|
||||||
|
* @param list
|
||||||
|
* @param hasData
|
||||||
|
* @param isUpdateCfg 业务配置全部生效时需同步更新库表配置状态
|
||||||
|
* @return
|
||||||
|
* @throws NoSuchFieldException
|
||||||
|
* @throws SecurityException
|
||||||
|
* @throws IllegalArgumentException
|
||||||
|
* @throws IllegalAccessException
|
||||||
|
*/
|
||||||
|
public boolean auditDdosMaatData(List<Map<String,Object>> cfgList,
|
||||||
|
List<Map<String,Object>>userRegionList,
|
||||||
|
Page<DdosIpCfg> page,
|
||||||
|
BaseCfg entity,
|
||||||
|
List<DdosIpCfg> list,
|
||||||
|
boolean hasData,
|
||||||
|
boolean isUpdateCfg) throws NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException{
|
||||||
|
ToMaatBean maatBean;
|
||||||
|
MaatCfg maatCfg;
|
||||||
|
List<MaatCfg> configCompileList;
|
||||||
|
List<GroupCfg> groupRelationList;
|
||||||
|
List<IpCfg> ipRegionList;
|
||||||
|
List<StringCfg> strRegionList;
|
||||||
|
List<NumBoundaryCfg> numRegionList;
|
||||||
|
List<DigestCfg> digestRegionList;
|
||||||
|
List<IpCfg> areaIpRegionList;
|
||||||
|
|
||||||
|
|
||||||
|
List<IpPortCfg> ipList = new ArrayList();
|
||||||
|
maatBean = new ToMaatBean();
|
||||||
|
configCompileList = new ArrayList();
|
||||||
|
|
||||||
for(DdosIpCfg cfg:list){
|
for(DdosIpCfg cfg:list){
|
||||||
maatCfg = new MaatCfg();
|
maatCfg = new MaatCfg();
|
||||||
maatCfg.initDefaultValue();
|
maatCfg.initDefaultValue();
|
||||||
@@ -438,8 +509,6 @@ public class ConfigSynchronizationService extends BaseService{
|
|||||||
page.setList(list);
|
page.setList(list);
|
||||||
if(page.isLastPage()){
|
if(page.isLastPage()){
|
||||||
hasData = false;
|
hasData = false;
|
||||||
}else{
|
|
||||||
page.setPageNo(page.getNext());
|
|
||||||
}
|
}
|
||||||
if(!StringUtil.isEmpty(configCompileList.size())){
|
if(!StringUtil.isEmpty(configCompileList.size())){
|
||||||
maatBean.setConfigCompileList(configCompileList);
|
maatBean.setConfigCompileList(configCompileList);
|
||||||
@@ -448,15 +517,10 @@ public class ConfigSynchronizationService extends BaseService{
|
|||||||
maatBean.setVersion(Constants.MAAT_VERSION);
|
maatBean.setVersion(Constants.MAAT_VERSION);
|
||||||
maatBean.setOpAction(Constants.INSERT_ACTION);
|
maatBean.setOpAction(Constants.INSERT_ACTION);
|
||||||
String json=gsonToJson(maatBean);
|
String json=gsonToJson(maatBean);
|
||||||
// System.out.println(json);
|
|
||||||
|
|
||||||
//调用服务接口配置全量更新
|
//调用服务接口配置全量更新
|
||||||
ToMaatResult result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,(hasData?null:"FINISHED"));
|
ToMaatResult result = ConfigServiceUtil.configSync(json,1,entity.getServiceId(),null,(hasData?null:"FINISHED"));
|
||||||
}
|
}
|
||||||
}else{
|
return hasData;
|
||||||
hasData = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
* 处理app业务maat类配置
|
* 处理app业务maat类配置
|
||||||
@@ -494,9 +558,39 @@ public class ConfigSynchronizationService extends BaseService{
|
|||||||
|
|
||||||
boolean hasData = true;
|
boolean hasData = true;
|
||||||
while(hasData){
|
while(hasData){
|
||||||
|
entity.setPage(page);
|
||||||
|
hasData=auditCallbackData(className,page,entity,hasData,isUpdateCfg);
|
||||||
|
if(hasData){
|
||||||
|
page.setPageNo(page.getNext());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* 回调类配置下发
|
||||||
|
* @param className
|
||||||
|
* @param page
|
||||||
|
* @param entity
|
||||||
|
* @param hasData
|
||||||
|
* @param isUpdateCfg
|
||||||
|
* @throws ClassNotFoundException
|
||||||
|
*/
|
||||||
|
public boolean auditCallbackData(String className,
|
||||||
|
Page<BaseCfg> page,BaseCfg entity,
|
||||||
|
boolean hasData,
|
||||||
|
boolean isUpdateCfg) throws ClassNotFoundException{
|
||||||
|
ToMaatBean maatBean;
|
||||||
|
MaatCfg maatCfg;
|
||||||
|
List<MaatCfg> configCompileList;
|
||||||
|
List<GroupCfg> groupRelationList;
|
||||||
|
List<IpCfg> ipRegionList;
|
||||||
|
List<StringCfg> strRegionList;
|
||||||
|
List<NumBoundaryCfg> numRegionList;
|
||||||
|
List<DigestCfg> digestRegionList;
|
||||||
|
List<IpCfg> areaIpRegionList;
|
||||||
|
|
||||||
maatBean = new ToMaatBean();
|
maatBean = new ToMaatBean();
|
||||||
configCompileList = new ArrayList();
|
configCompileList = new ArrayList();
|
||||||
entity.setPage(page);
|
|
||||||
List list = new ArrayList();
|
List list = new ArrayList();
|
||||||
List newList = new ArrayList();
|
List newList = new ArrayList();
|
||||||
if(className.equals("AvFileSampleCfg")){
|
if(className.equals("AvFileSampleCfg")){
|
||||||
@@ -541,8 +635,6 @@ public class ConfigSynchronizationService extends BaseService{
|
|||||||
page.setList(list);
|
page.setList(list);
|
||||||
if(page.isLastPage()){
|
if(page.isLastPage()){
|
||||||
hasData = false;
|
hasData = false;
|
||||||
}else{
|
|
||||||
page.setPageNo(page.getNext());
|
|
||||||
}
|
}
|
||||||
//调用服务接口下发配置数据
|
//调用服务接口下发配置数据
|
||||||
String json=gsonToJson(newList);
|
String json=gsonToJson(newList);
|
||||||
@@ -550,8 +642,7 @@ public class ConfigSynchronizationService extends BaseService{
|
|||||||
//调用服务接口同步回调类配置
|
//调用服务接口同步回调类配置
|
||||||
ToMaatResult result = ConfigServiceUtil.configSync(json,2,entity.getServiceId(),entity.getTableName(),(hasData?null:"FINISHED"));
|
ToMaatResult result = ConfigServiceUtil.configSync(json,2,entity.getServiceId(),entity.getTableName(),(hasData?null:"FINISHED"));
|
||||||
// logger.info("回调类配置同步:"+result.getMsg());
|
// logger.info("回调类配置同步:"+result.getMsg());
|
||||||
}
|
|
||||||
|
|
||||||
|
return hasData;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user