请求资源列表的size大于maxListSize(默认10)时,请求日志中不保存request_content

This commit is contained in:
zhangdongxu
2018-11-20 16:19:11 +08:00
parent 374c439347
commit 0547f71248
6 changed files with 52 additions and 10 deletions

View File

@@ -213,4 +213,10 @@ public final class Constants {
public static final Boolean IS_USE_MINIO = Configurations.getBooleanProperty("isUseMinio", true);
public static final int MAXTHREADNUM = Configurations.getIntProperty("maxThreadNum", 10);
public static final int EVERTHREADNUM = Configurations.getIntProperty("everThreadNum", 10000);
/**
* 保存请求内容时最大的资源列表size
*/
public static final int MAX_LIST_SIZE = Configurations.getIntProperty("maxListSize", 10);
}

View File

@@ -50,6 +50,7 @@ public class AuditLogThread implements Runnable {
private int businessCode;
private String exceptionInfo;
private String traceCode;
private Boolean saveContentFlag=true;//是否保存请求内容
/*
* (non-Javadoc)
*
@@ -62,7 +63,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);
opTime, content, requestTime, consumerTime, businessCode, exceptionInfo, traceCode,saveContentFlag);
} else {
logger.error("service 为空!");
}
@@ -430,4 +431,11 @@ public class AuditLogThread implements Runnable {
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) {
long consumerTime, int businessCode, String exceptionInfo, String traceCode,Boolean saveContentFlag) {
logger.info("开始记录日志---");
logger.info("请求IP---" + requestAddr);
logger.info("请求路径---" + requestURI);
@@ -171,6 +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,6 +127,9 @@ 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();
@@ -323,6 +326,9 @@ 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);
@@ -416,7 +422,9 @@ public class ConfigSourcesService extends BaseService {
throw new RestServiceException(RestBusinessCode.CBParamFormateError.getErrorReason() + "," + e.getMessage(),
RestBusinessCode.CBParamFormateError.getValue());
}
if (jsonObjectList!=null&&jsonObjectList.size()>Constants.MAX_LIST_SIZE) {
thread.setSaveContentFlag(false);
}
Map<Integer, List<Map<String, String>>> dstMaps = new HashMap<Integer, List<Map<String, String>>>();
for (int i = 0; i < jsonObjectList.size(); i++) {
JsonObject jsonObj = (JsonObject) jsonObjectList.get(i);
@@ -636,6 +644,9 @@ public class ConfigSourcesService extends BaseService {
throw new RestServiceException(RestBusinessCode.CBParamFormateError.getErrorReason() + "," + e.getMessage(),
RestBusinessCode.CBParamFormateError.getValue());
}
if (jsonObjectList!=null&&jsonObjectList.size()>Constants.MAX_LIST_SIZE) {
thread.setSaveContentFlag(false);
}
// <service,cfgIdList>
Map<Integer, List<Long>> cfgMap = new HashMap<Integer, List<Long>>();
// 所有状态更新的配置isValid的值必须相同
@@ -867,10 +878,18 @@ public class ConfigSourcesService extends BaseService {
} else {
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);
}
// 调用接口入redis
logger.info("---------------调用Redis 分组复用配置新增接口---------------------");
configRedisService.saveGroupReuseConfig(list);
@@ -938,6 +957,9 @@ public class ConfigSourcesService extends BaseService {
}
}
logger.info("调用接口删除Redis中分组复用的域配置接口");
if (reuseMap!=null&&reuseMap.size()>Constants.MAX_LIST_SIZE) {
thread.setSaveContentFlag(false);
}
// 所有的都删除成功返回true
if (!configRedisService.delGroupReuseConfig(reuseMap)) {
// if (!configRedisService.delGroupReuseConfigByPipeline(reuseMap)) {

View File

@@ -55,6 +55,7 @@ public class MaatTestServiceimpl {
Map<String, String[]> tapFieldMap = ServiceAndRDBIndexReal.getMaatToValveMap().get(service);
//用于判断是否是入阀门时添加的额外字段
Map<String, String> keyMap = new HashMap<String, String>();
if(null!=tapFieldMap){
Iterator iterator = tapFieldMap.keySet().iterator();
while (iterator.hasNext()) {
String [] tapFields = tapFieldMap.get(iterator.next().toString());
@@ -62,6 +63,7 @@ public class MaatTestServiceimpl {
keyMap.put(CamelUnderlineUtil.underlineToCamel(obj).toLowerCase(), obj.toLowerCase());
}
}
}
List<Integer> redisDBList = ServiceAndRDBIndexReal.getRedisDBByService(service);
if (ServiceAndRDBIndexReal.isAddASU(service)) {
if (!redisDBList.contains(TAPREDISDB)) {

View File

@@ -174,7 +174,8 @@ maxPageSize=100000
#是否开启Debug模式
isDebug=false
#保存请求内容时最大的资源列表size
maxListSize=10
#实时报表统计时间,单位:分钟
pzReportTime=5