From d1274a88d001119c155a8dd4ed47c018553da9f0 Mon Sep 17 00:00:00 2001 From: shentao Date: Wed, 15 Nov 2017 16:30:47 +0800 Subject: Fix monitor bug for calling dmapp Change-Id: I92a15d969e81ae2697b4637512ebe0627b2f9289 Issue-Id: USECASEUI-54 Signed-off-by: shentao --- .../server/UsecaseuiServerApplication.java | 12 +- .../onap/usecaseui/server/bean/AlarmsHeader.java | 17 +- .../usecaseui/server/bean/PerformanceHeader.java | 17 +- .../onap/usecaseui/server/constant/Constant.java | 1 + .../server/controller/AlarmController.java | 43 ++- .../server/controller/PerformanceController.java | 248 +++++++++--------- .../usecaseui/server/util/DmaapSubscriber.java | 287 +++++++++------------ server/src/main/resources/dmaap.properties | 2 +- .../dbscripts/mysql/usecase-ui-createobj.sql | 120 ++++----- 9 files changed, 370 insertions(+), 377 deletions(-) diff --git a/server/src/main/java/org/onap/usecaseui/server/UsecaseuiServerApplication.java b/server/src/main/java/org/onap/usecaseui/server/UsecaseuiServerApplication.java index 7b9a0b53..e57bd5e4 100644 --- a/server/src/main/java/org/onap/usecaseui/server/UsecaseuiServerApplication.java +++ b/server/src/main/java/org/onap/usecaseui/server/UsecaseuiServerApplication.java @@ -16,16 +16,27 @@ package org.onap.usecaseui.server; import org.onap.usecaseui.server.util.DmaapSubscriber; +import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.ComponentScan; import org.springframework.web.client.RestTemplate; +import javax.annotation.Resource; + @SpringBootApplication @ComponentScan(basePackages = "org.onap.usecaseui.server") public class UsecaseuiServerApplication { + + public static DmaapSubscriber dmaapSubscriber; + + @Autowired + public void setDatastore(DmaapSubscriber dmaapSubscriber) { + UsecaseuiServerApplication.dmaapSubscriber = dmaapSubscriber; + } + @Bean public RestTemplate getRestTemplate(){ return new RestTemplate(); @@ -33,7 +44,6 @@ public class UsecaseuiServerApplication { public static void main(String[] args) { SpringApplication.run(UsecaseuiServerApplication.class, args); - DmaapSubscriber dmaapSubscriber = new DmaapSubscriber(); dmaapSubscriber.run(); } } diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/AlarmsHeader.java b/server/src/main/java/org/onap/usecaseui/server/bean/AlarmsHeader.java index 2edaa155..b0ed3ae3 100644 --- a/server/src/main/java/org/onap/usecaseui/server/bean/AlarmsHeader.java +++ b/server/src/main/java/org/onap/usecaseui/server/bean/AlarmsHeader.java @@ -27,11 +27,14 @@ import javax.persistence.Table; @Entity @Table(name="alarms_commoneventheader") public class AlarmsHeader implements Serializable{ - + + @Id + @Column(name = "id") + private int id; + @Column(name = "version") private String version; - @Id @Column(name = "eventName") private String eventName; @@ -353,6 +356,12 @@ public class AlarmsHeader implements Serializable{ public void setUpdateTime(Date updateTime) { this.updateTime = updateTime; } - - + + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } } diff --git a/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeader.java b/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeader.java index 1d4bd8fa..8fe725a0 100755 --- a/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeader.java +++ b/server/src/main/java/org/onap/usecaseui/server/bean/PerformanceHeader.java @@ -27,11 +27,14 @@ import javax.persistence.Table; @Entity @Table(name="performance_commoneventheader") public class PerformanceHeader implements Serializable { - + + @Id + @Column(name = "id") + private int id; + @Column(name = "version") private String version; - @Id @Column(name = "eventName") private String eventName; @@ -268,7 +271,11 @@ public class PerformanceHeader implements Serializable { this.updateTime = updateTime; } - - - + public int getId() { + return id; + } + + public void setId(int id) { + this.id = id; + } } diff --git a/server/src/main/java/org/onap/usecaseui/server/constant/Constant.java b/server/src/main/java/org/onap/usecaseui/server/constant/Constant.java index 9a818e4e..013eaab4 100755 --- a/server/src/main/java/org/onap/usecaseui/server/constant/Constant.java +++ b/server/src/main/java/org/onap/usecaseui/server/constant/Constant.java @@ -21,5 +21,6 @@ public final class Constant public static final String DATE_FORMAT= "yyyy-MM-dd HH:mm:ss"; + public static final String RegEX_DATE_FORMAT = "[^0-9-:]"; } diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java b/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java index ab7534c6..5c971037 100755 --- a/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java +++ b/server/src/main/java/org/onap/usecaseui/server/controller/AlarmController.java @@ -71,13 +71,6 @@ public class AlarmController private ObjectMapper omAlarm = new ObjectMapper(); - - @RequestMapping(value = {"/usecase-ui"}, method = RequestMethod.GET) - public ModelAndView index(){ - return new ModelAndView("index"); - } - - @RequestMapping(value = {"/alarm/{currentPage}/{pageSize}", "/alarm/{currentPage}/{pageSize}/{sourceId}/{sourceName}/{priority}/{startTime}/{endTime}/{vfStatus}"}, method = RequestMethod.GET , produces = "application/json") @@ -110,20 +103,14 @@ public class AlarmController if (null != alarmsHeaders && alarmsHeaders.size() > 0) { alarmsHeaders.forEach(a ->{ AlarmBo abo = new AlarmBo(); - abo.setAlarmsHeader(a); - AlarmsInformation information = new AlarmsInformation(); - information.setEventId(a.getSourceId()); - List informationList = alarmsInformationService.queryAlarmsInformation(information,1,100).getList(); - informationList.forEach( il -> { - if (il.getValue().equals("")){ - StringBuffer value1 = new StringBuffer(); - alarmsInformationService.queryAlarmsInformation(new AlarmsInformation(il.getName()),1,100).getList() - .forEach( val -> value1.append(val.getValue()) ); - il.setValue(value1.toString()); - } - } ); - abo.setAlarmsInformation(informationList); - list.add(abo); + if (!a.getStatus().equals("3")){ + abo.setAlarmsHeader(a); + AlarmsInformation information = new AlarmsInformation(); + information.setEventId(a.getSourceId()); + List informationList = alarmsInformationService.queryAlarmsInformation(information,1,100).getList(); + abo.setAlarmsInformation(informationList); + list.add(abo); + } }); } }else { @@ -132,9 +119,12 @@ public class AlarmController if (null != alarmsHeaders && alarmsHeaders.size() > 0) { alarmsHeaders.forEach(a -> { AlarmBo abo = new AlarmBo(); - abo.setAlarmsHeader(a); - abo.setAlarmsInformation(alarmsInformationService.queryAlarmsInformation(new AlarmsInformation(a.getEventId()),currentPage,pageSize).getList()); - list.add(abo); + if (!a.getStatus().equals("3")){ + abo.setAlarmsHeader(a); + abo.setAlarmsInformation(alarmsInformationService.queryAlarmsInformation(new AlarmsInformation(a.getEventId()),currentPage,pageSize).getList()); + list.add(abo); + } + }); } } @@ -194,8 +184,9 @@ public class AlarmController @RequestMapping(value = {"/alarm/sourceId"},method = RequestMethod.GET) public String getSourceId(){ List sourceIds = new ArrayList<>(); - alarmsHeaderService.queryAlarmsHeader(null,1,Integer.MAX_VALUE).getList().forEach( al ->{ - sourceIds.add(al.getSourceId()); + alarmsHeaderService.queryAlarmsHeader(new AlarmsHeader(),1,Integer.MAX_VALUE).getList().forEach( al ->{ + if (!al.getStatus().equals("3") || !sourceIds.contains(al.getSourceId())) + sourceIds.add(al.getSourceId()); } ); try { return omAlarm.writeValueAsString(sourceIds); diff --git a/server/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java b/server/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java index 2f0b9722..fe67c7a9 100755 --- a/server/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java +++ b/server/src/main/java/org/onap/usecaseui/server/controller/PerformanceController.java @@ -56,205 +56,205 @@ public class PerformanceController { private Logger logger = LoggerFactory.getLogger(PerformanceController.class); private final String[] PerformanceCSVHeaders = {"version", - "eventName","domain","eventId","eventType","nfcNamingCode", - "nfNamingCode","sourceId","sourceName","reportingEntityId", - "reportingEntityName","priority","startEpochMicrosec","lastEpochMicroSec", - "sequence","measurementsForVfScalingVersion","measurementInterval", - "createTime","updateTime","value","name"}; + "eventName", "domain", "eventId", "eventType", "nfcNamingCode", + "nfNamingCode", "sourceId", "sourceName", "reportingEntityId", + "reportingEntityName", "priority", "startEpochMicrosec", "lastEpochMicroSec", + "sequence", "measurementsForVfScalingVersion", "measurementInterval", + "createTime", "updateTime", "value", "name"}; private ObjectMapper omPerformance = new ObjectMapper(); - @RequestMapping(value = {"/performance/{currentPage}/{pageSize}","/performance/{currentPage}/{pageSize}/{sourceId}/{sourceName}/{priority}/{startTime}/{endTime}"},method = RequestMethod.GET, produces = "application/json") - public String getPerformanceData(HttpServletResponse response,@PathVariable int currentPage, - @PathVariable int pageSize,@PathVariable(required = false) String sourceId, - @PathVariable(required = false) String sourceName,@PathVariable(required = false) String priority, - @PathVariable(required = false) String startTime,@PathVariable(required = false) String endTime) throws JsonProcessingException { + @RequestMapping(value = {"/performance/{currentPage}/{pageSize}", "/performance/{currentPage}/{pageSize}/{sourceId}/{sourceName}/{priority}/{startTime}/{endTime}"}, method = RequestMethod.GET, produces = "application/json") + public String getPerformanceData(HttpServletResponse response, @PathVariable int currentPage, + @PathVariable int pageSize, @PathVariable(required = false) String sourceId, + @PathVariable(required = false) String sourceName, @PathVariable(required = false) String priority, + @PathVariable(required = false) String startTime, @PathVariable(required = false) String endTime) throws JsonProcessingException { logger.info("transfer getAlarmData Apis, " + "Parameter all follows : [currentPage : {} , pageSize : {} , sourceId : {} , " + "sourceName : {} , priority : {} , startTime :{} , endTime : {} ]" - ,currentPage,pageSize,sourceId,sourceName,priority,startTime,endTime); + , currentPage, pageSize, sourceId, sourceName, priority, startTime, endTime); List list = new ArrayList<>(); Page pa = null; - if (null != sourceId || null != sourceName || null != priority || null != startTime || null != endTime){ + if (null != sourceId || null != sourceName || null != priority || null != startTime || null != endTime) { PerformanceHeader performanceHeader = new PerformanceHeader(); - performanceHeader.setSourceId(!"null".equals(sourceId)?sourceId:null); - performanceHeader.setSourceName(!"null".equals(sourceName)?sourceName:null); + performanceHeader.setSourceId(!"null".equals(sourceId) ? sourceId : null); + performanceHeader.setSourceName(!"null".equals(sourceName) ? sourceName : null); try { - performanceHeader.setCreateTime(!"null".equals(startTime)?new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(startTime):null); - performanceHeader.setUpdateTime(!"null".equals(endTime)?new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(endTime):null); + performanceHeader.setCreateTime(!"null".equals(startTime) ? new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(startTime) : null); + performanceHeader.setUpdateTime(!"null".equals(endTime) ? new SimpleDateFormat("yyyy-MM-dd HH:mm").parse(endTime) : null); } catch (ParseException e) { - if (null != response) + if (null != response) response.setStatus(400); - logger.error("ParseException["+startTime+"]:"+e.getMessage()); + logger.error("ParseException[" + startTime + "]:" + e.getMessage()); return "{'result':'error'}"; } - pa = performanceHeaderService.queryPerformanceHeader(performanceHeader,currentPage,pageSize); + pa = performanceHeaderService.queryPerformanceHeader(performanceHeader, currentPage, pageSize); List performanceHeaders = pa.getList(); - performanceHeaders.forEach( per ->{ + performanceHeaders.forEach(per -> { PerformanceBo pbo = new PerformanceBo(); PerformanceInformation pe = new PerformanceInformation(); pe.setEventId(per.getSourceId()); - List performanceInformations = performanceInformationService.queryPerformanceInformation(pe,1,100).getList(); + List performanceInformations = performanceInformationService.queryPerformanceInformation(pe, 1, 100).getList(); pbo.setPerformanceHeader(per); - performanceInformations.forEach( pi ->{ - if (pi.getValue().equals("")){ + performanceInformations.forEach(pi -> { + if (pi.getValue().equals("")) { StringBuffer value1 = new StringBuffer(); - performanceInformationService.queryPerformanceInformation(new PerformanceInformation(pi.getName()),1,100).getList() - .forEach( val -> value1.append(val.getValue())); + performanceInformationService.queryPerformanceInformation(new PerformanceInformation(pi.getName()), 1, 100).getList() + .forEach(val -> value1.append(val.getValue())); pi.setValue(value1.toString()); } - } ); + }); pbo.setPerformanceInformation(performanceInformations); list.add(pbo); }); - }else{ - pa = performanceHeaderService.queryPerformanceHeader(null,currentPage,pageSize); - List p = pa!=null?pa.getList():null; + } else { + pa = performanceHeaderService.queryPerformanceHeader(null, currentPage, pageSize); + List p = pa != null ? pa.getList() : null; if (null != p && p.size() > 0) - p.forEach( per ->{ + p.forEach(per -> { PerformanceBo pbo = new PerformanceBo(); pbo.setPerformanceHeader(per); - pbo.setPerformanceInformation(performanceInformationService.queryPerformanceInformation(new PerformanceInformation(per.getEventId()),1,100).getList()); + pbo.setPerformanceInformation(performanceInformationService.queryPerformanceInformation(new PerformanceInformation(per.getEventId()), 1, 100).getList()); list.add(pbo); }); } try { - Map map = new HashMap<>(); - map.put("performances",list); - map.put("totalRecords",pa.getTotalRecords()); + Map map = new HashMap<>(); + map.put("performances", list); + map.put("totalRecords", pa.getTotalRecords()); omPerformance.setDateFormat(new SimpleDateFormat(Constant.DATE_FORMAT)); return omPerformance.writeValueAsString(map); } catch (JsonProcessingException e) { - logger.error("JsonProcessingException"+e.getMessage()); + logger.error("JsonProcessingException" + e.getMessage()); return omPerformance.writeValueAsString("failed"); } } @RequestMapping(value = {"/performance/genCsv/{eventId}"}, method = RequestMethod.GET, produces = "application/json") public String generateCsvFile(HttpServletResponse response, @PathVariable String[] eventId) throws JsonProcessingException { - String csvFile = "csvFiles/vnf_performance_"+new SimpleDateFormat("yy-MM-ddHH:mm:ss").format(new Date())+".csv"; + String csvFile = "csvFiles/vnf_performance_" + new SimpleDateFormat("yy-MM-ddHH:mm:ss").format(new Date()) + ".csv"; List performanceHeaders = performanceHeaderService.queryId(eventId); if (null == performanceHeaders || performanceHeaders.size() <= 0) return new ObjectMapper().writeValueAsString("selected eventId don't exist"); List csvData = new ArrayList<>(); - performanceHeaders.forEach(s ->{ - List information = performanceInformationService.queryPerformanceInformation(new PerformanceInformation(s.getEventId()),1,100).getList(); + performanceHeaders.forEach(s -> { + List information = performanceInformationService.queryPerformanceInformation(new PerformanceInformation(s.getEventId()), 1, 100).getList(); String names = ""; String values = ""; - if (0 < information.size() && null != information){ - for (PerformanceInformation a : information){ - names += a.getName()+","; - values += a.getValue()+","; + if (0 < information.size() && null != information) { + for (PerformanceInformation a : information) { + names += a.getName() + ","; + values += a.getValue() + ","; } - names = names.substring(0,names.lastIndexOf(',')); - values = values.substring(0,values.lastIndexOf(',')); + names = names.substring(0, names.lastIndexOf(',')); + values = values.substring(0, values.lastIndexOf(',')); } csvData.add(new String[]{ - s.getVersion(),s.getEventName(),s.getDomain(),s.getEventId(),s.getEventType(),s.getNfcNamingCode(),s.getNfNamingCode(), - s.getSourceId(),s.getSourceName(),s.getReportingEntityId(),s.getReportingEntityName(),s.getPriority(), - s.getStartEpochMicrosec(),s.getLastEpochMicroSec(),s.getSequence(),s.getMeasurementsForVfScalingVersion(), - s.getMeasurementInterval(),DateUtils.dateToString(s.getCreateTime()),DateUtils.dateToString(s.getUpdateTime()), - names,values + s.getVersion(), s.getEventName(), s.getDomain(), s.getEventId(), s.getEventType(), s.getNfcNamingCode(), s.getNfNamingCode(), + s.getSourceId(), s.getSourceName(), s.getReportingEntityId(), s.getReportingEntityName(), s.getPriority(), + s.getStartEpochMicrosec(), s.getLastEpochMicroSec(), s.getSequence(), s.getMeasurementsForVfScalingVersion(), + s.getMeasurementInterval(), DateUtils.dateToString(s.getCreateTime()), DateUtils.dateToString(s.getUpdateTime()), + names, values }); }); - CSVUtils.writeCsv(PerformanceCSVHeaders,csvData,csvFile); - if (ResponseUtil.responseDownload(csvFile,response)){ + CSVUtils.writeCsv(PerformanceCSVHeaders, csvData, csvFile); + if (ResponseUtil.responseDownload(csvFile, response)) { return omPerformance.writeValueAsString("success"); - }else{ + } else { return omPerformance.writeValueAsString("failed"); } } @RequestMapping(value = {"/performance/genDiaCsv/{dataJson}"}, method = RequestMethod.GET, produces = "application/json") - public String generateDiaCsvFile(HttpServletResponse response,@PathVariable String dataJson) throws IOException { - List> dataList = omPerformance.readValue(dataJson,List.class); - String csvFileName = "csvFiles/"+dataList.get(0).get("name")+"_"+new SimpleDateFormat("yy-MM-ddHH:mm:ss").format(new Date())+".csv"; - try{ - String[] headers = new String[]{"eventId","name","dateUnit","value"}; + public String generateDiaCsvFile(HttpServletResponse response, @PathVariable String dataJson) throws IOException { + List> dataList = omPerformance.readValue(dataJson, List.class); + String csvFileName = "csvFiles/" + dataList.get(0).get("name") + "_" + new SimpleDateFormat("yy-MM-ddHH:mm:ss").format(new Date()) + ".csv"; + try { + String[] headers = new String[]{"eventId", "name", "dateUnit", "value"}; List csvDatas = new ArrayList<>(); - if (null != dataList){ - dataList.forEach((l)->{ + if (null != dataList) { + dataList.forEach((l) -> { StringBuffer fileData = new StringBuffer(); - l.forEach((k,v)->{ + l.forEach((k, v) -> { logger.info(v.toString()); - fileData.append(v.toString()+","); + fileData.append(v.toString() + ","); }); csvDatas.add(fileData.toString().split(",")); }); } - CSVUtils.writeCsv(headers,csvDatas,csvFileName); - }catch (Exception pe){ + CSVUtils.writeCsv(headers, csvDatas, csvFileName); + } catch (Exception pe) { logger.error(pe.getMessage()); } - if (ResponseUtil.responseDownload(csvFileName,response)){ + if (ResponseUtil.responseDownload(csvFileName, response)) { return omPerformance.writeValueAsString("success"); - }else{ + } else { return omPerformance.writeValueAsString("failed"); } } @ResponseBody @RequestMapping(value = {"/performance/diagram/{unit}/{eventId}"}, method = RequestMethod.GET, produces = "application/json") - public String generateDiagram(@PathVariable String unit,@PathVariable String eventId) throws ParseException, JsonProcessingException { - Map> diagramSource = new HashMap<>(); - String[] names = {"cpu","network","disk","memory"}; - switch (unit){ + public String generateDiagram(@PathVariable String unit, @PathVariable String eventId) throws ParseException, JsonProcessingException { + Map> diagramSource = new HashMap<>(); + String[] names = {"cpu", "network", "disk", "memory"}; + switch (unit) { case "hour": - for(int i = 0 ; i < 4 ; i++){ - Date startDateHour = DateUtils.stringToDate(DateUtils.initDate(new Date(),1,1,1,-1,0,0)); - Date endDateHour = DateUtils.stringToDate(DateUtils.initDate(new Date(),1,1,1,-1,0,0)); - endDateHour = DateUtils.stringToDate(DateUtils.addDate(endDateHour,"minute",15)); + for (int i = 0; i < 4; i++) { + Date startDateHour = DateUtils.stringToDate(DateUtils.initDate(new Date(), 1, 1, 1, -1, 0, 0)); + Date endDateHour = DateUtils.stringToDate(DateUtils.initDate(new Date(), 1, 1, 1, -1, 0, 0)); + endDateHour = DateUtils.stringToDate(DateUtils.addDate(endDateHour, "minute", 15)); List values = new ArrayList<>(); - for (int j = 0 ; j < 4 ; j++){ + for (int j = 0; j < 4; j++) { logger.info(DateUtils.dateToString(startDateHour)); logger.info(DateUtils.dateToString(endDateHour)); - values.add(performanceInformationService.queryDataBetweenSum(eventId,names[i],startDateHour,endDateHour)); - startDateHour = DateUtils.stringToDate(DateUtils.addDate(startDateHour,"minute",15)); - endDateHour = DateUtils.stringToDate(DateUtils.addDate(endDateHour,"minute",15)); + values.add(performanceInformationService.queryDataBetweenSum(eventId, names[i], startDateHour, endDateHour)); + startDateHour = DateUtils.stringToDate(DateUtils.addDate(startDateHour, "minute", 15)); + endDateHour = DateUtils.stringToDate(DateUtils.addDate(endDateHour, "minute", 15)); } - diagramSource.put(names[i],values); + diagramSource.put(names[i], values); } break; case "day": - for(int i = 0 ; i < 4 ; i++){ - Date startDateDay = DateUtils.stringToDate(DateUtils.initDate(new Date(),1,1,-1,0,0,0)); - Date endDateDay = DateUtils.stringToDate(DateUtils.initDate(new Date(),1,1,-1,0,0,0)); - endDateDay = DateUtils.stringToDate(DateUtils.addDate(endDateDay,"hour",1)); + for (int i = 0; i < 4; i++) { + Date startDateDay = DateUtils.stringToDate(DateUtils.initDate(new Date(), 1, 1, -1, 0, 0, 0)); + Date endDateDay = DateUtils.stringToDate(DateUtils.initDate(new Date(), 1, 1, -1, 0, 0, 0)); + endDateDay = DateUtils.stringToDate(DateUtils.addDate(endDateDay, "hour", 1)); List values = new ArrayList<>(); - for (int j = 0 ; j < 24 ; j++){ - values.add(performanceInformationService.queryDataBetweenSum(eventId,names[i],startDateDay,endDateDay)); - startDateDay = DateUtils.stringToDate(DateUtils.addDate(startDateDay,"hour",1)); - endDateDay = DateUtils.stringToDate(DateUtils.addDate(endDateDay,"hour",1)); + for (int j = 0; j < 24; j++) { + values.add(performanceInformationService.queryDataBetweenSum(eventId, names[i], startDateDay, endDateDay)); + startDateDay = DateUtils.stringToDate(DateUtils.addDate(startDateDay, "hour", 1)); + endDateDay = DateUtils.stringToDate(DateUtils.addDate(endDateDay, "hour", 1)); } - diagramSource.put(names[i],values); + diagramSource.put(names[i], values); } break; case "month": - for(int i = 0 ; i < 4 ; i++){ - Date startDateMonth = DateUtils.stringToDate(DateUtils.initDate(new Date(),1,-1,0,0,0,0)); - Date endDateMonth = DateUtils.stringToDate(DateUtils.initDate(new Date(),1,-1,0,0,0,0)); - endDateMonth = DateUtils.stringToDate(DateUtils.addDate(endDateMonth,"day",1)); - List values = new ArrayList<>(); - for (int j = 0 ; j < 31 ; j++){ - values.add(performanceInformationService.queryDataBetweenSum(eventId,names[i],startDateMonth,endDateMonth)); - startDateMonth = DateUtils.stringToDate(DateUtils.addDate(startDateMonth,"day",1)); - endDateMonth = DateUtils.stringToDate(DateUtils.addDate(endDateMonth,"day",1)); + for (int i = 0; i < 4; i++) { + Date startDateMonth = DateUtils.stringToDate(DateUtils.initDate(new Date(), 1, -1, 0, 0, 0, 0)); + Date endDateMonth = DateUtils.stringToDate(DateUtils.initDate(new Date(), 1, -1, 0, 0, 0, 0)); + endDateMonth = DateUtils.stringToDate(DateUtils.addDate(endDateMonth, "day", 1)); + List values = new ArrayList<>(); + for (int j = 0; j < 31; j++) { + values.add(performanceInformationService.queryDataBetweenSum(eventId, names[i], startDateMonth, endDateMonth)); + startDateMonth = DateUtils.stringToDate(DateUtils.addDate(startDateMonth, "day", 1)); + endDateMonth = DateUtils.stringToDate(DateUtils.addDate(endDateMonth, "day", 1)); } - diagramSource.put(names[i],values); + diagramSource.put(names[i], values); } break; case "year": - for(int i = 0 ; i < 4 ; i++){ - Date startDateYear = DateUtils.stringToDate(DateUtils.initDate(new Date(),-1,0,0,0,0,0)); - Date endDateYear = DateUtils.stringToDate(DateUtils.initDate(new Date(),-1,0,0,0,0,0)); - endDateYear = DateUtils.stringToDate(DateUtils.addDate(endDateYear,"month",1)); + for (int i = 0; i < 4; i++) { + Date startDateYear = DateUtils.stringToDate(DateUtils.initDate(new Date(), -1, 0, 0, 0, 0, 0)); + Date endDateYear = DateUtils.stringToDate(DateUtils.initDate(new Date(), -1, 0, 0, 0, 0, 0)); + endDateYear = DateUtils.stringToDate(DateUtils.addDate(endDateYear, "month", 1)); List values = new ArrayList<>(); - for (int j = 0 ; j < 12 ; j++){ - values.add(performanceInformationService.queryDataBetweenSum(eventId,names[i],startDateYear,endDateYear)); - startDateYear = DateUtils.stringToDate(DateUtils.addDate(startDateYear,"month",1)); - endDateYear = DateUtils.stringToDate(DateUtils.addDate(endDateYear,"month",1)); + for (int j = 0; j < 12; j++) { + values.add(performanceInformationService.queryDataBetweenSum(eventId, names[i], startDateYear, endDateYear)); + startDateYear = DateUtils.stringToDate(DateUtils.addDate(startDateYear, "month", 1)); + endDateYear = DateUtils.stringToDate(DateUtils.addDate(endDateYear, "month", 1)); } - diagramSource.put(names[i],values); + diagramSource.put(names[i], values); } break; } @@ -263,17 +263,17 @@ public class PerformanceController { } @RequestMapping(value = {"/performance/diagram"}, method = RequestMethod.POST, produces = "application/json") - public String generateDiagram(@RequestParam String sourceId,@RequestParam String startTime,@RequestParam String endTime,@RequestParam String nameParent,@RequestParam(required = false) String nameChild) { + public String generateDiagram(@RequestParam String sourceId, @RequestParam String startTime, @RequestParam String endTime, @RequestParam String nameParent, @RequestParam(required = false) String nameChild) { List diagramSource = new ArrayList<>(); try { - logger.info(sourceId+":"+startTime+":"+endTime+":"+nameParent+":"+nameChild); - if (performanceHeaderService.queryPerformanceHeader(new PerformanceHeader(sourceId),1,10).getList() != null){ - if (nameChild != null && !"".equals(nameChild)){ + logger.info(sourceId + ":" + startTime + ":" + endTime + ":" + nameParent + ":" + nameChild); + if (performanceHeaderService.queryPerformanceHeader(new PerformanceHeader(sourceId), 1, 10).getList() != null) { + if (nameChild != null && !"".equals(nameChild)) { sourceId = nameParent; nameParent = nameChild; } - performanceInformationService.queryDateBetween(sourceId,nameParent,startTime,endTime) - .forEach( per -> { + performanceInformationService.queryDateBetween(sourceId, nameParent, startTime, endTime) + .forEach(per -> { diagramSource.add(Integer.parseInt(per.getValue())); }); } @@ -283,29 +283,35 @@ public class PerformanceController { try { return omPerformance.writeValueAsString(diagramSource); } catch (JsonProcessingException e) { - logger.error("JsonProcessingException:"+e.getMessage()); + logger.error("JsonProcessingException:" + e.getMessage()); return ""; } } - @RequestMapping(value = {"/performance/resourceIds"},method = RequestMethod.GET) - public String getSourceIds(){ + @RequestMapping(value = {"/performance/resourceIds"}, method = RequestMethod.GET) + public String getSourceIds() { + List sourceIds = new ArrayList<>(); try { - return omPerformance.writeValueAsString(performanceHeaderService.queryAllSourceId()); + performanceHeaderService.queryAllSourceId().forEach( ph -> { + if (!sourceIds.contains(ph)) + sourceIds.add(ph); + } ); + return omPerformance.writeValueAsString(sourceIds); } catch (JsonProcessingException e) { logger.error(e.getMessage()); return ""; } } - @RequestMapping(value = {"/performance/names"},method = RequestMethod.POST) - public String getNames(@RequestParam Object sourceId){ + @RequestMapping(value = {"/performance/names"}, method = RequestMethod.POST) + public String getNames(@RequestParam Object sourceId) { try { List names = new ArrayList<>(); - performanceInformationService.queryDateBetween(sourceId.toString(),null,null,null).forEach( per ->{ - if (!names.contains(per.getName())) + performanceInformationService.queryDateBetween(sourceId.toString(), null, null, null).forEach(per -> { + if (!names.contains(per.getName()) && per.getValue().matches("[0-9]*")) names.add(per.getName()); - } ); + + }); return omPerformance.writeValueAsString(names); } catch (JsonProcessingException e) { logger.error(e.getMessage()); diff --git a/server/src/main/java/org/onap/usecaseui/server/util/DmaapSubscriber.java b/server/src/main/java/org/onap/usecaseui/server/util/DmaapSubscriber.java index 199bc7e4..d0664c81 100644 --- a/server/src/main/java/org/onap/usecaseui/server/util/DmaapSubscriber.java +++ b/server/src/main/java/org/onap/usecaseui/server/util/DmaapSubscriber.java @@ -26,9 +26,19 @@ import org.onap.usecaseui.server.service.AlarmsHeaderService; import org.onap.usecaseui.server.service.AlarmsInformationService; import org.onap.usecaseui.server.service.PerformanceHeaderService; import org.onap.usecaseui.server.service.PerformanceInformationService; +import org.onap.usecaseui.server.service.impl.AlarmsHeaderServiceImpl; +import org.onap.usecaseui.server.service.impl.AlarmsInformationServiceImpl; +import org.onap.usecaseui.server.service.impl.PerformanceHeaderServiceImpl; +import org.onap.usecaseui.server.service.impl.PerformanceInformationServiceImpl; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.EnableAspectJAutoProxy; +import org.springframework.stereotype.Component; +import org.springframework.stereotype.Controller; +import org.springframework.stereotype.Repository; +import org.springframework.stereotype.Service; import javax.annotation.Resource; import javax.ws.rs.client.Client; @@ -40,8 +50,7 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.*; -@org.springframework.context.annotation.Configuration -@EnableAspectJAutoProxy +@Component public class DmaapSubscriber implements Runnable { private Logger logger = LoggerFactory.getLogger(DmaapSubscriber.class); @@ -68,62 +77,40 @@ public class DmaapSubscriber implements Runnable { private PerformanceInformationService performanceInformationService; public void subscribe(String topic) { - String response; try { - response = getDMaaPData(topic); - logger.info(response); - if (response == null && "".equals(response)) { + List respList = getDMaaPData(topic); + if (respList.size() <= 0 || respList == null) { logger.info("response is null"); return; - } else { - ObjectMapper objMapper = new ObjectMapper(); - objMapper.setDateFormat(new SimpleDateFormat(Constant.DATE_FORMAT)); - if (response.contains("}}\"")) - response = response.replaceAll("}}\"","}}"); - if (response.contains("\"{\"VESversion\"")) - response = response.replaceAll("\"\\{\"VESversion\"","{\"VESversion\""); - if (response.contains("]\"")) - response = response.replaceAll("]\"","]"); - if (response.contains("\"[")) - response = response.replaceAll("\"\\[","["); - if (response.contains("Remark:\"")) - response = response.replaceAll("Remark:\"",":"); - if (response.contains("\";")) - response = response.replaceAll("\";",";"); - - if (response.indexOf("[") == 0) { - List eventList = objMapper.readValue(response, List.class); - - eventList.forEach(el -> { - Map eventMaps = (Map) ((Map) el).get("event"); - if (eventMaps.containsKey("measurementsForVfScalingFields")) { - performanceProcess(eventMaps); - } else if (eventMaps.containsKey("faultFields")) { - alarmProcess(eventMaps); - } - }); - } else if (response.indexOf("{") == 0) { - Map eventMaps = (Map) objMapper.readValue(response, Map.class).get("event"); - + } + ObjectMapper objMapper = new ObjectMapper(); + objMapper.setDateFormat(new SimpleDateFormat(Constant.DATE_FORMAT)); + respList.forEach(rl -> { + logger.info(rl); + try { + Map eventMaps = (Map) objMapper.readValue(rl, Map.class).get("event"); if (eventMaps.containsKey("measurementsForVfScalingFields")) { performanceProcess(eventMaps); } else if (eventMaps.containsKey("faultFields")) { alarmProcess(eventMaps); } - } else { - logger.error("unknown json type!"); + } catch (IOException e) { + e.printStackTrace(); } - } + }); + } catch (Exception e) { + e.printStackTrace(); logger.error("getDMaaP Information failed :" + e.getMessage()); } } - private String getDMaaPData(String topic) { + private List getDMaaPData(String topic) { Client client = ClientBuilder.newClient(new ClientConfig()); WebTarget webTarget = client.target(url + "/" + topic + "/" + consumerGroup + "/" + consumer); + logger.info("target:" + url + "/" + topic + "/" + consumerGroup + "/" + consumer); Response response = webTarget.queryParam("timeout", timeout).request().get(); - return response.readEntity(String.class); + return response.readEntity(List.class); } private void initConfig() { @@ -131,10 +118,12 @@ public class DmaapSubscriber implements Runnable { Properties p = new Properties(); try { p.load(inputStream); - this.url = p.getProperty("dmaap.url") + System.getenv("MR_ADDR"); + //this.url = p.getProperty("dmaap.url") + System.getenv("MR_ADDR"); + this.url = "http://172.30.3.42:3904"; this.alarmTopic = p.getProperty("dmaap.alarmTopic"); this.performanceTopic = p.getProperty("dmaap.performanceTopic"); - this.consumerGroup = p.getProperty("dmaap.consumerGroup"); + //this.consumerGroup = p.getProperty("dmaap.consumerGroup"); + this.consumerGroup = "gaolei"; this.consumer = p.getProperty("dmaap.consumer"); this.timeout = Integer.parseInt(p.getProperty("dmaap.timeout")); } catch (IOException e1) { @@ -144,10 +133,15 @@ public class DmaapSubscriber implements Runnable { public void run() { try { + //logger.info((alarmsHeaderService == null)+""); initConfig(); while (isActive) { + logger.info("alarm data subscription is starting......"); subscribe(alarmTopic); + logger.info("alarm data subscription has finished."); + logger.info("performance data subscription is starting......"); subscribe(performanceTopic); + logger.info("performance data subscription has finished."); } } catch (Exception e) { try { @@ -155,7 +149,9 @@ public class DmaapSubscriber implements Runnable { } catch (InterruptedException e1) { e1.printStackTrace(); } + e.printStackTrace(); logger.error("subscribe raise error :" + e.getCause()); + run(); } } @@ -221,36 +217,12 @@ public class DmaapSubscriber implements Runnable { if (i.get("name").toString().equals("eventTime")) try { alarm_header.setCreateTime(DateUtils.stringToDate(i.get("value").toString())); - alarm_header.setUpdateTime(DateUtils.stringToDate(i.get("value").toString())); + alarm_header.setUpdateTime(DateUtils.now()); } catch (ParseException e) { e.printStackTrace(); } - if (i.get("value").toString().contains(";")) { - alarm_informations.add(new AlarmsInformation(i.get("name").toString(), "", alarm_header.getSourceId(), null, null)); - char[] valStr = i.get("value").toString().toCharArray(); - String name = ""; - String value = ""; - boolean nameFlag = true; - boolean valueFlag = false; - for (int j = 0; j < valStr.length; j++) { - if (valStr[j] == ':') { - nameFlag = false; - valueFlag = true; - continue; - } - if (valStr[j] == ';') { - nameFlag = true; - valueFlag = false; - alarm_informations.add(new AlarmsInformation(name, value, i.get("name").toString(), null, null)); - continue; - } - if (nameFlag) - name += valStr[j]; - if (valueFlag) - value += valStr[j]; - } - } else { - alarm_informations.add(new AlarmsInformation(i.get("name").toString(), i.get("value").toString(), alarm_header.getSourceId(), null, null)); + else { + alarm_informations.add(new AlarmsInformation(i.get("name").toString(), i.get("value").toString(), alarm_header.getSourceId(), null, new Date())); } }); } catch (Exception e) { @@ -265,9 +237,13 @@ public class DmaapSubscriber implements Runnable { }); if (alarm_header.getEventName().contains("Cleared")) { alarm_header.setStatus("3"); + logger.info("alarmCleared data header insert is starting......"); alarmsHeaderService.saveAlarmsHeader(alarm_header); + logger.info("alarmCleared data header insert has finished."); + logger.info("alarmCleared data detail insert is starting......"); alarm_informations.forEach(information -> alarmsInformationService.saveAlarmsInformation(information)); + logger.info("alarmCleared data detail insert has finished. " + alarm_informations.size() + " records have been inserted."); AlarmsHeader header1 = new AlarmsHeader(); header1.setEventName(alarm_header.getEventName().substring(0, alarm_header.getEventName().indexOf("Cleared"))); List alarmsHeaders = alarmsHeaderService.queryAlarmsHeader(header1, 1, 10).getList(); @@ -279,116 +255,107 @@ public class DmaapSubscriber implements Runnable { } else { alarm_header.setUpdateTime(new Date()); alarm_header.setStatus("1"); + logger.info("alarm data header insert is starting......"); alarmsHeaderService.saveAlarmsHeader(alarm_header); + logger.info("alarm data header insert has finished."); + logger.info("alarm data detail insert is starting......"); alarm_informations.forEach(information -> alarmsInformationService.saveAlarmsInformation(information)); + logger.info("alarm data detail insert has finished. " + alarm_informations.size() + " records have been inserted."); } } }); } - private void performanceProcess(Map maps) { + private void performanceProcess(Map eventMap) { PerformanceHeader performance_header = new PerformanceHeader(); List performance_informations = new ArrayList<>(); - maps.forEach((k, v) -> { - if (k.equals("event")) { - Map eventMap = (Map) v; - eventMap.forEach((ek1, ev1) -> { - if (ek1.equals("commonEventHeader")) { - ((Map) ev1).forEach((k2, v2) -> { - if (k2.equals("version")) - performance_header.setVersion(v2.toString()); - if (k2.equals("eventName")) - performance_header.setEventName(v2.toString()); - if (k2.equals("domain")) - performance_header.setDomain(v2.toString()); - if (k2.equals("eventId")) - performance_header.setEventId(v2.toString()); - if (k2.equals("eventType")) - performance_header.setEventType(v2.toString()); - if (k2.equals("nfcNamingCode")) - performance_header.setNfcNamingCode(v2.toString()); - if (k2.equals("nfNamingCode")) - performance_header.setNfNamingCode(v2.toString()); - if (k2.equals("sourceId")) - performance_header.setSourceId(v2.toString()); - if (k2.equals("sourceName")) - performance_header.setSourceName(v2.toString()); - if (k2.equals("reportingEntityId")) - performance_header.setReportingEntityId(v2.toString()); - if (k2.equals("reportingEntityName")) - performance_header.setReportingEntityName(v2.toString()); - if (k2.equals("priority")) - performance_header.setPriority(v2.toString()); - if (k2.equals("startEpochMicrosec")) - performance_header.setStartEpochMicrosec(v2.toString()); - if (k2.equals("lastEpochMicrosec")) - performance_header.setLastEpochMicroSec(v2.toString()); - if (k2.equals("sequence")) - performance_header.setSequence(v2.toString()); - }); - } else if (ek1.equals("measurementsForVfScalingFields")) { - ((Map) ev1).forEach((k3, v3) -> { - if (k3.equals("measurementsForVfScalingVersion")) - performance_header.setMeasurementsForVfScalingVersion(v3.toString()); - if (k3.equals("measurementInterval")) - performance_header.setMeasurementInterval(v3.toString()); - if (k3.equals("additionalMeasurements")) { - try { - List> m = (List>) v3; - m.forEach(i -> { - if (i.get("name").toString().equals("eventTime")) + eventMap.forEach((ek1, ev1) -> { + if (ek1.equals("commonEventHeader")) { + ((Map) ev1).forEach((k2, v2) -> { + if (k2.equals("version")) + performance_header.setVersion(v2.toString()); + if (k2.equals("eventName")) + performance_header.setEventName(v2.toString()); + if (k2.equals("domain")) + performance_header.setDomain(v2.toString()); + if (k2.equals("eventId")) + performance_header.setEventId(v2.toString()); + if (k2.equals("eventType")) + performance_header.setEventType(v2.toString()); + if (k2.equals("nfcNamingCode")) + performance_header.setNfcNamingCode(v2.toString()); + if (k2.equals("nfNamingCode")) + performance_header.setNfNamingCode(v2.toString()); + if (k2.equals("sourceId")) + performance_header.setSourceId(v2.toString()); + if (k2.equals("sourceName")) + performance_header.setSourceName(v2.toString()); + if (k2.equals("reportingEntityId")) + performance_header.setReportingEntityId(v2.toString()); + if (k2.equals("reportingEntityName")) + performance_header.setReportingEntityName(v2.toString()); + if (k2.equals("priority")) + performance_header.setPriority(v2.toString()); + if (k2.equals("startEpochMicrosec")) + performance_header.setStartEpochMicrosec(v2.toString()); + if (k2.equals("lastEpochMicrosec")) + performance_header.setLastEpochMicroSec(v2.toString()); + if (k2.equals("sequence")) + performance_header.setSequence(v2.toString()); + }); + } else if (ek1.equals("measurementsForVfScalingFields")) { + ((Map) ev1).forEach((k3, v3) -> { + if (k3.equals("measurementsForVfScalingVersion")) + performance_header.setMeasurementsForVfScalingVersion(v3.toString()); + if (k3.equals("measurementInterval")) + performance_header.setMeasurementInterval(v3.toString()); + if (k3.equals("additionalMeasurements")) { + try { + List> m = (List>) v3; + m.forEach(i -> { + if (i.containsKey("arrayOfFields")){ + List> arrayOfFields = (List>) i.get("arrayOfFields"); + arrayOfFields.forEach( fields -> { + if (fields.get("name").equals("StartTime")){ try { - performance_header.setCreateTime(DateUtils.stringToDate(i.get("value").toString())); - performance_header.setUpdateTime(DateUtils.stringToDate(i.get("value").toString())); + performance_informations.add(new PerformanceInformation(fields.get("name"),fields.get("value"),performance_header.getSourceId(),null,DateUtils.now())); + performance_header.setCreateTime(DateUtils.stringToDate(fields.get("value").replaceAll(Constant.RegEX_DATE_FORMAT," "))); + performance_header.setUpdateTime(DateUtils.now()); } catch (ParseException e) { e.printStackTrace(); } - if (i.get("value").toString().contains(";")) { - performance_informations.add(new PerformanceInformation(i.get("name").toString(), "", performance_header.getSourceId(), null, null)); - - char[] valStr = i.get("value").toString().replace("=", ":").toCharArray(); - String name = ""; - String value = ""; - boolean nameFlag = true; - boolean valueFlag = false; - for (int j = 0; j < valStr.length; j++) { - if (valStr[j] == ':') { - nameFlag = false; - valueFlag = true; - continue; - } - if (valStr[j] == ';') { - nameFlag = true; - valueFlag = false; - performance_informations.add(new PerformanceInformation(name, value, i.get("name").toString(), null, null)); - continue; - } - if (nameFlag) - name += valStr[j]; - if (valueFlag) - value += valStr[j]; + }else{ + try { + performance_informations.add(new PerformanceInformation(fields.get("name"),fields.get("value"),performance_header.getSourceId(),null,DateUtils.now())); + } catch (ParseException e) { + e.printStackTrace(); } - } else { - performance_informations.add(new PerformanceInformation(i.get("name").toString(), i.get("value").toString(), performance_header.getSourceId(), null, null)); } - }); - - } catch (Exception e) { - e.printStackTrace(); - logger.error("convert performanceAdditionalInformation error:" + e.getMessage()); + } ); } - } - }); - performanceHeaderService.savePerformanceHeader(performance_header); - performance_informations.forEach(ai -> { - ai.setCreateTime(performance_header.getCreateTime()); - ai.setUpdateTime(new Date()); - performanceInformationService.savePerformanceInformation(ai); - }); + + }); + + } catch (Exception e) { + e.printStackTrace(); + logger.error("convert performanceAdditionalInformation error:" + e.getMessage()); + } } }); + + logger.info("performance data header insert is starting......"); + performanceHeaderService.savePerformanceHeader(performance_header); + logger.info("performance data header insert has finished."); + logger.info("performance data detail insert is starting......"); + performance_informations.forEach(ai -> { + ai.setCreateTime(performance_header.getCreateTime()); + performanceInformationService.savePerformanceInformation(ai); + }); + logger.info("performance data detail insert has finished. " + performance_informations.size() + " records have been inserted."); } }); + + } } \ No newline at end of file diff --git a/server/src/main/resources/dmaap.properties b/server/src/main/resources/dmaap.properties index 793fabf2..61efacee 100644 --- a/server/src/main/resources/dmaap.properties +++ b/server/src/main/resources/dmaap.properties @@ -17,5 +17,5 @@ dmaap.url = http:// dmaap.alarmTopic = events/unauthenticated.SEC_FAULT_OUTPUT dmaap.performanceTopic = events/unauthenticated.SEC_MEASUREMENT_OUTPUT dmaap.consumerGroup = uuiGroup -dmaap.conusmer = uuiUser +dmaap.consumer = uuiUser dmaap.timeout = 10000 \ No newline at end of file diff --git a/standalone/src/main/assembly/resources/dbscripts/mysql/usecase-ui-createobj.sql b/standalone/src/main/assembly/resources/dbscripts/mysql/usecase-ui-createobj.sql index 82c71424..fc1e08a3 100644 --- a/standalone/src/main/assembly/resources/dbscripts/mysql/usecase-ui-createobj.sql +++ b/standalone/src/main/assembly/resources/dbscripts/mysql/usecase-ui-createobj.sql @@ -22,12 +22,12 @@ SET FOREIGN_KEY_CHECKS=0; -- ---------------------------- DROP TABLE IF EXISTS `alarms_additionalinformation`; CREATE TABLE `alarms_additionalinformation` ( - `name` varchar(50) NOT NULL, - `value` varchar(500) NOT NULL, - `eventId` varchar(30) NOT NULL, - `createTime` datetime NOT NULL, - `updateTime` datetime NOT NULL, - `id` int(10) NOT NULL, + `name` varchar(500), + `value` varchar(500), + `eventId` varchar(500), + `createTime` datetime, + `updateTime` datetime, + `id` int(10) NOT NULL auto_increment, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -36,33 +36,34 @@ CREATE TABLE `alarms_additionalinformation` ( -- ---------------------------- DROP TABLE IF EXISTS `alarms_commoneventheader`; CREATE TABLE `alarms_commoneventheader` ( - `version` varchar(10) NOT NULL, - `eventName` varchar(50) NOT NULL, - `domain` varchar(30) NOT NULL, - `eventId` varchar(30) NOT NULL, - `eventType` varchar(30) NOT NULL, - `nfcNamingCode` varchar(30) DEFAULT NULL, - `nfNamingCode` varchar(30) DEFAULT NULL, - `sourceId` varchar(50) NOT NULL, - `sourceName` varchar(50) NOT NULL, - `reportingEntityId` varchar(30) NOT NULL, - `reportingEntityName` varchar(30) NOT NULL, - `priority` varchar(20) NOT NULL, - `startEpochMicrosec` varchar(20) NOT NULL, - `lastEpochMicroSec` varchar(20) NOT NULL, - `sequence` varchar(10) NOT NULL, - `faultFieldsVersion` varchar(10) NOT NULL, - `eventServrity` varchar(30) NOT NULL, - `eventSourceType` varchar(30) NOT NULL, - `eventCategory` varchar(30) NOT NULL, - `alarmCondition` varchar(400) NOT NULL, - `specificProblem` varchar(400) NOT NULL, - `vfStatus` varchar(10) NOT NULL, - `alarmInterfaceA` varchar(40) NOT NULL, - `status` varchar(11) NOT NULL, - `createTime` datetime NOT NULL, - `updateTime` datetime NOT NULL, - PRIMARY KEY (`eventName`) + `version` varchar(500), + `eventName` varchar(500), + `domain` varchar(500), + `eventId` varchar(500), + `eventType` varchar(500), + `nfcNamingCode` varchar(500) DEFAULT NULL, + `nfNamingCode` varchar(500) DEFAULT NULL, + `sourceId` varchar(500), + `sourceName` varchar(500), + `reportingEntityId` varchar(500), + `reportingEntityName` varchar(500), + `priority` varchar(50), + `startEpochMicrosec` varchar(500), + `lastEpochMicroSec` varchar(500), + `sequence` varchar(500), + `faultFieldsVersion` varchar(500), + `eventServrity` varchar(500), + `eventSourceType` varchar(500), + `eventCategory` varchar(500), + `alarmCondition` varchar(500), + `specificProblem` varchar(500), + `vfStatus` varchar(500), + `alarmInterfaceA` varchar(500), + `status` varchar(50), + `createTime` datetime, + `updateTime` datetime, + `id` int(10) NOT NULL auto_increment, + PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- ---------------------------- @@ -70,12 +71,12 @@ CREATE TABLE `alarms_commoneventheader` ( -- ---------------------------- DROP TABLE IF EXISTS `performance_additionalinformation`; CREATE TABLE `performance_additionalinformation` ( - `name` varchar(50) NOT NULL, - `value` varchar(500) NOT NULL, - `eventId` varchar(30) NOT NULL, - `createTime` datetime NOT NULL, - `updateTime` datetime NOT NULL, - `id` int(10) NOT NULL, + `name` varchar(500), + `value` varchar(500), + `eventId` varchar(500), + `createTime` datetime, + `updateTime` datetime, + `id` int(10) NOT NULL auto_increment, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; @@ -84,24 +85,25 @@ CREATE TABLE `performance_additionalinformation` ( -- ---------------------------- DROP TABLE IF EXISTS `performance_commoneventheader`; CREATE TABLE `performance_commoneventheader` ( - `version` varchar(10) NOT NULL, - `eventName` varchar(50) NOT NULL, - `domain` varchar(30) NOT NULL, - `eventId` varchar(30) NOT NULL, - `eventType` varchar(30) NOT NULL, - `nfcNamingCode` varchar(30) DEFAULT NULL, - `nfNamingCode` varchar(30) DEFAULT NULL, - `sourceId` varchar(50) NOT NULL, - `sourceName` varchar(50) NOT NULL, - `reportingEntityId` varchar(30) NOT NULL, - `reportingEntityName` varchar(30) NOT NULL, - `priority` varchar(20) NOT NULL, - `startEpochMicrosec` varchar(20) NOT NULL, - `lastEpochMicroSec` varchar(20) NOT NULL, - `sequence` varchar(10) NOT NULL, - `measurementsForVfScalingVersion` varchar(10) NOT NULL, - `measurementInterval` varchar(10) NOT NULL, - `createTime` datetime NOT NULL, - `updateTime` datetime NOT NULL, - PRIMARY KEY (`eventName`) + `version` varchar(500), + `eventName` varchar(500), + `domain` varchar(500), + `eventId` varchar(500), + `eventType` varchar(500), + `nfcNamingCode` varchar(500) DEFAULT NULL, + `nfNamingCode` varchar(500) DEFAULT NULL, + `sourceId` varchar(500), + `sourceName` varchar(500), + `reportingEntityId` varchar(500), + `reportingEntityName` varchar(500), + `priority` varchar(50), + `startEpochMicrosec` varchar(500), + `lastEpochMicroSec` varchar(500), + `sequence` varchar(500), + `measurementsForVfScalingVersion` varchar(500), + `measurementInterval` varchar(500), + `createTime` datetime, + `updateTime` datetime, + `id` int(10) NOT NULL auto_increment, + PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8; -- cgit 1.2.3-korg