summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/messagemgr/MessageChannel.java9
-rw-r--r--ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/messagemgr/MessageChannelFactory.java10
-rw-r--r--ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/HttpClientFactory.java3
-rw-r--r--ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/HttpClientUtil.java1
-rw-r--r--ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/NorthMessageMgr.java34
-rw-r--r--ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/service/CommandResource.java7
-rw-r--r--ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/serviceregister/MsbRestServiceProxy.java5
-rw-r--r--ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/taskscheduler/CollectManager.java29
-rw-r--r--ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/taskscheduler/QuartzManager.java18
9 files changed, 57 insertions, 59 deletions
diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/messagemgr/MessageChannel.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/messagemgr/MessageChannel.java
index 7ee159e..30d61d6 100644
--- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/messagemgr/MessageChannel.java
+++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/messagemgr/MessageChannel.java
@@ -18,6 +18,7 @@ package org.onap.vfc.nfvo.emsdriver.messagemgr;
import java.util.concurrent.BlockingQueue;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.TimeUnit;
+import java.io.IOException;
public class MessageChannel {
@@ -26,17 +27,17 @@ public class MessageChannel {
public MessageChannel(int size) {
if (size > 0) {
- queue = new LinkedBlockingQueue<Object>(size);
+ queue = new LinkedBlockingQueue<>(size);
} else {
- queue = new LinkedBlockingQueue<Object>();
+ queue = new LinkedBlockingQueue<>();
}
}
public MessageChannel() {
- queue = new LinkedBlockingQueue<Object>();
+ queue = new LinkedBlockingQueue<>();
}
- public void put(Object msg) throws InterruptedException {
+ public void put(Object msg) throws IOException {
while (!queue.offer(msg)) {
queue.poll();
}
diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/messagemgr/MessageChannelFactory.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/messagemgr/MessageChannelFactory.java
index 494620d..d3ae4d7 100644
--- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/messagemgr/MessageChannelFactory.java
+++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/messagemgr/MessageChannelFactory.java
@@ -20,9 +20,9 @@ import java.util.Map;
public class MessageChannelFactory {
- private static Map<String, MessageChannel> map = new HashMap<String, MessageChannel>();
+ private static Map<String, MessageChannel> map = new HashMap<>();
- public synchronized static MessageChannel getMessageChannel(String key, Integer size) {
+ public static synchronized MessageChannel getMessageChannel(String key, Integer size) {
if (map.get(key) != null) {
return map.get(key);
}
@@ -37,7 +37,7 @@ public class MessageChannelFactory {
return mc;
}
- public synchronized static MessageChannel getMessageChannel(String key) {
+ public static synchronized MessageChannel getMessageChannel(String key) {
if (map.get(key) != null) {
return map.get(key);
}
@@ -47,7 +47,7 @@ public class MessageChannelFactory {
return mc;
}
- public synchronized static boolean destroyMessageChannel(String key) {
+ public static synchronized boolean destroyMessageChannel(String key) {
if (map.get(key) != null) {
map.remove(key);
return true;
@@ -55,7 +55,7 @@ public class MessageChannelFactory {
return false;
}
- public synchronized static void clean() {
+ public static synchronized void clean() {
map.clear();
}
}
diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/HttpClientFactory.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/HttpClientFactory.java
index bc286fd..168b86d 100644
--- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/HttpClientFactory.java
+++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/client/HttpClientFactory.java
@@ -42,9 +42,8 @@ public class HttpClientFactory {
}
}).build();
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(sslContext);
- CloseableHttpClient httpclient = HttpClients.custom().setSSLSocketFactory(sslsf).build();
+ return HttpClients.custom().setSSLSocketFactory(sslsf).build();
- return httpclient;
}
}
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 3069a9c..5c844c6 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
@@ -28,7 +28,6 @@ import org.apache.http.impl.client.CloseableHttpClient;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
-import java.io.IOException;
/*
* HttpClient post request
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 179dcd5..1d618e5 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
@@ -52,7 +52,7 @@ public class NorthMessageMgr extends DriverThread {
log.info("NorthMessageMgr Thread start threadStop=" + threadStop);
try {
Properties properties = configurationInterface.getProperties();
- String event_api_url = properties.getProperty("event_api_url");
+ String eventApiUrl = properties.getProperty("event_api_url");
String port = properties.getProperty("port");
String path = properties.getProperty("path");
String topic = properties.getProperty("topic");
@@ -66,11 +66,11 @@ public class NorthMessageMgr extends DriverThread {
}
//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 + "]"
+ eventApiUrl = "http://" + eventApiUrl;
+ log.info("AgentMain.evel_initialize start event_api_url=[" + eventApiUrl + "]port=[" + port + "]path=[" + path + "]"
+ "topic=[" + topic + "]username=[" + username + /*"]password=[" + password +*/ "]level=[" + level + "]");
try {
- EVEL_ERR_CODES evecode = AgentMain.evel_initialize(event_api_url, Integer.parseInt(port),
+ EVEL_ERR_CODES evecode = AgentMain.evel_initialize(eventApiUrl, Integer.parseInt(port),
path, topic,
username,
password,
@@ -78,9 +78,7 @@ public class NorthMessageMgr extends DriverThread {
log.info("AgentMain.evel_initialize sucess EVEL_ERR_CODES=" + evecode);
} 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);
}
@@ -112,7 +110,7 @@ public class NorthMessageMgr extends DriverThread {
}
class HeatBeatTread extends Thread {
-
+ @Override
public void run() {
while (!threadStop) {
@@ -126,7 +124,6 @@ public class NorthMessageMgr extends DriverThread {
try {
Thread.sleep(60 * 1000L);//60 secs
} catch (Exception e) {
- // e.printStackTrace();
log.error("Unable to sleep the HB thread ", e);
}
} catch (Exception e) {
@@ -139,6 +136,7 @@ public class NorthMessageMgr extends DriverThread {
class AlarmMessageRecv extends Thread {
long timeStamp = System.currentTimeMillis();
+ @Override
public void run() {
while (!threadStop) {
@@ -249,6 +247,7 @@ public class NorthMessageMgr extends DriverThread {
class ResultMessageRecv extends Thread {
long timeStamp = System.currentTimeMillis();
+ @Override
public void run() {
while (!threadStop) {
@@ -282,6 +281,7 @@ public class NorthMessageMgr extends DriverThread {
class CollectMessageRecv extends Thread {
long timeStamp = System.currentTimeMillis();
+ @Override
public void run() {
log.info("CollectMessageRecv Thread is start threadStop=" + threadStop);
while (!threadStop) {
@@ -314,17 +314,15 @@ public class NorthMessageMgr extends DriverThread {
} catch (Exception e) {
log.error("CollectMessageRecv exception", e);
- } /*catch (Error e) {
- log.error("CollectMessageRecv Error", e);
- }*/
- }
+ }
+ }
}
private EvelScalingMeasurement resultEvelScalingMeasurement(Map<String, String> reMap) {
String evname = "Mfvs_" + reMap.get("ElementType") + reMap.get("ObjectType");
String evid = reMap.get("StartTime") + reMap.get("ObjectType") + reMap.get("rmUID");
- int Period = Integer.parseInt(reMap.get("Period") != null ? reMap.get("Period") : "15");
- EvelScalingMeasurement sm = new EvelScalingMeasurement(Period, evname, evid);
+ int period = Integer.parseInt(reMap.get("Period") != null ? reMap.get("Period") : "15");
+ EvelScalingMeasurement sm = new EvelScalingMeasurement(period, evname, evid);
for (String key : reMap.keySet()) {
sm.evel_measurement_custom_measurement_add(reMap.get("ElementType"), key, reMap.get(key));
@@ -336,9 +334,9 @@ public class NorthMessageMgr extends DriverThread {
sm.evel_header_type_set("applicationVnf");
String rmUID = reMap.get("rmUID");
sm.evel_reporting_entity_id_set(rmUID.substring(0, 9));//
- String Dn = reMap.get("Dn");
- if (Dn != null)
- sm.evel_reporting_entity_name_set(Dn.substring(0, Dn.indexOf(";") > -1 ? Dn.indexOf(";") : Dn.length()));//0 is valid index
+ String dn = reMap.get("Dn");
+ if (dn != null)
+ sm.evel_reporting_entity_name_set(dn.substring(0, dn.indexOf(";") > -1 ? dn.indexOf(";") : dn.length()));//0 is valid index
else {
// decide the flow if Dn is null
diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/service/CommandResource.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/service/CommandResource.java
index 93a6ea8..692048b 100644
--- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/service/CommandResource.java
+++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/northbound/service/CommandResource.java
@@ -25,18 +25,21 @@ import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.MediaType;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
@Path("/ems-driver")
@Produces(MediaType.APPLICATION_JSON)
@Api(tags = {"ems-driver TestResource"})
public class CommandResource {
+ private Log log = LogFactory.getLog(CommandResource.class);
@GET
@Timed
@ApiOperation(value = "get ems-driver Info")
public String executeCommand(@QueryParam("command") String command) {
-
- System.out.println("receiver command = " + command);
+ log.info("receiver command = " + command);
return command;
}
diff --git a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/serviceregister/MsbRestServiceProxy.java b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/serviceregister/MsbRestServiceProxy.java
index 437744c..dbfae02 100644
--- a/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/serviceregister/MsbRestServiceProxy.java
+++ b/ems/boco/src/main/java/org/onap/vfc/nfvo/emsdriver/serviceregister/MsbRestServiceProxy.java
@@ -31,8 +31,7 @@ public class MsbRestServiceProxy {
String url = MsbConfiguration.getMsbAddress() + Constant.MSBAPIROOTDOMAIN;
String registerObj = JSON.toJSONString(registerInfo);
- String registerResponse = HttpClientUtil.doPost(url, registerObj, Constant.ENCODING_UTF8);
- return registerResponse;
+ return HttpClientUtil.doPost(url, registerObj, Constant.ENCODING_UTF8);
}
public static void unRegiserService(String serviceName, String version, String ip, String port) {
@@ -41,7 +40,7 @@ public class MsbRestServiceProxy {
}
public static List<String> queryService(String serviceName, String version) {
- List<String> ipList = new ArrayList<String>();
+ List<String> ipList = new ArrayList<>();
String url = MsbConfiguration.getMsbAddress() + Constant.MSBAPIROOTDOMAIN + "/" + serviceName + "/version/" + version;
String response = HttpClientUtil.doGet(url, Constant.ENCODING_UTF8);
if (response != null && !"".equals(response)) {
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 8515dc7..9e8aa26 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
@@ -1,4 +1,4 @@
-/*
+/**
* Copyright 2017 BOCO Corporation. CMCC Technologies Co., Ltd
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -33,10 +33,10 @@ public class CollectManager extends DriverThread {
public void dispose() {
if (configurationInterface != null) {
List<EMSInfo> emsInfos = configurationInterface.getAllEMSInfo();
- while (isRun() && emsInfos.size() == 0) {
+ while (isRun() && emsInfos.isEmpty()) {
emsInfos = configurationInterface.getAllEMSInfo();
- if (emsInfos.size() == 0) {
+ if (emsInfos.isEmpty()) {
try {
Thread.sleep(1000);
} catch (Exception e) {
@@ -46,24 +46,24 @@ public class CollectManager extends DriverThread {
}
- List<CollectVo> collectVos = new ArrayList<CollectVo>();
+ List<CollectVo> collectVos = new ArrayList<>();
for (EMSInfo emsInfo : emsInfos) {
//cm
- CollectVo CollectVoCm = emsInfo.getCollectVoByType(Constant.COLLECT_TYPE_CM);
- if (CollectVoCm != null) {
- CollectVoCm.setEmsName(emsInfo.getName());
- collectVos.add(CollectVoCm);
+ CollectVo collectVoCm = emsInfo.getCollectVoByType(Constant.COLLECT_TYPE_CM);
+ if (collectVoCm != null) {
+ collectVoCm.setEmsName(emsInfo.getName());
+ collectVos.add(collectVoCm);
}
//pm
- CollectVo CollectVoPm = emsInfo.getCollectVoByType(Constant.COLLECT_TYPE_PM);
- if (CollectVoPm != null) {
- CollectVoPm.setEmsName(emsInfo.getName());
- collectVos.add(CollectVoPm);
+ CollectVo collectVoPm = emsInfo.getCollectVoByType(Constant.COLLECT_TYPE_PM);
+ if (collectVoPm != null) {
+ collectVoPm.setEmsName(emsInfo.getName());
+ collectVos.add(collectVoPm);
}
}
- if (collectVos.size() > 0) {
+ if (!collectVos.isEmpty()) {
this.addCollectJob(collectVos);
log.info("1 addCollectJob is OK ");
} else {
@@ -79,8 +79,7 @@ public class CollectManager extends DriverThread {
for (CollectVo collectVo : collectVos) {
try {
String jobName = collectVo.getEmsName() + "_" + collectVo.getType() + collectVo.getIP();
- Job job = new CollectOderJob();
- String jobClass = job.getClass().getName();
+ String jobClass = CollectOderJob.class.getName();
String time = collectVo.getCrontab();
if (time != null && !"".equals(time)) {
QuartzManager.addJob(jobName, jobClass, time, collectVo);
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 c182c2a..cd1e4af 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
@@ -29,8 +29,8 @@ public class QuartzManager {
private static Log log = LogFactory.getFactory().getInstance(QuartzManager.class);
private static SchedulerFactory gSchedulerFactory = new StdSchedulerFactory();
- private static String JOB_GROUP_NAME = "EXTJWEB_JOBGROUP_NAME";
- private static String TRIGGER_GROUP_NAME = "EXTJWEB_TRIGGERGROUP_NAME";
+ private static String jobGroupName = "EXTJWEB_JOBGROUP_NAME";
+ private static String triggerGroupName = "EXTJWEB_TRIGGERGROUP_NAME";
/**
* @param jobName
@@ -43,9 +43,9 @@ public class QuartzManager {
boolean sucess = false;
try {
Scheduler sched = gSchedulerFactory.getScheduler();
- JobDetail jobDetail = new JobDetail(jobName, JOB_GROUP_NAME, Class.forName(jobClass));
+ JobDetail jobDetail = new JobDetail(jobName, jobGroupName, Class.forName(jobClass));
- CronTrigger trigger = new CronTrigger(jobName, TRIGGER_GROUP_NAME);
+ CronTrigger trigger = new CronTrigger(jobName, triggerGroupName);
trigger.setCronExpression(time);
jobDetail.getJobDataMap().put("collectVo", collectVo);
@@ -73,13 +73,13 @@ public class QuartzManager {
boolean sucess = false;
try {
Scheduler sched = gSchedulerFactory.getScheduler();
- CronTrigger trigger = (CronTrigger) sched.getTrigger(jobName, TRIGGER_GROUP_NAME);
+ CronTrigger trigger = (CronTrigger) sched.getTrigger(jobName, triggerGroupName);
if (trigger == null) {
return false;
}
String oldTime = trigger.getCronExpression();
if (!oldTime.equalsIgnoreCase(time)) {
- JobDetail jobDetail = sched.getJobDetail(jobName, JOB_GROUP_NAME);
+ JobDetail jobDetail = sched.getJobDetail(jobName, jobGroupName);
Class<Job> objJobClass = jobDetail.getJobClass();
String jobClass = objJobClass.getName();
@@ -105,9 +105,9 @@ public class QuartzManager {
boolean sucess = false;
try {
Scheduler sched = gSchedulerFactory.getScheduler();
- sched.pauseTrigger(jobName, TRIGGER_GROUP_NAME);
- sched.unscheduleJob(jobName, TRIGGER_GROUP_NAME);
- sched.deleteJob(jobName, JOB_GROUP_NAME);
+ sched.pauseTrigger(jobName, triggerGroupName);
+ sched.unscheduleJob(jobName, triggerGroupName);
+ sched.deleteJob(jobName, jobGroupName);
sucess = true;
} catch (Exception e) {
sucess = false;