diff options
30 files changed, 527 insertions, 131 deletions
diff --git a/ems/boco/conf/config.properties b/ems/boco/conf/config.properties index 7a946d0..4207839 100644 --- a/ems/boco/conf/config.properties +++ b/ems/boco/conf/config.properties @@ -26,14 +26,11 @@ ftp_type = ftp msbAddress=10.74.205.123:80 esr_ems_listUrl=/aai/v11/external-system/esr-ems-list esr_emsUrl=/aai/v11/external-system/esr-ems-list/esr-ems/%s?depth=all -alarmUrl=/alarm #north event_api_url=http://127.0.0.1 -port=30000 -path=/vendor_event_listener -topic=/example_vnf -username=pill -password=will +port=3000 +username= +password= level=debug diff --git a/ems/boco/conf/crontab.xml b/ems/boco/conf/crontab.xml index 0d7f591..412160a 100644 --- a/ems/boco/conf/crontab.xml +++ b/ems/boco/conf/crontab.xml @@ -18,15 +18,15 @@ --> <scheduler> - <crontab type ="ems-resource" crontab="0 0/15 * * * ?"> + <crontab type ="ems_resource" crontab=""> <match>*</match> <granularity>15</granularity> </crontab> - <crontab type ="ems-performance" crontab=""> - <match>*</match> + <crontab type ="ems_performance" crontab="0 0/15 * * * ?"> + <match>/<*${s_year}${s_mon}${s_day}${s_hour}>/.*${s_year}${s_mon}${s_day}${s_hour}${s_min}.*</match> <granularity>15</granularity> </crontab> - <crontab type ="ems-alarm" iscollect = "false"> - <readtimeout>6</readtimeout>; + <crontab type ="ems_alarm" iscollect="true"> + <readtimeout>18000</readtimeout>; </crontab> </scheduler>
\ No newline at end of file diff --git a/ems/boco/conf/emsdriver.yml b/ems/boco/conf/emsdriver.yml index 1319656..5b82754 100644 --- a/ems/boco/conf/emsdriver.yml +++ b/ems/boco/conf/emsdriver.yml @@ -19,7 +19,7 @@ defaultName: EmsDriver-Stranger #microservice Bus address msbAddress: 10.74.205.123:80 -autoServiceRegister: true +autoServiceRegister: false server: type: simple rootPath: '/api/emsdriver/v1/*' diff --git a/ems/boco/conf/spring.xml b/ems/boco/conf/spring.xml index d60cc8b..64f4ec9 100644 --- a/ems/boco/conf/spring.xml +++ b/ems/boco/conf/spring.xml @@ -19,7 +19,7 @@ --> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd" + xsi:schemaLocation="http://www.springframework.org/schema/beans classpath:/org/springframework/beans/factory/xml/spring-beans-4.0.xsd" default-lazy-init="true"> <bean id="configurationManager" class="org.onap.vfc.nfvo.emsdriver.configmgr.ConfigurationManager"> diff --git a/ems/boco/data/PM-test.xml b/ems/boco/data/PM-test.xml new file mode 100644 index 0000000..66d08af --- /dev/null +++ b/ems/boco/data/PM-test.xml @@ -0,0 +1,75 @@ +<?xml version="1.0" encoding="utf-8"?> + +<PmFile xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> + <FileHeader> + <TimeStamp>2016-06-27T22:37:45</TimeStamp> + <TimeZone>UTC+8</TimeZone> + <Period>15</Period> + <VendorName>ZTE</VendorName> + <ElementType>CSCF</ElementType> + <PmVersion>V2.0.0</PmVersion> + <StartTime>2016-06-27T22:15:00</StartTime> + </FileHeader> + <Measurements> + <ObjectType>IcscfFunction</ObjectType> + <PmName> + <N i="1">LIQ.AttLIR</N> + <N i="2">LIQ.FailLIA._Cause</N> + <N i="3">LIQ.SuccLIA</N> + <N i="4">UR.AttUAR</N> + <N i="5">UR.FailUAA._Cause</N> + <N i="6">UR.SuccUAA</N> + </PmName> + <PmData> + <Object rmUID="3201ZTHX1ICS24F1A451" Dn=" ZTE-CMHN-CS,SubNetwork=100001,ManagedElement=532024_24,IcscfFunction=1" UserLabel="ICSCF_24"> + <V i="1">16</V> + <CV i="2"> + <SN>LIQ.FailLIA.5001</SN> + <SV>0</SV> + <SN>LIQ.FailLIA.5003</SN> + <SV>0</SV> + </CV> + <V i="3">16</V> + <V i="4">13</V> + <CV i="5"> + <SN>UR.FailUAA.5001</SN> + <SV>0</SV> + <SN>UR.FailUAA.5002</SN> + <SV>0</SV> + <SN>UR.FailUAA.5003</SN> + <SV>0</SV> + <SN>UR.FailUAA.5004</SN> + <SV>0</SV> + </CV> + <V i="6">13</V> + </Object> + </PmData> + </Measurements> + <Measurements> + <ObjectType>EpRpDynCxIcscf</ObjectType> + <PmName> + <N i="1">SIG.SLFHSSCongest</N> + <N i="2">SIG.SLFHSSCongestDuration</N> + <N i="3">SIG.SLFHSSCongestPack</N> + <N i="4">SIG.SLFHSSReceiveBytes</N> + <N i="5">SIG.SLFHSSReceivePack</N> + <N i="6">SIG.SLFHSSSendBytes</N> + <N i="7">SIG.SLFHSSSendPack</N> + <N i="8">SIG.SLFHSSUnavailable</N> + <N i="9">SIG.SLFHSSUnavailableDuration</N> + </PmName> + <PmData> + <Object rmUID="3201ZTHX1CXI24F11A1" Dn=" ZTE-CMHN-CS,SubNetwork=100001,ManagedElement=100021_21,IcscfFunction=1,EpRpDynCxIcscf=1001" UserLabel="JNICSCF7-DRA1_1001"> + <V i="1">0</V> + <V i="2">0</V> + <V i="3">0</V> + <V i="4">30720</V> + <V i="5">57</V> + <V i="6">30720</V> + <V i="7">57</V> + <V i="8">0</V> + <V i="9">0</V> + </Object> + </PmData> + </Measurements> +</PmFile> diff --git a/ems/boco/pom.xml b/ems/boco/pom.xml index b2d9c01..a311d85 100644 --- a/ems/boco/pom.xml +++ b/ems/boco/pom.xml @@ -74,7 +74,7 @@ <transformers> <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer"/> <transformer implementation="org.apache.maven.plugins.shade.resource.ManifestResourceTransformer"> - <mainClass>org.onap.vfc.nfvo.emsdriver.EMSDriver</mainClass> + <mainClass>org.onap.vfc.nfvo.emsdriver.EmsDriverApplication</mainClass> </transformer> </transformers> </configuration> @@ -215,5 +215,15 @@ <scope>system</scope> <systemPath>${basedir}/3rdParty/evel_javalib2-0.0.1-SNAPSHOT.jar</systemPath> </dependency> + <dependency> + <groupId>javax.json</groupId> + <artifactId>javax.json-api</artifactId> + <version>1.1</version> + </dependency> + <dependency> + <groupId>org.glassfish</groupId> + <artifactId>javax.json</artifactId> + <version>1.0.4</version> + </dependency> </dependencies> </project> diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/EmsDriverApplication.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/EmsDriverApplication.java index b850f9f..1984ccb 100644 --- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/EmsDriverApplication.java +++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/EmsDriverApplication.java @@ -49,7 +49,9 @@ public class EmsDriverApplication extends Application<EmsDriverConfiguration> { private ApplicationContext context = null; public static void main(String[] args) throws Exception { + log.info("EmsDriverApplication start"); new EmsDriverApplication().run(args); + log.info("EmsDriverApplication start sucess"); } @Override diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/TaskThread.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/TaskThread.java index fdbf3ba..b4cec85 100644 --- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/TaskThread.java +++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/TaskThread.java @@ -47,6 +47,7 @@ import org.onap.vfc.nfvo.emsdriver.commons.constant.Constant; import org.onap.vfc.nfvo.emsdriver.commons.ftp.AFtpRemoteFile; import org.onap.vfc.nfvo.emsdriver.commons.ftp.FTPInterface; import org.onap.vfc.nfvo.emsdriver.commons.ftp.FTPSrv; +import org.onap.vfc.nfvo.emsdriver.commons.ftp.RemoteFile; import org.onap.vfc.nfvo.emsdriver.commons.model.CollectMsg; import org.onap.vfc.nfvo.emsdriver.commons.model.CollectVo; import org.onap.vfc.nfvo.emsdriver.commons.utils.DateUtil; @@ -94,7 +95,7 @@ public class TaskThread implements Runnable{ public void run(){ cmResultChannel = MessageChannelFactory.getMessageChannel(Constant.COLLECT_RESULT_CHANNEL_KEY); - pmResultChannel = MessageChannelFactory.getMessageChannel(Constant.COLLECT_CHANNEL_KEY); + pmResultChannel = MessageChannelFactory.getMessageChannel(Constant.COLLECT_RESULT_PM_CHANNEL_KEY); try { collectMsgHandle(data); } catch (Exception e) { @@ -129,13 +130,13 @@ public class TaskThread implements Runnable{ continue; String nename = ma.group(1); boolean parseResult = false; - if("ems-resource".equalsIgnoreCase(collectVo.getType())){ + if(Constant.COLLECT_TYPE_CM.equalsIgnoreCase(collectVo.getType())){ parseResult = processCMXml(tempfile, nename,"CM"); }else{ if(unfileName.indexOf(".csv") > 0){ parseResult = processPMCsv(tempfile); }else{ - parseResult = processPMCsv(tempfile); + parseResult = processPMXml(tempfile); } } @@ -148,6 +149,214 @@ public class TaskThread implements Runnable{ } } + public boolean processPMXml(File file) { + + FileInputStream fis = null; + InputStreamReader isr = null; + XMLStreamReader reader = null; + try { + fis = new FileInputStream(file); + isr = new InputStreamReader(fis, Constant.ENCODING_UTF8); + + XMLInputFactory fac = XMLInputFactory.newInstance(); + reader = fac.createXMLStreamReader(isr); + + boolean fileHeaderStart = false; + boolean measurementStart = false; + boolean pmNameFlag = false; + boolean pmDataFlag = false; + boolean objectFlag = true; + + int index = -1; + int nameIndex = -1; + String currentMea = null; + String subName = null; + String localName = null; + String endLocalName = null; + String objectType = null; + + + LinkedHashMap<String, String> commonNameAndValue = new LinkedHashMap<String, String>(); + LinkedHashMap<String, String> pmDatas = null; + LinkedHashMap<Integer, String> pmNames = null; + + + int event = -1; + while (reader.hasNext()) { + try{ + event = reader.next(); + + switch (event) { + case XMLStreamConstants.START_ELEMENT: + localName = reader.getLocalName(); + if ("FileHeader".equalsIgnoreCase(localName)) { + fileHeaderStart = true; + } + if(fileHeaderStart){ + if(!"FileHeader".equalsIgnoreCase(localName)){ + commonNameAndValue.put(localName,reader.getElementText().trim()); + } + + } + if ("Measurements".equalsIgnoreCase(localName)) { + // a new Measurement starts + measurementStart = true; + } + if (measurementStart) { + // measurement handler + if ("ObjectType".equalsIgnoreCase(localName)) { + objectType = reader.getElementText().trim(); + commonNameAndValue.put("ObjectType",objectType); + } + if ("PmName".equalsIgnoreCase(localName)) { + pmNameFlag = true; + pmNames = new LinkedHashMap<Integer, String>(); + + } + if (pmNameFlag) { + // pmname handler, add columnNames + if ("N".equalsIgnoreCase(localName)) { + nameIndex = Integer.parseInt(getXMLAttribute(reader, "i")); + String text = reader.getElementText().trim(); + pmNames.put(nameIndex, text); + } + } + if ("PmData".equalsIgnoreCase(localName)) { + pmDataFlag = true; + pmDatas = new LinkedHashMap<String, String>(); + } + + if (pmDataFlag) { + // pmdata handler + if ("Object".equalsIgnoreCase(localName)) { + objectFlag = true; + int n = reader.getAttributeCount(); + for(int i = 0; i < n; i++) { + String name = reader.getAttributeLocalName(i); + commonNameAndValue.put(name, reader.getAttributeValue(i)); + } + } + if (objectFlag) { + + // add columnValues + if ("V".equalsIgnoreCase(localName)) { + String indexStr = getXMLAttribute(reader, "i"); + if(indexStr == null) { + log.error("ERROR: illegal value index"); + continue; + } + index = Integer.parseInt(indexStr); + String name = pmNames.get(index); + if(name == null){ + log.error("illegal data: valueIndex="+index); + continue; + } + + String value = reader.getElementText().trim(); + pmDatas.put(name, value); + } + if ("CV".equalsIgnoreCase(localName)) { + + String indexStr = getXMLAttribute(reader, "i"); + if(indexStr == null) { + log.error("ERROR: illegal value index"); + continue; + } + index = Integer.parseInt(indexStr); + + currentMea = pmNames.get(index); + if(currentMea == null){ + log.error("illegal data: valueIndex="+index); + continue; + } + } + + if ("SN".equalsIgnoreCase(localName)) { + subName = reader.getElementText().trim(); + + } + if ("SV".equalsIgnoreCase(localName)) { + String subValue = reader.getElementText().trim(); +// pmDatas.put(currentMea+subName, subValue); + pmDatas.put(subName, subValue); + } + } + } + + } + + break; + case XMLStreamConstants.CHARACTERS: + // ... + break; + case XMLStreamConstants.END_ELEMENT: + // ... + endLocalName = reader.getLocalName(); + if("Object".equalsIgnoreCase(endLocalName)){ + objectFlag = false; + pmDatas.putAll(commonNameAndValue); + try { + pmResultChannel.put(pmDatas); + + } catch (InterruptedException e) { + log.error("collectResultChannel.put(resultMap) error ",e); + } +// System.out.println(pmDatas); +// pmDatas.clear(); + } + if (endLocalName.equalsIgnoreCase("PmData")) { + pmDataFlag = false; + } + + if (endLocalName.equalsIgnoreCase("PmName")) { + pmNameFlag = false; + } + if (endLocalName.equalsIgnoreCase("Measurements")) { + // a measurement over + measurementStart = false; + } + + if("FileHeader".equalsIgnoreCase(endLocalName)){ + fileHeaderStart = false; + } + break; + } + }catch (Exception e){ + log.error("",e); + event = reader.next(); + } + } + + } catch (Exception e) { + log.error("processPMXml is Exception ",e); + return false; + } finally{ + try{ + if(reader != null)reader.close(); + if(isr!= null)isr.close(); + if(fis != null)fis.close(); + }catch (Exception e) { + e.printStackTrace(); + } + } + return true; + } + + private String getXMLAttribute(XMLStreamReader reader, String obj) { + String res = null; + if(obj == null || reader == null){ + return res; + } + int n = reader.getAttributeCount(); + for(int i = 0; i < n; i++) { + String name = reader.getAttributeLocalName(i); + if(obj.equalsIgnoreCase(name)){ + res = reader.getAttributeValue(i); + } + } + return res; + } + public boolean processPMCsv(File tempfile) { FileInputStream brs = null; @@ -175,9 +384,7 @@ public class TaskThread implements Runnable{ for(String name : names){ columnNames.add(name); } - -// xmlPathAndFileName = this.setColumnNames(nename, columnNames,type); - + String valueLine = ""; List<String> valuelist = new ArrayList<String>(); @@ -668,6 +875,7 @@ public class TaskThread implements Runnable{ //login try { + log.info("ftp login ,ip=["+ip+"] port=["+port+"] user=["+user+"]password=["+password+"]"); ftpClient.login(ip, Integer.parseInt(port), user, password, "GBK", Boolean.parseBoolean(passivemode), 5*60*1000); } catch (Exception e) { log.error("login fail,ip=["+ip+"] port=["+port+"] user=["+user+"]password=["+password+"]"+StringUtil.getStackTrace(e)); @@ -680,27 +888,42 @@ public class TaskThread implements Runnable{ String []FPath = dir.split(";"); for(int i=0;i<FPath.length;i++){ int oldSize = searchExprList.size(); - String conpath = FPath[i]; + String conpath = FPath[i] + collectVo.getMatch(); Hashtable<String,String> varMap = new Hashtable<String,String>(); - long[] d = DateUtil.getScanScope(new Date(), 900); + long collectPeriod = 900; + try { + collectPeriod = Long.parseLong(collectVo.getGranularity())*60; + log.info("collectPeriod =["+collectPeriod+"]"); + } catch (NumberFormatException e) { + e.printStackTrace(); + } + long[] d = DateUtil.getScanScope(new Date(), collectPeriod); searchExprList.add(VarExprParser.replaceVar(conpath,d[0],d[1])); varMap.clear(); varMap = null; - log.info("["+conpath+"],result["+(searchExprList.size()-oldSize)+"] path"); + log.info("["+conpath+"] result["+(searchExprList.size()-oldSize)+"] path"); conpath = null; } - searchExprList =getLocalPathNoRegular(searchExprList); + String nowdir = null; + try { + nowdir = ftpClient.pwd(); + searchExprList =getPathNoRegular(searchExprList,ftpClient); + } catch (Exception e1) { + log.error(" collect fail ",e1); + return fileList; + } List<AFtpRemoteFile> remoteFiles = new ArrayList<AFtpRemoteFile>(); for(String expr :searchExprList){ + ftpClient.chdir(nowdir); String keys[] = parseExprKeys(expr); String ftpRegular = keys[1]; String ftpDir = keys[0]; - boolean cdsucess = ftpClient.chdir(expr); + boolean cdsucess = ftpClient.chdir(ftpDir); if(cdsucess){ AFtpRemoteFile[] arf = (AFtpRemoteFile[]) ftpClient.list(); - log.info(" list ["+ftpDir+"],result["+(arf==null?"null":arf.length)+"] files"); + log.info(" list ["+ftpDir+"] result["+(arf==null?"null":arf.length)+"] files"); //filter rfileFilter(remoteFiles,arf,ftpRegular); @@ -737,7 +960,7 @@ public class TaskThread implements Runnable{ } }else{ - log.error("chdir is faill dir =["+dir+"]"); + log.error("cd dir is faill dir =["+ftpDir+"]"); } } @@ -792,7 +1015,8 @@ public class TaskThread implements Runnable{ return dirkeys; } - public List<String> getLocalPathNoRegular(List<String> searchExprList){ + + public List<String> getPathNoRegular(List<String> searchExprList,FTPInterface ftpCache) throws Exception{ boolean isregular = false; List<String> regularList = new ArrayList<String>(); for(String regular : searchExprList){ @@ -800,26 +1024,37 @@ public class TaskThread implements Runnable{ try{ lpattern = Pattern.compile("(.*/)<([^/]+)>(/.*)"); }catch (Exception e) { - log.info("["+regular+"]compile fails:"+e.getMessage()); + log.error("["+regular+"]compile fails:"+e.getMessage()); + e.printStackTrace(); } Matcher matcher = lpattern.matcher(regular); if(matcher.find()){ isregular = true; String parpath = matcher.group(1); - File[] arryFile = new File(parpath).listFiles(); - for(File file :arryFile){ - if(file.isDirectory()&&file.getName().matches(matcher.group(2))){ - regularList.add(matcher.group(1)+file.getName()+matcher.group(3)); + try{ + boolean isin = ftpCache.chdir(parpath); + if(isin){ + log.info("cd dir [" + parpath + "] sucess"); + }else{ + log.error("cd dir [" + parpath + "] fail"); + } + }catch(Exception e){ + log.error(" cd dir ["+parpath+"]fail",e); + throw e; + } + RemoteFile[] remotef = ftpCache.list(); + for(RemoteFile aremote :remotef){ + if(aremote.isDirectory()&&aremote.getFileName().matches(matcher.group(2))){ + regularList.add(matcher.group(1)+aremote.getFileName()+matcher.group(3)); } } }else{ regularList.add(regular); - } - + } } if(isregular==true){ - getLocalPathNoRegular(regularList); + getPathNoRegular(regularList,ftpCache); } return regularList; } diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/AlarmManager.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/AlarmManager.java index b34c6c5..38ee12d 100644 --- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/AlarmManager.java +++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/AlarmManager.java @@ -49,6 +49,8 @@ public class AlarmManager extends DriverThread{ if(CollectVo != null){ CollectVo.setEmsName(emsInfo.getName()); collectVos.add(CollectVo); + }else{ + log.error("emsInfo.getCollectVoByType(EMS_RESOUCE) result CollectVo = null emsInfo ="+emsInfo); } } @@ -56,6 +58,7 @@ public class AlarmManager extends DriverThread{ AlarmTaskThread alarm = new AlarmTaskThread(collectVo); alarm.setName(collectVo.getIP()+collectVo.getPort()); alarm.start(); + log.info("AlarmTaskThread is start"); } } diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/AlarmTaskThread.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/AlarmTaskThread.java index ffc1822..d964f32 100644 --- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/AlarmTaskThread.java +++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/AlarmTaskThread.java @@ -21,7 +21,6 @@ import java.io.IOException; import java.net.Socket; import java.net.SocketException; import java.net.UnknownHostException; -import java.util.Set; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; @@ -31,8 +30,6 @@ import org.onap.vfc.nfvo.emsdriver.commons.utils.StringUtil; import org.onap.vfc.nfvo.emsdriver.messagemgr.MessageChannel; import org.onap.vfc.nfvo.emsdriver.messagemgr.MessageChannelFactory; -import com.alibaba.fastjson.JSONObject; - public class AlarmTaskThread extends Thread{ public Log log = LogFactory.getLog(AlarmTaskThread.class); @@ -93,7 +90,8 @@ public class AlarmTaskThread extends Thread{ while (retString == null && !this.isStop) { msg = MessageUtil.readOneMsg(is); - + log.debug("msg = "+msg.toString(true)); + log.info("msg.getMsgType().name = "+msg.getMsgType().name); if("ackLoginAlarm".equalsIgnoreCase(msg.getMsgType().name)){ log.debug("receive login ack"); boolean suc = this.ackLoginAlarm(msg); @@ -150,7 +148,7 @@ public class AlarmTaskThread extends Thread{ log.error(StringUtil.getStackTrace(e)); } } - log.debug("socket connect host=" + host + ", port=" + port); + log.info("socket connect host=" + host + ", port=" + port); try { int portInt = Integer.parseInt(port); socket = new Socket(host, portInt); @@ -268,7 +266,7 @@ public class AlarmTaskThread extends Thread{ close(); time++; try { - Thread.sleep(1000 * 10); + Thread.sleep(1000 * 30); init(); return; } catch (Exception e) { diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/HeartBeat.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/HeartBeat.java index 9b25298..96a301d 100644 --- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/HeartBeat.java +++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/collector/alarm/HeartBeat.java @@ -41,19 +41,19 @@ public class HeartBeat extends Thread{ } public void run(){ - log.debug("HeartBeat start heartStr:"+heartStr.toString(false)); + log.info("HeartBeat start heartStr:"+heartStr.toString(false)); this.stop=false; try { while(!this.isStop()){ out = new BufferedOutputStream(socket.getOutputStream()); MessageUtil.writeMsg(heartStr,out); - log.debug("send HeartBeat heartStr:"+heartStr.toString(false)); + log.info("send HeartBeat heartStr:"+heartStr.toString(false)); Thread.sleep(Constant.ONEMINUTE); } } catch (Exception e) { log.error("send HeartBeat fail ",e); } - log.debug("HeartBeat thread stop"); + log.info("HeartBeat thread stop"); } diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/constant/Constant.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/constant/Constant.java index 6c08879..50649a4 100644 --- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/constant/Constant.java +++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/constant/Constant.java @@ -22,18 +22,19 @@ public class Constant { public static String SYS_HOME = System.getenv("RUNHOME")==null?System.getProperty("user.dir"):System.getenv("RUNHOME"); public static String SYS_CFG = SYS_HOME + File.separator + "conf" + File.separator; - public static String SYS_DATA = SYS_HOME + "data" + File.separator; + public static String SYS_DATA = SYS_HOME + File.separator + "data" + File.separator; public static String SYS_DATA_TEMP = SYS_DATA + File.separator + "temp" + File.separator; public static String SYS_DATA_RESULT = SYS_DATA + File.separator + "RESULT" + File.separator; - public static String COLLECT_TYPE_CM = "ems-resource"; - public static String COLLECT_TYPE_PM = "ems-performance"; - public static String COLLECT_TYPE_ALARM = "ems-alarm"; + public static String COLLECT_TYPE_CM = "EMS_RESOUCE"; + public static String COLLECT_TYPE_PM = "EMS_PERFORMANCE"; + public static String COLLECT_TYPE_ALARM = "EMS_ALARM"; public static String ENCODING_UTF8 = "UTF-8"; public static String ENCODING_GBK = "GBK"; public static final String COLLECT_CHANNEL_KEY = "COLLECT_CHANNEL_KEY"; public static final String COLLECT_RESULT_CHANNEL_KEY = "COLLECT_RESULT_CHANNEL_KEY"; + public static final String COLLECT_RESULT_PM_CHANNEL_KEY = "COLLECT_RESULT_PM_CHANNEL_KEY"; public static final String RESULT_CHANNEL_KEY = "RESULT_CHANNEL_KEY"; diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/ftp/AFtpRemoteFile.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/ftp/AFtpRemoteFile.java index 3d3a27d..8692687 100644 --- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/ftp/AFtpRemoteFile.java +++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/ftp/AFtpRemoteFile.java @@ -37,4 +37,8 @@ public class AFtpRemoteFile implements RemoteFile{ public String getAbsFileName() { return currDir.concat(getFileName()); } + + public boolean isDirectory() { + return ftpFile.isDirectory(); + } }
\ No newline at end of file diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/ftp/FTPInterface.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/ftp/FTPInterface.java index ee9c3fb..ceca30f 100644 --- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/ftp/FTPInterface.java +++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/ftp/FTPInterface.java @@ -15,6 +15,8 @@ */ package org.onap.vfc.nfvo.emsdriver.commons.ftp; +import java.io.IOException; + public interface FTPInterface { /** @@ -38,6 +40,8 @@ public interface FTPInterface { public RemoteFile[] list(); + public String pwd() throws IOException; + // public RemoteFile[] list(String dir); // public boolean store(String localFile,String remoteFile); diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/ftp/FTPSrv.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/ftp/FTPSrv.java index fdb838f..4f987a5 100644 --- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/ftp/FTPSrv.java +++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/ftp/FTPSrv.java @@ -162,6 +162,13 @@ public class FTPSrv implements FTPInterface{ return ftpRemoteFiles; } + + @Override + public String pwd() throws IOException { + String returnValue = ftpClient.printWorkingDirectory(); + return returnValue; + } + // public boolean store(String localFile, String remoteFile) { // // boolean sucess = false; diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/ftp/RemoteFile.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/ftp/RemoteFile.java index 591c9e3..636c3ed 100644 --- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/ftp/RemoteFile.java +++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/ftp/RemoteFile.java @@ -17,4 +17,9 @@ package org.onap.vfc.nfvo.emsdriver.commons.ftp; public interface RemoteFile { + public String getFileName(); + + public String getAbsFileName(); + + public boolean isDirectory(); } diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/model/CrontabVo.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/model/CrontabVo.java index e76b039..66fbede 100644 --- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/model/CrontabVo.java +++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/model/CrontabVo.java @@ -114,6 +114,13 @@ public class CrontabVo { public void setRead_timeout(String read_timeout) { this.read_timeout = read_timeout; } + + @Override + public String toString() { + return "CrontabVo [type=" + type + ", crontab=" + crontab + ", match=" + + match + ", granularity=" + granularity + ", iscollect=" + + iscollect + ", read_timeout=" + read_timeout + "]"; + } diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/utils/DateUtil.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/utils/DateUtil.java index c0fddad..7cfd8fe 100644 --- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/utils/DateUtil.java +++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/commons/utils/DateUtil.java @@ -15,6 +15,8 @@ */ package org.onap.vfc.nfvo.emsdriver.commons.utils; +import java.text.ParseException; +import java.text.SimpleDateFormat; import java.util.Calendar; import java.util.Date; @@ -56,5 +58,27 @@ public class DateUtil { return new long[] {start,end}; } + + public static String TimeString(String timeString){ + if(timeString == null){ + return ""; + }else{ + timeString = timeString.replace("T", " "); + if(timeString.contains("+")){ + timeString = timeString.substring(0, timeString.indexOf("+")); + } + return timeString; + } + } + + public static String addTime(String srcTimeString,String period) throws ParseException{ + String finaldate = TimeString(srcTimeString); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + Date date = sdf.parse(finaldate); + Calendar calendar = Calendar.getInstance(); + calendar.setTime(date); + calendar.add(Calendar.MINUTE, Integer.valueOf(period)); + return sdf.format(calendar.getTime()); + } } diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/configmgr/ConfigurationManager.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/configmgr/ConfigurationManager.java index 923d2ed..f82160b 100644 --- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/configmgr/ConfigurationManager.java +++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/configmgr/ConfigurationManager.java @@ -87,7 +87,7 @@ public class ConfigurationManager extends DriverThread{ } } - private Map<String, CrontabVo> readCorntab() { + public Map<String, CrontabVo> readCorntab() { String path = Constant.SYS_CFG + "crontab.xml"; File cfg = new File(path); log.debug("start loading " + path); @@ -95,7 +95,6 @@ public class ConfigurationManager extends DriverThread{ log.debug("not exists " + path); return null; } - InputStream is = null; Map<String, CrontabVo> tmpcache = new HashMap<String, CrontabVo>(); @@ -116,7 +115,7 @@ public class ConfigurationManager extends DriverThread{ continue; } crontabVo.setType(type); - if("ems-alarm".equalsIgnoreCase(type)){ + if(Constant.COLLECT_TYPE_ALARM.equalsIgnoreCase(type)){ boolean iscollect = Boolean.parseBoolean(child.getAttributeValue("iscollect")); if(iscollect){ crontabVo.setIscollect(iscollect); @@ -135,13 +134,12 @@ public class ConfigurationManager extends DriverThread{ crontabVo.setMatch(child.getChildText("match")); crontabVo.setGranularity(child.getChildText("granularity")); } - tmpcache.put(type, crontabVo); + tmpcache.put(type.toUpperCase(), crontabVo); } } catch (Exception e) { log.error("load crontab.xml is error "+StringUtil.getStackTrace(e)); }finally{ - tmpcache.clear(); try { if(is != null){ is.close(); @@ -307,7 +305,7 @@ public class ConfigurationManager extends DriverThread{ // if(emsInfoCache.size() > 0){ - Thread.sleep(5*60*1000); + Thread.sleep(30*60*1000); }else{ Thread.sleep(60*1000); } @@ -327,7 +325,7 @@ public class ConfigurationManager extends DriverThread{ String msbAddress = properties.getProperty("msbAddress"); String emstUrl = properties.getProperty("esr_emsUrl"); //set emsId to url - String.format(emstUrl, emsId); + emstUrl = String.format(emstUrl, emsId); String getemstUrl = "http://"+msbAddress+emstUrl; String emsResult = HttpClientUtil.doGet(getemstUrl, Constant.ENCODING_UTF8); log.debug(getemstUrl+" result="+emsResult); @@ -344,7 +342,7 @@ public class ConfigurationManager extends DriverThread{ JSONObject collect = (JSONObject)obj; String system_type = (String)collect.get("system-type"); CollectVo collectVo = new CollectVo(); - if("ems-resource".equalsIgnoreCase(system_type)){ + if(Constant.COLLECT_TYPE_CM.equalsIgnoreCase(system_type)){ CrontabVo crontabVo = emsCrontab.get(system_type); if(crontabVo != null){ collectVo.setType(system_type); @@ -358,10 +356,12 @@ public class ConfigurationManager extends DriverThread{ collectVo.setMatch(crontabVo.getMatch()); collectVo.setPassive(collect.getString("passive")); collectVo.setGranularity(crontabVo.getGranularity()); + }else{ + log.error("emsCrontab.get(system_type) result crontabVo is null system_type=["+system_type+"] emsCrontabMap="+emsCrontab ); } - }else if("ems-performance".equalsIgnoreCase(system_type)){ + }else if(Constant.COLLECT_TYPE_PM.equalsIgnoreCase(system_type)){ CrontabVo crontabVo = emsCrontab.get(system_type); if(crontabVo != null){ collectVo.setType(system_type); @@ -375,8 +375,10 @@ public class ConfigurationManager extends DriverThread{ collectVo.setMatch(crontabVo.getMatch()); collectVo.setPassive(collect.getString("passive")); collectVo.setGranularity(crontabVo.getGranularity()); + }else{ + log.error("emsCrontab.get(system_type) result crontabVo is null system_type=["+system_type+"]" ); } - }else if("ems-alarm".equalsIgnoreCase(system_type)){ + }else if(Constant.COLLECT_TYPE_ALARM.equalsIgnoreCase(system_type)){ CrontabVo crontabVo = emsCrontab.get(system_type); if(crontabVo != null){ collectVo.setIscollect(crontabVo.isIscollect()); @@ -387,7 +389,7 @@ public class ConfigurationManager extends DriverThread{ collectVo.setPassword(collect.getString("password")); collectVo.setRead_timeout(crontabVo.getRead_timeout()); }else{ - log.error("emsCrontab.get(system_type) result crontabVo is null" ); + log.error("emsCrontab.get(system_type) result crontabVo is null system_type=["+system_type+"]"); } diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/HttpClientUtil.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/HttpClientUtil.java index f9484f8..8551b20 100644 --- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/HttpClientUtil.java +++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/HttpClientUtil.java @@ -129,12 +129,16 @@ public class HttpClientUtil { try{ httpClient = HttpClients.createDefault(); httpGet = new HttpGet(url); + httpGet.setHeader("Content-Type", "application/json"); + httpGet.setHeader("Accept", "application/json"); + httpGet.setHeader("X-TransactionId", "111"); + httpGet.setHeader("X-FromAppId", "ems-driver"); Base64 token = new Base64(); String authenticationEncoding = new String(token.encode(("AAI:AAI").getBytes())); httpGet.setHeader("Authorization", "Basic " + authenticationEncoding); CloseableHttpResponse response = httpClient.execute(httpGet); - log.info("doGet sucess url ="+url); + log.info("1 doGet sucess url ="+url); try { if(response != null){ HttpEntity resEntity = response.getEntity(); @@ -161,24 +165,4 @@ public class HttpClientUtil { } return result; } - - public static CloseableHttpClient createCloseableHttpClientWithBasicAuth(){ - // 创建HttpClientBuilder - HttpClientBuilder httpClientBuilder = HttpClientBuilder.create(); - // 设置BasicAuth - CredentialsProvider provider = new BasicCredentialsProvider(); - // Create the authentication scope - AuthScope scope = new AuthScope(AuthScope.ANY_HOST, AuthScope.ANY_PORT, AuthScope.ANY_REALM); - // Create credential pair,username and password - UsernamePasswordCredentials credentials = new UsernamePasswordCredentials("AAI", "AAI"); - // Inject the credentials - provider.setCredentials(scope, credentials); - // Set the default credentials provider - httpClientBuilder.setDefaultCredentialsProvider(provider); - // HttpClient - CloseableHttpClient closeableHttpClient = httpClientBuilder.build(); - - return closeableHttpClient; - } - }
\ No newline at end of file diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/NorthMessageMgr.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/NorthMessageMgr.java index 22dbe69..9c8802f 100644 --- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/NorthMessageMgr.java +++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/NorthMessageMgr.java @@ -41,7 +41,7 @@ import evel_javalibrary.att.com.EvelScalingMeasurement; public class NorthMessageMgr extends DriverThread{ private MessageChannel alarmChannel = MessageChannelFactory.getMessageChannel(Constant.RESULT_CHANNEL_KEY); - private MessageChannel collectChannel = MessageChannelFactory.getMessageChannel(Constant.COLLECT_CHANNEL_KEY); + private MessageChannel collectResultPMChannel = MessageChannelFactory.getMessageChannel(Constant.COLLECT_RESULT_PM_CHANNEL_KEY); private MessageChannel collectResultChannel = MessageChannelFactory.getMessageChannel(Constant.COLLECT_RESULT_CHANNEL_KEY); private ConfigurationInterface configurationInterface ; @@ -50,31 +50,40 @@ public class NorthMessageMgr extends DriverThread{ @Override public void dispose() { - Properties properties = configurationInterface.getProperties(); - String event_api_url = properties.getProperty("event_api_url"); - String port = properties.getProperty("port"); - String path = properties.getProperty("path"); - String topic = properties.getProperty("topic"); - String username = properties.getProperty("username"); - String password = properties.getProperty("password"); - String levelStr = properties.getProperty("level"); - if("debug".equals(levelStr)){ - level = Level.DEBUG; - }else{ - level = Level.INFO; - } - - //login north - event_api_url = "http://"+event_api_url; - try{ - AgentMain.evel_initialize(event_api_url, Integer.parseInt(port), - path,topic, - username, - password, - level); - log.info("AgentMain.evel_initialize sucess "); - } catch( Exception e ){ - log.error("AgentMain.evel_initialize fail ",e); + log.info("NorthMessageMgr Thread start threadStop="+threadStop); + try { + Properties properties = configurationInterface.getProperties(); + String event_api_url = properties.getProperty("event_api_url"); + String port = properties.getProperty("port"); + String path = properties.getProperty("path"); + String topic = properties.getProperty("topic"); + String username = properties.getProperty("username"); + String password = properties.getProperty("password"); + String levelStr = properties.getProperty("level"); + if("debug".equals(levelStr)){ + level = Level.DEBUG; + }else{ + level = Level.INFO; + } + + //login north + event_api_url = "http://"+event_api_url; + log.info("AgentMain.evel_initialize start event_api_url=["+event_api_url+"]port=["+port+"]path=["+path+"]" + + "topic=["+topic+"]username=["+username+"]password=["+password+"]level=["+level+"]"); + try{ + AgentMain.evel_initialize(event_api_url, Integer.parseInt(port), + path,topic, + username, + password, + level); + log.info("AgentMain.evel_initialize sucess "); + } catch( Exception e ){ + log.error("AgentMain.evel_initialize fail ",e); + }catch( Error e1 ){ + log.error("AgentMain.evel_initialize Error ",e1); + } + } catch (Exception e2) { + log.error("NorthMessageMgr start fail ",e2); } new HeatBeatTread().start(); @@ -84,6 +93,8 @@ public class NorthMessageMgr extends DriverThread{ new ResultMessageRecv().start(); new CollectMessageRecv().start(); + + log.error("NorthMessageMgr start sucess "); } @@ -98,7 +109,7 @@ public class NorthMessageMgr extends DriverThread{ header.evel_nfnamingcode_set("EMS-driver"); header.evel_nfcnamingcode_set("EMS-driver"); AgentMain.evel_post_event(header); - log.debug("HeatBeat send!"); + log.info("HeatBeat send!"); try { Thread.sleep(60*1000); } catch( Exception e ){ @@ -121,7 +132,7 @@ public class NorthMessageMgr extends DriverThread{ if(System.currentTimeMillis() - timeStamp > Constant.ONEMINUTE){ timeStamp = System.currentTimeMillis(); - log.debug("ALARM_CHANNEL Msg size :"+alarmChannel.size()); + log.info("ALARM_CHANNEL Msg size :"+alarmChannel.size()); } Object obj = alarmChannel.poll(); @@ -135,7 +146,9 @@ public class NorthMessageMgr extends DriverThread{ EvelFault evelFault = this.resultEvelFault(reagobj); //send + log.info("AgentMain.evel_post_event alarm start"); AgentMain.evel_post_event(evelFault); + log.info("AgentMain.evel_post_event alarm sucess"); }else{ log.error("AlarmMessageRecv receive Object = "+obj); } @@ -257,26 +270,30 @@ public class NorthMessageMgr extends DriverThread{ long timeStamp = System.currentTimeMillis(); public void run() { + log.info("CollectMessageRecv Thread is start threadStop="+threadStop); while(!threadStop){ try { if(System.currentTimeMillis() - timeStamp > Constant.ONEMINUTE){ timeStamp = System.currentTimeMillis(); - log.debug("COLLECT_CHANNEL_KEY Msg size :"+collectChannel.size()); + log.debug(Constant.COLLECT_RESULT_PM_CHANNEL_KEY+" Msg size :"+collectResultPMChannel.size()); } - Object obj = collectChannel.poll(); + Object obj = collectResultPMChannel.poll(); if(obj == null){ continue; } if(obj instanceof Map){ @SuppressWarnings("unchecked") Map<String,String> reMap = (Map<String,String>)obj; + log.debug("reMap ="+reMap); EvelScalingMeasurement evelScalingMeasurement = this.resultEvelScalingMeasurement(reMap); - + log.debug("evelScalingMeasurement="+evelScalingMeasurement); //send + log.info("AgentMain.evel_post_event start"); AgentMain.evel_post_event(evelScalingMeasurement); + log.info("AgentMain.evel_post_event sucess"); }else{ log.error("CollectMessageRecv receive Object = "+obj); @@ -284,6 +301,8 @@ public class NorthMessageMgr extends DriverThread{ } catch (Exception e) { log.error("CollectMessageRecv exception",e); + }catch (Error e) { + log.error("CollectMessageRecv Error",e); } } } diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/taskscheduler/CollectManager.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/taskscheduler/CollectManager.java index ad2bb03..f21f2fb 100644 --- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/taskscheduler/CollectManager.java +++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/taskscheduler/CollectManager.java @@ -61,8 +61,13 @@ public class CollectManager extends DriverThread{ } } - this.addCollectJob(collectVos); - log.info("addCollectJob is OK "); + if(collectVos.size() > 0){ + this.addCollectJob(collectVos); + log.info("1 addCollectJob is OK "); + }else{ + log.error("collectVos size is 0"); + } + }else{ log.error("configurationInterface = null,check spring.xml"); } diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/taskscheduler/QuartzManager.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/taskscheduler/QuartzManager.java index 5b9e2ba..ca62dc0 100644 --- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/taskscheduler/QuartzManager.java +++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/taskscheduler/QuartzManager.java @@ -60,6 +60,7 @@ public class QuartzManager { } sucess = true; + log.info("add job sucess cronExpression="+time); } catch (Exception e) { log.error("add job fail cronExpression="+time,e); sucess = false; diff --git a/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/collector/TaskThreadTest.java b/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/collector/TaskThreadTest.java index 4f4cbd2..f6d2b9b 100644 --- a/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/collector/TaskThreadTest.java +++ b/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/collector/TaskThreadTest.java @@ -32,13 +32,14 @@ import org.onap.vfc.nfvo.emsdriver.messagemgr.MessageChannelFactory; public class TaskThreadTest { private String csvPath = System.getProperty("user.dir")+"/data/" +"PM-ENB-EUTRANCELLNB-test.csv"; + private String xmlPath = System.getProperty("user.dir")+"/data/" +"PM-test.xml"; private String gzPath = System.getProperty("user.dir")+"/data/" +"PM-ENB-EUTRANCELLNB-testa.csv.gz"; private TaskThread taskThread; private List<File> list = null; @Before public void setUp() throws IOException { taskThread = new TaskThread(); - taskThread.pmResultChannel = MessageChannelFactory.getMessageChannel(Constant.COLLECT_CHANNEL_KEY); + taskThread.pmResultChannel = MessageChannelFactory.getMessageChannel(Constant.COLLECT_RESULT_PM_CHANNEL_KEY); Gzip gzip = new Gzip(); gzip.compress(csvPath, gzPath); } @@ -58,6 +59,13 @@ public class TaskThreadTest { assertTrue(re); } } + @Test + public void processPMXml(){ + File file = new File(xmlPath); + boolean re = taskThread.processPMXml(file); + assertTrue(re); + System.out.println(taskThread.pmResultChannel.size()); + } @Test public void parseFtpAndSendMessage(){ @@ -73,10 +81,6 @@ public class TaskThreadTest { taskThread.createMessage("zipName", "user", "pwd", "ip", "port", 122, "nename"); } - - - - @After public void setDown() throws IOException { new File(gzPath).delete(); diff --git a/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/configmgr/ConfigurationManagerTest.java b/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/configmgr/ConfigurationManagerTest.java index 68ff99d..575d3be 100644 --- a/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/configmgr/ConfigurationManagerTest.java +++ b/ems/boco/src/test/java/org/onap/vfc/nfvo/emsdriver/configmgr/ConfigurationManagerTest.java @@ -20,10 +20,12 @@ import static org.junit.Assert.assertTrue; import java.io.IOException; import java.util.List; +import java.util.Map; import java.util.Properties; import org.junit.Before; import org.junit.Test; +import org.onap.vfc.nfvo.emsdriver.commons.model.CrontabVo; import org.onap.vfc.nfvo.emsdriver.commons.model.EMSInfo; import org.onap.vfc.nfvo.emsdriver.configmgr.ConfigurationManager; @@ -60,5 +62,12 @@ public class ConfigurationManagerTest { assertNotNull(properties); } + @Test + public void readCorntab() { + + Map<String, CrontabVo> list = configurationManager.readCorntab(); + System.out.println(list); + assertTrue(list.size() >0); + } } diff --git a/ems/microservice-standalone/src/main/assembly/conf/config.properties b/ems/microservice-standalone/src/main/assembly/conf/config.properties index 70bd090..4207839 100644 --- a/ems/microservice-standalone/src/main/assembly/conf/config.properties +++ b/ems/microservice-standalone/src/main/assembly/conf/config.properties @@ -29,8 +29,8 @@ esr_emsUrl=/aai/v11/external-system/esr-ems-list/esr-ems/%s?depth=all #north -event_api_url= -port=30000 +event_api_url=http://127.0.0.1 +port=3000 username= password= level=debug diff --git a/ems/microservice-standalone/src/main/assembly/conf/crontab.xml b/ems/microservice-standalone/src/main/assembly/conf/crontab.xml index e6ef0aa..412160a 100644 --- a/ems/microservice-standalone/src/main/assembly/conf/crontab.xml +++ b/ems/microservice-standalone/src/main/assembly/conf/crontab.xml @@ -18,15 +18,15 @@ --> <scheduler> - <crontab type ="ems-resource" crontab=""> + <crontab type ="ems_resource" crontab=""> <match>*</match> <granularity>15</granularity> </crontab> - <crontab type ="ems-performance" crontab="0 0/15 * * * ?"> - <match>*</match> + <crontab type ="ems_performance" crontab="0 0/15 * * * ?"> + <match>/<*${s_year}${s_mon}${s_day}${s_hour}>/.*${s_year}${s_mon}${s_day}${s_hour}${s_min}.*</match> <granularity>15</granularity> </crontab> - <crontab type ="ems-alarm" iscollect = "true"> - <readtimeout>180000</readtimeout>; + <crontab type ="ems_alarm" iscollect="true"> + <readtimeout>18000</readtimeout>; </crontab> </scheduler>
\ No newline at end of file diff --git a/ems/microservice-standalone/src/main/assembly/conf/spring.xml b/ems/microservice-standalone/src/main/assembly/conf/spring.xml index 6813ce8..64f4ec9 100644 --- a/ems/microservice-standalone/src/main/assembly/conf/spring.xml +++ b/ems/microservice-standalone/src/main/assembly/conf/spring.xml @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="GBK"?> <!-- - Copyright 2017 BOCO Corporation. CMCC Technologies Co., Ltd + Copyright 2017 BOCO Corporation. CMCC Technologies Co., Ltd Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -19,7 +19,7 @@ --> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" - xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd" + xsi:schemaLocation="http://www.springframework.org/schema/beans classpath:/org/springframework/beans/factory/xml/spring-beans-4.0.xsd" default-lazy-init="true"> <bean id="configurationManager" class="org.onap.vfc.nfvo.emsdriver.configmgr.ConfigurationManager"> diff --git a/ems/microservice-standalone/src/main/assembly/run.bat b/ems/microservice-standalone/src/main/assembly/run.bat index 284f5f8..3c052ab 100755 --- a/ems/microservice-standalone/src/main/assembly/run.bat +++ b/ems/microservice-standalone/src/main/assembly/run.bat @@ -47,7 +47,7 @@ set date_time_string=%date_time_string:|=-% set jvm_opts=%jvm_opts% -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=%RUNHOME%logs\dump-dac-%date_time_string%.hprof
-set class_path=%RUNHOME%;%RUNHOME%boco-driver.jar
+set class_path=%RUNHOME%;%RUNHOME%boco-driver.jar;%RUNHOME%/3rdParty/evel_javalib2-0.0.1-SNAPSHOT.jar
echo ### jvm_opts: %jvm_opts%
echo ### class_path: %class_path%
diff --git a/ems/microservice-standalone/src/main/assembly/run.sh b/ems/microservice-standalone/src/main/assembly/run.sh index 2cb7d6b..6e16518 100755 --- a/ems/microservice-standalone/src/main/assembly/run.sh +++ b/ems/microservice-standalone/src/main/assembly/run.sh @@ -88,7 +88,7 @@ fi # JAVA_OPTS="$JAVA_OPTS -Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,address=$port,server=y,suspend=n" echo @JAVA_OPTS@ $JAVA_OPTS -class_path="$RUNHOME/:$RUNHOME/boco-driver.jar" +class_path="$RUNHOME/:$RUNHOME/boco-driver.jar:$RUNHOME/3rdParty/evel_javalib2-0.0.1-SNAPSHOT.jar" echo @class_path@ $class_path # Start -"$JAVA" $JAVA_OPTS -classpath "$class_path" org.onap.vfc.nfvo.emsdriver.EmsDriverApplication server "$RUNHOME/conf/emsdriver.yml" +"$JAVA" $JAVA_OPTS -classpath "$class_path" org.onap.vfc.nfvo.emsdriver.EmsDriverApplication server "$RUNHOME/conf/emsdriver.yml" |