1、删除无用测试类;

2、修改maat与非maat配置下发接口,支持多service同时下发;
3、新增摘要获取接口
This commit is contained in:
zhangdongxu
2018-06-01 10:23:18 +08:00
parent bc600c12a4
commit cdc72ca655
27 changed files with 436 additions and 2492 deletions

View File

@@ -33,35 +33,25 @@ public class ConfigCompile implements Serializable {
@ApiModelProperty(value = "配置ID", required = true)
private Long compileId;
@ApiModelProperty(value = "业务ID", required = true)
private Long service;
private Integer service;
@ApiModelProperty(value = "动作", required = true)
private Integer action;
@ApiModelProperty(value = "有害类型", required = false)
private Integer contType;
@ApiModelProperty(value = "有害性质", required = false)
private Integer attrType;
@ApiModelProperty(value = "内容标签", required = false)
@ApiModelProperty(value = "分类", required = false)
private String contType;
@ApiModelProperty(value = "性质", required = false)
private String attrType;
@ApiModelProperty(value = "标签", required = false)
private String contLabel;
@ApiModelProperty(value = "任务", required = false)
private Integer taskId;
@ApiModelProperty(value = "保障期", required = false)
private Integer guaranteeId;
@ApiModelProperty(value = "事件", required = false)
@ApiModelProperty(value = "来文函号ID", required = false)
private Integer affairId;
@ApiModelProperty(value = "子话题", required = false)
private Integer topicId;
@ApiModelProperty(value = "是否黑名单", required = true)
private Long doBlacklist;
private Integer doBlacklist;
@ApiModelProperty(value = "是否生成日志", required = true)
private Integer doLog;
@ApiModelProperty(value = "生效范围", required = true)
private Integer activeSys;
@ApiModelProperty(value = "生效系统", required = true)
private String effectiveRange;
@ApiModelProperty(value = "管控比例", required = true)
private Long configPercent;
@ApiModelProperty(value = "管控方式", required = true)
private Integer configOption;
@ApiModelProperty(value = "开始时间", required = true)
private Date startTime;
@ApiModelProperty(value = "结束时间", required = true)
@@ -76,14 +66,10 @@ public class ConfigCompile implements Serializable {
private Long fatherCfgId;
@ApiModelProperty(value = "操作时间", required = true)
private Date opTime;
@ApiModelProperty(value = "本地更新时间 ", required = true)
private Date lastUpdate;
@ApiModelProperty(value = "编译分组关系列表", required = true)
private List<ConfigGroupRelation> groupRelationList;
@ApiModelProperty(value = "字符串域分组列表", access = "", required = true)
private List<StrRegion> strRegionList;
@@ -96,24 +82,8 @@ public class ConfigCompile implements Serializable {
@ApiModelProperty(value = "摘要域分组列表", required = true)
private List<DigestRegion> digestRegionList;
@ApiModelProperty(value="版本序列号", required=true)
private Long procSeq;
@JsonIgnore
public Date getLastUpdate() {
return lastUpdate;
}
public void setLastUpdate(Date lastUpdate) {
this.lastUpdate = lastUpdate;
}
public Integer getActiveSys() {
return activeSys;
}
public void setActiveSys(Integer activeSys) {
this.activeSys = activeSys;
}
@ApiModelProperty(value = "生效范围IP域分组列表", required = true)
private List<IpRegion> ipClientRangeList;
public Long getCompileId() {
return compileId;
@@ -126,7 +96,7 @@ public class ConfigCompile implements Serializable {
/**
* @return service
*/
public Long getService() {
public Integer getService() {
return service;
}
@@ -134,7 +104,7 @@ public class ConfigCompile implements Serializable {
* @param service
* 要设置的 service
*/
public void setService(Long service) {
public void setService(Integer service) {
this.service = service;
}
@@ -153,19 +123,19 @@ public class ConfigCompile implements Serializable {
this.action = action;
}
public Integer getContType() {
public String getContType() {
return contType;
}
public void setContType(Integer contType) {
public void setContType(String contType) {
this.contType = contType;
}
public Integer getAttrType() {
public String getAttrType() {
return attrType;
}
public void setAttrType(Integer attrType) {
public void setAttrType(String attrType) {
this.attrType = attrType;
}
@@ -180,7 +150,7 @@ public class ConfigCompile implements Serializable {
/**
* @return doBlackList
*/
public Long getDoBlacklist() {
public Integer getDoBlacklist() {
return doBlacklist;
}
@@ -188,7 +158,7 @@ public class ConfigCompile implements Serializable {
* @param doBlackList
* 要设置的 doBlackList
*/
public void setDoBlacklist(Long doBlacklist) {
public void setDoBlacklist(Integer doBlacklist) {
this.doBlacklist = doBlacklist;
}
@@ -222,35 +192,6 @@ public class ConfigCompile implements Serializable {
this.effectiveRange = effectiveRange;
}
/**
* @return configPercent
*/
public Long getConfigPercent() {
return configPercent;
}
/**
* @param configPercent
* 要设置的 configPercent
*/
public void setConfigPercent(Long configPercent) {
this.configPercent = configPercent;
}
/**
* @return configOption
*/
public Integer getConfigOption() {
return configOption;
}
/**
* @param configOption
* 要设置的 configOption
*/
public void setConfigOption(Integer configOption) {
this.configOption = configOption;
}
/**
* @return startTime
@@ -437,14 +378,6 @@ public class ConfigCompile implements Serializable {
this.taskId = taskId;
}
public Integer getGuaranteeId() {
return guaranteeId;
}
public void setGuaranteeId(Integer guaranteeId) {
this.guaranteeId = guaranteeId;
}
public Integer getAffairId() {
return affairId;
}
@@ -453,19 +386,12 @@ public class ConfigCompile implements Serializable {
this.affairId = affairId;
}
public Integer getTopicId() {
return topicId;
public List<IpRegion> getIpClientRangeList() {
return ipClientRangeList;
}
public void setTopicId(Integer topicId) {
this.topicId = topicId;
public void setIpClientRangeList(List<IpRegion> ipClientRangeList) {
this.ipClientRangeList = ipClientRangeList;
}
@JsonIgnore
public Long getProcSeq() {
return procSeq;
}
public void setProcSeq(Long procSeq) {
this.procSeq = procSeq;
}
}

View File

@@ -29,8 +29,6 @@ public class ConfigGroupRelation implements Serializable {
*
*/
private static final long serialVersionUID = -9021829042309605139L;
@ApiModelProperty(value = "id", required = true)
private Long id;
@ApiModelProperty(value = "分组ID", required = true)
private Long groupId;
@ApiModelProperty(value = "编译ID", required = true)
@@ -39,19 +37,7 @@ public class ConfigGroupRelation implements Serializable {
private Integer isValid;
@ApiModelProperty(value = "操作时间", required = true)
private Date opTime;
@ApiModelProperty(value = "本地更新时间", required = true)
private Date lastUpdate;
@ApiModelProperty(value = "版本序列号", required = true)
private Long procSeq;
@JsonIgnore
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
/**
* @return groupId
@@ -114,22 +100,4 @@ public class ConfigGroupRelation implements Serializable {
this.opTime = opTime;
}
@JsonIgnore
public Date getLastUpdate() {
return lastUpdate;
}
public void setLastUpdate(Date lastUpdate) {
this.lastUpdate = lastUpdate;
}
@JsonIgnore
public Long getProcSeq() {
return procSeq;
}
public void setProcSeq(Long procSeq) {
this.procSeq = procSeq;
}
}

View File

@@ -49,6 +49,10 @@ public class MaatConfig implements Serializable {
*/
private List<Map<String, String>> fileLikeRegionMapList;
/**
*
*/
private List<Map<String, String>> ipClientRangeMapList;
/**
* 业务类型
*/
@@ -118,6 +122,15 @@ public class MaatConfig implements Serializable {
this.fileLikeRegionMapList = fileLikeRegionMapList;
}
public List<Map<String, String>> getIpClientRangeMapList() {
return ipClientRangeMapList;
}
public void setIpClientRangeMapList(
List<Map<String, String>> ipClientRangeMapList) {
this.ipClientRangeMapList = ipClientRangeMapList;
}
public Integer getService() {
return service;
}

View File

@@ -382,7 +382,7 @@ public class CompileJudge {
* @param tableName
* @return
*/
public static boolean type2TableNameIsOk(Long serviceType, String tableName) {
public static boolean type2TableNameIsOk(Integer serviceType, String tableName) {
if (null != serviceType && null != tableName && !tableName.equals("")) {
Map<Integer, Map<String, String>> tableRelation = ConfigSourcesService.getTableRelation();
Map<String, String> map = tableRelation.get(serviceType.intValue());
@@ -456,12 +456,6 @@ public class CompileJudge {
if (null == configCompile.getEffectiveRange() || configCompile.getEffectiveRange().equals("")) {
return "id为" + compileId + "的编译配置中effectiveRange不能为空";
}
if (null == configCompile.getConfigPercent()) {
return "id为" + compileId + "的编译配置中configPercent不能为空";
}
if (null == configCompile.getConfigOption()) {
return "id为" + compileId + "的编译配置中configOption不能为空";
}
if (null == configCompile.getStartTime()) {
return "id为" + compileId + "的编译配置中startTime不能为空";
}
@@ -483,9 +477,6 @@ public class CompileJudge {
if (null == configCompile.getOpTime()) {
return "id为" + compileId + "的编译配置中opTime不能为空";
}
if (null == configCompile.getActiveSys()) {
return "id为" + compileId + "的编译配置中activeSys不能为空";
}
return "ok";
}

View File

@@ -358,7 +358,7 @@ public class CompileVal {
* @param tableName
* @return
*/
public static boolean type2TableNameIsOk(Long serviceType, String tableName) {
public static boolean type2TableNameIsOk(Integer serviceType, String tableName) {
if (null != serviceType && null != tableName && !tableName.equals("")) {
Map<Integer, Map<String, String>> tableRelation = ConfigSourcesService.getTableRelation();
Map<String, String> map = tableRelation.get(serviceType.intValue());
@@ -432,12 +432,6 @@ public class CompileVal {
if (null == configCompile.getEffectiveRange() || configCompile.getEffectiveRange().equals("")) {
return "id为" + compileId + "的编译配置中effectiveRange不能为空";
}
if (null == configCompile.getConfigPercent()) {
return "id为" + compileId + "的编译配置中configPercent不能为空";
}
if (null == configCompile.getConfigOption()) {
return "id为" + compileId + "的编译配置中configOption不能为空";
}
if (null == configCompile.getStartTime()) {
return "id为" + compileId + "的编译配置中startTime不能为空";
}
@@ -459,9 +453,6 @@ public class CompileVal {
if (null == configCompile.getOpTime()) {
return "id为" + compileId + "的编译配置中opTime不能为空";
}
if (null == configCompile.getActiveSys()) {
return "id为" + compileId + "的编译配置中activeSys不能为空";
}
return "ok";
}
@@ -645,18 +636,19 @@ public class CompileVal {
+ "的域配置direction的值不正确,只能是0或1";
}
if (ipRegion.getTableName().toLowerCase().equals("dj_ip_port")) {
if (ipRegion.getProtocol() < 0 || ipRegion.getProtocol() > 255) {
return "编译配置id为" + compileId + "的配置中ipRegionList中regionId为" + ipRegion.getRegionId()
+ "的域配置tableName为dj_ip_port时,protocol的取值范围只能是0-255";
}
} else {
if (ipRegion.getProtocol() != 0) {
return "编译配置id为" + compileId + "的配置中ipRegionList中regionId为" + ipRegion.getRegionId() + "的域配置tableName为"
+ ipRegion.getTableName() + "时,protocol的值只能是0";
}
}
//zdx protocol验证
// if (ipRegion.getTableName().toLowerCase().equals("dj_ip_port")) {
// if (ipRegion.getProtocol() < 0 || ipRegion.getProtocol() > 255) {
// return "编译配置id为" + compileId + "的配置中ipRegionList中regionId为" + ipRegion.getRegionId()
// + "的域配置tableName为dj_ip_port时,protocol的取值范围只能是0-255";
// }
// } else {
// if (ipRegion.getProtocol() != 0) {
// return "编译配置id为" + compileId + "的配置中ipRegionList中regionId为" + ipRegion.getRegionId() + "的域配置tableName为"
// + ipRegion.getTableName() + "时,protocol的值只能是0";
// }
//
// }
return "ok";
}
@@ -694,14 +686,6 @@ public class CompileVal {
return "编译配置id为" + compileId + "的配置中doLog的值只能是0(不需要),1(需要),2(只记录结构化日志,不记录非结构化日志)";
}
if (configCompile.getActiveSys() < 1 || configCompile.getActiveSys() > 7) {
return "编译配置id为" + compileId + "的配置中activeSys的值范围只能是1-7";
}
if (configCompile.getConfigOption() != 1 && configCompile.getConfigOption() != 2) {
return "编译配置id为" + compileId + "的配置中configOption的值只能是1或2";
}
if (configCompile.getFatherCfgId() != 0) {
return "编译配置id为" + compileId + "的配置中fatherCfgId的值只能是0";
}

View File

@@ -189,4 +189,6 @@ public final class Constants {
*/
public static final String HIVEBDBNAME = Configurations.getStringProperty("jdbc.hive.BName", "xa_z2_mesalog_hive");
public static final String DIGEST_GEN_TOOL_PATH = Configurations.getStringProperty("digest.gen.tool.path", "maat-redis/digest_gen");
}

View File

@@ -377,6 +377,7 @@ public class BaseRestController {
thread.setService(service);
thread.setContent(fileInfo);
thread.setOpAction(opAction);
thread.setTraceCode(sdf.format(new Date())+(Math.round((Math.random()*9+1)*10000)+""));
if (data != null && ConfigCommonSource.class.isAssignableFrom(data.getClass())) {
System.out.println(data.getClass().getSimpleName());
ConfigCommonSource source = (ConfigCommonSource) data;

View File

@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import com.nis.domain.restful.ConfigCompile;
import com.nis.domain.restful.ConfigSource;
@@ -264,15 +265,9 @@ public class ConfigSourcesController extends BaseRestController {
checkOpAction(thread, System.currentTimeMillis() - start, opAction, 2);
String msg = "";
ConfigCompile compile = configSource.getConfigCompileList().get(0);
if (StringUtil.isEmpty(compile.getGroupRelationList()) && StringUtil.isEmpty(compile.getIpRegionList())
&& StringUtil.isEmpty(compile.getStrRegionList())
&& StringUtil.isEmpty(compile.getNumRegionList())) {
msg = configSourcesService.updateByJDBCThread3(thread, start, configSource.getConfigCompileList(),
//zdx 20180528改为调用rkg接口取消配置
msg = configSourcesService.cancleConfigSources(thread, start, configSource.getConfigCompileList(),
configSource.getOpTime(), sb);
} else {
msg = configSourcesService.updateByJDBCThread12(thread, start, configSource.getConfigCompileList(),
configSource.getOpTime(), sb);
}
if (msg.equals("error")) {
String errorCode = "";
@@ -337,11 +332,11 @@ public class ConfigSourcesController extends BaseRestController {
throw new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置id不能为空",
RestBusinessCode.missing_args.getValue());
}
if ((configCompile.getActiveSys() != null) || (configCompile.getEffectiveRange() != null
&& !configCompile.getEffectiveRange().equals(""))) {
count++;
configSourcesService.setCompileInvalid(configCompile);
}
// if ((configCompile.getActiveSys() != null) || (configCompile.getEffectiveRange() != null
// && !configCompile.getEffectiveRange().equals(""))) {
// count++;
// configSourcesService.setCompileInvalid(configCompile);
// }
}
if (count > 0) {
Thread.sleep(14000);
@@ -369,33 +364,33 @@ public class ConfigSourcesController extends BaseRestController {
throw new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置id不能为空",
RestBusinessCode.missing_args.getValue());
}
if ((configCompile.getActiveSys() != null) || (configCompile.getEffectiveRange() != null
&& !configCompile.getEffectiveRange().equals(""))) {
try {
configSourcesService.setCompileValid(configCompile);
} catch (Exception e1) {
String errorCode = "";
String message = e.getMessage();
if (null != message && message.length() > 0) {
int index = message.toUpperCase().indexOf("ORA-");
if (index != -1) {
errorCode = message.substring(index + 4, index + 9);
}
}
Map<Integer, String> throwExceptionInfo = OracleErrorCodeUtil
.throwExceptionInfo(errorCode);
for (int errorNum : throwExceptionInfo.keySet()) {
if (errorNum == 998) {
thread.setExceptionInfo(e.toString());
} else {
thread.setExceptionInfo(throwExceptionInfo.get(errorNum));
}
throw new RestServiceException(thread, System.currentTimeMillis() - start,
throwExceptionInfo.get(errorNum), errorNum);
}
}
}
// if ((configCompile.getActiveSys() != null) || (configCompile.getEffectiveRange() != null
// && !configCompile.getEffectiveRange().equals(""))) {
// try {
// configSourcesService.setCompileValid(configCompile);
// } catch (Exception e1) {
// String errorCode = "";
// String message = e.getMessage();
// if (null != message && message.length() > 0) {
// int index = message.toUpperCase().indexOf("ORA-");
// if (index != -1) {
// errorCode = message.substring(index + 4, index + 9);
//
// }
// }
// Map<Integer, String> throwExceptionInfo = OracleErrorCodeUtil
// .throwExceptionInfo(errorCode);
// for (int errorNum : throwExceptionInfo.keySet()) {
// if (errorNum == 998) {
// thread.setExceptionInfo(e.toString());
// } else {
// thread.setExceptionInfo(throwExceptionInfo.get(errorNum));
// }
// throw new RestServiceException(thread, System.currentTimeMillis() - start,
// throwExceptionInfo.get(errorNum), errorNum);
// }
// }
// }
}
}
@@ -459,7 +454,6 @@ public class ConfigSourcesController extends BaseRestController {
@RequestMapping(value = "/cfg/v1/commonSources", method = RequestMethod.POST, produces = org.springframework.http.MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "回调配置存储", httpMethod = "POST", response = Map.class, notes = "回调配置存储服务")
// @ApiParam(value = "回调配置数据源", name = "JSONObject", requirerue)
public Map createCommonConfigSource(@RequestBody String jsonString, HttpServletRequest request,
HttpServletResponse response) {
ConfigSourcesService.setMsgList(new ArrayList<Exception>());// 清除上次记录的日志信息
@@ -468,12 +462,27 @@ public class ConfigSourcesController extends BaseRestController {
null);
StringBuffer sb = new StringBuffer();
configSourcesService.savaCommonSources(thread, start, jsonString, sb);
configSourcesService.saveCommonSources(thread, start, jsonString, sb);
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "配置数据插入成功",
Constants.IS_DEBUG ? jsonString : null);
}
@RequestMapping(value = "/cfg/v1/commonSources", method = RequestMethod.PUT, produces=org.springframework.http.MediaType.APPLICATION_JSON_VALUE)
@ApiOperation(value = "回调配置状态修改", httpMethod = "PUT", response = Map.class, notes = "回调配置状态修改服务")
public Map updateCommonConfigSource(@RequestBody String jsonString , HttpServletRequest request,
HttpServletResponse response) {
ConfigSourcesService.setMsgList(new ArrayList<Exception>());// 清除上次记录的日志信息
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,null);
StringBuffer sb = new StringBuffer();
configSourcesService.saveCommonSources(thread, start, jsonString, sb);
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
"配置数据插入成功" , Constants.IS_DEBUG ? jsonString : null);
}
@RequestMapping(value = "/cfg/v1/fileUploadSources", method = RequestMethod.POST)
@ApiOperation(value = "样例文件上传服务", httpMethod = "POST", response = Map.class, notes = "样例文件上传服务")
@ApiParam(value = "样例文件上传服务", name = "MultipartFile", required = true)
@@ -481,12 +490,16 @@ public class ConfigSourcesController extends BaseRestController {
HttpServletResponse response) {
ConfigSourcesService.setMsgList(new ArrayList<Exception>());// 清除上次记录的日志信息
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
null);
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,null);
String filePath ="";
try {
FileDesc fileDesc = (FileDesc) JSONObject.toBean(JSONObject.fromObject(request.getHeader("File-Desc")),
FileDesc.class);
FileDesc fileDesc = (FileDesc) JSONObject.toBean(JSONObject.fromObject(request.getHeader("File-Desc")),FileDesc.class);
if(null==file){
thread.setExceptionInfo("请选择上传文件到file参数");
throw new RestServiceException(thread, System.currentTimeMillis() - start, "请选择上传文件到file参数",
RestBusinessCode.missing_args.getValue());
}
if (!StringUtil.isEmpty(fileDesc.getChecksum())) {
//验证Md5
String md5 = DigestUtils.md5Hex(file.getBytes());
@@ -500,11 +513,11 @@ public class ConfigSourcesController extends BaseRestController {
FastDFSFile fdsfile = new FastDFSFile(file.getBytes(),file.getOriginalFilename(), ext);
// NameValuePair[] meta_list = new NameValuePair[5];
// meta_list[0] = new NameValuePair("fileName", file.getOriginalFilename());
// meta_list[1] = new NameValuePair("fileLength",
// String.valueOf(file.getSize()));
// meta_list[1] = new NameValuePair("fileLength", String.valueOf(file.getSize()));
// meta_list[2] = new NameValuePair("fileExt", ext);
// meta_list[3] = new NameValuePair("fileAuthor", "rkg");
// meta_list[4] = new NameValuePair("fileMd5", md5);
logger.info("-----------------调用接口上传文件---------------");
filePath = FileManager.upload(fdsfile, null);
}else{
thread.setExceptionInfo("请求头信息中缺少checksum参数");
@@ -517,9 +530,76 @@ public class ConfigSourcesController extends BaseRestController {
}
JSONObject jsonObj = new JSONObject();
jsonObj.put("accessUrl", filePath.substring(filePath.indexOf("group")));
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "文件上传成功", jsonObj);
// jsonObj.put("accessUrl", "filePath");
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response,
"文件上传成功" ,jsonObj);
}
@RequestMapping(value = "/cfg/v1/fileDigestSources", method = RequestMethod.POST)
@ApiOperation(value = "文件摘要获取", httpMethod = "POST", response = Map.class, notes = "文件摘要获取")
@ApiParam(value = "摘要文件", name = "MultipartFile", required = true)
public Map fileDigestSources(MultipartFile file,HttpServletRequest request,
HttpServletResponse response){
long start = System.currentTimeMillis();
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,file,null);
//JSONArray fileArray=new JSONArray();
if (file==null) {
thread.setExceptionInfo("请上传获取摘要的文件到file");
throw new RestServiceException(thread, System.currentTimeMillis() - start, "请上传获取摘要的文件到file参数",
RestBusinessCode.missing_args.getValue());
}
JSONObject resultObject = new JSONObject();
FileDesc fileDesc = (FileDesc) JSONObject.toBean(JSONObject.fromObject(request.getHeader("File-Desc")),FileDesc.class);
try {
if (!StringUtil.isEmpty(fileDesc.getChecksum())) {
//验证Md5
String md5 = DigestUtils.md5Hex(file.getBytes());
System.out.println("----------------------------MD5:'"+md5+"'==='"+fileDesc.getChecksum()+"'");
if (!md5.equals(fileDesc.getChecksum())) {
thread.setExceptionInfo("checksum与文件MD5值不一致");
throw new RestServiceException(thread, System.currentTimeMillis() - start, "checksum与文件MD5值不一致",
RestBusinessCode.config_integrity_error.getValue());
}
String ext = file.getOriginalFilename().substring(file.getOriginalFilename().lastIndexOf(".") + 1);
FastDFSFile fdsfile = new FastDFSFile(file.getBytes(),file.getOriginalFilename(), ext);
// NameValuePair[] meta_list = new NameValuePair[5];
// meta_list[0] = new NameValuePair("fileName", file.getOriginalFilename());
// meta_list[1] = new NameValuePair("fileLength", String.valueOf(file.getSize()));
// meta_list[2] = new NameValuePair("fileExt", ext);
// meta_list[3] = new NameValuePair("fileAuthor", "rkg");
// meta_list[4] = new NameValuePair("fileMd5", md5);
logger.info("-----------------调用接口上传文件---------------");
String filePath = FileManager.upload(fdsfile, null);
resultObject.put("path", filePath.substring(filePath.indexOf("group")));
}else{
thread.setExceptionInfo("请求头信息中缺少checksum参数");
throw new RestServiceException(thread, System.currentTimeMillis() - start, "请求头信息中缺少checksum参数",
RestBusinessCode.missing_args.getValue());
}
CommonsMultipartFile filetemp = (CommonsMultipartFile) file;
String tempFilePath = filetemp.getStorageDescription().toString();
tempFilePath = tempFilePath.substring(tempFilePath.indexOf("[")+1, tempFilePath.indexOf("]"));
String digestStr = configSourcesService.getDigestGen(request.getRealPath("/"),tempFilePath);
resultObject.put("digest", digestStr);
resultObject.put("rawLen", file.getSize());
}catch (IOException e) {
// TODO Auto-generated catch block
logger.error("文件上传过程中出现异常");
thread.setExceptionInfo("文件上传过程中出现异常");
throw new RestServiceException(thread, System.currentTimeMillis() - start, "文件上传过程中出现异常",
RestBusinessCode.unknow_error.getValue());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
logger.error("摘要获取过程中出现异常");
thread.setExceptionInfo("摘要获取过程中出现异常");
throw new RestServiceException(thread, System.currentTimeMillis() - start, "摘要获取过程中出现异常",
RestBusinessCode.unknow_error.getValue());
}
return serviceResponse(thread,System.currentTimeMillis()-start,request, response, "摘要获取成功",resultObject);
}
private boolean isBlank(Date datetime) {
if (null != datetime) {
return true;

View File

@@ -577,28 +577,28 @@ public class ConfigTestController extends BaseRestController {
System.out.println("compileId--------------------------" + compileId);
ConfigCompileTest configCompile = new ConfigCompileTest();
configCompile.setCompileId(compileId);
configCompile.setService(serviceType);
// configCompile.setService(serviceType);
configCompile.setAction(action);
configCompile.setContType(0);
configCompile.setAttrType(0);
// configCompile.setContType(0);
// configCompile.setAttrType(0);
configCompile.setContLabel("0");
configCompile.setTaskId(0);
configCompile.setGuaranteeId(0);
// configCompile.setGuaranteeId(0);
configCompile.setAffairId(0);
configCompile.setTopicId(0);
configCompile.setDoBlacklist(0l);
// configCompile.setTopicId(0);
// configCompile.setDoBlacklist(0l);
configCompile.setDoLog(0);
configCompile.setEffectiveRange("0");
configCompile.setConfigPercent(100l);
configCompile.setConfigOption(1);
// configCompile.setConfigPercent(100l);
// configCompile.setConfigOption(1);
configCompile.setStartTime(sdf.parse(startTime));
configCompile.setEndTime(sdf.parse(endTime));
// configCompile.setStartTime(startTime);
// configCompile.setEndTime(endTime);
configCompile.setActiveSys(0);
configCompile.setLastUpdate(date);
configCompile.setProcSeq(compileId);
// configCompile.setActiveSys(0);
// configCompile.setLastUpdate(date);
// configCompile.setProcSeq(compileId);
configCompile.setUserRegion("0");
configCompile.setIsValid(1);
configCompile.setGroupNum(1);
@@ -634,7 +634,7 @@ public class ConfigTestController extends BaseRestController {
List<ConfigGroupRelation> groupRelationList = new ArrayList<ConfigGroupRelation>();
ConfigGroupRelation configGroupRelation = new ConfigGroupRelation();
configGroupRelation.setGroupId(groupId);
configGroupRelation.setId(groupId);
// configGroupRelation.setId(groupId);
configGroupRelation.setCompileId(compileId);
configGroupRelation.setIsValid(1);
configGroupRelation.setOpTime(date);

View File

@@ -1,721 +0,0 @@
package com.nis.web.controller.restful;
import java.sql.SQLException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.nis.domain.Page;
import com.nis.domain.restful.ConfigCompile;
import com.nis.domain.restful.ConfigCompileTest;
import com.nis.domain.restful.ConfigGroupRelation;
import com.nis.domain.restful.ConfigSourceTest;
import com.nis.domain.restful.IpRegion;
import com.nis.domain.restful.IpRegionTest;
import com.nis.domain.restful.NumRegion;
import com.nis.domain.restful.NumRegionTest;
import com.nis.domain.restful.StrRegion;
import com.nis.domain.restful.StrRegionTest;
import com.nis.restful.RestBusinessCode;
import com.nis.restful.RestServiceException;
import com.nis.util.Constants;
import com.nis.util.JsonDateValueProcessor;
import com.nis.util.StringUtils;
import com.nis.web.controller.BaseRestController;
import com.nis.web.service.SaveRequestLogThread;
import com.nis.web.service.ServicesRequestLogService;
import com.nis.web.service.restful.ConfigSourcesService;
import com.wordnik.swagger.annotations.Api;
import com.wordnik.swagger.annotations.ApiOperation;
import net.sf.json.JSONArray;
import net.sf.json.JsonConfig;
@RestController
@RequestMapping("${servicePath}/cfg/v1/test")
@Api(value = "SaveConfigTestController", description = "配置存储服务,包括管控、监测、白名单的控制类")
public class SaveConfigTestController extends BaseRestController {
private long allCount = 0l;
private static SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Logger logger = Logger.getLogger(ConfigTestController.class);
@Autowired
protected ConfigSourcesService configSourcesService;
@Autowired
protected ServicesRequestLogService servicesRequestLogService;
@RequestMapping(value = "/testSaveByJDBCThread", method = RequestMethod.GET)
@ApiOperation(value = "测试批量业务配置存储", httpMethod = "GET", response = Map.class, notes = "对有效的配置(封堵|监测|白名单)存储")
public Map testSaveByJDBCThread(@RequestParam(value = "configCount", required = false) Long configCount,
@RequestParam(value = "startNum", required = false) Long startNum,
@RequestParam(value = "startTime", required = false) String startTime,
@RequestParam(value = "endTime", required = false) String endTime, HttpServletRequest request,
HttpServletResponse response) {
try {
startTime = "2016-11-01 08:20:20";
endTime = "2016-11-8 15:55:33";
if (configCount == null) {
configCount = 0l;
}
allCount = 0l;
long dataCount = 0l;
if (startTime == null || startTime.equals("")) {
startTime = sdf.format(new Date());
}
if (endTime == null || endTime.equals("")) {
endTime = sdf.format(new Date());
}
Date date = new Date();
ConfigSourceTest configSource = new ConfigSourceTest();
configSource.setOpTime(date);
configSource.setOpAction(1);
configSource.setOperator("rkg");
configSource.setVersion("0.1");
List<ConfigCompile> configCompileList = new ArrayList<ConfigCompile>();
if (startNum == null || startNum == 0) {
startNum = 1l;
}
long count = System.currentTimeMillis() + startNum;
Integer[] zeroArr = { 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
Integer[] oneArr = { 15, 16, 17, 18, 32, 33, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62 };
Integer[] twoArr = { 2 };
for (Integer x = 0; x < zeroArr.length; x++) {
for (Long i = 1l; i <= configCount; i++) {
count++;
dataCount++;
allCount++;
ConfigCompile configCompile = setCompileTest(zeroArr[x].longValue(), 0, date, startTime, endTime,
count);
configCompileList.add(configCompile);
}
}
for (Integer x = 15; x < oneArr.length + 15; x++) {
for (Long i = 1l; i <= configCount; i++) {
count++;
dataCount++;
allCount++;
ConfigCompile configCompile = setCompileTest(oneArr[x - 15].longValue(), 1, date, startTime,
endTime, count);
configCompileList.add(configCompile);
}
}
for (Integer x = 50; x < twoArr.length + 50; x++) {
for (Long i = 1l; i <= configCount; i++) {
count++;
dataCount++;
allCount++;
ConfigCompile configCompile = setCompileTest(twoArr[x - 50].longValue(), 2, date, startTime,
endTime, count);
configCompileList.add(configCompile);
}
}
configSource.setConfigCompileList(configCompileList);
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST,
request, configSource);
// JsonConfig jsonConfig = new JsonConfig();
// jsonConfig.registerJsonValueProcessor(Date.class, new
// JsonDateValueProcessor());
// JSONArray jsonArray = JSONArray.fromObject(configSource,
// jsonConfig);
// String jsonStr = jsonArray.getString(0);
// String distisct = "\"district\":\"\",";
// if (jsonStr.contains(distisct)) {
// jsonStr = jsonStr.replaceAll(distisct, "");
// }
// System.out.println(jsonStr);
System.out.println("开始执行插入操作" + dataCount + "条配置总计" + allCount + "条数据");
long start = System.currentTimeMillis();
StringBuffer sb = new StringBuffer();
configSourcesService.saveByJDBCThread(thread, start, configCompileList, sb);
Long end = System.currentTimeMillis();
Long time = (end - start) / 1000;
System.out.println("插入了" + dataCount + "条配置总计" + allCount + "条数据总共需要" + time + "");
validateConfigSourceTest(thread, start, configSource);
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "编译配置数据插入成功",
configSource);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
@RequestMapping(value = "/testSaveByMybatis", method = RequestMethod.GET)
@ApiOperation(value = "测试批量业务配置存储", httpMethod = "GET", response = Map.class, notes = "对有效的配置(封堵|监测|白名单)存储")
public Map testSaveByMybatis(@RequestParam(value = "configCount", required = false) Long configCount,
@RequestParam(value = "batchSize", required = false) Integer batchSize,
@RequestParam(value = "startNum", required = false) Long startNum, HttpServletRequest request,
HttpServletResponse response) {
try {
if (startNum == null || startNum == 0) {
startNum = 1l;
}
allCount = 0l;
long dataCount = 0l;
String startTime = "2016-11-01 08:20:20";
String endTime = "2016-11-8 15:55:33";
Date date = new Date();
ConfigSourceTest configSource = new ConfigSourceTest();
configSource.setOpTime(date);
configSource.setOpAction(1);
configSource.setOperator("rkg");
configSource.setVersion("0.1");
List<ConfigCompile> configCompileList = new ArrayList<ConfigCompile>();
long count = System.currentTimeMillis() + startNum;
Integer[] zeroArr = { 1, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14 };
Integer[] oneArr = { 15, 16, 17, 18, 32, 33, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62 };
Integer[] twoArr = { 2 };
for (Integer x = 0; x < zeroArr.length; x++) {
for (Long i = 1l; i <= configCount; i++) {
count++;
dataCount++;
allCount++;
ConfigCompile configCompile = setCompileTest(zeroArr[x].longValue(), 0, date, startTime, endTime,
count);
configCompileList.add(configCompile);
}
}
for (Integer x = 15; x < oneArr.length + 15; x++) {
for (Long i = 1l; i <= configCount; i++) {
count++;
dataCount++;
allCount++;
ConfigCompile configCompile = setCompileTest(oneArr[x - 15].longValue(), 1, date, startTime,
endTime, count);
configCompileList.add(configCompile);
}
}
for (Integer x = 50; x < twoArr.length + 50; x++) {
for (Long i = 1l; i <= configCount; i++) {
count++;
dataCount++;
allCount++;
ConfigCompile configCompile = setCompileTest(twoArr[x - 50].longValue(), 2, date, startTime,
endTime, count);
configCompileList.add(configCompile);
}
}
configSource.setConfigCompileList(configCompileList);
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST,
request, configSource);
System.out.println("开始执行插入操作" + dataCount + "条配置总计" + allCount + "条数据");
long start = System.currentTimeMillis();
StringBuffer sb = new StringBuffer();
configSourcesService.insertConfigSourceData(thread, start, configCompileList, sb);
Long end = System.currentTimeMillis();
Long time = (end - start) / 1000;
System.out.println("插入了" + dataCount + "条配置总计" + allCount + "条数据总共需要" + time + "");
validateConfigSourceTest(thread, start, configSource);
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "编译配置数据插入成功",
configSource);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public ConfigCompileTest setCompileTest(Long serviceType, Integer action, Date date, String startTime,
String endTime, Long index) throws Exception {
Long compileId = System.currentTimeMillis() + index;
//System.out.println("compileId--------------------------" + compileId);
ConfigCompileTest configCompile = new ConfigCompileTest();
configCompile.setCompileId(compileId);
configCompile.setService(serviceType);
configCompile.setAction(1);
configCompile.setContType(0);
configCompile.setAttrType(0);
configCompile.setContLabel("0");
configCompile.setTaskId(0);
configCompile.setGuaranteeId(0);
configCompile.setAffairId(0);
configCompile.setTopicId(0);
configCompile.setDoBlacklist(1l);
configCompile.setDoLog(0);
configCompile.setEffectiveRange("0");
configCompile.setConfigPercent(100l);
configCompile.setConfigOption(1);
configCompile.setStartTime(new Date(1482472334731l));
configCompile.setEndTime(new Date(1482472734731l));
//configCompile.setStartTime(sdf.parse("2016-12-22 08:20:20"));
//configCompile.setEndTime(sdf.parse("2016-12-23 08:20:20"));
// configCompile.setStartTime(startTime);
// configCompile.setEndTime(endTime);
configCompile.setActiveSys(2);
configCompile.setLastUpdate(date);
configCompile.setProcSeq(compileId);
configCompile.setUserRegion("0");
configCompile.setIsValid(1);
configCompile.setGroupNum(1);
configCompile.setFatherCfgId(0l);
configCompile.setOpTime(date);
Long groupId = System.currentTimeMillis() + (long) ((Math.random()) * 100000);
configCompile.setGroupRelationList(setGroupList(compileId, date, groupId));
Map<String, String> tableMap = configSourcesService.getTableMap(serviceType.intValue());
List<String> strTable = new ArrayList<String>();
String ipTable = null;
String numTable = null;
if (null != tableMap && tableMap.size() > 0) {
for (String str : tableMap.keySet()) {
if (tableMap.get(str).equals("ip")) {
ipTable = str;
} else if (tableMap.get(str).equals("num")) {
numTable = str;
} else if (tableMap.get(str).equals("str")) {
strTable.add(str);
}
}
}
configCompile.setStrRegionList(setAllStrRegionList(serviceType, groupId, date, strTable, index));
configCompile.setIpRegionList(setIpRegionList(serviceType, groupId, date, ipTable, index));
configCompile.setNumRegionList(setNumRegionList(serviceType, groupId, date, numTable, index));
return configCompile;
}
public List<ConfigGroupRelation> setGroupList(Long compileId, Date date, Long groupId) {
List<ConfigGroupRelation> groupRelationList = new ArrayList<ConfigGroupRelation>();
ConfigGroupRelation configGroupRelation = new ConfigGroupRelation();
configGroupRelation.setGroupId(groupId);
configGroupRelation.setId(groupId);
configGroupRelation.setCompileId(compileId);
configGroupRelation.setIsValid(1);
configGroupRelation.setOpTime(date);
groupRelationList.add(configGroupRelation);
allCount++;
return groupRelationList;
}
public List<StrRegion> setStrRegionList(Long service, Long groupId, Date date, List<String> tableName, Long index) {
List<StrRegion> strRegionList = new ArrayList<StrRegion>();
if (tableName != null & tableName.size() > 0) {
Long regionId = System.currentTimeMillis() + index + 10000000000000l;
//System.out.println("Strid--------------------------" + regionId);
StrRegionTest strRegion = new StrRegionTest();
strRegion.setRegionId(regionId);
strRegion.setGroupId(groupId);
strRegion.setKeywords("百度");
strRegion.setExprType(0);
strRegion.setMatchMethod(0);
strRegion.setIsHexbin(0);
strRegion.setIsValid(1);
strRegion.setOpTime(date);
if (configSourcesService.isStrStrongRegion(tableName.get(0))) {
strRegion.setDistrict("南京");
}
strRegion.setTableName(tableName.get(0));
strRegion.setProcSeq(regionId);
strRegionList.add(strRegion);
StrRegionTest strRegion1 = new StrRegionTest();
Long regionId1 = System.currentTimeMillis() + index + 100000;
//System.out.println("Strid===================================" + regionId);
strRegion1.setRegionId(regionId1);
strRegion1.setGroupId(groupId);
strRegion1.setKeywords("新浪");
strRegion1.setExprType(0);
strRegion1.setMatchMethod(0);
strRegion1.setIsHexbin(0);
strRegion1.setIsValid(1);
strRegion1.setOpTime(date);
strRegion1.setProcSeq(regionId1);
if (tableName.size() > 1) {
strRegion1.setTableName(tableName.get(1));
if (configSourcesService.isStrStrongRegion(tableName.get(1))) {
strRegion1.setDistrict("北京");
}
} else {
strRegion1.setTableName(tableName.get(0));
if (configSourcesService.isStrStrongRegion(tableName.get(0))) {
strRegion1.setDistrict("上海");
}
}
strRegionList.add(strRegion1);
allCount++;
return strRegionList;
} else {
return strRegionList;
}
}
public List<StrRegion> setAllStrRegionList(Long service, Long groupId, Date date, List<String> tableName,
Long index) {
List<StrRegion> strRegionList = new ArrayList<StrRegion>();
int num = 0;
if (tableName != null & tableName.size() > 0) {
for (String tbName : tableName) {
num++;
Long regionId = System.currentTimeMillis() + index + 999999999999999l * num;
//System.out.println("Strid--------------------------" + regionId);
StrRegionTest strRegion = new StrRegionTest();
strRegion.setRegionId(regionId);
strRegion.setGroupId(groupId);
strRegion.setKeywords("百度");
strRegion.setExprType(0);
strRegion.setMatchMethod(0);
strRegion.setIsHexbin(2);
strRegion.setIsValid(1);
strRegion.setOpTime(date);
if (configSourcesService.isStrStrongRegion(tbName)) {
strRegion.setDistrict("南京");
}
strRegion.setTableName(tbName);
strRegion.setProcSeq(regionId);
strRegionList.add(strRegion);
allCount++;
}
return strRegionList;
} else {
return strRegionList;
}
}
public List<IpRegion> setIpRegionList(Long service, Long groupId, Date date, String tableName, Long index) {
List<IpRegion> ipRegionList = new ArrayList<IpRegion>();
if (tableName != null) {
IpRegionTest ipRegion = new IpRegionTest();
Long regionId = System.currentTimeMillis() + index + 20000000000000l;
//System.out.println("Ipid--------------------------" + regionId);
ipRegion.setRegionId(regionId);
ipRegion.setGroupId(groupId);
ipRegion.setAddrType(4);
ipRegion.setSrcIp("0.0.0.0");
ipRegion.setMaskSrcIp("0.0.0.0");
ipRegion.setSrcPort("0");
ipRegion.setMaskSrcPort("0");
ipRegion.setDstIp("0.0.0.2");
ipRegion.setMaskDstIp("0.0.0.0");
ipRegion.setDstPort("0");
ipRegion.setMaskDstPort("0");
ipRegion.setProtocol(0);
ipRegion.setDirection(0);
ipRegion.setIsValid(1);
ipRegion.setOpTime(date);
ipRegion.setTableName(tableName);
ipRegion.setProcSeq(regionId);
ipRegionList.add(ipRegion);
allCount++;
return ipRegionList;
} else {
return ipRegionList;
}
}
public List<NumRegion> setNumRegionList(Long service, Long groupId, Date date, String tableName, Long index) {
List<NumRegion> numRegionList = new ArrayList<NumRegion>();
if (tableName != null) {
NumRegionTest numRegion = new NumRegionTest();
Long regionId = System.currentTimeMillis() + index + 30000000000000l;
//System.out.println("numid--------------------------" + regionId);
numRegion.setRegionId(regionId);
numRegion.setGroupId(groupId);
numRegion.setLowBoundary(4294967294l);
numRegion.setUpBoundary(4294967295l);
numRegion.setIsValid(1);
numRegion.setOpTime(date);
numRegion.setTableName(tableName);
numRegion.setProcSeq(regionId);
numRegionList.add(numRegion);
allCount++;
return numRegionList;
} else {
return numRegionList;
}
}
private void validateConfigSourceTest(SaveRequestLogThread thread, long start, ConfigSourceTest configSource) {
String errorInfo = "";
List<ConfigCompile> configCompileList = configSource.getConfigCompileList();
if (StringUtils.isEmpty(configSource.getOperator())) {
errorInfo = "get operator is Empty";
}
if (StringUtils.isEmpty(configSource.getVersion())) {
errorInfo = "get version is Empty";
}
if (!isBlank(configSource.getOpTime())) {
errorInfo = "get OpTime is Empty";
}
if (configCompileList.size() <= 0) {
errorInfo = "编译配置不能为空";
}
if (!errorInfo.equals("")) {
throw new RestServiceException(thread, System.currentTimeMillis() - start, errorInfo,
RestBusinessCode.missing_args.getValue());
}
}
private boolean isBlank(Date datetime) {
if (null != datetime) {
return true;
}
return false;
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@RequestMapping(value = "/testUpdateByJDBCThread", method = RequestMethod.GET)
@ApiOperation(value = "测试批量业务配置修改", httpMethod = "GET", response = Map.class, notes = "对有效的配置(封堵|监测|白名单)存储")
public Map testUpdateByJDBCThread(@RequestParam(value = "compileId", required = false) Long compileId,
HttpServletRequest request, HttpServletResponse response) {
allCount = 0l;
long dataCount = 0l;
List<ConfigCompile> compileList = new ArrayList<ConfigCompile>();
ConfigCompileTest configCompileTest = new ConfigCompileTest();
configCompileTest.setIsValid(1);
if (null != compileId) {
configCompileTest.setCompileId(compileId);
}
List<ConfigCompileTest> queryAllCompile = configSourcesService.queryAllCompile(configCompileTest);
for (int i = 0; i < queryAllCompile.size(); i++) {
ConfigCompile compileInfo = getCompileInfo(queryAllCompile.get(i));
compileInfo.setOpTime(new Date());
dataCount++;
allCount++;
// compileInfo.setIsValid(0);
compileList.add(compileInfo);
}
ConfigSourceTest configSource = new ConfigSourceTest();
configSource.setOpTime(new Date());
configSource.setOpAction(1);
configSource.setOperator("rkg");
configSource.setVersion("0.1");
configSource.setConfigCompileList(compileList);
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request,
configSource);
long start = System.currentTimeMillis();
try {
System.out.println("开始执行修改操作" + dataCount + "条配置总计" + allCount + "条数据");
StringBuffer sb = new StringBuffer();
configSourcesService.updateByJDBCThread(thread, start, configSource.getConfigCompileList(),
configSource.getOpTime(), sb);
Long end = System.currentTimeMillis();
Long time = (end - start) / 1000;
System.out.println("修改了" + dataCount + "条配置总计" + allCount + "条数据总共需要" + time + "");
} catch (Exception e) {
logger.error(e);
if (!e.getMessage().contains("Connection is closed!")) {
RestServiceException rse = (RestServiceException) e;
throw new RestServiceException(thread, System.currentTimeMillis() - start, rse.getMessage(),
rse.getErrorCode());
} else {
throw new RestServiceException(thread, System.currentTimeMillis() - start, "数据保存发生异常!",
RestBusinessCode.unknow_error.getValue());
}
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "编译配置数据修改成功",
configSource);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
@RequestMapping(value = "/updateConfigSource", method = RequestMethod.GET)
@ApiOperation(value = "测试批量业务配置修改", httpMethod = "GET", response = Map.class, notes = "对有效的配置(封堵|监测|白名单)存储")
public Map updateConfigSource(@RequestParam(value = "compileId", required = false) Long compileId,
HttpServletRequest request, HttpServletResponse response) {
allCount = 0l;
long dataCount = 0l;
List<ConfigCompile> compileList = new ArrayList<ConfigCompile>();
ConfigCompileTest configCompileTest = new ConfigCompileTest();
configCompileTest.setIsValid(1);
if (null != compileId) {
configCompileTest.setCompileId(compileId);
}
List<ConfigCompileTest> queryAllCompile = configSourcesService.queryAllCompile(configCompileTest);
for (int i = 0; i < queryAllCompile.size(); i++) {
ConfigCompile compileInfo = getCompileInfo(queryAllCompile.get(i));
// compileInfo.setIsValid(0);
compileInfo.setOpTime(new Date());
compileList.add(compileInfo);
dataCount++;
allCount++;
}
ConfigSourceTest configSource = new ConfigSourceTest();
configSource.setOpTime(new Date());
configSource.setOpAction(1);
configSource.setOperator("rkg");
configSource.setVersion("0.1");
configSource.setConfigCompileList(compileList);
JsonConfig jsonConfig = new JsonConfig();
jsonConfig.registerJsonValueProcessor(Date.class, new JsonDateValueProcessor());
JSONArray jsonArray = JSONArray.fromObject(configSource, jsonConfig);
String jsonStr = jsonArray.getString(0);
String distisct = "\"district\":\"\",";
if (jsonStr.contains(distisct)) {
jsonStr = jsonStr.replaceAll(distisct, "");
}
// System.out.println(jsonStr);
SaveRequestLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_PUT, request,
configSource);
long start = System.currentTimeMillis();
try {
System.out.println("开始执行修改操作" + dataCount + "条配置总计" + allCount + "条数据");
StringBuffer sb = new StringBuffer();
configSourcesService.updateConfigSource(thread, start, configSource.getConfigCompileList(),
configSource.getOpTime(), sb);
Long end = System.currentTimeMillis();
Long time = (end - start) / 1000;
System.out.println("修改了" + dataCount + "条配置总计" + allCount + "条数据总共需要" + time + "");
} catch (Exception e) {
logger.error(e);
if (!e.getMessage().contains("Connection is closed!")) {
RestServiceException rse = (RestServiceException) e;
throw new RestServiceException(thread, System.currentTimeMillis() - start, rse.getMessage(),
rse.getErrorCode());
} else {
throw new RestServiceException(thread, System.currentTimeMillis() - start, "数据保存发生异常!",
RestBusinessCode.unknow_error.getValue());
}
}
return serviceResponse(thread, System.currentTimeMillis() - start, request, response, "编译配置数据修改成功",
configSource);
}
public ConfigCompile getCompileInfo(ConfigCompile configCompileTest) {
List<ConfigGroupRelation> groupByCompileList = configSourcesService
.getGroupByCompile(configCompileTest.getCompileId());
configCompileTest.setGroupRelationList(groupByCompileList);
Long[] groupIdArr = new Long[groupByCompileList.size()];
for (int i = 0; i < groupByCompileList.size(); i++) {
groupIdArr[i] = groupByCompileList.get(i).getGroupId();
allCount++;
}
Map<String, String> tableMap = configSourcesService.getTableMap(configCompileTest.getService().intValue());
List<String> strTable = new ArrayList<String>();
String ipTable = null;
String numTable = null;
if (null != tableMap && tableMap.size() > 0) {
for (String str : tableMap.keySet()) {
if (tableMap.get(str).equals("ip")) {
ipTable = str;
} else if (tableMap.get(str).equals("num")) {
numTable = str;
} else if (tableMap.get(str).equals("str")) {
strTable.add(str);
}
}
}
if (strTable.size() > 0) {
// List<StrRegion> strList =new ArrayList<StrRegion>();
List<StrRegion> strRegionList = configSourcesService.getStrRegionByGId(strTable, groupIdArr);
if (null != strRegionList && strRegionList.size() > 0) {
for (StrRegion strRegion : strRegionList) {
// strList.add(strRegion)
strRegion.setIsValid(0);
allCount++;
}
configCompileTest.setStrRegionList(strRegionList);
} else {
List<StrRegion> strList = new ArrayList<StrRegion>();
configCompileTest.setStrRegionList(strList);
}
} else {
List<StrRegion> strList = new ArrayList<StrRegion>();
configCompileTest.setStrRegionList(strList);
}
if (ipTable != null) {
List<IpRegion> ipRegionByGId = configSourcesService.getIpRegionByGId(ipTable, groupIdArr);
if (null != ipRegionByGId && ipRegionByGId.size() > 0) {
for (IpRegion ipRegion : ipRegionByGId) {
ipRegion.setIsValid(0);
allCount++;
}
configCompileTest.setIpRegionList(ipRegionByGId);
} else {
List<IpRegion> ipList = new ArrayList<IpRegion>();
configCompileTest.setIpRegionList(ipList);
}
} else {
List<IpRegion> ipList = new ArrayList<IpRegion>();
configCompileTest.setIpRegionList(ipList);
}
if (numTable != null) {
List<NumRegion> numRegionList = configSourcesService.getNumRegionByGId(numTable, groupIdArr);
if (null != numRegionList && numRegionList.size() > 0) {
for (NumRegion numRegion : numRegionList) {
numRegion.setIsValid(0);
allCount++;
}
configCompileTest.setNumRegionList(numRegionList);
} else {
List<NumRegion> numList = new ArrayList<NumRegion>();
configCompileTest.setNumRegionList(numList);
}
} else {
List<NumRegion> numList = new ArrayList<NumRegion>();
configCompileTest.setNumRegionList(numList);
}
return configCompileTest;
}
@RequestMapping(value = "/findCompile", method = RequestMethod.POST)
public Map findCompile(ConfigCompileTest configCompileTest, HttpServletRequest request,
HttpServletResponse response) {
long start = System.currentTimeMillis();
SaveRequestLogThread thread1 = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_GET, request,
configCompileTest);
Page page = new Page();
int no = configCompileTest.getPagesNo() == null ? 1 : configCompileTest.getPagesNo();
int size = configCompileTest.getPagesSize() == null ? 10 : configCompileTest.getPagesSize();
page.setPageNo(no);
page.setPageSize(size);
Page<ConfigCompileTest> queryAllCompile = null;
try {
if (configCompileTest.getSearchStartTime() != null && !configCompileTest.getSearchStartTime().equals("")) {
configCompileTest.setStartTime(sdf.parse(configCompileTest.getSearchStartTime()));
// configCompile.setStartTime(configCompile.getSearchStartTime());
}
if (configCompileTest.getSearchEndTime() != null && !configCompileTest.getSearchEndTime().equals("")) {
configCompileTest.setEndTime(sdf.parse(configCompileTest.getSearchEndTime()));
// configCompile.setEndTime(configCompile.getSearchEndTime());
}
queryAllCompile = configSourcesService.queryAllCompile(page, configCompileTest);
} catch (SQLException e) {
thread1.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
throw new RestServiceException(thread1, System.currentTimeMillis() - start, "编译配置获取失败");
} catch (Exception e) {
thread1.setExceptionInfo(e.getMessage() + " " + e.getCause());
e.printStackTrace();
throw new RestServiceException(thread1, System.currentTimeMillis() - start, "编译配置获取失败");
}
return serviceResponse(thread1, System.currentTimeMillis() - start, request, response, "编译配置获取成功",
queryAllCompile);
}
}

View File

@@ -95,7 +95,7 @@ public interface ConfigCompileDao {
* @return
*/
public List<ConfigCompileTest> queryAllCompile(@Param("searchEndTime") String searchEndTime,
@Param("searchStartTime") String searchStartTime, @Param("service") Long service,
@Param("searchStartTime") String searchStartTime, @Param("service") Integer service,
@Param("compileId") Long compileId);
/**

View File

@@ -96,6 +96,8 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
}
}
maatKey = keyBF.toString();
System.out.println(keyBF.toString());
System.out.println(valBF.toString());
redisTemplate.opsForValue().set(keyBF.toString().toUpperCase(),
valBF.toString());
break;
@@ -274,7 +276,7 @@ public class ConfigRedisServiceimpl implements ConfigRedisService {
redisTemplate.boundValueOps("MAAT_VERSION").increment(1l);
}
}
addMaatRelation(configMap);
// addMaatRelation(configMap);
}
}

View File

@@ -50,8 +50,10 @@ import com.nis.util.BasicProvingUtil;
import com.nis.util.CamelUnderlineUtil;
import com.nis.util.CompileVal;
import com.nis.util.Configurations;
import com.nis.util.Constants;
import com.nis.util.OracleErrorCodeUtil;
import com.nis.util.ReadCommSourceXmlUtil;
import com.nis.util.ServiceAndRDBIndexReal;
import com.nis.util.StringUtil;
import com.nis.util.StringUtils;
import com.nis.web.dao.ConfigCompileDao;
@@ -108,32 +110,32 @@ public class ConfigSourcesService extends BaseService {
public static Map<Integer, Map<String, String>> getTableRelation() {
Map<Integer, Map<String, String>> tableMap = new HashMap<Integer, Map<String, String>>();
Map<String, String> typeMap = new HashMap<String, String>();
typeMap.put("AV_CONT_IP_PORT", "ip");
typeMap.put("MM_AV_IP", "ip");
tableMap.put(80, typeMap);
tableMap.put(144, typeMap);
typeMap = new HashMap<String, String>();
typeMap.put("AV_CONT_URL", "str");
typeMap.put("MM_AV_URL", "str");
tableMap.put(81, typeMap);
tableMap.put(145, typeMap);
typeMap = new HashMap<String, String>();
typeMap.put("AV_PIC_IP_PORT", "ip");
typeMap.put("MM_PIC_IP", "ip");
tableMap.put(82, typeMap);
tableMap.put(146, typeMap);
typeMap = new HashMap<String, String>();
typeMap.put("AV_PIC_URL", "str");
typeMap.put("MM_PIC_URL", "str");
tableMap.put(83, typeMap);
tableMap.put(147, typeMap);
typeMap = new HashMap<String, String>();
typeMap.put("AV_VoIP_IP_PORT", "ip");
typeMap.put("MM_VOIP_IP", "ip");
tableMap.put(84, typeMap);
tableMap.put(148, typeMap);
typeMap = new HashMap<String, String>();
typeMap.put("AV_VoIP_ACCOUNT", "str");
typeMap.put("MM_VOIP_ACCOUNT", "str");
tableMap.put(85, typeMap);
tableMap.put(149, typeMap);
@@ -223,6 +225,8 @@ public class ConfigSourcesService extends BaseService {
typeMap.put("UNIVERSAL_IP", "ip");
typeMap.put("FX_HTTP_REQ_HDR", "str");
typeMap.put("FX_HTTP_URL", "str");
typeMap.put("WHITE_LIST_IP", "ip");
tableMap.put(15, typeMap);
typeMap = new HashMap<String, String>();
@@ -472,7 +476,7 @@ public class ConfigSourcesService extends BaseService {
}
}
}
config.setLastUpdate(new Date());
// config.setLastUpdate(new Date());
if (Configurations.getStringProperty("isCommit", "false").equals("true")) {
batchSqlSession.getMapper(ConfigCompileDao.class).updateConfigCompile(config);
}
@@ -625,7 +629,6 @@ public class ConfigSourcesService extends BaseService {
num++;
configGroupRelation.setIsValid(0);
configGroupRelation.setOpTime(opTime);
configGroupRelation.setLastUpdate(new Date());
if (Configurations.getStringProperty("isCommit", "false").equals("true")) {
batchSqlSession.getMapper(ConfigGroupRelationDao.class)
.updateConfigGroupRelation(configGroupRelation);
@@ -1107,18 +1110,13 @@ public class ConfigSourcesService extends BaseService {
*/
public String saveMaatConfig(SaveRequestLogThread thread, long start, List<ConfigCompile> configCompileList,
StringBuffer sb) {
List<MaatConfig> maatConfigList = new ArrayList<MaatConfig>();
List<Integer> serviceList = new ArrayList<Integer>();
// List<MaatConfig> maatConfigList = new ArrayList<MaatConfig>();
// List<Integer> serviceList = new ArrayList<Integer>();
Map<Integer, List<MaatConfig>> maatMap = new HashMap<Integer, List<MaatConfig>>();
for (ConfigCompile configCompile : configCompileList) {
serviceList.add(Integer.valueOf(configCompile.getService().toString()));
Integer service = Integer.valueOf(configCompile.getService().toString());
MaatConfig maatConfig = new MaatConfig();
List<ConfigGroupRelation> groupRelationList = new ArrayList<ConfigGroupRelation>();
List<StrRegion> strRegionList = new ArrayList<StrRegion>();
List<StrRegion> strStrongRegionList = new ArrayList<StrRegion>();
List<IpRegion> ipRegionList =new ArrayList<IpRegion>();
List<NumRegion> numRegionList = new ArrayList<NumRegion>();
List<DigestRegion> digestRegionList = new ArrayList<DigestRegion>();
String msg = CompileVal.compileIsOk(configCompile, false, sb);
if (msg != CompileJudgeCode.CompileIsOk.getErrorReason()) {
logger1.error(msg);
@@ -1128,9 +1126,7 @@ public class ConfigSourcesService extends BaseService {
}
if (null != configCompile.getGroupRelationList() && configCompile.getGroupRelationList().size() > 0) {
groupRelationList.addAll(configCompile.getGroupRelationList());
} else {
if (!(null != configCompile.getGroupRelationList() && configCompile.getGroupRelationList().size() > 0)) {
logger1.error("配置分组数量不能为空" + sb.toString());
thread.setExceptionInfo("配置分组数量不能为空" + sb.toString());
throw new RestServiceException(thread, System.currentTimeMillis() - start, "配置分组数量不能为空" + sb.toString(),
@@ -1138,7 +1134,6 @@ public class ConfigSourcesService extends BaseService {
}
if (null != configCompile.getStrRegionList() && configCompile.getStrRegionList().size() > 0) {
for (StrRegion strRegion : configCompile.getStrRegionList()) {
if (!isStrStrongRegion(strRegion.getTableName())) {
if (strRegion.getRegionId() == null) {
String errorMsg = "字符类域配置id不能为空 ,表名---" + strRegion.getTableName() + "" + sb.toString();
logger1.error(errorMsg);
@@ -1146,26 +1141,11 @@ public class ConfigSourcesService extends BaseService {
throw new RestServiceException(thread, System.currentTimeMillis() - start, errorMsg,
RestBusinessCode.missing_args.getValue());
}
strRegionList.add(strRegion);
} else {
if (strRegion.getRegionId() == null) {
String errorMsg = "增强字符类域配置id不能为空 ,表名---" + strRegion.getTableName() + "" + sb.toString();
logger1.error(errorMsg);
thread.setExceptionInfo(errorMsg);
throw new RestServiceException(thread, System.currentTimeMillis() - start, errorMsg,
RestBusinessCode.missing_args.getValue());
}
strStrongRegionList.add(strRegion);
}
}
}
if (null != configCompile.getIpRegionList() && configCompile.getIpRegionList().size() > 0) {
for (IpRegion ipRegion : configCompile.getIpRegionList()) {
if (!ipRegion.getTableName().toUpperCase().equals("DJ_IP_PORT")) {
ipRegion.setProtocol(0);
}
if (ipRegion.getRegionId() == null) {
String errorMsg = "ip类域配置id不能为空 ,表名---" + ipRegion.getTableName() + "" + sb.toString();
logger1.error(errorMsg);
@@ -1173,8 +1153,6 @@ public class ConfigSourcesService extends BaseService {
throw new RestServiceException(thread, System.currentTimeMillis() - start, errorMsg,
RestBusinessCode.missing_args.getValue());
}
ipRegionList.add(ipRegion);
}
}
@@ -1187,7 +1165,6 @@ public class ConfigSourcesService extends BaseService {
throw new RestServiceException(thread, System.currentTimeMillis() - start, errorMsg,
RestBusinessCode.missing_args.getValue());
}
numRegionList.add(numRegion);
}
}
if (null != configCompile.getDigestRegionList() && configCompile.getDigestRegionList().size() > 0) {
@@ -1199,46 +1176,56 @@ public class ConfigSourcesService extends BaseService {
throw new RestServiceException(thread, System.currentTimeMillis() - start, errorMsg,
RestBusinessCode.missing_args.getValue());
}
digestRegionList.add(digestRegion);
}
}
maatConfig.setService(Integer.valueOf(configCompile.getService().toString()));
if (null != configCompile.getIpClientRangeList() && configCompile.getIpClientRangeList().size() > 0) {
for (IpRegion ipRegion : configCompile.getIpClientRangeList()) {
if (ipRegion.getRegionId() == null) {
String errorMsg = "生效范围IP域类域配置id不能为空 ,表名---" + ipRegion.getTableName() + "" + sb.toString();
logger1.error(errorMsg);
thread.setExceptionInfo(errorMsg);
throw new RestServiceException(thread, System.currentTimeMillis() - start, errorMsg,
RestBusinessCode.missing_args.getValue());
}
}
}
maatConfig.setService(service);
//编译
maatConfig.setCompileMap(convertObjectToMap(configCompile, ConfigCompile.class));
//分组
List<Map<String, String>> dstMaplList = null;
if (!StringUtil.isEmpty(groupRelationList)) {
if (!StringUtil.isEmpty(configCompile.getGroupRelationList())) {
dstMaplList = new ArrayList<Map<String,String>>();
for (ConfigGroupRelation group : groupRelationList) {
for (ConfigGroupRelation group : configCompile.getGroupRelationList()) {
dstMaplList.add(convertObjectToMap(group, ConfigGroupRelation.class));
}
}
maatConfig.setGroupMapList(dstMaplList);
//字符串域
dstMaplList = null;
if (!StringUtil.isEmpty(strRegionList)) {
if (!StringUtil.isEmpty(configCompile.getStrRegionList())) {
dstMaplList = new ArrayList<Map<String,String>>();
for (StrRegion region : strRegionList) {
for (StrRegion region : configCompile.getStrRegionList()) {
dstMaplList.add(convertObjectToMap(region, StrRegion.class));
}
}
maatConfig.setStrRegionMapList(dstMaplList);
//增强字符串域
dstMaplList = null;
if (!StringUtil.isEmpty(strStrongRegionList)) {
dstMaplList = new ArrayList<Map<String,String>>();
for (StrRegion region : strStrongRegionList) {
dstMaplList.add(convertObjectToMap(region, StrRegion.class));
}
}
maatConfig.setStrStrRegionMapList((dstMaplList));
// //增强字符串域
// dstMaplList = null;
// if (!StringUtil.isEmpty(strStrongRegionList)) {
// dstMaplList = new ArrayList<Map<String,String>>();
// for (StrRegion region : strStrongRegionList) {
// dstMaplList.add(convertObjectToMap(region, StrRegion.class));
// }
// }
// maatConfig.setStrStrRegionMapList((dstMaplList));
//数值域
dstMaplList = null;
if (!StringUtil.isEmpty(numRegionList)) {
if (!StringUtil.isEmpty(configCompile.getNumRegionList())) {
dstMaplList = new ArrayList<Map<String,String>>();
for (NumRegion region : numRegionList) {
for (NumRegion region : configCompile.getNumRegionList()) {
dstMaplList.add(convertObjectToMap(region, NumRegion.class));
}
}
@@ -1246,9 +1233,9 @@ public class ConfigSourcesService extends BaseService {
//Ip域
dstMaplList = null;
if (!StringUtil.isEmpty(ipRegionList)) {
if (!StringUtil.isEmpty(configCompile.getIpRegionList())) {
dstMaplList = new ArrayList<Map<String,String>>();
for (IpRegion region : ipRegionList) {
for (IpRegion region : configCompile.getIpRegionList()) {
dstMaplList.add(convertObjectToMap(region, IpRegion.class));
}
}
@@ -1256,29 +1243,57 @@ public class ConfigSourcesService extends BaseService {
//摘要类域
dstMaplList = null;
if (!StringUtil.isEmpty(digestRegionList)) {
if (!StringUtil.isEmpty(configCompile.getDigestRegionList())) {
dstMaplList = new ArrayList<Map<String,String>>();
for (DigestRegion region : digestRegionList) {
for (DigestRegion region : configCompile.getDigestRegionList()) {
dstMaplList.add(convertObjectToMap(region, DigestRegion.class));
}
}
maatConfig.setFileDigestRegionMapList(dstMaplList);
dstMaplList = null;
//文本相似性域
maatConfig.setFileLikeRegionMapList(dstMaplList);
maatConfigList.add(maatConfig);
// dstMaplList = null;
// maatConfig.setFileLikeRegionMapList(dstMaplList);
//生效范围IP域
dstMaplList = null;
if (!StringUtil.isEmpty(configCompile.getIpClientRangeList())) {
dstMaplList = new ArrayList<Map<String,String>>();
for (IpRegion region : configCompile.getIpClientRangeList()) {
dstMaplList.add(convertObjectToMap(region, IpRegion.class));
}
}
maatConfig.setIpClientRangeMapList(dstMaplList);
if (maatMap.containsKey(service)) {
maatMap.get(service).add(maatConfig);
}else{
List<MaatConfig> maatCfgList = new ArrayList<MaatConfig>();
maatCfgList.add(maatConfig);
maatMap.put(service, maatCfgList);
}
if (!StringUtil.isEmpty(serviceList)&&serviceList.size()!=1) {
String errorMsg = "只能添加单一service配置信息列表";
logger1.error(errorMsg);
thread.setExceptionInfo(errorMsg);
throw new RestServiceException(thread, System.currentTimeMillis() - start, errorMsg,
RestBusinessCode.op_action_error.getValue());
}
//调用接口入redis
configRedisService.saveMaatConfig(maatConfigList, serviceList.get(0));
Map<Integer, List<MaatConfig>> configMap = new HashMap<Integer, List<MaatConfig>>();
Iterator serviceIterator = maatMap.keySet().iterator();
while (serviceIterator.hasNext()) {
Integer service =Integer.valueOf(serviceIterator.next().toString());
List<Integer> dbIndexList = ServiceAndRDBIndexReal.getRedisDBByService(service);
for (Integer dbIndex : dbIndexList) {
if (configMap.containsKey(dbIndex)) {
configMap.get(dbIndex).addAll(maatMap.get(service));
}else{
configMap.put(dbIndex, maatMap.get(service));
}
}
}
configRedisService.saveMaatConfig(configMap);
logger1.info("---------------调用maat配置新增接口---------------------");
return "ok";
}
@@ -1308,6 +1323,32 @@ public class ConfigSourcesService extends BaseService {
}
return dstMap;
}
public String cancleConfigSources(SaveRequestLogThread thread, long start, List<ConfigCompile> compileList,
Date opTime, StringBuffer sb) {
List<ConfigCompile> compileAllList = new ArrayList<ConfigCompile>();
if (null != compileList && compileList.size() > 0) {
for (ConfigCompile config : compileList) {
String msg = checkCompileOptForUpdate(config);
if (config.getOpTime()==null) {
config.setOpTime(opTime);
}
if (!msg.equals("ok")) {
thread.setExceptionInfo(msg + sb.toString());
throw new RestServiceException(thread, System.currentTimeMillis() - start, msg + sb.toString(),
RestBusinessCode.config_integrity_error.getValue());
}
compileAllList.add(config);
}
} else {
thread.setExceptionInfo("编译配置不能为空" + sb.toString());
throw new RestServiceException(thread, System.currentTimeMillis() - start, "编译配置不能为空" + sb.toString(),
RestBusinessCode.config_integrity_error.getValue());
}
return "";
}
public String saveByJDBCThread(SaveRequestLogThread thread, long start, List<ConfigCompile> configCompileList,
StringBuffer sb) {
List<ConfigGroupRelation> groupRelationList = new ArrayList<ConfigGroupRelation>();
@@ -1750,7 +1791,6 @@ public class ConfigSourcesService extends BaseService {
num++;
configGroupRelation.setIsValid(0);
configGroupRelation.setLastUpdate(new Date());
groupRelationAllList.add(configGroupRelation);
}
}
@@ -2172,6 +2212,11 @@ public class ConfigSourcesService extends BaseService {
if (StringUtil.isEmpty(config.getCompileId())) {
return "compileId字段不能为空";
}
if (StringUtil.isEmpty(config.getService())) {
return "service字段不能为空";
}
if (StringUtil.isEmpty(config.getIsValid())) {
return "编译配置id为" + config.getCompileId()+"的IsValid字段不能为空";
}
@@ -2349,7 +2394,7 @@ public class ConfigSourcesService extends BaseService {
return "ok";
}
public String savaCommonSources(SaveRequestLogThread thread, long start,String jsonString,
public String saveCommonSources(SaveRequestLogThread thread, long start,String jsonString,
StringBuffer sb) {
JsonArray jsonObjectList = new JsonParser().parse(jsonString).getAsJsonArray();
Map<Integer,List<Map<String, String>>> dstMaps = new HashMap<Integer, List<Map<String,String>>>();
@@ -2360,7 +2405,7 @@ public class ConfigSourcesService extends BaseService {
Map<String,String> dstMap = new HashMap<String, String>();
List<CommonSourceFieldCfg> commonSourceFieldCfgList = ReadCommSourceXmlUtil.getCommonSourceCfgByService(srcMap.get("service").toString().trim());
if (StringUtil.isEmpty(commonSourceFieldCfgList)) {
logger.error("service请检查service配置是否正确");
logger1.error("service请检查service配置是否正确");
thread.setExceptionInfo("请检查service配置是否正确");
throw new RestServiceException(thread, System.currentTimeMillis() - start,"请检查service配置是否正确",
RestBusinessCode.wrong_range.getValue());
@@ -2368,7 +2413,7 @@ public class ConfigSourcesService extends BaseService {
for (CommonSourceFieldCfg commonSourceFieldCfg : commonSourceFieldCfgList) {
//是否必填
if(commonSourceFieldCfg.getIsRequired()&&!srcMap.containsKey(commonSourceFieldCfg.getSrcName())){
logger.error(commonSourceFieldCfg.getSrcName()+"参数不能为空");
logger1.error(commonSourceFieldCfg.getSrcName()+"参数不能为空");
thread.setExceptionInfo(commonSourceFieldCfg.getSrcName()+"参数不能为空");
throw new RestServiceException(thread, System.currentTimeMillis() - start,commonSourceFieldCfg.getSrcName()+"参数不能为空",
RestBusinessCode.missing_args.getValue());
@@ -2381,7 +2426,7 @@ public class ConfigSourcesService extends BaseService {
switch (commonSourceFieldCfg.getFieldType()) {
case "Number":
if(!StringUtil.isNumeric(dstStr)){
logger.error(commonSourceFieldCfg.getSrcName()+"参数不能格式不正确,必需是数值型");
logger1.error(commonSourceFieldCfg.getSrcName()+"参数不能格式不正确,必需是数值型");
thread.setExceptionInfo(commonSourceFieldCfg.getSrcName()+"参数不能格式不正确,必需是数值型");
throw new RestServiceException(thread, System.currentTimeMillis() - start,commonSourceFieldCfg.getSrcName()+"参数不能格式不正确",
RestBusinessCode.missing_args.getValue());
@@ -2390,11 +2435,12 @@ public class ConfigSourcesService extends BaseService {
case "Date":
try {
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
System.out.println("--------------------TimeZone:"+sdf.getTimeZone());
Date date = sdf.parse(dstStr);
dstStr = date.getTime()+"000";
} catch (ParseException e) {
// TODO Auto-generated catch block
logger.error(commonSourceFieldCfg.getSrcName()+"参数格式不正确,必须是日期型");
logger1.error(commonSourceFieldCfg.getSrcName()+"参数格式不正确,必须是日期型");
thread.setExceptionInfo(commonSourceFieldCfg.getSrcName()+"参数格式不正确,必须是日期型");
throw new RestServiceException(thread, System.currentTimeMillis() - start,commonSourceFieldCfg.getSrcName()+"参数不能格式不正确,必须是日期型",
RestBusinessCode.missing_args.getValue());
@@ -2402,7 +2448,7 @@ public class ConfigSourcesService extends BaseService {
break;
case "Ip":
if (!isIp(dstStr)) {
logger.error(commonSourceFieldCfg.getSrcName()+"参数格式不正确不是合法的IP地址");
logger1.error(commonSourceFieldCfg.getSrcName()+"参数格式不正确不是合法的IP地址");
thread.setExceptionInfo(commonSourceFieldCfg.getSrcName()+"参数格式不正确不是合法的IP地址");
throw new RestServiceException(thread, System.currentTimeMillis() - start,commonSourceFieldCfg.getSrcName()+"参数不能格式不正确不是合法的IP地址",
RestBusinessCode.missing_args.getValue());
@@ -2410,7 +2456,7 @@ public class ConfigSourcesService extends BaseService {
break;
case "Port":
if (!BasicProvingUtil.isPortOrPortMask(dstStr)) {
logger.error(commonSourceFieldCfg.getSrcName()+"参数格式不正确不是合法的Port");
logger1.error(commonSourceFieldCfg.getSrcName()+"参数格式不正确不是合法的Port");
thread.setExceptionInfo(commonSourceFieldCfg.getSrcName()+"参数格式不正确不是合法的Port");
throw new RestServiceException(thread, System.currentTimeMillis() - start,commonSourceFieldCfg.getSrcName()+"参数不能格式不正确不是合法的Port",
RestBusinessCode.missing_args.getValue());
@@ -2422,7 +2468,7 @@ public class ConfigSourcesService extends BaseService {
if(!StringUtil.isEmpty(commonSourceFieldCfg.getRange())){
String [] range= commonSourceFieldCfg.getRange().split("-");
if(!(Long.valueOf(range[0]).compareTo(Long.valueOf(dstStr))<=0&&Long.valueOf(range[1]).compareTo(Long.valueOf(dstStr))>=0)){
logger.error(commonSourceFieldCfg.getSrcName()+"参数不在有效范围");
logger1.error(commonSourceFieldCfg.getSrcName()+"参数不在有效范围");
thread.setExceptionInfo(commonSourceFieldCfg.getSrcName()+"参数不在有效范围");
throw new RestServiceException(thread, System.currentTimeMillis() - start, commonSourceFieldCfg.getSrcName()+"参数不在有效范围",
RestBusinessCode.wrong_range.getValue());
@@ -2439,7 +2485,7 @@ public class ConfigSourcesService extends BaseService {
if (valFlag) {
dstMap.put(commonSourceFieldCfg.getDstName(),dstStr);
}else{
logger.error(commonSourceFieldCfg.getSrcName()+"参数格式与正则不匹配");
logger1.error(commonSourceFieldCfg.getSrcName()+"参数格式与正则不匹配");
thread.setExceptionInfo(commonSourceFieldCfg.getSrcName()+"参数格式与正则不匹配");
throw new RestServiceException(thread, System.currentTimeMillis() - start, commonSourceFieldCfg.getSrcName()+"参数格式不正确或数据不在有效范围",
RestBusinessCode.param_formate_error.getValue());
@@ -2460,13 +2506,22 @@ public class ConfigSourcesService extends BaseService {
RestBusinessCode.missing_args.getValue());
}
}
Iterator iterator =dstMaps.keySet().iterator();
while (iterator.hasNext()) {
Integer key = Integer.valueOf(iterator.next().toString());
configRedisService.saveUnMaatConfig(dstMaps.get(key),key);
// configRedisService.saveConfigYSPDemoCompile(key,);
logger1.info("------------------调用非maat配置新增接口-------------------");
//按service分库
Map<Integer, List<Map<String, String>>> configMap = new HashMap<Integer, List<Map<String, String>>>();
Iterator serviceIterator = dstMaps.keySet().iterator();
while (serviceIterator.hasNext()) {
Integer service =Integer.valueOf(serviceIterator.next().toString());
List<Integer> dbIndexList = ServiceAndRDBIndexReal.getRedisDBByService(service);
for (Integer dbIndex : dbIndexList) {
if (configMap.containsKey(dbIndex)) {
configMap.get(dbIndex).addAll(dstMaps.get(service));
}else{
configMap.put(dbIndex, dstMaps.get(service));
}
}
}
configRedisService.saveUnMaatConfig(configMap);
return "ok";
}
@@ -2488,4 +2543,32 @@ public class ConfigSourcesService extends BaseService {
return "ok";
}
public String getDigestGen(String realPath,String filePath)throws Exception{
System.out.println("----------------getDigestGen");
String content="";
String digestGenToolPath=Constants.DIGEST_GEN_TOOL_PATH;
String chmodCommond="chmod +x "+realPath+digestGenToolPath;//执行权限命令
System.out.println("----------------chmodCommod:"+chmodCommond);
String commondStr=realPath+digestGenToolPath+" -f "+filePath; //执行
//执行摘要获取命令 digest -f /home/aa.txt
System.out.println("------------commondStr:"+commondStr);
Runtime.getRuntime().exec(chmodCommond);
Process p=Runtime.getRuntime().exec(commondStr);
byte[] b=new byte[1024];
StringBuffer sb=new StringBuffer();
while (p.getInputStream().read(b) != -1) {
sb.append(new String(b, "UTF-8"));
}
content=sb.toString();
if (!StringUtil.isBlank(content)) {
content = StringUtil.stripAll(content);
}
System.out.println("-------------------->>"+content);
String[] digestGenReslt=content.split(" ");
if(digestGenReslt.length >=4 && !StringUtil.isEmpty(digestGenReslt[3])){
return digestGenReslt[3];
}
return null;
}
}

View File

@@ -1,221 +0,0 @@
package com.nis.web.service.restful;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.List;
import com.nis.domain.restful.ConfigCompile;
import com.nis.domain.restful.ConfigGroupRelation;
import com.nis.domain.restful.IpRegion;
import com.nis.domain.restful.NumRegion;
import com.nis.domain.restful.StrRegion;
/**
* jdbc测试批量插入
*
* @author RenKaiGe-Office
*
*/
public class JDBCTest {
public static java.sql.Timestamp utileDate2TimeStamp(java.util.Date udate) {
java.sql.Timestamp sqlDate = null;
long t = udate.getTime();
sqlDate = new java.sql.Timestamp(t);
return sqlDate;
}
public static void saveCompile(List<ConfigCompile> compileList, Connection conn, int batchSize) throws Exception {
StringBuffer sb = new StringBuffer();
sb.append(
"insert into CONFIG_COMPILE (COMPILE_ID ,SERVICE ,ACTION , CONT_TYPE, ATTR_TYPE, CONT_LABEL, Task_id, Guarantee_ID, AFFAIR_ID, TOPIC_ID, DO_BLACKLIST ,DO_LOG ,EFFECTIVE_RANGE , ACTIVE_SYS, CONFIG_PERCENT ,CONFIG_OPTION ,START_TIME ,END_TIME , USER_REGION, IS_VALID,GROUP_NUM,FATHER_CFG_ID ,OP_TIME,LAST_UPDATE ) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate)");
conn.setAutoCommit(false);
PreparedStatement ps = conn.prepareStatement(sb.toString());
int count = 0;
for (ConfigCompile compile : compileList) {
count++;
Object[] obj = new Object[] { compile.getCompileId(), compile.getService(), compile.getAction(),
compile.getContType(), compile.getAttrType(), compile.getContLabel(), compile.getTaskId(),
compile.getGuaranteeId(), compile.getAffairId(), compile.getTopicId(), compile.getDoBlacklist(),
compile.getDoLog(), compile.getEffectiveRange(), compile.getActiveSys(), compile.getConfigPercent(),
compile.getConfigOption(), compile.getStartTime(), compile.getEndTime(), compile.getUserRegion(),
compile.getIsValid(), compile.getGroupNum(), compile.getFatherCfgId(), compile.getOpTime() };
for (int x = 0; x < obj.length; x++) {
if (x == 16) {
ps.setTimestamp(x + 1, utileDate2TimeStamp(compile.getStartTime()));
} else if (x == 17) {
ps.setTimestamp(x + 1, utileDate2TimeStamp(compile.getEndTime()));
} else if (x == 22) {
ps.setTimestamp(x + 1, utileDate2TimeStamp(compile.getOpTime()));
} else {
ps.setObject(x + 1, obj[x]);
}
}
ps.addBatch();
if (count % batchSize == 0) {
ps.executeBatch();
////conn.commit();
}
}
ps.executeBatch();
//conn.commit();
}
public static void saveGroup(List<ConfigGroupRelation> groupList, Connection conn, int batchSize) throws Exception {
StringBuffer sb = new StringBuffer();
sb.append(
"insert into CONFIG_GROUP (ID,GROUP_ID, COMPILE_ID, IS_VALID, LAST_UPDATE, OP_TIME ) values ( seq_config_group.nextval, ?, ?, ?, sysdate, ?) ");
conn.setAutoCommit(false);
PreparedStatement ps = conn.prepareStatement(sb.toString());
int count = 0;
for (ConfigGroupRelation group : groupList) {
count++;
Object[] obj = new Object[] { group.getGroupId(), group.getCompileId(), group.getIsValid(),
group.getOpTime() };
for (int x = 0; x < obj.length; x++) {
if (x == 3) {
ps.setTimestamp(x + 1, utileDate2TimeStamp(group.getOpTime()));
} else {
ps.setObject(x + 1, obj[x]);
}
}
ps.addBatch();
if (count % batchSize == 0) {
ps.executeBatch();
//conn.commit();
}
}
ps.executeBatch();
//conn.commit();
}
public static void saveIPRegion(String name, List<IpRegion> ipRegionList, Connection conn, int batchSize)
throws Exception {
StringBuffer sb = new StringBuffer();
sb.append("insert into ");
sb.append(name);
sb.append(
"(REGION_ID, GROUP_ID, ADDR_TYPE, SRC_IP, MASK_SRC_IP, SRC_PORT, MASK_SRC_PORT, DST_IP, MASK_DST_IP, DST_PORT, MASK_DST_PORT, PROTOCOL, DIRECTION, IS_VALID, OP_TIME,LAST_UPDATE ) values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
conn.setAutoCommit(false);
PreparedStatement ps = conn.prepareStatement(sb.toString());
int count = 0;
for (IpRegion ipRegion : ipRegionList) {
count++;
Object[] obj = new Object[] { ipRegion.getRegionId(), ipRegion.getGroupId(), ipRegion.getAddrType(),
ipRegion.getSrcIp(), ipRegion.getMaskSrcIp(), ipRegion.getSrcPort(), ipRegion.getMaskSrcPort(),
ipRegion.getDstIp(), ipRegion.getMaskDstIp(), ipRegion.getDstPort(), ipRegion.getMaskDstPort(),
ipRegion.getProtocol(), ipRegion.getDirection(), ipRegion.getIsValid(), ipRegion.getOpTime()
};
for (int x = 0; x < obj.length; x++) {
if (x == 14) {
ps.setTimestamp(x + 1, utileDate2TimeStamp(ipRegion.getOpTime()));
} else {
ps.setObject(x + 1, obj[x]);
}
}
ps.addBatch();
if (count % batchSize == 0) {
ps.executeBatch();
//conn.commit();
}
}
ps.executeBatch();
//conn.commit();
}
public static void saveNumRegion(String name, List<NumRegion> numRegionList, Connection conn, int batchSize)
throws Exception {
StringBuffer sb = new StringBuffer();
sb.append("insert into ");
sb.append(name);
sb.append(
" (REGION_ID,GROUP_ID,LOW_BOUNDARY,UP_BOUNDARY,IS_VALID,OP_TIME,LAST_UPDATE) values(?, ?, ?, ?, ?, ?, sysdate)");
conn.setAutoCommit(false);
PreparedStatement ps = conn.prepareStatement(sb.toString());
int count = 0;
for (NumRegion numRegion : numRegionList) {
count++;
Object[] obj = new Object[] { numRegion.getRegionId(), numRegion.getGroupId(), numRegion.getLowBoundary(),
numRegion.getUpBoundary(), numRegion.getIsValid(), numRegion.getOpTime() };
for (int x = 0; x < obj.length; x++) {
if (x == 5) {
ps.setTimestamp(x + 1, utileDate2TimeStamp(numRegion.getOpTime()));
} else {
ps.setObject(x + 1, obj[x]);
}
}
ps.addBatch();
if (count % batchSize == 0) {
ps.executeBatch();
//conn.commit();
}
}
ps.executeBatch();
//conn.commit();
}
public static void saveStrongStrRegion(String name, List<StrRegion> strRegionList, Connection conn, int batchSize)
throws Exception {
StringBuffer sb = new StringBuffer();
sb.append("insert into ");
sb.append(name);
sb.append(
"(REGION_ID, GROUP_ID, DISTRICT, KEYWORDS, EXPR_TYPE, MATCH_METHOD , IS_HEXBIN, IS_VALID, OP_TIME,LAST_UPDATE ) values(?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
conn.setAutoCommit(false);
PreparedStatement ps = conn.prepareStatement(sb.toString());
int count = 0;
for (StrRegion strRegion : strRegionList) {
count++;
Object[] obj = new Object[] { strRegion.getRegionId(), strRegion.getGroupId(), strRegion.getDistrict(),
strRegion.getKeywords(), strRegion.getExprType(), strRegion.getMatchMethod(),
strRegion.getIsHexbin(), strRegion.getIsValid(), strRegion.getOpTime() };
for (int x = 0; x < obj.length; x++) {
if (x == 8) {
ps.setTimestamp(x + 1, utileDate2TimeStamp(strRegion.getOpTime()));
} else {
ps.setObject(x + 1, obj[x]);
}
}
ps.addBatch();
if (count % batchSize == 0) {
ps.executeBatch();
//conn.commit();
}
}
ps.executeBatch();
//conn.commit();
}
public static void saveStrRegion(String name, List<StrRegion> strRegionList, Connection conn, int batchSize)
throws Exception {
StringBuffer sb = new StringBuffer();
sb.append("insert into ");
sb.append(name);
sb.append(
"(REGION_ID, GROUP_ID, KEYWORDS, EXPR_TYPE, MATCH_METHOD , IS_HEXBIN, IS_VALID, OP_TIME,LAST_UPDATE ) values( ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
conn.setAutoCommit(false);
PreparedStatement ps = conn.prepareStatement(sb.toString());
int count = 0;
for (StrRegion strRegion : strRegionList) {
count++;
Object[] obj = new Object[] { strRegion.getRegionId(), strRegion.getGroupId(), strRegion.getKeywords(),
strRegion.getExprType(), strRegion.getMatchMethod(), strRegion.getIsHexbin(),
strRegion.getIsValid(), strRegion.getOpTime() };
for (int x = 0; x < obj.length; x++) {
if (x == 7) {
ps.setTimestamp(x + 1, utileDate2TimeStamp(strRegion.getOpTime()));
} else {
ps.setObject(x + 1, obj[x]);
}
}
ps.addBatch();
if (count % batchSize == 0) {
ps.executeBatch();
//conn.commit();
}
}
ps.executeBatch();
//conn.commit();
}
}

View File

@@ -1,472 +0,0 @@
package com.nis.web.service.restful;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import com.nis.domain.restful.ConfigCompile;
import com.nis.domain.restful.ConfigGroupRelation;
import com.nis.domain.restful.IpRegion;
import com.nis.domain.restful.NumRegion;
import com.nis.domain.restful.StrRegion;
import com.nis.web.service.SaveRequestLogThread;
/**
* jdbc测试批量插入
*
* @author RenKaiGe-Office
*
*/
public class JDBCThreadTest implements Runnable {
private static SaveRequestLogThread thread;
private static Long start;
private CountDownLatch latch;
private Boolean isStrongStr;
private String tableName;
private int batchSize;
private Connection conn;
private List<ConfigCompile> compileList;
private List<ConfigGroupRelation> groupList;
private List<IpRegion> ipRegionList;
private List<NumRegion> numRegionList;
private List<StrRegion> strRegionList;
public JDBCThreadTest() {
super();
}
public JDBCThreadTest(int batchSize, Connection conn, CountDownLatch latch, SaveRequestLogThread thread,
Long start) {
super();
this.batchSize = batchSize;
this.conn = conn;
this.latch = latch;
}
public JDBCThreadTest(String tableName, int batchSize, Connection conn, CountDownLatch latch,
SaveRequestLogThread thread, Long start) {
super();
this.tableName = tableName;
this.batchSize = batchSize;
this.conn = conn;
this.latch = latch;
}
public JDBCThreadTest(boolean isStrongStr, String tableName, int batchSize, Connection conn, CountDownLatch latch,
SaveRequestLogThread thread, Long start) {
super();
this.isStrongStr = isStrongStr;
this.tableName = tableName;
this.batchSize = batchSize;
this.conn = conn;
this.latch = latch;
}
public SaveRequestLogThread getThread() {
return thread;
}
public void setThread(SaveRequestLogThread thread) {
this.thread = thread;
}
public Long getStart() {
return start;
}
public void setStart(Long start) {
this.start = start;
}
public int getBatchSize() {
return batchSize;
}
public void setBatchSize(int batchSize) {
this.batchSize = batchSize;
}
public CountDownLatch getLatch() {
return latch;
}
public void setLatch(CountDownLatch latch) {
this.latch = latch;
}
public Boolean getIsStrongStr() {
return isStrongStr;
}
public void setIsStrongStr(Boolean isStrongStr) {
this.isStrongStr = isStrongStr;
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
public Connection getConn() {
return conn;
}
public void setConn(Connection conn) {
this.conn = conn;
}
public List<ConfigCompile> getCompileList() {
return compileList;
}
public void setCompileList(List<ConfigCompile> compileList) {
this.compileList = compileList;
}
public List<ConfigGroupRelation> getGroupList() {
return groupList;
}
public void setGroupList(List<ConfigGroupRelation> groupList) {
this.groupList = groupList;
}
public List<IpRegion> getIpRegionList() {
return ipRegionList;
}
public void setIpRegionList(List<IpRegion> ipRegionList) {
this.ipRegionList = ipRegionList;
}
public List<NumRegion> getNumRegionList() {
return numRegionList;
}
public void setNumRegionList(List<NumRegion> numRegionList) {
this.numRegionList = numRegionList;
}
public List<StrRegion> getStrRegionList() {
return strRegionList;
}
public void setStrRegionList(List<StrRegion> strRegionList) {
this.strRegionList = strRegionList;
}
public static java.sql.Timestamp utileDate2TimeStamp(java.util.Date udate) {
java.sql.Timestamp sqlDate = null;
long t = udate.getTime();
sqlDate = new java.sql.Timestamp(t);
return sqlDate;
}
public static void saveCompile(List<ConfigCompile> compileList, Connection conn, int batchSize) {
if (null != conn) {
try {
StringBuffer sb = new StringBuffer();
sb.append(
"insert into CONFIG_COMPILE (COMPILE_ID ,SERVICE ,ACTION , CONT_TYPE, ATTR_TYPE, CONT_LABEL, Task_id, Guarantee_ID, AFFAIR_ID, TOPIC_ID, DO_BLACKLIST ,DO_LOG ,EFFECTIVE_RANGE , ACTIVE_SYS, CONFIG_PERCENT ,CONFIG_OPTION ,START_TIME ,END_TIME , USER_REGION, IS_VALID,GROUP_NUM,FATHER_CFG_ID ,OP_TIME,LAST_UPDATE ) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate)");
conn.setAutoCommit(false);
PreparedStatement ps = conn.prepareStatement(sb.toString());
int count = 0;
for (ConfigCompile compile : compileList) {
count++;
Object[] obj = new Object[] { compile.getCompileId(), compile.getService(), compile.getAction(),
compile.getContType(), compile.getAttrType(), compile.getContLabel(), compile.getTaskId(),
compile.getGuaranteeId(), compile.getAffairId(), compile.getTopicId(),
compile.getDoBlacklist(), compile.getDoLog(), compile.getEffectiveRange(),
compile.getActiveSys(), compile.getConfigPercent(), compile.getConfigOption(),
compile.getStartTime(), compile.getEndTime(), compile.getUserRegion(), compile.getIsValid(),
compile.getGroupNum(), compile.getFatherCfgId(), compile.getOpTime() };
for (int x = 0; x < obj.length; x++) {
if (x == 16) {
ps.setTimestamp(x + 1, utileDate2TimeStamp(compile.getStartTime()));
} else if (x == 17) {
ps.setTimestamp(x + 1, utileDate2TimeStamp(compile.getEndTime()));
} else if (x == 22) {
ps.setTimestamp(x + 1, utileDate2TimeStamp(compile.getOpTime()));
} else {
ps.setObject(x + 1, obj[x]);
}
}
ps.addBatch();
// if (count % batchSize == 0) {
// ps.executeBatch();
// ps.clearBatch();
// }
}
ps.executeBatch();
} catch (Exception e) {
e.printStackTrace();
try {
conn.close();
conn = null;
} catch (SQLException e1) {
e1.printStackTrace();
}
}
}
// ps.close();
// conn.commit();
}
public static void saveGroup(List<ConfigGroupRelation> groupList, Connection conn, int batchSize) {
if (null != conn) {
try {
StringBuffer sb = new StringBuffer();
sb.append(
"insert into CONFIG_GROUP (ID,GROUP_ID, COMPILE_ID, IS_VALID, LAST_UPDATE, OP_TIME ) values ( seq_config_group.nextval, ?, ?, ?, sysdate, ?) ");
conn.setAutoCommit(false);
PreparedStatement ps = conn.prepareStatement(sb.toString());
int count = 0;
for (ConfigGroupRelation group : groupList) {
count++;
Object[] obj = new Object[] { group.getGroupId(), group.getCompileId(), group.getIsValid(),
group.getOpTime() };
for (int x = 0; x < obj.length; x++) {
if (x == 3) {
ps.setTimestamp(x + 1, utileDate2TimeStamp(group.getOpTime()));
} else {
ps.setObject(x + 1, obj[x]);
}
}
ps.addBatch();
// if (count % batchSize == 0) {
// ps.executeBatch();
// ps.clearBatch();
// }
}
ps.executeBatch();
} catch (Exception e) {
e.printStackTrace();
try {
conn.close();
conn = null;
} catch (SQLException e1) {
e1.printStackTrace();
}
}
}
// ps.close();
// conn.commit();
}
public static void saveIPRegion(String name, List<IpRegion> ipRegionList, Connection conn, int batchSize) {
if (null != conn) {
try {
StringBuffer sb = new StringBuffer();
sb.append("insert into ");
sb.append(name);
sb.append(
"(REGION_ID, GROUP_ID, ADDR_TYPE, SRC_IP, MASK_SRC_IP, SRC_PORT, MASK_SRC_PORT, DST_IP, MASK_DST_IP, DST_PORT, MASK_DST_PORT, PROTOCOL, DIRECTION, IS_VALID, OP_TIME,LAST_UPDATE ) values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
conn.setAutoCommit(false);
PreparedStatement ps = conn.prepareStatement(sb.toString());
int count = 0;
for (IpRegion ipRegion : ipRegionList) {
count++;
Object[] obj = new Object[] { ipRegion.getRegionId(), ipRegion.getGroupId(), ipRegion.getAddrType(),
ipRegion.getSrcIp(), ipRegion.getMaskSrcIp(), ipRegion.getSrcPort(),
ipRegion.getMaskSrcPort(), ipRegion.getDstIp(), ipRegion.getMaskDstIp(),
ipRegion.getDstPort(), ipRegion.getMaskDstPort(), ipRegion.getProtocol(),
ipRegion.getDirection(), ipRegion.getIsValid(), ipRegion.getOpTime()
};
for (int x = 0; x < obj.length; x++) {
if (x == 14) {
ps.setTimestamp(x + 1, utileDate2TimeStamp(ipRegion.getOpTime()));
} else {
ps.setObject(x + 1, obj[x]);
}
}
ps.addBatch();
// if (count % batchSize == 0) {
// ps.executeBatch();
// ps.clearBatch();
// }
}
ps.executeBatch();
} catch (Exception e) {
e.printStackTrace();
try {
conn.close();
conn = null;
} catch (SQLException e1) {
e1.printStackTrace();
}
}
}
// ps.close();
// conn.commit();
}
public static void saveNumRegion(String name, List<NumRegion> numRegionList, Connection conn, int batchSize) {
if (null != conn) {
try {
StringBuffer sb = new StringBuffer();
sb.append("insert into ");
sb.append(name);
sb.append(
" (REGION_ID,GROUP_ID,LOW_BOUNDARY,UP_BOUNDARY,IS_VALID,OP_TIME,LAST_UPDATE) values(?, ?, ?, ?, ?, ?, sysdate)");
conn.setAutoCommit(false);
PreparedStatement ps = conn.prepareStatement(sb.toString());
int count = 0;
for (NumRegion numRegion : numRegionList) {
count++;
Object[] obj = new Object[] { numRegion.getRegionId(), numRegion.getGroupId(),
numRegion.getLowBoundary(), numRegion.getUpBoundary(), numRegion.getIsValid(),
numRegion.getOpTime() };
for (int x = 0; x < obj.length; x++) {
if (x == 5) {
ps.setTimestamp(x + 1, utileDate2TimeStamp(numRegion.getOpTime()));
} else {
ps.setObject(x + 1, obj[x]);
}
}
ps.addBatch();
// if (count % batchSize == 0) {
// ps.executeBatch();
// ps.clearBatch();
// }
}
ps.executeBatch();
} catch (Exception e) {
e.printStackTrace();
try {
conn.close();
conn = null;
} catch (SQLException e1) {
e1.printStackTrace();
}
}
}
// ps.close();
// conn.commit();
}
public static void saveStrongStrRegion(String name, List<StrRegion> strRegionList, Connection conn, int batchSize) {
if (null != conn) {
try {
StringBuffer sb = new StringBuffer();
sb.append("insert into ");
sb.append(name);
sb.append(
"(REGION_ID, GROUP_ID, DISTRICT, KEYWORDS, EXPR_TYPE, MATCH_METHOD , IS_HEXBIN, IS_VALID, OP_TIME,LAST_UPDATE ) values(?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
conn.setAutoCommit(false);
PreparedStatement ps = conn.prepareStatement(sb.toString());
int count = 0;
for (StrRegion strRegion : strRegionList) {
count++;
Object[] obj = new Object[] { strRegion.getRegionId(), strRegion.getGroupId(),
strRegion.getDistrict(), strRegion.getKeywords(), strRegion.getExprType(),
strRegion.getMatchMethod(), strRegion.getIsHexbin(), strRegion.getIsValid(),
strRegion.getOpTime() };
for (int x = 0; x < obj.length; x++) {
if (x == 8) {
ps.setTimestamp(x + 1, utileDate2TimeStamp(strRegion.getOpTime()));
} else {
ps.setObject(x + 1, obj[x]);
}
}
ps.addBatch();
// if (count % batchSize == 0) {
// ps.executeBatch();
// ps.clearBatch();
// }
}
ps.executeBatch();
} catch (Exception e) {
e.printStackTrace();
try {
conn.close();
conn = null;
} catch (SQLException e1) {
e1.printStackTrace();
}
}
}
// ps.close();
// conn.commit();
}
public static void saveStrRegion(String name, List<StrRegion> strRegionList, Connection conn, int batchSize) {
if (null != conn) {
try {
StringBuffer sb = new StringBuffer();
sb.append("insert into ");
sb.append(name);
sb.append(
"(REGION_ID, GROUP_ID, KEYWORDS, EXPR_TYPE, MATCH_METHOD , IS_HEXBIN, IS_VALID, OP_TIME,LAST_UPDATE ) values( ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
conn.setAutoCommit(false);
PreparedStatement ps = conn.prepareStatement(sb.toString());
int count = 0;
for (StrRegion strRegion : strRegionList) {
count++;
Object[] obj = new Object[] { strRegion.getRegionId(), strRegion.getGroupId(),
strRegion.getKeywords(), strRegion.getExprType(), strRegion.getMatchMethod(),
strRegion.getIsHexbin(), strRegion.getIsValid(), strRegion.getOpTime() };
for (int x = 0; x < obj.length; x++) {
if (x == 7) {
ps.setTimestamp(x + 1, utileDate2TimeStamp(strRegion.getOpTime()));
} else {
ps.setObject(x + 1, obj[x]);
}
}
ps.addBatch();
// if (count % batchSize == 0) {
// ps.executeBatch();
// ps.clearBatch();
// }
}
ps.executeBatch();
} catch (Exception e) {
e.printStackTrace();
try {
conn.close();
conn = null;
} catch (SQLException e1) {
e1.printStackTrace();
}
}
}
// ps.close();
// conn.commit();
}
@Override
public void run() {
synchronized (conn) {
try {
if (null != compileList && compileList.size() > 0) {
saveCompile(compileList, conn, batchSize);
} else if (null != groupList && groupList.size() > 0) {
saveGroup(groupList, conn, batchSize);
} else if (null != ipRegionList && ipRegionList.size() > 0) {
saveIPRegion(tableName, ipRegionList, conn, batchSize);
} else if (null != strRegionList && strRegionList.size() > 0) {
if (null != isStrongStr && isStrongStr) {
saveStrongStrRegion(tableName, strRegionList, conn, batchSize);
} else {
saveStrRegion(tableName, strRegionList, conn, batchSize);
}
}else if (null != numRegionList && numRegionList.size() > 0) {
saveNumRegion(tableName, numRegionList, conn, batchSize);
}
latch.countDown();
System.out.println("latchCount=======================" + latch.getCount());
} catch (Exception e) {
e.printStackTrace();
}
}
}
}

View File

@@ -1,139 +0,0 @@
package com.nis.web.service.restful;
import java.sql.Types;
import java.util.List;
import javax.sql.DataSource;
import org.springframework.jdbc.object.BatchSqlUpdate;
import com.nis.domain.restful.ConfigCompile;
import com.nis.domain.restful.ConfigGroupRelation;
import com.nis.domain.restful.IpRegion;
import com.nis.domain.restful.NumRegion;
import com.nis.domain.restful.StrRegion;
/**
* jdbc测试批量插入
*
* @author RenKaiGe-Office
*
*/
public class SpringJDBCTest {
public static BatchSqlUpdate saveCompile(List<ConfigCompile> compileList, DataSource ds, int batchSize) {
StringBuffer sb = new StringBuffer();
sb.append(
"insert into CONFIG_COMPILE (COMPILE_ID ,SERVICE ,ACTION , CONT_TYPE, ATTR_TYPE, CONT_LABEL, Task_id, Guarantee_ID, AFFAIR_ID, TOPIC_ID, DO_BLACKLIST ,DO_LOG ,EFFECTIVE_RANGE , ACTIVE_SYS, CONFIG_PERCENT ,CONFIG_OPTION ,START_TIME ,END_TIME , USER_REGION, IS_VALID,GROUP_NUM,FATHER_CFG_ID ,OP_TIME,LAST_UPDATE ) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate)");
BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
bsu.setBatchSize(batchSize);
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR,
Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR,
Types.INTEGER, Types.BIGINT, Types.INTEGER, Types.DATE, Types.DATE, Types.VARCHAR, Types.INTEGER,
Types.INTEGER, Types.BIGINT, Types.DATE });
for (ConfigCompile compile : compileList) {
bsu.update(new Object[] { compile.getCompileId(), compile.getService(), compile.getAction(),
compile.getContType(), compile.getAttrType(), compile.getContLabel(), compile.getTaskId(),
compile.getGuaranteeId(), compile.getAffairId(), compile.getTopicId(), compile.getDoBlacklist(),
compile.getDoLog(), compile.getEffectiveRange(), compile.getActiveSys(), compile.getConfigPercent(),
compile.getConfigOption(), compile.getStartTime(), compile.getEndTime(), compile.getUserRegion(),
compile.getIsValid(), compile.getGroupNum(), compile.getFatherCfgId(), compile.getOpTime() });
}
// bsu.flush();
return bsu;
}
public static BatchSqlUpdate saveGroup(List<ConfigGroupRelation> groupList, DataSource ds, int batchSize) {
StringBuffer sb = new StringBuffer();
sb.append(
"insert into CONFIG_GROUP (ID,GROUP_ID, COMPILE_ID, IS_VALID, LAST_UPDATE, OP_TIME ) values ( seq_config_group.nextval, ?, ?, ?, sysdate, ?) ");
BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
bsu.setBatchSize(batchSize);
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.INTEGER, Types.DATE });
for (ConfigGroupRelation group : groupList) {
bsu.update(
new Object[] { group.getGroupId(), group.getCompileId(), group.getIsValid(), group.getOpTime() });
}
// bsu.flush();
return bsu;
}
public static BatchSqlUpdate saveIPRegion(String name, List<IpRegion> ipRegionList, DataSource ds, int batchSize) {
StringBuffer sb = new StringBuffer();
sb.append("insert into ");
sb.append(name);
sb.append(
"(REGION_ID, GROUP_ID, ADDR_TYPE, SRC_IP, MASK_SRC_IP, SRC_PORT, MASK_SRC_PORT, DST_IP, MASK_DST_IP, DST_PORT, MASK_DST_PORT, PROTOCOL, DIRECTION, IS_VALID, OP_TIME,LAST_UPDATE ) values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
bsu.setBatchSize(batchSize);
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER,
Types.INTEGER, Types.DATE });
for (IpRegion ipRegion : ipRegionList) {
bsu.update(new Object[] { ipRegion.getRegionId(), ipRegion.getGroupId(), ipRegion.getAddrType(),
ipRegion.getSrcIp(), ipRegion.getMaskSrcIp(), ipRegion.getSrcPort(), ipRegion.getMaskSrcPort(),
ipRegion.getDstIp(), ipRegion.getMaskDstIp(), ipRegion.getDstPort(), ipRegion.getMaskDstPort(),
ipRegion.getProtocol(), ipRegion.getDirection(), ipRegion.getIsValid(), ipRegion.getOpTime()
});
}
// bsu.flush();
return bsu;
}
public static BatchSqlUpdate saveNumRegion(String name, List<NumRegion> numRegionList, DataSource ds,
int batchSize) {
StringBuffer sb = new StringBuffer();
sb.append("insert into ");
sb.append(name);
sb.append(
" (REGION_ID,GROUP_ID,LOW_BOUNDARY,UP_BOUNDARY,IS_VALID,OP_TIME,LAST_UPDATE) values(?, ?, ?, ?, ?, ?, sysdate)");
BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
bsu.setBatchSize(batchSize);
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.INTEGER, Types.DATE });
for (NumRegion numRegion : numRegionList) {
bsu.update(new Object[] { numRegion.getRegionId(), numRegion.getGroupId(), numRegion.getLowBoundary(),
numRegion.getUpBoundary(), numRegion.getIsValid(), numRegion.getOpTime() });
}
// bsu.flush();
return bsu;
}
public static BatchSqlUpdate saveStrongStrRegion(String name, List<StrRegion> strRegionList, DataSource ds,
int batchSize) {
StringBuffer sb = new StringBuffer();
sb.append("insert into ");
sb.append(name);
sb.append(
"(REGION_ID, GROUP_ID, DISTRICT, KEYWORDS, EXPR_TYPE, MATCH_METHOD , IS_HEXBIN, IS_VALID, OP_TIME,LAST_UPDATE ) values(?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
bsu.setBatchSize(batchSize);
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER,
Types.INTEGER, Types.INTEGER, Types.DATE });
for (StrRegion strRegion : strRegionList) {
bsu.update(new Object[] { strRegion.getRegionId(), strRegion.getGroupId(), strRegion.getDistrict(),
strRegion.getKeywords(), strRegion.getExprType(), strRegion.getMatchMethod(),
strRegion.getIsHexbin(), strRegion.getIsValid(), strRegion.getOpTime() });
}
// bsu.flush();
return bsu;
}
public static BatchSqlUpdate saveStrRegion(String name, List<StrRegion> strRegionList, DataSource ds,
int batchSize) {
StringBuffer sb = new StringBuffer();
sb.append("insert into ");
sb.append(name);
sb.append(
"(REGION_ID, GROUP_ID, KEYWORDS, EXPR_TYPE, MATCH_METHOD , IS_HEXBIN, IS_VALID, OP_TIME,LAST_UPDATE ) values( ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
bsu.setBatchSize(batchSize);
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER,
Types.INTEGER, Types.DATE });
for (StrRegion strRegion : strRegionList) {
bsu.update(new Object[] { strRegion.getRegionId(), strRegion.getGroupId(), strRegion.getKeywords(),
strRegion.getExprType(), strRegion.getMatchMethod(), strRegion.getIsHexbin(),
strRegion.getIsValid(), strRegion.getOpTime() });
}
// bsu.flush();
return bsu;
}
}

View File

@@ -1,287 +0,0 @@
package com.nis.web.service.restful;
import java.sql.Connection;
import java.sql.Types;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import javax.sql.DataSource;
import org.springframework.jdbc.object.BatchSqlUpdate;
import com.nis.domain.restful.ConfigCompile;
import com.nis.domain.restful.ConfigGroupRelation;
import com.nis.domain.restful.IpRegion;
import com.nis.domain.restful.NumRegion;
import com.nis.domain.restful.StrRegion;
/**
* jdbc测试批量插入
*
* @author RenKaiGe-Office
*
*/
public class SpringJDBCThreadTest implements Runnable {
private CountDownLatch latch;
private Boolean isStrongStr;
private String tableName;
private int batchSize;
private BatchSqlUpdate bsu;
private List<ConfigCompile> compileList;
private List<ConfigGroupRelation> groupList;
private List<IpRegion> ipRegionList;
private List<NumRegion> numRegionList;
private List<StrRegion> strRegionList;
public SpringJDBCThreadTest() {
super();
}
public SpringJDBCThreadTest(int batchSize, BatchSqlUpdate bsu, CountDownLatch latch) {
super();
this.batchSize = batchSize;
this.bsu = bsu;
this.latch = latch;
}
public SpringJDBCThreadTest(String tableName, int batchSize, BatchSqlUpdate bsu, CountDownLatch latch) {
super();
this.tableName = tableName;
this.batchSize = batchSize;
this.bsu = bsu;
this.latch = latch;
}
public SpringJDBCThreadTest(boolean isStrongStr, String tableName, int batchSize, BatchSqlUpdate bsu,
CountDownLatch latch) {
super();
this.isStrongStr = isStrongStr;
this.tableName = tableName;
this.batchSize = batchSize;
this.bsu = bsu;
this.latch = latch;
}
public int getBatchSize() {
return batchSize;
}
public void setBatchSize(int batchSize) {
this.batchSize = batchSize;
}
public BatchSqlUpdate getBsu() {
return bsu;
}
public void setBsu(BatchSqlUpdate bsu) {
this.bsu = bsu;
}
public CountDownLatch getLatch() {
return latch;
}
public void setLatch(CountDownLatch latch) {
this.latch = latch;
}
public Boolean getIsStrongStr() {
return isStrongStr;
}
public void setIsStrongStr(Boolean isStrongStr) {
this.isStrongStr = isStrongStr;
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
public List<ConfigCompile> getCompileList() {
return compileList;
}
public void setCompileList(List<ConfigCompile> compileList) {
this.compileList = compileList;
}
public List<ConfigGroupRelation> getGroupList() {
return groupList;
}
public void setGroupList(List<ConfigGroupRelation> groupList) {
this.groupList = groupList;
}
public List<IpRegion> getIpRegionList() {
return ipRegionList;
}
public void setIpRegionList(List<IpRegion> ipRegionList) {
this.ipRegionList = ipRegionList;
}
public List<NumRegion> getNumRegionList() {
return numRegionList;
}
public void setNumRegionList(List<NumRegion> numRegionList) {
this.numRegionList = numRegionList;
}
public List<StrRegion> getStrRegionList() {
return strRegionList;
}
public void setStrRegionList(List<StrRegion> strRegionList) {
this.strRegionList = strRegionList;
}
public static void saveCompile(List<ConfigCompile> compileList, BatchSqlUpdate bsu, int batchSize) {
StringBuffer sb = new StringBuffer();
sb.append(
"insert into CONFIG_COMPILE (COMPILE_ID ,SERVICE ,ACTION , CONT_TYPE, ATTR_TYPE, CONT_LABEL, Task_id, Guarantee_ID, AFFAIR_ID, TOPIC_ID, DO_BLACKLIST ,DO_LOG ,EFFECTIVE_RANGE , ACTIVE_SYS, CONFIG_PERCENT ,CONFIG_OPTION ,START_TIME ,END_TIME , USER_REGION, IS_VALID,GROUP_NUM,FATHER_CFG_ID ,OP_TIME,LAST_UPDATE ) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate)");
// BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
bsu.setSql(sb.toString());
bsu.setBatchSize(batchSize);
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR,
Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR,
Types.INTEGER, Types.BIGINT, Types.INTEGER, Types.DATE, Types.DATE, Types.VARCHAR, Types.INTEGER,
Types.INTEGER, Types.BIGINT, Types.DATE });
for (ConfigCompile compile : compileList) {
bsu.update(new Object[] { compile.getCompileId(), compile.getService(), compile.getAction(),
compile.getContType(), compile.getAttrType(), compile.getContLabel(), compile.getTaskId(),
compile.getGuaranteeId(), compile.getAffairId(), compile.getTopicId(), compile.getDoBlacklist(),
compile.getDoLog(), compile.getEffectiveRange(), compile.getActiveSys(), compile.getConfigPercent(),
compile.getConfigOption(), compile.getStartTime(), compile.getEndTime(), compile.getUserRegion(),
compile.getIsValid(), compile.getGroupNum(), compile.getFatherCfgId(), compile.getOpTime() });
}
bsu.flush();
}
public static void saveGroup(List<ConfigGroupRelation> groupList, BatchSqlUpdate bsu, int batchSize) {
StringBuffer sb = new StringBuffer();
sb.append(
"insert into CONFIG_GROUP (ID,GROUP_ID, COMPILE_ID, IS_VALID, LAST_UPDATE, OP_TIME ) values ( seq_config_group.nextval, ?, ?, ?, sysdate, ?) ");
// BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
bsu.setSql(sb.toString());
bsu.setBatchSize(batchSize);
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.INTEGER, Types.DATE });
for (ConfigGroupRelation group : groupList) {
bsu.update(
new Object[] { group.getGroupId(), group.getCompileId(), group.getIsValid(), group.getOpTime() });
}
bsu.flush();
}
public static void saveIPRegion(String name, List<IpRegion> ipRegionList, BatchSqlUpdate bsu, int batchSize) {
StringBuffer sb = new StringBuffer();
sb.append("insert into ");
sb.append(name);
sb.append(
"(REGION_ID, GROUP_ID, ADDR_TYPE, SRC_IP, MASK_SRC_IP, SRC_PORT, MASK_SRC_PORT, DST_IP, MASK_DST_IP, DST_PORT, MASK_DST_PORT, PROTOCOL, DIRECTION, IS_VALID, OP_TIME,LAST_UPDATE ) values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
// BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
bsu.setSql(sb.toString());
bsu.setBatchSize(batchSize);
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER,
Types.INTEGER, Types.DATE });
for (IpRegion ipRegion : ipRegionList) {
bsu.update(new Object[] { ipRegion.getRegionId(), ipRegion.getGroupId(), ipRegion.getAddrType(),
ipRegion.getSrcIp(), ipRegion.getMaskSrcIp(), ipRegion.getSrcPort(), ipRegion.getMaskSrcPort(),
ipRegion.getDstIp(), ipRegion.getMaskDstIp(), ipRegion.getDstPort(), ipRegion.getMaskDstPort(),
ipRegion.getProtocol(), ipRegion.getDirection(), ipRegion.getIsValid(), ipRegion.getOpTime()
});
}
bsu.flush();
}
public static void saveNumRegion(String name, List<NumRegion> numRegionList, BatchSqlUpdate bsu, int batchSize) {
StringBuffer sb = new StringBuffer();
sb.append("insert into ");
sb.append(name);
sb.append(
" (REGION_ID,GROUP_ID,LOW_BOUNDARY,UP_BOUNDARY,IS_VALID,OP_TIME,LAST_UPDATE) values(?, ?, ?, ?, ?, ?, sysdate)");
// BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
bsu.setSql(sb.toString());
bsu.setBatchSize(batchSize);
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.INTEGER, Types.DATE });
for (NumRegion numRegion : numRegionList) {
bsu.update(new Object[] { numRegion.getRegionId(), numRegion.getGroupId(), numRegion.getLowBoundary(),
numRegion.getUpBoundary(), numRegion.getIsValid(), numRegion.getOpTime() });
}
bsu.flush();
}
public static void saveStrongStrRegion(String name, List<StrRegion> strRegionList, BatchSqlUpdate bsu,
int batchSize) {
StringBuffer sb = new StringBuffer();
sb.append("insert into ");
sb.append(name);
sb.append(
"(REGION_ID, GROUP_ID, DISTRICT, KEYWORDS, EXPR_TYPE, MATCH_METHOD , IS_HEXBIN, IS_VALID, OP_TIME,LAST_UPDATE ) values(?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
// BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
bsu.setSql(sb.toString());
bsu.setBatchSize(batchSize);
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER,
Types.INTEGER, Types.INTEGER, Types.DATE });
for (StrRegion strRegion : strRegionList) {
bsu.update(new Object[] { strRegion.getRegionId(), strRegion.getGroupId(), strRegion.getDistrict(),
strRegion.getKeywords(), strRegion.getExprType(), strRegion.getMatchMethod(),
strRegion.getIsHexbin(), strRegion.getIsValid(), strRegion.getOpTime() });
}
bsu.flush();
}
public static void saveStrRegion(String name, List<StrRegion> strRegionList, BatchSqlUpdate bsu, int batchSize) {
StringBuffer sb = new StringBuffer();
sb.append("insert into ");
sb.append(name);
sb.append(
"(REGION_ID, GROUP_ID, KEYWORDS, EXPR_TYPE, MATCH_METHOD , IS_HEXBIN, IS_VALID, OP_TIME,LAST_UPDATE ) values( ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
// BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
bsu.setSql(sb.toString());
bsu.setBatchSize(batchSize);
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER,
Types.INTEGER, Types.DATE });
for (StrRegion strRegion : strRegionList) {
bsu.update(new Object[] { strRegion.getRegionId(), strRegion.getGroupId(), strRegion.getKeywords(),
strRegion.getExprType(), strRegion.getMatchMethod(), strRegion.getIsHexbin(),
strRegion.getIsValid(), strRegion.getOpTime() });
}
bsu.flush();
}
@Override
public void run() {
try {
if (null != compileList && compileList.size() > 0) {
saveCompile(compileList, bsu, batchSize);
} else if (null != groupList && groupList.size() > 0) {
saveGroup(groupList, bsu, batchSize);
} else if (null != ipRegionList && ipRegionList.size() > 0) {
saveIPRegion(tableName, ipRegionList, bsu, batchSize);
} else if (null != strRegionList && strRegionList.size() > 0) {
if (null != isStrongStr && isStrongStr) {
saveStrongStrRegion(tableName, strRegionList, bsu, batchSize);
} else {
saveStrRegion(tableName, strRegionList, bsu, batchSize);
}
} else if (null != numRegionList && numRegionList.size() > 0) {
saveNumRegion(tableName, numRegionList, bsu, batchSize);
}
latch.countDown();
System.out.println("SpringJDBC--latchCount=======================" + latch.getCount());
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -1,287 +0,0 @@
package com.nis.web.service.restful;
import java.sql.Connection;
import java.sql.Types;
import java.util.List;
import java.util.concurrent.CountDownLatch;
import javax.sql.DataSource;
import org.springframework.jdbc.object.BatchSqlUpdate;
import com.nis.domain.restful.ConfigCompile;
import com.nis.domain.restful.ConfigGroupRelation;
import com.nis.domain.restful.IpRegion;
import com.nis.domain.restful.NumRegion;
import com.nis.domain.restful.StrRegion;
/**
* jdbc测试批量插入
*
* @author RenKaiGe-Office
*
*/
public class SpringJDBCThreadTest2 implements Runnable {
private CountDownLatch latch;
private Boolean isStrongStr;
private String tableName;
private int batchSize;
private BatchSqlUpdate bsu;
private List<ConfigCompile> compileList;
private List<ConfigGroupRelation> groupList;
private List<IpRegion> ipRegionList;
private List<NumRegion> numRegionList;
private List<StrRegion> strRegionList;
public SpringJDBCThreadTest2() {
super();
}
public SpringJDBCThreadTest2(int batchSize, BatchSqlUpdate bsu, CountDownLatch latch) {
super();
this.batchSize = batchSize;
this.bsu = bsu;
this.latch = latch;
}
public SpringJDBCThreadTest2(String tableName, int batchSize, BatchSqlUpdate bsu, CountDownLatch latch) {
super();
this.tableName = tableName;
this.batchSize = batchSize;
this.bsu = bsu;
this.latch = latch;
}
public SpringJDBCThreadTest2(boolean isStrongStr, String tableName, int batchSize, BatchSqlUpdate bsu,
CountDownLatch latch) {
super();
this.isStrongStr = isStrongStr;
this.tableName = tableName;
this.batchSize = batchSize;
this.bsu = bsu;
this.latch = latch;
}
public int getBatchSize() {
return batchSize;
}
public void setBatchSize(int batchSize) {
this.batchSize = batchSize;
}
public BatchSqlUpdate getBsu() {
return bsu;
}
public void setBsu(BatchSqlUpdate bsu) {
this.bsu = bsu;
}
public CountDownLatch getLatch() {
return latch;
}
public void setLatch(CountDownLatch latch) {
this.latch = latch;
}
public Boolean getIsStrongStr() {
return isStrongStr;
}
public void setIsStrongStr(Boolean isStrongStr) {
this.isStrongStr = isStrongStr;
}
public String getTableName() {
return tableName;
}
public void setTableName(String tableName) {
this.tableName = tableName;
}
public List<ConfigCompile> getCompileList() {
return compileList;
}
public void setCompileList(List<ConfigCompile> compileList) {
this.compileList = compileList;
}
public List<ConfigGroupRelation> getGroupList() {
return groupList;
}
public void setGroupList(List<ConfigGroupRelation> groupList) {
this.groupList = groupList;
}
public List<IpRegion> getIpRegionList() {
return ipRegionList;
}
public void setIpRegionList(List<IpRegion> ipRegionList) {
this.ipRegionList = ipRegionList;
}
public List<NumRegion> getNumRegionList() {
return numRegionList;
}
public void setNumRegionList(List<NumRegion> numRegionList) {
this.numRegionList = numRegionList;
}
public List<StrRegion> getStrRegionList() {
return strRegionList;
}
public void setStrRegionList(List<StrRegion> strRegionList) {
this.strRegionList = strRegionList;
}
public static void saveCompile(List<ConfigCompile> compileList, BatchSqlUpdate bsu, int batchSize) {
StringBuffer sb = new StringBuffer();
sb.append(
"insert into CONFIG_COMPILE (COMPILE_ID ,SERVICE ,ACTION , CONT_TYPE, ATTR_TYPE, CONT_LABEL, Task_id, Guarantee_ID, AFFAIR_ID, TOPIC_ID, DO_BLACKLIST ,DO_LOG ,EFFECTIVE_RANGE , ACTIVE_SYS, CONFIG_PERCENT ,CONFIG_OPTION ,START_TIME ,END_TIME , USER_REGION, IS_VALID,GROUP_NUM,FATHER_CFG_ID ,OP_TIME,LAST_UPDATE ) values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate)");
// BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
bsu.setSql(sb.toString());
bsu.setBatchSize(batchSize);
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR,
Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.INTEGER, Types.VARCHAR,
Types.INTEGER, Types.BIGINT, Types.INTEGER, Types.DATE, Types.DATE, Types.VARCHAR, Types.INTEGER,
Types.INTEGER, Types.BIGINT, Types.DATE });
for (ConfigCompile compile : compileList) {
bsu.update(new Object[] { compile.getCompileId(), compile.getService(), compile.getAction(),
compile.getContType(), compile.getAttrType(), compile.getContLabel(), compile.getTaskId(),
compile.getGuaranteeId(), compile.getAffairId(), compile.getTopicId(), compile.getDoBlacklist(),
compile.getDoLog(), compile.getEffectiveRange(), compile.getActiveSys(), compile.getConfigPercent(),
compile.getConfigOption(), compile.getStartTime(), compile.getEndTime(), compile.getUserRegion(),
compile.getIsValid(), compile.getGroupNum(), compile.getFatherCfgId(), compile.getOpTime() });
}
bsu.flush();
}
public static void saveGroup(List<ConfigGroupRelation> groupList, BatchSqlUpdate bsu, int batchSize) {
StringBuffer sb = new StringBuffer();
sb.append(
"insert into CONFIG_GROUP (ID,GROUP_ID, COMPILE_ID, IS_VALID, LAST_UPDATE, OP_TIME ) values ( seq_config_group.nextval, ?, ?, ?, sysdate, ?) ");
// BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
bsu.setSql(sb.toString());
bsu.setBatchSize(batchSize);
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.INTEGER, Types.DATE });
for (ConfigGroupRelation group : groupList) {
bsu.update(
new Object[] { group.getGroupId(), group.getCompileId(), group.getIsValid(), group.getOpTime() });
}
bsu.flush();
}
public static void saveIPRegion(String name, List<IpRegion> ipRegionList, BatchSqlUpdate bsu, int batchSize) {
StringBuffer sb = new StringBuffer();
sb.append("insert into ");
sb.append(name);
sb.append(
"(REGION_ID, GROUP_ID, ADDR_TYPE, SRC_IP, MASK_SRC_IP, SRC_PORT, MASK_SRC_PORT, DST_IP, MASK_DST_IP, DST_PORT, MASK_DST_PORT, PROTOCOL, DIRECTION, IS_VALID, OP_TIME,LAST_UPDATE ) values( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
// BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
bsu.setSql(sb.toString());
bsu.setBatchSize(batchSize);
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.INTEGER, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR,
Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER,
Types.INTEGER, Types.DATE });
for (IpRegion ipRegion : ipRegionList) {
bsu.update(new Object[] { ipRegion.getRegionId(), ipRegion.getGroupId(), ipRegion.getAddrType(),
ipRegion.getSrcIp(), ipRegion.getMaskSrcIp(), ipRegion.getSrcPort(), ipRegion.getMaskSrcPort(),
ipRegion.getDstIp(), ipRegion.getMaskDstIp(), ipRegion.getDstPort(), ipRegion.getMaskDstPort(),
ipRegion.getProtocol(), ipRegion.getDirection(), ipRegion.getIsValid(), ipRegion.getOpTime()
});
}
bsu.flush();
}
public static void saveNumRegion(String name, List<NumRegion> numRegionList, BatchSqlUpdate bsu, int batchSize) {
StringBuffer sb = new StringBuffer();
sb.append("insert into ");
sb.append(name);
sb.append(
" (REGION_ID,GROUP_ID,LOW_BOUNDARY,UP_BOUNDARY,IS_VALID,OP_TIME,LAST_UPDATE) values(?, ?, ?, ?, ?, ?, sysdate)");
// BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
bsu.setSql(sb.toString());
bsu.setBatchSize(batchSize);
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.BIGINT, Types.INTEGER, Types.DATE });
for (NumRegion numRegion : numRegionList) {
bsu.update(new Object[] { numRegion.getRegionId(), numRegion.getGroupId(), numRegion.getLowBoundary(),
numRegion.getUpBoundary(), numRegion.getIsValid(), numRegion.getOpTime() });
}
bsu.flush();
}
public static void saveStrongStrRegion(String name, List<StrRegion> strRegionList, BatchSqlUpdate bsu,
int batchSize) {
StringBuffer sb = new StringBuffer();
sb.append("insert into ");
sb.append(name);
sb.append(
"(REGION_ID, GROUP_ID, DISTRICT, KEYWORDS, EXPR_TYPE, MATCH_METHOD , IS_HEXBIN, IS_VALID, OP_TIME,LAST_UPDATE ) values(?, ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
// BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
bsu.setSql(sb.toString());
bsu.setBatchSize(batchSize);
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.VARCHAR, Types.VARCHAR, Types.INTEGER, Types.INTEGER,
Types.INTEGER, Types.INTEGER, Types.DATE });
for (StrRegion strRegion : strRegionList) {
bsu.update(new Object[] { strRegion.getRegionId(), strRegion.getGroupId(), strRegion.getDistrict(),
strRegion.getKeywords(), strRegion.getExprType(), strRegion.getMatchMethod(),
strRegion.getIsHexbin(), strRegion.getIsValid(), strRegion.getOpTime() });
}
bsu.flush();
}
public static void saveStrRegion(String name, List<StrRegion> strRegionList, BatchSqlUpdate bsu, int batchSize) {
StringBuffer sb = new StringBuffer();
sb.append("insert into ");
sb.append(name);
sb.append(
"(REGION_ID, GROUP_ID, KEYWORDS, EXPR_TYPE, MATCH_METHOD , IS_HEXBIN, IS_VALID, OP_TIME,LAST_UPDATE ) values( ?, ?, ?, ?, ?, ?, ?, ?, sysdate) ");
// BatchSqlUpdate bsu = new BatchSqlUpdate(ds, sb.toString());
bsu.setSql(sb.toString());
bsu.setBatchSize(batchSize);
bsu.setTypes(new int[] { Types.BIGINT, Types.BIGINT, Types.VARCHAR, Types.INTEGER, Types.INTEGER, Types.INTEGER,
Types.INTEGER, Types.DATE });
for (StrRegion strRegion : strRegionList) {
bsu.update(new Object[] { strRegion.getRegionId(), strRegion.getGroupId(), strRegion.getKeywords(),
strRegion.getExprType(), strRegion.getMatchMethod(), strRegion.getIsHexbin(),
strRegion.getIsValid(), strRegion.getOpTime() });
}
bsu.flush();
}
@Override
public void run() {
try {
if (null != compileList && compileList.size() > 0) {
saveCompile(compileList, bsu, batchSize);
} else if (null != groupList && groupList.size() > 0) {
saveGroup(groupList, bsu, batchSize);
} else if (null != ipRegionList && ipRegionList.size() > 0) {
saveIPRegion(tableName, ipRegionList, bsu, batchSize);
} else if (null != strRegionList && strRegionList.size() > 0) {
if (null != isStrongStr && isStrongStr) {
saveStrongStrRegion(tableName, strRegionList, bsu, batchSize);
} else {
saveStrRegion(tableName, strRegionList, bsu, batchSize);
}
} else if (null != numRegionList && numRegionList.size() > 0) {
saveNumRegion(tableName, numRegionList, bsu, batchSize);
}
latch.countDown();
System.out.println("SpringJDBC--latchCount=======================" + latch.getCount());
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -45,14 +45,14 @@
</p:expressions>
</p:maatType>
<p:maatType service="80;82;84;144;146;148">
<p:maatType service="3;15;80;82;84;144;146;148">
<p:expressions>
<p:keyExpression>EFFECTIVE_RULE;:;{compile_table_name};,;[cfg_id]</p:keyExpression>
<p:valueExpression>[cfg_id];\t;[service];\t;[action];\t;[do_blacklist];\t;[do_log];\t;[effective_range];\t;[user_region];\t;[is_valid];\t;[group_num];\t;[father_cfg_id];\t;[op_time]</p:valueExpression>
<p:keyExpression>EFFECTIVE_RULE;:;{compile_table_name};,;[compile_id]</p:keyExpression>
<p:valueExpression>[compile_id];\t;[service];\t;[action];\t;[do_blacklist];\t;[do_log];\t;[effective_range];\t;[user_region];\t;[is_valid];\t;[group_num];\t;[father_cfg_id];\t;[op_time]</p:valueExpression>
</p:expressions>
<p:expressions>
<p:keyExpression>EFFECTIVE_RULE;:;{group_table_name};,;[group_id]</p:keyExpression>
<p:valueExpression>[group_id];\t;[cfg_id];\t;[is_valid];\t;[op_time]</p:valueExpression>
<p:valueExpression>[group_id];\t;[compile_id];\t;[is_valid];\t;[op_time]</p:valueExpression>
</p:expressions>
<p:expressions>
<p:keyExpression>EFFECTIVE_RULE;:;{ip_region_table_name};,;[region_id]</p:keyExpression>
@@ -86,8 +86,8 @@
<p:maatType service="81;145">
<p:expressions>
<p:keyExpression>EFFECTIVE_RULE;:;{compile_table_name};,;[cfg_id]</p:keyExpression>
<p:valueExpression>[cfg_id];\t;[service];\t;[action];\t;[do_blacklist];\t;[do_log];\t;[effective_range];\t;[user_region];\t;[is_valid];\t;[group_num];\t;[father_cfg_id];\t;[op_time]</p:valueExpression>
<p:keyExpression>EFFECTIVE_RULE;:;{compile_table_name};,;[compile_id]</p:keyExpression>
<p:valueExpression>[compile_id];\t;[service];\t;[action];\t;[do_blacklist];\t;[do_log];\t;[effective_range];\t;[user_region];\t;[is_valid];\t;[group_num];\t;[father_cfg_id];\t;[op_time]</p:valueExpression>
</p:expressions>
<p:expressions>
<p:keyExpression>EFFECTIVE_RULE;:;{group_table_name};,;[group_id]</p:keyExpression>
@@ -128,12 +128,12 @@
<p:maatType service="83;85;147;149">
<p:expressions>
<p:keyExpression>EFFECTIVE_RULE;:;{compile_table_name};,;[cfg_id]</p:keyExpression>
<p:valueExpression>[cfg_id];\t;[service];\t;[action];\t;[do_blacklist];\t;[do_log];\t;[effective_range];\t;[user_region];\t;[is_valid];\t;[group_num];\t;[father_cfg_id];\t;[op_time]</p:valueExpression>
<p:keyExpression>EFFECTIVE_RULE;:;{compile_table_name};,;[compile_id]</p:keyExpression>
<p:valueExpression>[compile_id];\t;[service];\t;[action];\t;[do_blacklist];\t;[do_log];\t;[effective_range];\t;[user_region];\t;[is_valid];\t;[group_num];\t;[father_cfg_id];\t;[op_time]</p:valueExpression>
</p:expressions>
<p:expressions>
<p:keyExpression>EFFECTIVE_RULE;:;{group_table_name};,;[group_id]</p:keyExpression>
<p:valueExpression>[group_id];\t;[cfg_id];\t;[is_valid];\t;[op_time]</p:valueExpression>
<p:valueExpression>[group_id];\t;[compile_id];\t;[is_valid];\t;[op_time]</p:valueExpression>
</p:expressions>
<p:expressions>
<p:keyExpression>EFFECTIVE_RULE;:;{num_region_table_name};,;[region_id]</p:keyExpression>

View File

@@ -238,3 +238,6 @@ maxPageSize=100000
#是否开启Debug模式
isDebug=true
#文件摘要获取工具目录
digest.gen.tool.path=maat-redis/digest_gen

View File

@@ -2,35 +2,36 @@
####maat格式配置各业务类型对应的编译,分组,域配置等的表名
####1:固定需要写service=业务类型1;业务类型2
####2:然后每个业务类型:业务类型1=type1:表名1;type2:表名2;type3:表名3
####3:例如:80=10:AV_CONFIG_COMPILE;11:AV_CONFIG_GROUP;12:AV_CONT_IP_PORT
####3:例如:80=10:MM_COMPILE;11:MM_GROUP;12:AV_CONT_IP_PORT
####4:type中10代表是编译配置,11代表是分组配置,12代表是ip类域配置,13代表是数值类配置,14代表是字符串类域配置,15代表是增强字符串类域配置,16代表是文件摘要类域配置,17代表是文本相似性域配置
#################################################################################
service=80;81;82;83;84;85;144;145;146;147;148;149
service=3;15;80;81;82;83;84;85;144;145;146;147;148;149
3=10:NTC_COMPILE;11:NTC_GROUP;12:NTC_UNIVERSAL_IP
15=10:WHITE_LIST_COMPILE;11:WHITE_LIST_GROUP;12:WHITE_LIST_IP
80=10:MM_COMPILE;11:MM_GROUP;12:MM_AV_IP
81=10:MM_COMPILE;11:MM_GROUP;14:MM_AV_URL
82=10:MM_COMPILE;11:MM_GROUP;12:MM_PIC_IP
83=10:MM_COMPILE;11:MM_GROUP;13:MM_PIC_URL
84=10:MM_COMPILE;11:MM_GROUP;12:MM_VOIP_IP
85=10:MM_COMPILE;11:MM_GROUP;13:MM_VOIP_ACCOUNT
80=10:AV_CONFIG_COMPILE;11:AV_CONFIG_GROUP;12:AV_CONT_IP_PORT,AV_CONT_URL
81=10:AV_CONFIG_COMPILE;11:AV_CONFIG_GROUP;14:AV_CONT_URL
82=10:AV_CONFIG_COMPILE;11:AV_CONFIG_GROUP;12:AV_PIC_IP_PORT
83=10:AV_CONFIG_COMPILE;11:AV_CONFIG_GROUP;13:AV_PIC_URL
84=10:AV_CONFIG_COMPILE;11:AV_CONFIG_GROUP;12:AV_VOIP_IP_PORT
85=10:AV_CONFIG_COMPILE;11:AV_CONFIG_GROUP;13:AV_VOIP_ACCOUNT
144=10:AV_CONFIG_COMPILE;11:AV_CONFIG_GROUP;12:AV_CONT_IP_PORT
145=10:AV_CONFIG_COMPILE;11:AV_CONFIG_GROUP;14:AV_CONT_URL
146=10:AV_CONFIG_COMPILE;11:AV_CONFIG_GROUP;12:AV_PIC_IP_PORT
147=10:AV_CONFIG_COMPILE;11:AV_CONFIG_GROUP;13:AV_PIC_URL
148=10:AV_CONFIG_COMPILE;11:AV_CONFIG_GROUP;12:AV_VOIP_IP_PORT
149=10:AV_CONFIG_COMPILE;11:AV_CONFIG_GROUP;13:AV_VOIP_ACCOUNT
144=10:MM_COMPILE;11:MM_GROUP;12:MM_AV_IP
145=10:MM_COMPILE;11:MM_GROUP;14:MM_AV_URL
146=10:MM_COMPILE;11:MM_GROUP;12:MM_PIC_IP
147=10:MM_COMPILE;11:MM_GROUP;13:MM_PIC_URL
148=10:MM_COMPILE;11:MM_GROUP;12:MM_VOIP_IP
149=10:MM_COMPILE;11:MM_GROUP;13:MM_VOIP_ACCOUNT
##各业务类型对应的redisdb,业务类型:redisdb多个业务以分号分隔
serviceDBIndex=80:2;81:2;82:2;83:2;84:2;85:2;144:2;145:2;146:2;147:2;148:2;149:2;96:3;97:3;98:3;99:3;160:3;161:3;162:3;163:3;100:3;101:3;164:3;165:3
##各业务类型对应的redisdb,业务类型:redisdb,多个业务以“;”分隔,多个db以“,”数量不能超过6个
serviceDBIndex=3:2;15:2;80:2;81:2;82:2;83:2;84:2;85:2;144:2;145:2;146:2;147:2;148:2;149:2;96:3;97:3;98:3;99:3;160:3;161:3;162:3;163:3;100:3;101:3;164:3;165:3

View File

@@ -275,6 +275,7 @@
<property name="defaultEncoding" value="utf-8"></property>
<property name="maxUploadSize" value="10485760"></property>
<!--<property name="maxInMemorySize" value="1000"></property> -->
<property name="uploadTempDir" value="/upload"></property>
</bean>

9
src/main/webapp/maat-redis/.gitignore vendored Normal file
View File

@@ -0,0 +1,9 @@
SI/
*.I*
*.P*
*.S*
*.W*
*.[od]
*.[1-9]*
*.log
*.a

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,7 @@
操作系统运行环境linux7.0
文件摘要工具安装步骤:
1.将MESA.zip 拷贝opt目录下解压执行update_env.sh
2.可将digest_gen拷贝到任何目录ldd digest_gen查看依赖包
执行命令如下:
./digest_gen -f /home/a.txt 结果如下:
/home/a.txt 21 1.154222