aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java1
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java5
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImpl.java6
-rwxr-xr-xserver/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImpl.java11
-rw-r--r--server/src/main/java/org/onap/usecaseui/server/util/DmaapSubscriber.java28
-rw-r--r--standalone/src/main/assembly/bin/run.sh8
-rw-r--r--standalone/src/main/assembly/resources/bin/initDB.sh8
7 files changed, 23 insertions, 44 deletions
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java
index 2c63fdca..d290708c 100755
--- a/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsHeaderServiceImpl.java
@@ -375,7 +375,6 @@ public class AlarmsHeaderServiceImpl implements AlarmsHeaderService {
Query q=session.createQuery("update AlarmsHeader set status=:status, startEpochMicrosecCleared=:startEpochMicrosecCleared ,lastEpochMicroSecCleared=:lastEpochMicroSecCleared where eventName=:eventName and reportingEntityName=:reportingEntityName and specificProblem =:specificProblem");
q.setString("status",status);
- q.setDate("date",date);
q.setString("startEpochMicrosecCleared",startEpochMicrosecCleared);
q.setString("lastEpochMicroSecCleared",lastEpochMicroSecCleared);
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java
index b1d8d074..f5d590a2 100755
--- a/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/impl/AlarmsInformationServiceImpl.java
@@ -56,7 +56,6 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
if (null == alarmsInformation) {
logger.error("alarmsInformation saveAlarmsInformation alarmsInformation is null!");
}
- logger.info("AlarmsInformationServiceImpl saveAlarmsInformation: alarmsInformation={}", alarmsInformation);
Transaction tx = session.beginTransaction();
session.save(alarmsInformation);
tx.commit();
@@ -75,7 +74,6 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
if (null == alarmsInformation) {
logger.error("alarmsInformation updateAlarmsInformation alarmsInformation is null!");
}
- logger.info("AlarmsInformationServiceImpl updateAlarmsInformation: alarmsInformation={}", alarmsInformation);
Transaction tx = session.beginTransaction();
session.update(alarmsInformation);
tx.commit();
@@ -92,7 +90,6 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
try(Session session = getSession()){
StringBuffer hql = new StringBuffer("select count(*) from AlarmsInformation a where 1=1");
if (null == alarmsInformation) {
- logger.error("AlarmsInformationServiceImpl getAllCount alarmsInformation is null!");
}else {
if(null!=alarmsInformation.getName()) {
String ver=alarmsInformation.getName();
@@ -153,7 +150,6 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
hql.append(" and a.startEpochMicrosec between :startTime and :endTime");
}
}
- logger.info("AlarmsInformationServiceImpl queryAlarmsInformation: alarmsInformation={}", alarmsInformation);
Query query = session.createQuery(hql.toString());
if(null!=alarmsInformation.getStartEpochMicroSec() || alarmsInformation.getLastEpochMicroSec()!= null) {
query.setString("startTime",alarmsInformation.getStartEpochMicroSec());
@@ -179,7 +175,6 @@ public class AlarmsInformationServiceImpl implements AlarmsInformationService {
public List<AlarmsInformation> queryId(String[] id) {
try {
if(id.length==0) {
- logger.error("AlarmsInformationServiceImpl queryId is null!");
}
List<AlarmsInformation> list = new ArrayList<AlarmsInformation>();
Session session = getSession();
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImpl.java
index 4a5815a9..9a30b212 100755
--- a/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImpl.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceHeaderServiceImpl.java
@@ -57,7 +57,6 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
logger.error("PerformanceHeaderServiceImpl savePerformanceHeader performanceHeder is null!");
return "0";
}
- logger.info("PerformanceHeaderServiceImpl savePerformanceHeader: performanceHeder={}", performanceHeder);
Transaction tx = session.beginTransaction();
session.save(performanceHeder);
tx.commit();
@@ -76,7 +75,6 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
logger.error("PerformanceHeaderServiceImpl updatePerformanceHeader performanceHeder is null!");
return "0";
}
- logger.info("PerformanceHeaderServiceImpl updatePerformanceHeader: performanceHeder={}", performanceHeder);
Transaction tx = session.beginTransaction();
session.update(performanceHeder);
tx.commit();
@@ -92,7 +90,6 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
try(Session session = getSession()){
StringBuffer hql = new StringBuffer("select count(*) from PerformanceHeader a where 1=1");
if (null == performanceHeder) {
- logger.error("PerformanceHeaderServiceImpl getAllCount performanceHeder is null!");
return 0;
}else {
if(null!=performanceHeder.getVersion()) {
@@ -190,7 +187,6 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
try(Session session = getSession()){
StringBuffer hql =new StringBuffer("from PerformanceHeader a where 1=1");
if (null == performanceHeder) {
- logger.error("PerformanceHeaderServiceImpl queryPerformanceHeader performanceHeder is null!");
return page;
}else {
if(null!=performanceHeder.getVersion()) {
@@ -265,7 +261,6 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
hql.append(" and a.startEpochMicrosec between :startTime and :endTime ");
}
}
- logger.info("PerformanceHeaderServiceImpl queryPerformanceHeader: performanceHeder={}", performanceHeder);
Query query = session.createQuery(hql.toString());
if(null!=performanceHeder.getStartEpochMicrosec() && null!=performanceHeder.getLastEpochMicroSec()) {
query.setString("startTime",performanceHeder.getStartEpochMicrosec()).setString("endTime",performanceHeder.getLastEpochMicroSec());
@@ -291,7 +286,6 @@ public class PerformanceHeaderServiceImpl implements PerformanceHeaderService {
try(Session session = getSession()) {
List<PerformanceHeader> list = new ArrayList<PerformanceHeader>();
if(id.length==0) {
- logger.error("PerformanceHeaderServiceImpl queryId is null!");
return list;
}
Query query = session.createQuery("from PerformanceHeader a where a.eventName IN (:alist)");
diff --git a/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImpl.java b/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImpl.java
index 858bf8b7..a1d55616 100755
--- a/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImpl.java
+++ b/server/src/main/java/org/onap/usecaseui/server/service/impl/PerformanceInformationServiceImpl.java
@@ -59,9 +59,7 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
public String savePerformanceInformation(PerformanceInformation performanceInformation) {
try(Session session = getSession()) {
if (null == performanceInformation) {
- logger.error("performanceInformation savePerformanceInformation performanceInformation is null!");
}
- logger.info("PerformanceInformationServiceImpl savePerformanceInformation: performanceInformation={}", performanceInformation);
Transaction tx = session.beginTransaction();
session.save(performanceInformation);
tx.commit();
@@ -77,7 +75,6 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
public String updatePerformanceInformation(PerformanceInformation performanceInformation) {
try(Session session = getSession()) {
if (null == performanceInformation) {
- logger.error("performanceInformation updatePerformanceInformation performanceInformation is null!");
}
logger.info("PerformanceInformationServiceImpl updatePerformanceInformation: performanceInformation={}", performanceInformation);
Transaction tx = session.beginTransaction();
@@ -95,7 +92,6 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
try(Session session = getSession()){
StringBuffer hql = new StringBuffer("select count(*) from PerformanceInformation a where 1=1");
if (null == performanceInformation) {
- logger.error("AlarmsInformationServiceImpl getAllCount performanceInformation is null!");
}else {
if(null!=performanceInformation.getName()) {
String ver=performanceInformation.getName();
@@ -138,7 +134,6 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
try(Session session = getSession()){
StringBuffer hql =new StringBuffer("from PerformanceInformation a where 1=1 ");
if (null == performanceInformation) {
- logger.error("AlarmsInformationServiceImpl queryPerformanceInformation performanceInformation is null!");
}else {
if(null!=performanceInformation.getName()) {
String ver=performanceInformation.getName();
@@ -156,7 +151,6 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
hql.append(" and a.startEpochMicrosec between :startTime and :endTime");
}
}
- logger.info("PerformanceInformationServiceImpl queryPerformanceInformation: performanceInformation={}", performanceInformation);
Query query = session.createQuery(hql.toString());
if(null!=performanceInformation.getStartEpochMicrosec() || performanceInformation.getLastEpochMicroSec()!= null) {
query.setString("startTime",performanceInformation.getStartEpochMicrosec());
@@ -183,7 +177,6 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
public List<PerformanceInformation> queryId(String[] id) {
try(Session session = getSession()) {
if(id.length==0) {
- logger.error("PerformanceInformationServiceImpl queryId is null!");
}
List<PerformanceInformation> list = new ArrayList<>();
Query query = session.createQuery("from PerformanceInformation a where a.sourceId IN (:alist)");
@@ -203,7 +196,6 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
List<PerformanceInformation> list = new ArrayList<>();
Query query = session.createQuery("from PerformanceInformation a where a.sourceId = :sourceId and a.createTime BETWEEN :startDate and :endDate");
list = query.setParameter("sourceId",sourceId).setParameter("startDate", startDate).setParameter("endDate",endDate).list();
- logger.info("PerformanceInformationServiceImpl queryDateBetween: list={}", list);
return list;
} catch (Exception e) {
logger.error("exception occurred while performing PerformanceInformationServiceImpl queryDateBetween. Details:" + e.getMessage());
@@ -218,7 +210,6 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
int sum = 0;
Query query = session.createQuery("select sum(a.value) from PerformanceInformation a where a.sourceId = :sourceId and a.name = :name and a.createTime BETWEEN :startDate and :endDate");
sum = Integer.parseInt(query.setParameter("sourceId",sourceId).setParameter("name",name).setParameter("startDate", startDate).setParameter("endDate",endDate).uniqueResult().toString());
- logger.info("PerformanceInformationServiceImpl queryDataBetweenSum: sum={}", sum);
return sum;
} catch (Exception e) {
logger.error("exception occurred while performing PerformanceInformationServiceImpl queryDataBetweenSum. Details:" + e.getMessage());
@@ -284,7 +275,7 @@ public class PerformanceInformationServiceImpl implements PerformanceInformation
hql += " and a.name = :name ";
}
if (startTime != null && !"".equals(startTime) && endTime != null && !"".equals(endTime)){
- hql += " and a.startEpochMicrosec between :startTime and :endTime ";
+ hql += " and (CASE WHEN a.startEpochMicrosec=0 THEN a.lastEpochMicroSec ELSE a.startEpochMicrosec END) between :startTime and :endTime ";
}
Query query = session.createQuery(hql);
if (sourceId != null && !"".equals(sourceId)){
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 040417ef..9b64ab6c 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
@@ -173,9 +173,9 @@ public class DmaapSubscriber implements Runnable {
if (k2.equals("priority"))
alarm_header.setPriority(v2.toString());
if (k2.equals("startEpochMicrosec"))
- alarm_header.setStartEpochMicrosec(v2.toString().substring(0, 13));
+ alarm_header.setStartEpochMicrosec(this.getTime(v2.toString()));
if (k2.equals("lastEpochMicrosec"))
- alarm_header.setLastEpochMicroSec(v2.toString().substring(0, 13));
+ alarm_header.setLastEpochMicroSec(this.getTime(v2.toString()));
if (k2.equals("sequence"))
alarm_header.setSequence(v2.toString());
});
@@ -211,7 +211,7 @@ public class DmaapSubscriber implements Runnable {
});
}
});
- if (alarm_header.getEventName() != null){
+ if (alarm_header.getEventName() != null&&(alarm_header.getStartEpochMicrosec().length()>=13||alarm_header.getLastEpochMicroSec().length()>=13)){
Long l = System.currentTimeMillis();
Timestamp date_get = new Timestamp(l);
@@ -264,9 +264,9 @@ public class DmaapSubscriber implements Runnable {
if (k2.equals("priority"))
performance_header.setPriority(v2.toString());
if (k2.equals("startEpochMicrosec"))
- performance_header.setStartEpochMicrosec(v2.toString().substring(0, 13));
+ performance_header.setStartEpochMicrosec(this.getTime(v2.toString()));
if (k2.equals("lastEpochMicrosec"))
- performance_header.setLastEpochMicroSec(v2.toString().substring(0, 13));
+ performance_header.setLastEpochMicroSec(this.getTime(v2.toString()));
if (k2.equals("sequence"))
performance_header.setSequence(v2.toString());
});
@@ -295,11 +295,21 @@ public class DmaapSubscriber implements Runnable {
}
}
});
- performanceHeaderService.savePerformanceHeader(performance_header);
- performance_informations.forEach(ai -> {
- performanceInformationService.savePerformanceInformation(ai);
- });
+ if ((performance_header.getStartEpochMicrosec().length()>=13||performance_header.getLastEpochMicroSec().length()>=13)){//时间有效才会进行存储
+ performanceHeaderService.savePerformanceHeader(performance_header);
+ performance_informations.forEach(ai -> {
+ performanceInformationService.savePerformanceInformation(ai);
+ });
+ }
}
});
}
+
+ private String getTime(String time){
+ String result=time;
+ if(time.length()>=13){
+ result=time.substring(0, 13);
+ }
+ return result;
+ }
} \ No newline at end of file
diff --git a/standalone/src/main/assembly/bin/run.sh b/standalone/src/main/assembly/bin/run.sh
index 08d659cf..25a83d59 100644
--- a/standalone/src/main/assembly/bin/run.sh
+++ b/standalone/src/main/assembly/bin/run.sh
@@ -21,15 +21,11 @@ echo @RUNHOME@ $RUNHOME
echo "Starting mysql"
service mysql start
-sleep 10
-echo "run.sh 1"
+sleep 100
SCRIPT="/home/uui/resources/bin/initDB.sh"
-echo "run.sh 2"
chmod 755 $SCRIPT
-echo "run.sh 3"
-$SCRIPT root root 3306 127.0.0.1
-echo "run.sh 4"
+$SCRIPT root root 3306 127.0.0.1
echo @JAVA_HOME@ $JAVA_HOME
JAVA="$JAVA_HOME/bin/java"
diff --git a/standalone/src/main/assembly/resources/bin/initDB.sh b/standalone/src/main/assembly/resources/bin/initDB.sh
index b9504926..06d2bfc8 100644
--- a/standalone/src/main/assembly/resources/bin/initDB.sh
+++ b/standalone/src/main/assembly/resources/bin/initDB.sh
@@ -1,4 +1,4 @@
-#! /bin/bash
+#!/bin/bash
#
# Copyright (C) 2017 CMCC, Inc. and others. All rights reserved.
#
@@ -15,21 +15,15 @@
# limitations under the License.
#
-echo "initDB.sh 1"
DIRNAME=`dirname $0`
-echo "initDB.sh 2"
HOME=`cd $DIRNAME/; pwd`
-echo "initDB.sh 3"
user=$1
password=$2
port=$3
host=$4
-echo "initDB.sh 4"
echo "start create usecase-ui db"
sql_path=$HOME/../
-echo "initDB.sh 5"
mysql -u$user -p$password -P$port -h$host <$sql_path/dbscripts/mysql/usecase-ui-createdb.sql
-echo "initDB.sh 6"
sql_result=$?
if [ $sql_result != 0 ] ; then
echo "failed to create usecase-ui database"