1:添加nms上报服务器信息的接口
2:修改读取app*-rule.properties的方法
This commit is contained in:
55
src/main/java/com/nis/domain/restful/AbnormalMachine.java
Normal file
55
src/main/java/com/nis/domain/restful/AbnormalMachine.java
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
package com.nis.domain.restful;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.wordnik.swagger.annotations.ApiModel;
|
||||||
|
import com.wordnik.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* <p>Title: AbnormalMachine</p>
|
||||||
|
* <p>Description: nms上报的异常机器ip信息</p>
|
||||||
|
* <p>Company: IIE</p>
|
||||||
|
* @author rkg
|
||||||
|
* @date 2018年8月17日
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@ApiModel(value = "AbnormalMachine对象", description = "nms上报的异常机器ip信息类")
|
||||||
|
public class AbnormalMachine implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
// 与TrafficNmsServerStatistic中id是主外键关系,TrafficNmsServerStatistic中id是主键
|
||||||
|
@JsonIgnore
|
||||||
|
private Integer nmsServerId;
|
||||||
|
|
||||||
|
// 主机名称
|
||||||
|
@ApiModelProperty(value = "hostName", notes = "主机名称")
|
||||||
|
private String hostName;
|
||||||
|
private String ip;
|
||||||
|
|
||||||
|
public String getHostName() {
|
||||||
|
return hostName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHostName(String hostName) {
|
||||||
|
this.hostName = hostName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getIp() {
|
||||||
|
return ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setIp(String ip) {
|
||||||
|
this.ip = ip;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getNmsServerId() {
|
||||||
|
return nmsServerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNmsServerId(Integer nmsServerId) {
|
||||||
|
this.nmsServerId = nmsServerId;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,96 @@
|
|||||||
|
package com.nis.domain.restful;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||||
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
|
import com.wordnik.swagger.annotations.ApiModel;
|
||||||
|
import com.wordnik.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* <p>Title: TrafficNmsServerStatistic</p>
|
||||||
|
* <p>Description: 记录nms服务器信息,全网机器总量,正常在线机器总数,异常机器列表</p>
|
||||||
|
* <p>Company: IIE</p>
|
||||||
|
* @author rkg
|
||||||
|
* @date 2018年8月17日
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@ApiModel(value = "TrafficNmsServerStatistic对象", description = "nms上报的服务器相关信息对象类")
|
||||||
|
public class TrafficNmsServerStatistic implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
@JsonIgnore
|
||||||
|
private Integer id;
|
||||||
|
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||||
|
@ApiModelProperty(value = "commitTime", notes = "上报时间")
|
||||||
|
private Date commitTime;// 提交时间
|
||||||
|
@ApiModelProperty(value = "area", notes = "区域")
|
||||||
|
private String area;// 区域信息
|
||||||
|
@ApiModelProperty(value = "total", notes = "主机总数量")
|
||||||
|
private Integer total;// 机器总数量
|
||||||
|
@ApiModelProperty(value = "normal", notes = "正常主机数量")
|
||||||
|
private Integer normal;// 正常数量
|
||||||
|
@ApiModelProperty(value = "abnormal", notes = "异常主机数量")
|
||||||
|
private Integer abnormal;//
|
||||||
|
@ApiModelProperty(value = "abnormalMachineList", notes = "异常主机列表")
|
||||||
|
private List<AbnormalMachine> abnormalMachineList;
|
||||||
|
|
||||||
|
public Date getCommitTime() {
|
||||||
|
return commitTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommitTime(Date commitTime) {
|
||||||
|
this.commitTime = commitTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getArea() {
|
||||||
|
return area;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArea(String area) {
|
||||||
|
this.area = area;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getTotal() {
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotal(Integer total) {
|
||||||
|
this.total = total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getNormal() {
|
||||||
|
return normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNormal(Integer normal) {
|
||||||
|
this.normal = normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getAbnormal() {
|
||||||
|
return abnormal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAbnormal(Integer abnormal) {
|
||||||
|
this.abnormal = abnormal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<AbnormalMachine> getAbnormalMachineList() {
|
||||||
|
return abnormalMachineList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAbnormalMachineList(List<AbnormalMachine> abnormalMachineList) {
|
||||||
|
this.abnormalMachineList = abnormalMachineList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(Integer id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
82
src/main/java/com/nis/domain/restful/TrafficServerInfo.java
Normal file
82
src/main/java/com/nis/domain/restful/TrafficServerInfo.java
Normal file
@@ -0,0 +1,82 @@
|
|||||||
|
package com.nis.domain.restful;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.wordnik.swagger.annotations.ApiModel;
|
||||||
|
import com.wordnik.swagger.annotations.ApiModelProperty;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* <p>Title: NmsServerInfoVo</p>
|
||||||
|
* <p>Description: 记录nms服务器信息,全网机器总量,正常在线机器总数,异常机器列表</p>
|
||||||
|
* <p>Company: IIE</p>
|
||||||
|
* @author rkg
|
||||||
|
* @date 2018年8月17日
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
@ApiModel(value = "NmsServerInfoVo对象", description = "nms上报的服务器相关信息对象类")
|
||||||
|
public class TrafficServerInfo {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "commitTime", notes = "上报时间")
|
||||||
|
private Date commitTime;// 提交时间
|
||||||
|
@ApiModelProperty(value = "area", notes = "区域")
|
||||||
|
private String area;// 区域信息
|
||||||
|
@ApiModelProperty(value = "total", notes = "主机总数量")
|
||||||
|
private Integer total;// 机器总数量
|
||||||
|
@ApiModelProperty(value = "normal", notes = "正常主机数量")
|
||||||
|
private Integer normal;// 正常数量
|
||||||
|
@ApiModelProperty(value = "abnormal", notes = "异常主机数量")
|
||||||
|
private Integer abnormal;//
|
||||||
|
@ApiModelProperty(value = "abnormalMachineList", notes = "异常主机列表")
|
||||||
|
private List<AbnormalMachine> abnormalMachineList;
|
||||||
|
|
||||||
|
public Date getCommitTime() {
|
||||||
|
return commitTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCommitTime(Date commitTime) {
|
||||||
|
this.commitTime = commitTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getArea() {
|
||||||
|
return area;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArea(String area) {
|
||||||
|
this.area = area;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getTotal() {
|
||||||
|
return total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTotal(Integer total) {
|
||||||
|
this.total = total;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getNormal() {
|
||||||
|
return normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNormal(Integer normal) {
|
||||||
|
this.normal = normal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getAbnormal() {
|
||||||
|
return abnormal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAbnormal(Integer abnormal) {
|
||||||
|
this.abnormal = abnormal;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<AbnormalMachine> getAbnormalMachineList() {
|
||||||
|
return abnormalMachineList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAbnormalMachineList(List<AbnormalMachine> abnormalMachineList) {
|
||||||
|
this.abnormalMachineList = abnormalMachineList;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -147,17 +147,21 @@ public class ServiceAndRDBIndexReal {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
getUnMaatTable();
|
// getUnMaatTable();
|
||||||
|
getMaatTable();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void getUnMaatTable() {
|
public static void getUnMaatTable() {
|
||||||
Map<Integer, String> typeTable = new HashMap<Integer, String>();
|
Map<Integer, String> typeTable = new HashMap<Integer, String>();
|
||||||
|
|
||||||
|
Map<String, String> map = new HashMap<String, String>();
|
||||||
String unMaatService = Configurations.getStringProperty("unMaatService", "");
|
String unMaatService = Configurations.getStringProperty("unMaatService", "");
|
||||||
if (unMaatService != null && !unMaatService.trim().equals("")) {
|
if (unMaatService != null && !unMaatService.trim().equals("")) {
|
||||||
String[] split = unMaatService.split(";");
|
String[] split = unMaatService.split(";");
|
||||||
for (String str : split) {
|
for (String str : split) {
|
||||||
String[] serviceAction = str.split(":");
|
String[] serviceAction = str.split(":");
|
||||||
|
String action = serviceAction[1];
|
||||||
|
map.put(serviceAction[0], action);
|
||||||
String serviceType = Configurations.getStringProperty(serviceAction[0], "");
|
String serviceType = Configurations.getStringProperty(serviceAction[0], "");
|
||||||
if (serviceType != null && !serviceType.trim().equals("")) {
|
if (serviceType != null && !serviceType.trim().equals("")) {
|
||||||
String[] typeArrs = serviceType.split(";");
|
String[] typeArrs = serviceType.split(";");
|
||||||
@@ -170,7 +174,7 @@ public class ServiceAndRDBIndexReal {
|
|||||||
} else {
|
} else {
|
||||||
System.out.println();
|
System.out.println();
|
||||||
}
|
}
|
||||||
|
map.put(serviceAction[0], action);
|
||||||
unMaatSercieNameMap.put(Integer.parseInt(serviceAction[0]), tableName.toUpperCase());
|
unMaatSercieNameMap.put(Integer.parseInt(serviceAction[0]), tableName.toUpperCase());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -178,48 +182,35 @@ public class ServiceAndRDBIndexReal {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Integer service : typeTable.keySet()) {
|
for (Integer service : typeTable.keySet()) {
|
||||||
List<MaatXmlExpr> expressionList = ReadMaatXmlUtil.getMaatConfigByService(service).getExpressionList();
|
System.out.println(
|
||||||
for (MaatXmlExpr maatXmlExpr : expressionList) {
|
"0x" + Integer.toHexString(service) + "--servie=" + service + "--table=" + typeTable.get(service)
|
||||||
if (maatXmlExpr.getValueExpression() != null) {
|
+ "---redisDB=" + serviceDBIndexmap.get(service) + "--action=" + map.get(service.toString())
|
||||||
String[] valSplit = maatXmlExpr.getValueExpression().split(";");
|
+ "--HexAction=0x" + Integer.toHexString(Integer.parseInt(map.get(service.toString()))));
|
||||||
int a = 1;
|
|
||||||
for (int i = 0; i < valSplit.length; i++) {
|
|
||||||
if (valSplit[i].toLowerCase().contains("is_valid")) {// xml中是字符串的\t这里判断的时候需要转义为\\t,但是添加的时候需要添加\t不是\\t
|
|
||||||
System.out.println(service + "--" + typeTable.get(service) + "---" + a);
|
|
||||||
} else if (valSplit[i].toLowerCase().contains("[")) {
|
|
||||||
a++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void getMaatTable() {
|
public static void getMaatTable() {
|
||||||
Map<Integer, Set<String>> typeMap = new HashMap<Integer, Set<String>>();
|
Map<Integer, Set<String>> typeMap = new HashMap<Integer, Set<String>>();
|
||||||
String service = Configurations.getStringProperty("service", "");
|
String serviceStr = Configurations.getStringProperty("service", "");
|
||||||
if (service != null && !service.trim().equals("")) {
|
if (serviceStr != null && !serviceStr.trim().equals("")) {
|
||||||
String[] split = service.split(";");
|
String[] split = serviceStr.split(";");
|
||||||
for (String str : split) {
|
for (String str : split) {
|
||||||
String[] serviceAction = str.split(":");
|
String[] serviceAction = str.split(":");
|
||||||
serviceActionMap.put(Integer.valueOf(serviceAction[0]), Integer.valueOf(serviceAction[1]));
|
Integer ser = Integer.parseInt(serviceAction[0]);
|
||||||
String type = Configurations.getStringProperty(serviceAction[0], "");
|
String type = Configurations.getStringProperty(serviceAction[0], "");
|
||||||
if (type != null && !type.trim().equals("")) {
|
if (type != null && !type.trim().equals("")) {
|
||||||
|
|
||||||
String[] typeArrs = type.split(";");
|
String[] typeArrs = type.split(";");
|
||||||
for (String typeStr : typeArrs) {
|
for (String typeStr : typeArrs) {
|
||||||
String[] typeArr = typeStr.split(":");
|
String[] typeArr = typeStr.split(":");
|
||||||
int tableType = Integer.parseInt(typeArr[0]);
|
|
||||||
String tableNameArr[] = typeArr[1].split(",");
|
String tableNameArr[] = typeArr[1].split(",");
|
||||||
for (String tableName : tableNameArr) {
|
for (String tableName : tableNameArr) {
|
||||||
if (typeMap.containsKey(tableType)) {
|
if (typeMap.containsKey(ser)) {
|
||||||
typeMap.get(tableType).add(tableName.toUpperCase());
|
typeMap.get(ser).add(tableName.toUpperCase());
|
||||||
} else {
|
} else {
|
||||||
Set<String> list = new HashSet<String>();
|
Set<String> list = new HashSet<String>();
|
||||||
list.add(tableName.toUpperCase());
|
list.add(tableName.toUpperCase());
|
||||||
typeMap.put(tableType, list);
|
typeMap.put(ser, list);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -227,8 +218,16 @@ public class ServiceAndRDBIndexReal {
|
|||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Integer type : typeMap.keySet()) {
|
if (serviceStr != null && !serviceStr.trim().equals("")) {
|
||||||
System.out.println(type + "----" + typeMap.get(type));
|
String[] split = serviceStr.split(";");
|
||||||
|
for (String str : split) {
|
||||||
|
String[] serviceAction = str.split(":");
|
||||||
|
Integer ser = Integer.parseInt(serviceAction[0]);
|
||||||
|
String action = serviceAction[1];
|
||||||
|
System.out.println("0x" + Integer.toHexString(ser) + "--servie=" + ser + "--table="
|
||||||
|
+ typeMap.get(ser) + "---redisDB=" + serviceDBIndexmap.get(ser) + "--action=" + action
|
||||||
|
+ "--HexAction=0x" + Integer.toHexString(Integer.parseInt(action)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -351,6 +350,4 @@ public class ServiceAndRDBIndexReal {
|
|||||||
ServiceAndRDBIndexReal.unMaatSercieNameMap = unMaatSercieNameMap;
|
ServiceAndRDBIndexReal.unMaatSercieNameMap = unMaatSercieNameMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package com.nis.web.controller.restful;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMethod;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.nis.domain.restful.TrafficNmsServerStatistic;
|
||||||
|
import com.nis.restful.RestBusinessCode;
|
||||||
|
import com.nis.restful.RestConstants;
|
||||||
|
import com.nis.restful.RestServiceException;
|
||||||
|
import com.nis.util.Constants;
|
||||||
|
import com.nis.web.controller.BaseRestController;
|
||||||
|
import com.nis.web.service.AuditLogThread;
|
||||||
|
import com.nis.web.service.ServicesRequestLogService;
|
||||||
|
import com.nis.web.service.restful.TrafficNmsServerStatisticService;
|
||||||
|
import com.wordnik.swagger.annotations.Api;
|
||||||
|
import com.wordnik.swagger.annotations.ApiOperation;
|
||||||
|
import com.wordnik.swagger.annotations.ApiParam;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("${servicePath}")
|
||||||
|
@Api(value = "NmsInfoController", description = "接收nms提交的系统状态等数据,将数据入库供服务推送给大屏")
|
||||||
|
public class NmsInfoController extends BaseRestController {
|
||||||
|
@Autowired
|
||||||
|
protected ServicesRequestLogService servicesRequestLogService;
|
||||||
|
@Autowired
|
||||||
|
TrafficNmsServerStatisticService trafficNmsServerStatisticService;
|
||||||
|
|
||||||
|
@RequestMapping(value = "/nms/v1/saveServerStatus", method = RequestMethod.POST)
|
||||||
|
@ApiOperation(value = "存储NMS系统上报的服务器状态接口", httpMethod = "POST", response = Map.class, notes = "接收NMS系统上报的服务器状态信息")
|
||||||
|
@ApiParam(value = "存储NMS系统上报的服务器状态接口", name = "saveServerStatus", required = true)
|
||||||
|
public Map<String, Object> saveServerStatus(@RequestBody TrafficNmsServerStatistic trafficNmsServerStatistic,
|
||||||
|
HttpServletRequest request, HttpServletResponse response) {
|
||||||
|
long start = System.currentTimeMillis();
|
||||||
|
AuditLogThread thread = super.saveRequestLog(servicesRequestLogService, Constants.OPACTION_POST, request,
|
||||||
|
trafficNmsServerStatistic);
|
||||||
|
|
||||||
|
Map<String, Object> map = new HashMap<String, Object>();
|
||||||
|
map.put(RestConstants.REST_SERVICE_HTTP_STATUS, HttpStatus.OK);
|
||||||
|
try {
|
||||||
|
TrafficNmsServerStatistic saveNmsServer = trafficNmsServerStatisticService
|
||||||
|
.saveNmsServer(trafficNmsServerStatistic);
|
||||||
|
try {
|
||||||
|
trafficNmsServerStatisticService.saveAbnormalMachine(saveNmsServer.getId(),
|
||||||
|
saveNmsServer.getAbnormalMachineList());
|
||||||
|
} catch (Exception e) {
|
||||||
|
trafficNmsServerStatisticService.delNmsServer(saveNmsServer);
|
||||||
|
throw e;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new RestServiceException(thread, System.currentTimeMillis() - start, "上报服务器状态信息异常:" + e.getMessage(),
|
||||||
|
RestBusinessCode.unknow_error.getValue());
|
||||||
|
}
|
||||||
|
return compileServiceResponse(thread, System.currentTimeMillis() - start, request, response, "上报服务器状态信息成功",
|
||||||
|
Constants.IS_DEBUG ? trafficNmsServerStatistic : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
package com.nis.web.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.apache.ibatis.annotations.Param;
|
||||||
|
|
||||||
|
import com.nis.domain.restful.AbnormalMachine;
|
||||||
|
import com.nis.domain.restful.TrafficNmsServerStatistic;
|
||||||
|
|
||||||
|
@MyBatisDao
|
||||||
|
public interface TrafficNmsServerStatisticDao extends CrudDao<TrafficNmsServerStatistic> {
|
||||||
|
|
||||||
|
public void insertAbnormalMachine(@Param("nmsServerId") Integer nmsServerId,@Param("list") List<AbnormalMachine> abnormalMachineList);
|
||||||
|
}
|
||||||
@@ -0,0 +1,50 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8" ?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
|
||||||
|
<mapper namespace="com.nis.web.dao.TrafficNmsServerStatisticDao">
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<insert id="insert" parameterType="trafficNmsServerStatistic"
|
||||||
|
useGeneratedKeys="true" keyProperty="id">
|
||||||
|
INSERT INTO
|
||||||
|
traffic_nmsserver_statistic(
|
||||||
|
commit_time ,
|
||||||
|
area ,
|
||||||
|
total ,
|
||||||
|
normal ,
|
||||||
|
abnormal
|
||||||
|
) VALUES (
|
||||||
|
#{commitTime},
|
||||||
|
#{area},
|
||||||
|
#{total},
|
||||||
|
#{normal},
|
||||||
|
#{abnormal}
|
||||||
|
)
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<insert id="delete" parameterType="trafficNmsServerStatistic"
|
||||||
|
useGeneratedKeys="true" keyProperty="id">
|
||||||
|
delete from
|
||||||
|
traffic_nmsserver_statistic
|
||||||
|
where id=#{id}
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
|
||||||
|
<insert id="insertAbnormalMachine" parameterType="trafficNmsServerStatistic">
|
||||||
|
INSERT INTO traffic_abnormal_machine(
|
||||||
|
nmsserver_id ,
|
||||||
|
hostName ,
|
||||||
|
ip
|
||||||
|
)
|
||||||
|
VALUES
|
||||||
|
<foreach collection="list" item="item" separator=",">
|
||||||
|
(
|
||||||
|
#{nmsServerId},
|
||||||
|
#{item.hostName},
|
||||||
|
#{item.ip}
|
||||||
|
)
|
||||||
|
</foreach>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.nis.web.service.restful;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import com.nis.domain.restful.AbnormalMachine;
|
||||||
|
import com.nis.domain.restful.TrafficNmsServerStatistic;
|
||||||
|
import com.nis.web.dao.TrafficNmsServerStatisticDao;
|
||||||
|
|
||||||
|
@Service
|
||||||
|
public class TrafficNmsServerStatisticService {
|
||||||
|
@Autowired
|
||||||
|
TrafficNmsServerStatisticDao trafficNmsServerStatisticDao;
|
||||||
|
|
||||||
|
public TrafficNmsServerStatistic saveNmsServer(TrafficNmsServerStatistic trafficNmsServerStatistic) {
|
||||||
|
trafficNmsServerStatisticDao.insert(trafficNmsServerStatistic);
|
||||||
|
return trafficNmsServerStatistic;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void saveAbnormalMachine(Integer id, List<AbnormalMachine> abnormalMachineList) {
|
||||||
|
trafficNmsServerStatisticDao.insertAbnormalMachine(id, abnormalMachineList);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void delNmsServer(TrafficNmsServerStatistic trafficNmsServerStatistic) {
|
||||||
|
trafficNmsServerStatisticDao.delete(trafficNmsServerStatistic);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -83,33 +83,43 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
<bean id="HiveDataSourceByDruid" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
|
<bean id="HiveDataSourceByDruid" class="com.alibaba.druid.pool.DruidDataSource"
|
||||||
|
init-method="init" destroy-method="close">
|
||||||
<property name="driverClassName" value="${jdbc.hive.driver}" />
|
<property name="driverClassName" value="${jdbc.hive.driver}" />
|
||||||
<property name="url" value="${jdbc.hive.url}" />
|
<property name="url" value="${jdbc.hive.url}" />
|
||||||
<property name="username" value="${jdbc.hive.username}" />
|
<property name="username" value="${jdbc.hive.username}" />
|
||||||
<property name="password" value="${jdbc.hive.password}" />
|
<property name="password" value="${jdbc.hive.password}" />
|
||||||
<property name="initialSize" value="${druid.hive.initialSize}" /><!-- 配置初始化连接池数量-->
|
<!-- 配置初始化连接池数量 -->
|
||||||
<property name="minIdle" value="${druid.hive.minIdle}" /><!-- 配置最小连接池数量-->
|
<property name="initialSize" value="${druid.hive.initialSize}" />
|
||||||
<property name="maxActive" value="${druid.hive.maxActive}" /><!-- 配置最大连接池数量-->
|
<!-- 配置最小连接池数量 -->
|
||||||
<property name="maxWait" value="${druid.hive.maxWait}" /><!-- 配置获取连接等待超时的时间 单位毫秒-->
|
<property name="minIdle" value="${druid.hive.minIdle}" />
|
||||||
<property name="useUnfairLock" value="${druid.hive.useUnfairLock}"/><!--使用非公平锁-->
|
<!-- 配置最大连接池数量 -->
|
||||||
<property name="timeBetweenEvictionRunsMillis" value="${druid.hive.timeBetweenEvictionRunsMillis}" /><!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
|
<property name="maxActive" value="${druid.hive.maxActive}" />
|
||||||
<property name="minEvictableIdleTimeMillis" value="${druid.hive.minEvictableIdleTimeMillis}" /><!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
|
<!-- 配置获取连接等待超时的时间 单位毫秒 -->
|
||||||
<property name="validationQuery" value="${druid.hive.validationQuery}" /><!--用来检测连接是否有效的sql,要求是一个查询语句。 -->
|
<property name="maxWait" value="${druid.hive.maxWait}" />
|
||||||
<property name="testWhileIdle" value="${druid.hive.testWhileIdle}" /><!--申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效。-->
|
<!--使用非公平锁 -->
|
||||||
<property name="testOnBorrow" value="${druid.hive.testOnBorrow}" /><!--申请连接时执行validationQuery检测连接是否有效,-->
|
<property name="useUnfairLock" value="${druid.hive.useUnfairLock}" />
|
||||||
<property name="testOnReturn" value="${druid.hive.testOnReturn}" /><!--归还连接时执行validationQuery检测连接是否有效,-->
|
<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
|
||||||
<property name="poolPreparedStatements" value="${druid.hive.poolPreparedStatements}" /><!-- 打开PSCache,并且指定每个连接上PSCache的大小 -->
|
<property name="timeBetweenEvictionRunsMillis" value="${druid.hive.timeBetweenEvictionRunsMillis}" />
|
||||||
<property name="maxOpenPreparedStatements" value="${druid.hive.maxOpenPreparedStatements}" /><!--要启用PSCache,必须配置大于0,当大于0时,poolPreparedStatements自动触发修改为true。在Druid中,不会存在Oracle下PSCache占用内存过多的问题,可以把这个数值配置大一些,比如说100 -->
|
<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
|
||||||
<property name="filters" value="${druid.hive.filters}" /><!-- 配置监控统计拦截的filters,去掉后监控界面sql无法统计 -->
|
<property name="minEvictableIdleTimeMillis" value="${druid.hive.minEvictableIdleTimeMillis}" />
|
||||||
|
<!--用来检测连接是否有效的sql,要求是一个查询语句。 -->
|
||||||
|
<property name="validationQuery" value="${druid.hive.validationQuery}" />
|
||||||
|
<!--申请连接的时候检测,如果空闲时间大于timeBetweenEvictionRunsMillis,执行validationQuery检测连接是否有效。 -->
|
||||||
|
<property name="testWhileIdle" value="${druid.hive.testWhileIdle}" />
|
||||||
|
<!--申请连接时执行validationQuery检测连接是否有效, -->
|
||||||
|
<property name="testOnBorrow" value="${druid.hive.testOnBorrow}" />
|
||||||
|
<!--归还连接时执行validationQuery检测连接是否有效, -->
|
||||||
|
<property name="testOnReturn" value="${druid.hive.testOnReturn}" />
|
||||||
|
<!-- 打开PSCache,并且指定每个连接上PSCache的大小 -->
|
||||||
|
<property name="poolPreparedStatements" value="${druid.hive.poolPreparedStatements}" />
|
||||||
|
<!--要启用PSCache,必须配置大于0,当大于0时,poolPreparedStatements自动触发修改为true。在Druid中,不会存在Oracle下PSCache占用内存过多的问题,可以把这个数值配置大一些,比如说100 -->
|
||||||
|
<property name="maxOpenPreparedStatements" value="${druid.hive.maxOpenPreparedStatements}" />
|
||||||
|
<!-- 配置监控统计拦截的filters,去掉后监控界面sql无法统计 -->
|
||||||
|
<property name="filters" value="${druid.hive.filters}" />
|
||||||
|
|
||||||
</bean>
|
</bean>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<bean id="dynamicDataSource" class="com.nis.datasource.DynamicDataSource">
|
<bean id="dynamicDataSource" class="com.nis.datasource.DynamicDataSource">
|
||||||
<property name="targetDataSources">
|
<property name="targetDataSources">
|
||||||
<map key-type="java.lang.String">
|
<map key-type="java.lang.String">
|
||||||
|
|||||||
Reference in New Issue
Block a user