1、修改记录请求日志中,是否记录请求内容的逻辑;

2、配置下发测试程序中回调类获取序列号名称由seq_compileid改为SEQ_COMPILEID;
3、maat配置下阀门时域配置追加生效范围(effective_range)额外字段;
  回调类配置INLINE_IP_CB和IR_STATIC_IP_POOL_CB表添加生效范围(effective_range)字段;
This commit is contained in:
zhangdongxu
2018-11-26 17:36:01 +08:00
parent b7f46e3293
commit 50aca2d2df
8 changed files with 17 additions and 34 deletions

View File

@@ -81,6 +81,9 @@ public class ConfigSourcesController extends BaseRestController {
if (getLock(requestId)) {
if (null != configSource && null != configSource.getConfigCompileList()
&& configSource.getConfigCompileList().size() > 0) {
if (configSource.getConfigCompileList()!=null&&configSource.getConfigCompileList().size()>Constants.MAX_LIST_SIZE) {
thread.setContent("批量提交数量超过"+Constants.MAX_LIST_SIZE+"条,不记录请求内容");
}
checkOpAction(thread, System.currentTimeMillis() - start, configSource.getOpAction(),
Constants.OPACTION_POST);
// 验证配置编译数据
@@ -131,6 +134,9 @@ public class ConfigSourcesController extends BaseRestController {
if (null != configSource && null != configSource.getConfigCompileList()
&& configSource.getConfigCompileList().size() > 0) {
int opAction = configSource.getOpAction();
if (configSource.getConfigCompileList()!=null&&configSource.getConfigCompileList().size()>Constants.MAX_LIST_SIZE) {
thread.setContent("批量提交数量超过"+Constants.MAX_LIST_SIZE+"条,不记录请求内容");
}
checkOpAction(thread, System.currentTimeMillis() - start, opAction, 2);
configSourcesService.updateConfigSources(thread, start, configSource.getConfigCompileList(),
configSource.getOpTime(), sb);

View File

@@ -578,7 +578,7 @@ public class MaatTestController {
} else if (srcName.toLowerCase().equals("cfgid")
|| srcName.toLowerCase().equals("keyringid")
|| srcName.toLowerCase().equals("fileid")) {
Long incrId = configRedisService.getIncrId("seq_compileid");
Long incrId = configRedisService.getIncrId("SEQ_COMPILEID");
compileIdList.add(incrId);
jsonString.append(incrId);
} else {

View File

@@ -50,7 +50,6 @@ public class AuditLogThread implements Runnable {
private int businessCode;
private String exceptionInfo;
private String traceCode;
private Boolean saveContentFlag=true;//是否保存请求内容
/*
* (non-Javadoc)
*
@@ -63,7 +62,7 @@ public class AuditLogThread implements Runnable {
CustomerContextHolder.setCustomerType(CustomerContextHolder.DATA_SOURCE_A);// 开启数据源B
if (service != null) {
service.saveRequestLog(remoteAddr, requestURI, queryString, contextPath, operator, version, opAction,
opTime, content, requestTime, consumerTime, businessCode, exceptionInfo, traceCode,saveContentFlag);
opTime, content, requestTime, consumerTime, businessCode, exceptionInfo, traceCode);
} else {
logger.error("service 为空!");
}
@@ -430,12 +429,4 @@ public class AuditLogThread implements Runnable {
public void setTraceCode(String traceCode) {
this.traceCode = traceCode;
}
public Boolean getSaveContentFlag() {
return saveContentFlag;
}
public void setSaveContentFlag(Boolean saveContentFlag) {
this.saveContentFlag = saveContentFlag;
}
}

View File

@@ -92,7 +92,7 @@ public class ServicesRequestLogService {
*/
public void saveRequestLog(String requestAddr, String requestURI, String queryString, String contextPath,
String operator, String version, int opAction, Date opTime, Object content, Date requestTime,
long consumerTime, int businessCode, String exceptionInfo, String traceCode,Boolean saveContentFlag) {
long consumerTime, int businessCode, String exceptionInfo, String traceCode) {
logger.info("开始记录日志---");
logger.info("请求IP---" + requestAddr);
logger.info("请求路径---" + requestURI);
@@ -171,13 +171,9 @@ public class ServicesRequestLogService {
if ("file".equals(type)) {// 文件上传
log.setRequestContent(content.toString());
} else {
if(!saveContentFlag){
log.setRequestContent("批量提交数量超过"+Constants.MAX_LIST_SIZE+",不记录请求内容");
}
if (content != null) {
log.setRequestContent(content.toString());
}
}
}

View File

@@ -127,9 +127,6 @@ public class ConfigSourcesService extends BaseService {
Map<Integer, List<MaatConfig>> maatMap = new HashMap<Integer, List<MaatConfig>>();
Map<Integer, List<MaatConfig>> configMap = new HashMap<Integer, List<MaatConfig>>();
if (configCompileList!=null&&configCompileList.size()>Constants.MAX_LIST_SIZE) {
thread.setSaveContentFlag(false);
}
for (ConfigCompile configCompile : configCompileList) {
Integer service = Integer.valueOf(configCompile.getService().toString());
MaatConfig maatConfig = new MaatConfig();
@@ -326,9 +323,6 @@ public class ConfigSourcesService extends BaseService {
public void updateConfigSources(AuditLogThread thread, long start, List<ConfigCompile> compileList, Date opTime,
StringBuffer sb) throws Exception {
Map<Integer, List<Long>> compileMap = new HashMap<Integer, List<Long>>();
if (compileList!=null&&compileList.size()>Constants.MAX_LIST_SIZE) {
thread.setSaveContentFlag(false);
}
if (null != compileList && compileList.size() > 0) {
for (ConfigCompile config : compileList) {
checkCompileOptForUpdate(config);
@@ -423,7 +417,7 @@ public class ConfigSourcesService extends BaseService {
RestBusinessCode.CBParamFormateError.getValue());
}
if (jsonObjectList!=null&&jsonObjectList.size()>Constants.MAX_LIST_SIZE) {
thread.setSaveContentFlag(false);
thread.setContent("批量提交数量超过"+Constants.MAX_LIST_SIZE+"条,不记录请求内容");
}
Map<Integer, List<Map<String, String>>> dstMaps = new HashMap<Integer, List<Map<String, String>>>();
for (int i = 0; i < jsonObjectList.size(); i++) {
@@ -645,7 +639,7 @@ public class ConfigSourcesService extends BaseService {
RestBusinessCode.CBParamFormateError.getValue());
}
if (jsonObjectList!=null&&jsonObjectList.size()>Constants.MAX_LIST_SIZE) {
thread.setSaveContentFlag(false);
thread.setContent("批量提交数量超过"+Constants.MAX_LIST_SIZE+"条,不记录请求内容");
}
// <service,cfgIdList>
Map<Integer, List<Long>> cfgMap = new HashMap<Integer, List<Long>>();
@@ -879,12 +873,6 @@ public class ConfigSourcesService extends BaseService {
maatConfig.getIpRegionMapList().addAll(dstMapList);
}
if ((maatConfig.getStrRegionMapList()!=null&&maatConfig.getStrRegionMapList().size()>Constants.MAX_LIST_SIZE)
||(maatConfig.getStrStrRegionMapList()!=null&&maatConfig.getStrStrRegionMapList().size()>Constants.MAX_LIST_SIZE)
||(maatConfig.getIpRegionMapList()!=null&&maatConfig.getIpRegionMapList().size()>Constants.MAX_LIST_SIZE)
||(maatConfig.getNumRegionMapList()!=null&&maatConfig.getNumRegionMapList().size()>Constants.MAX_LIST_SIZE)) {
thread.setSaveContentFlag(false);
}
//maatConfig.setService(groupReuse.getService());
list.add(maatConfig);
}
@@ -958,7 +946,7 @@ public class ConfigSourcesService extends BaseService {
}
logger.info("调用接口删除Redis中分组复用的域配置接口");
if (reuseMap!=null&&reuseMap.size()>Constants.MAX_LIST_SIZE) {
thread.setSaveContentFlag(false);
thread.setContent("批量提交数量超过"+Constants.MAX_LIST_SIZE+"条,不记录请求内容");
}
// 所有的都删除成功返回true
if (!configRedisService.delGroupReuseConfig(reuseMap)) {

View File

@@ -345,7 +345,7 @@ tapRedisDb=5
#0x205 基于PXY IP替换 517
#0x402 APP DOMAIN特征发现 1026
#0x404 APP IP特征 1028
maat2Valve=33:strRegion@ACTION&SERVICE&USER_REGION;512:ipRegion@ACTION&SERVICE&USER_REGION;513:strRegion@ACTION&SERVICE&USER_REGION;514:ipRegion@ACTION&SERVICE&USER_REGION;515:strRegion@ACTION&SERVICE&USER_REGION;517:ipRegion@ACTION&SERVICE&USER_REGION;1026:strRegion|strStrRegion@ACTION&SERVICE&USER_REGION;1028:ipRegion@ACTION&SERVICE&USER_REGION;5:ipRegion@COMPILE_ID&USER_REGION
maat2Valve=33:strRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;512:ipRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;513:strRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;514:ipRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;515:strRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;517:ipRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;1026:strRegion|strStrRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;1028:ipRegion@ACTION&SERVICE&USER_REGION&EFFECTIVE_RANGE;5:ipRegion@COMPILE_ID&USER_REGION&EFFECTIVE_RANGE
##记录哪些service可以被分组复用(只有maat类配置可以被分组复用)
#业务ID:域类型1@表名,表名|域类型2@表名;业务ID:域类型1@表名,表名|域类型2@表名

View File

@@ -27,6 +27,7 @@
<t:field fieldType="Number" srcName="protocol" dstName="protocol" isRequired="true" defaultVal="0"/>
<t:field fieldType="Number" srcName="direction" dstName="direction" isRequired="true" range="0-1"/>
<t:field fieldType="Number" srcName="isValid" dstName="is_valid" isRequired="true" regexp="[1]"/>
<t:field fieldType="String" srcName="effectiveRange" dstName="effective_range" isRequired="true"/>
<t:field fieldType="Date" srcName="opTime" dstName="op_time" isRequired="true"/>
</t:commonSource>
<!--
@@ -110,6 +111,7 @@
<t:field fieldType="String" srcName="userRegion" dstName="user_region"/>
<t:field fieldType="Number" srcName="location" dstName="location" isRequired="true" regexp="[0|1]"/>
<t:field fieldType="Number" srcName="isValid" dstName="is_valid" isRequired="true" regexp="[1]"/>
<t:field fieldType="String" srcName="effectiveRange" dstName="effective_range" isRequired="true"/>
<t:field fieldType="Date" srcName="opTime" dstName="op_time" isRequired="true"/>
</t:commonSource>
<!--

View File

@@ -56,7 +56,7 @@
<p:maatType service="3;4;25;28;274">
<p:expressions>
<p:keyExpression>EFFECTIVE_RULE;:;{un_maat_table_name};,;[cfg_id]</p:keyExpression>
<p:valueExpression>[cfg_id];\t;0;\t;[addr_type];\t;[src_ip];\t;[mask_src_ip];\t;[src_port];\t;[mask_src_port];\t;[dst_ip];\t;[mask_dst_ip];\t;[dst_port];\t;[mask_dst_port];\t;[protocol];\t;[direction];\t;[is_valid];\t;[action];\t;[service];\t;[op_time];&amp;nbsp;0;\n</p:valueExpression>
<p:valueExpression>[cfg_id];\t;0;\t;[addr_type];\t;[src_ip];\t;[mask_src_ip];\t;[src_port];\t;[mask_src_port];\t;[dst_ip];\t;[mask_dst_ip];\t;[dst_port];\t;[mask_dst_port];\t;[protocol];\t;[direction];\t;[is_valid];\t;[action];\t;[service];\t;[effective_range];\t;[op_time];&amp;nbsp;0;\n</p:valueExpression>
</p:expressions>
<p:sequences>
<p:operation>1</p:operation>
@@ -141,7 +141,7 @@
<p:maatType service="832">
<p:expressions>
<p:keyExpression>EFFECTIVE_RULE;:;{un_maat_table_name};,;[cfg_id]</p:keyExpression>
<p:valueExpression>[cfg_id];\t;[addr_type];\t;[protocol];\t;[ip];\t;[port];\t;[direction];\t;[user_region];\t;[location];\t;[is_valid];\t;[service];\t;[policy_group];\t;[op_time];&amp;nbsp;0;\n</p:valueExpression>
<p:valueExpression>[cfg_id];\t;[addr_type];\t;[protocol];\t;[ip];\t;[port];\t;[direction];\t;[user_region];\t;[location];\t;[is_valid];\t;[service];\t;[policy_group];\t;[effective_range];\t;[op_time];&amp;nbsp;0;\n</p:valueExpression>
</p:expressions>
<p:sequences>
<p:operation>1</p:operation>