批量配置失效、全量下发、各业务全量下发功能提交

This commit is contained in:
段冬梅
2019-03-15 16:15:11 +08:00
parent e977d00657
commit 9a9b050fc7
14 changed files with 604 additions and 307 deletions

View File

@@ -2955,6 +2955,8 @@ public class BaseController {
/************************多域maat cfg_index_info 处理****************************************/
boolean hasData = true;
while(hasData){
page.setPageNo(1);
page.setLastPage(false);
List<CfgIndexInfo> list=getDataList(page,searchCfg,null,null,null);
if(!StringUtil.isEmpty(list)){
//配置生效处理 复用全量下发
@@ -2971,9 +2973,6 @@ public class BaseController {
}
hasData=commonPolicyService.auditNtcMaatData(cfgList, page, auditBatchCfg, cfgIndexList, hasData);
}
if(hasData) {
page.setPageNo(page.getNext());
}
}else{
hasData = false;
}
@@ -2982,6 +2981,9 @@ public class BaseController {
/************************多域 maat 摘要处理****************************************/
boolean hasData = true;
while(hasData){
page.setPageNo(1);
page.setLastPage(false);
List<FileDigestCfg> list=getDataList(page,null,null,searchDigestCfg,null);
if(!StringUtil.isEmpty(list)){
//配置生效处理 复用全量下发
@@ -2998,9 +3000,6 @@ public class BaseController {
}
hasData=commonPolicyService.auditNtcMaatData(cfgList, page, auditBatchCfg,baseCfgList, hasData);
}
if(hasData) {
page.setPageNo(page.getNext());
}
}else{
hasData = false;
}
@@ -3009,6 +3008,8 @@ public class BaseController {
/************************多域 maat app策略处理****************************************/
boolean hasData = true;
while(hasData){
page.setPageNo(1);
page.setLastPage(false);
List<AppPolicyCfg> list=getDataList(page,null,searchAppCfg,null,null);
if(!StringUtil.isEmpty(list)){
//配置生效处理 复用全量下发
@@ -3025,9 +3026,6 @@ public class BaseController {
}
hasData=commonPolicyService.auditNtcMaatData(cfgList, page, auditBatchCfg,cfgAppList, hasData);
}
if(hasData) {
page.setPageNo(page.getNext());
}
}else{
hasData = false;
}
@@ -3036,6 +3034,9 @@ public class BaseController {
/************************多域 maat app特征处理****************************************/
boolean hasData = true;
while(hasData){
page.setPageNo(1);
page.setLastPage(false);
List<AppFeatureIndex> list=getDataList(page,null,null,null,searchAppFeatureIndex);
if(!StringUtil.isEmpty(list)){
//配置生效处理 复用全量下发
@@ -3052,9 +3053,6 @@ public class BaseController {
}
hasData=commonPolicyService.auditNtcMaatData(cfgList, page, auditBatchCfg,cfgFeatrureList, hasData);
}
if(hasData) {
page.setPageNo(page.getNext());
}
}else{
hasData = false;
}
@@ -3068,6 +3066,9 @@ public class BaseController {
if("ddos_ip_cfg".equals(tableNameXml)){
boolean hasData = true;
while(hasData){
page.setPageNo(1);
page.setLastPage(false);
List<DdosIpCfg> list=ddosCfgService.findPage(page, searchDdosIpCfg).getList();
if(!StringUtil.isEmpty(list)){
if(auditBatchCfg.getIsValid().equals(1)) {
@@ -3084,7 +3085,8 @@ public class BaseController {
hasData=commonPolicyService.auditNtcMaatData(cfgList, page, auditBatchCfg,newList, hasData);
}
if(hasData) {
page.setPageNo(page.getNext());
page.setPageNo(1);
page.setLastPage(false);
}
}else{
hasData = false;
@@ -3096,6 +3098,8 @@ public class BaseController {
//所有已下发的ASN IP组
boolean hasData = true;
while(hasData){
page.setPageNo(1);
page.setLastPage(false);
//已下发的ASN IP
List<AsnIpCfg> list=asnIpCfgService.findPage(page, searchAsnIpCfg).getList();
@@ -3118,9 +3122,6 @@ public class BaseController {
}
hasData=commonPolicyService.auditReuseConfigData(page, auditBatchCfg,asnIpMap,hasData);
}
if(hasData) {
page.setPageNo(page.getNext());
}
}else{
hasData = false;
}
@@ -3138,6 +3139,9 @@ public class BaseController {
boolean hasData = true;
while(hasData){
page.setPageNo(1);
page.setLastPage(false);
//已下发的APP IP
List<AppIpCfg> list=appCfgService.findAppIpList(page, searchAppIpCfg).getList();
@@ -3164,9 +3168,6 @@ public class BaseController {
}
hasData=commonPolicyService.auditReuseConfigData(page, auditBatchCfg,appIpMap,hasData);
}
if(hasData) {
page.setPageNo(page.getNext());
}
}else{
hasData = false;
}
@@ -3262,6 +3263,8 @@ public class BaseController {
}else {
boolean hasData = true;
while(hasData){
page.setPageNo(1);
page.setLastPage(false);
List list = Lists.newArrayList();
/*
1026 app_domain_cfg
@@ -3297,9 +3300,6 @@ public class BaseController {
}
hasData=commonPolicyService.auditNtcMaatData(cfgList, page, auditBatchCfg,newList, hasData);
}
if(hasData) {
page.setPageNo(page.getNext());
}
}else{
hasData = false;
}
@@ -3312,6 +3312,8 @@ public class BaseController {
/********************回调类处理生效和失效一个方法【由于每个表检索条件不一样,需要自己处理,无法复用全量下发】*********/
boolean hasData = true;
while(hasData){
page.setPageNo(1);
page.setLastPage(false);
hasData=handelCallbackData(classNameXml, page, hasData, auditBatchCfg
, searchCfg
, searchAppCfg
@@ -3324,9 +3326,6 @@ public class BaseController {
, searchDnsIpCfg
, searchIpPortCfg
, searchSignSampleCfg);
if(hasData){
page.setPageNo(page.getNext());
}
}
}
}
@@ -3340,7 +3339,7 @@ public class BaseController {
}
}
long end=System.currentTimeMillis();
logger.info("配置批量生效/失效耗时:"+(end-start));
logger.warn("配置批量生效/失效耗时:"+(end-start));
}

View File

@@ -51,10 +51,11 @@ public class ConfigSynchronizationController extends BaseController {
* 下发同步命令
*/
@RequestMapping(value = {"configSync"})
public String configSync(Model model,Integer cmd,HttpServletRequest request,HttpServletResponse response){
public String configSync(Model model,Integer cmd,Integer serviceId,HttpServletRequest request,HttpServletResponse response){
Map<String,Integer> map = new HashMap();
map.put("syncStatus", cmd);
JSONObject result = ConfigServiceUtil.configSyncCmd(BaseService.gsonToJson(map));
//TODO 联调时打开JSONObject result = ConfigServiceUtil.configSyncCmd(BaseService.gsonToJson(map));
JSONObject result=JSONObject.fromObject("{\"status\": 201,\"businessCode\": 2001000,\"reason\":\"数据获取操作成功\",\"msg\": \"根据配置id获取对应的编译,组,域等信息成功\",\"fromuri\": \"/galaxy-service/service/cfg/v1/getAllKVByCompileId\",\"traceCode\": \"2019031211285044813363\",\"data\": [{\"service\":\"ntc\",\"status\":0,\"opTime\":\"2016-11-22 08:31:27\"}]}");
if(result.get("status").equals(201)){//响应成功
if(cmd.equals(1)){//同步
SysDataDictionaryName sysDictName = new SysDataDictionaryName();
@@ -73,7 +74,7 @@ public class ConfigSynchronizationController extends BaseController {
CacheUtils.remove(Constants.CACHE_DICT_MAP);
}
}
send(model,request,response);
send(serviceId,model,request,response);
}else if(cmd.equals(0)){//取消
}
@@ -85,10 +86,10 @@ public class ConfigSynchronizationController extends BaseController {
* 下发同步配置
*/
@RequestMapping(value = {"send"})
public void send(Model model,HttpServletRequest request,HttpServletResponse response){
public void send(Integer serviceId,Model model,HttpServletRequest request,HttpServletResponse response){
int status = -2;
try {
configSynchronizationService.send(request,response,null);
configSynchronizationService.send(serviceId,request,response,null);
status = 1;
} catch (NoSuchFieldException e) {
e.printStackTrace();
@@ -128,7 +129,8 @@ public class ConfigSynchronizationController extends BaseController {
}else{
boolean isFinished = true;
while(isFinished){
JSONObject result = ConfigServiceUtil.configSyncStatus();//获取同步状态
//TODO 联调时打开JSONObject result = ConfigServiceUtil.configSyncStatus();//获取同步状态
JSONObject result = JSONObject.fromObject("{\"status\": 200,\"businessCode\": 2001000,\"reason\":\"数据获取操作成功\",\"msg\": \"根据配置id获取对应的编译,组,域等信息成功\",\"fromuri\": \"/galaxy-service/service/cfg/v1/getAllKVByCompileId\",\"traceCode\": \"2019031211285044813363\",\"data\": [{\"service\":\"ntc\",\"status\":3,\"opTime\":\"2016-11-22 08:31:27\"}]}");
if(result.get("status").equals(200)){
List<Map<String,Object>> list = result.getJSONArray("data");
if(!StringUtil.isEmpty(list)){
@@ -180,7 +182,8 @@ public class ConfigSynchronizationController extends BaseController {
String failStatus = DictUtils.getDictCode("config_sync_status", "fail","-2");
Map<String,Object> map = Maps.newHashMap();
if(!currentStatus.equals(successStatus) && !currentStatus.equals(failStatus) && !currentStatus.equals(serverFailStatus)){
JSONObject result = ConfigServiceUtil.configSyncStatus();//获取同步状态
JSONObject result = JSONObject.fromObject("{\"status\": 200,\"businessCode\": 2001000,\"reason\":\"数据获取操作成功\",\"msg\": \"根据配置id获取对应的编译,组,域等信息成功\",\"fromuri\": \"/galaxy-service/service/cfg/v1/getAllKVByCompileId\",\"traceCode\": \"2019031211285044813363\",\"data\": [{\"service\":\"ntc\",\"status\":0,\"opTime\":\"2016-11-22 08:31:27\"}]}");
//TODO 联调时打开JSONObject result = ConfigServiceUtil.configSyncStatus();//获取同步状态
if(result.get("status").equals(200)){
List<Map<String,Object>> list = result.getJSONArray("data");
if(!StringUtil.isEmpty(list)){