summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestDeviceManagerAdapterManagerImpl.java65
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPFaultVESMsgConsumer.java8
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPPNFRegVESMsgConsumer.java10
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumer.java1
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java35
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerMain.java31
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/FaultConfig.java10
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/FaultNotificationClient.java6
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/GeneralConfig.java5
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MountpointRegistrarImpl.java2
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFMountPointClient.java23
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFRegistrationConfig.java10
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/PNFRegistrationConfigTest.java3
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestFaultConfig.java3
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestFaultNotificationClient.java6
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestPNFMountPointClient.java6
-rw-r--r--sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/Constants.java35
-rw-r--r--sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeConnectListenerImpl.java18
-rw-r--r--sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeStateListenerImpl.java28
-rw-r--r--sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStatePublisher.java7
-rw-r--r--sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStateVESMessageFormatter.java39
-rw-r--r--sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/VESEvent.java2
-rw-r--r--sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/VESNotificationFieldsPOJO.java12
-rw-r--r--sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointNodeStateListenerImpl.java1
-rw-r--r--sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointStateProviderImpl.java11
25 files changed, 168 insertions, 209 deletions
diff --git a/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestDeviceManagerAdapterManagerImpl.java b/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestDeviceManagerAdapterManagerImpl.java
index 5f79d943a..3f53abfa8 100644
--- a/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestDeviceManagerAdapterManagerImpl.java
+++ b/sdnr/wt/devicemanager-adapter-manager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/adaptermanager/test/TestDeviceManagerAdapterManagerImpl.java
@@ -17,79 +17,26 @@
*/
package org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.test;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.nio.file.Paths;
+import static org.mockito.Mockito.mock;
import org.junit.After;
-import org.junit.Before;
import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.adaptermanager.impl.DeviceManagerAdapterManagerImpl;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService;
public class TestDeviceManagerAdapterManagerImpl {
- private static Path KARAF_ETC = Paths.get("etc");
- private static final Logger LOG = LoggerFactory.getLogger(TestDeviceManagerAdapterManagerImpl.class);
DeviceManagerAdapterManagerImpl devMgrAdapterManager;
- @Before
- public void init() throws InterruptedException, IOException {
- /*System.out.println("Logger: " + LOG.getClass().getName() + " " + LOG.getName());
- Path etc = KARAF_ETC;
- delete(etc);
-
- System.out.println("Create empty:" + etc.toString());
- Files.createDirectories(etc);*/
- }
-
@Test
public void test() throws Exception {
devMgrAdapterManager = new DeviceManagerAdapterManagerImpl();
- /*DeviceManagerImpl devMgr = new DeviceManagerImpl();
-
- try {
- devMgr.init();
- devMgrOran.setNetconfNetworkElementService(devMgr);
- devMgrOran.init();
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }*/
- /*
- * devMgrOran.setNetconfNetworkElementService(null); devMgrOran.init();
- * NetconfNetworkElementService netConfNetworkElementService =
- * mock(NetconfNetworkElementService.class); devMgrOran =
- * mock(DeviceManagerORanImpl.class);
- * when(netConfNetworkElementService.registerNetworkElementFactory(new
- * ORanNetworkElementFactory())).thenReturn(null);
- */
-
+ NetconfNetworkElementService netConfNetworkElementService = mock(NetconfNetworkElementService.class);
+ devMgrAdapterManager.setNetconfNetworkElementService(netConfNetworkElementService);
+ devMgrAdapterManager.init();
}
@After
public void cleanUp() throws Exception {
devMgrAdapterManager.close();
}
-
- private static void delete(Path etc) throws IOException {
- if (Files.exists(etc)) {
- System.out.println("Found, removing:" + etc.toString());
- delete(etc.toFile());
- }
- }
-
- private static void delete(File f) throws IOException {
- if (f.isDirectory()) {
- for (File c : f.listFiles()) {
- delete(c);
- }
- }
- if (!f.delete()) {
- throw new FileNotFoundException("Failed to delete file: " + f);
- }
- }
-}
+ }
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPFaultVESMsgConsumer.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPFaultVESMsgConsumer.java
index b0227da6f..649f9a86f 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPFaultVESMsgConsumer.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPFaultVESMsgConsumer.java
@@ -29,7 +29,6 @@ public class DMaaPFaultVESMsgConsumer extends DMaaPVESMsgConsumerImpl {
private static final Logger LOG = LoggerFactory.getLogger(DMaaPFaultVESMsgConsumer.class);
- //private static int faultCounter = 0;
private static final String DEFAULT_SDNRUSER = "admin";
private static final String DEFAULT_SDNRPASSWD = "admin";
@@ -46,6 +45,7 @@ public class DMaaPFaultVESMsgConsumer extends DMaaPVESMsgConsumerImpl {
String faultObjectId;
String faultReason;
String faultSeverity;
+ String vesDomain;
int faultSequence;
ObjectMapper oMapper = new ObjectMapper();
JsonNode dmaapMessageRootNode;
@@ -53,6 +53,11 @@ public class DMaaPFaultVESMsgConsumer extends DMaaPVESMsgConsumerImpl {
LOG.info("Fault VES Message is - {}", msg);
try {
dmaapMessageRootNode = oMapper.readTree(msg);
+ vesDomain = dmaapMessageRootNode.at("/event/commonEventHeader/domain").textValue();
+ if (!vesDomain.equalsIgnoreCase("fault")) {
+ LOG.warn("Received {} domain VES Message in DMaaP Fault topic, ignoring it", vesDomain);
+ return;
+ }
faultNodeId = dmaapMessageRootNode.at("/event/commonEventHeader/sourceName").textValue();
faultOccurrenceTime =
dmaapMessageRootNode.at("/event/faultFields/alarmAdditionalInformation/eventTime").textValue();
@@ -60,7 +65,6 @@ public class DMaaPFaultVESMsgConsumer extends DMaaPVESMsgConsumerImpl {
faultReason = dmaapMessageRootNode.at("/event/faultFields/specificProblem").textValue();
faultSeverity = dmaapMessageRootNode.at("/event/faultFields/eventSeverity").textValue();
faultSequence = dmaapMessageRootNode.at("/event/commonEventHeader/sequence").intValue();
- //faultCounter++;
if (faultSeverity.equalsIgnoreCase("critical")) {
faultSeverity = SeverityType.Critical.toString();
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPPNFRegVESMsgConsumer.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPPNFRegVESMsgConsumer.java
index c412a7a91..b64f6c689 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPPNFRegVESMsgConsumer.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPPNFRegVESMsgConsumer.java
@@ -100,8 +100,14 @@ public class DMaaPPNFRegVESMsgConsumer extends DMaaPVESMsgConsumerImpl {
LOG.debug("Setting RESTConf Authorization values - {} : {}", sdnrUser, sdnrPasswd);
mountpointClient.setAuthorization(sdnrUser, sdnrPasswd);
- mountpointClient.pnfMountPointCreate(pnfId, pnfIPv4Address, pnfCommProtocol, pnfKeyId, pnfUsername,
- pnfPasswd, pnfCommPort);
+ if ((null != pnfId) && (null != pnfIPv4Address) && (null != pnfCommProtocol) && (null != pnfUsername)
+ && (null != pnfCommPort)) {
+ mountpointClient.pnfMountPointCreate(pnfId, pnfIPv4Address, pnfCommProtocol, pnfKeyId, pnfUsername,
+ pnfPasswd, pnfCommPort);
+ } else {
+ LOG.warn("One of the mandatory fields has a null value - pnfId = {} : pnfIPv4Address = {} : pnfCommProtocol = {} : pnfUsername {} : "
+ + "pnfCommPort {}", pnfId, pnfIPv4Address, pnfCommProtocol, pnfUsername, pnfCommPort, "- not invoking mountpoint creation");
+ }
} catch (IOException e) {
LOG.info("Cannot parse json object, ignoring the received PNF Registration VES Message. Reason: {}",
e.getMessage());
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumer.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumer.java
index 25f737583..2874c906f 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumer.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumer.java
@@ -22,7 +22,6 @@ import java.util.Properties;
public abstract interface DMaaPVESMsgConsumer extends Runnable {
- //public abstract void init(Properties baseProperties, String consumerPropertiesPath);
public abstract void init(Properties baseProperties);
public abstract void processMsg(String msg) throws Exception;//Implement something like InvalidMessageException;
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java
index 66cce840f..ac6c7f92d 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java
@@ -19,13 +19,11 @@
package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl;
import java.util.Properties;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
import org.onap.dmaap.mr.client.MRClientFactory;
import org.onap.dmaap.mr.client.MRConsumer;
import org.onap.dmaap.mr.client.response.MRConsumerResponse;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public abstract class DMaaPVESMsgConsumerImpl implements DMaaPVESMsgConsumer {
@@ -34,7 +32,6 @@ public abstract class DMaaPVESMsgConsumerImpl implements DMaaPVESMsgConsumer {
private final String name = this.getClass().getSimpleName();
private Properties properties = null;
private MRConsumer consumer = null;
- private MRConsumerResponse consumerResponse = null;
private boolean running = false;
private boolean ready = false;
private int fetchPause = 5000; // Default pause between fetch - 5 seconds
@@ -45,7 +42,7 @@ public abstract class DMaaPVESMsgConsumerImpl implements DMaaPVESMsgConsumer {
}
/*
- * Thread to fetch messages from the DMaaP topic. Waits for the messages to arrive on the topic until a certain timeout and returns.
+ * Thread to fetch messages from the DMaaP topic. Waits for the messages to arrive on the topic until a certain timeout and returns.
* If no data arrives on the topic, sleeps for a certain time period before checking again
*/
@Override
@@ -56,16 +53,17 @@ public abstract class DMaaPVESMsgConsumerImpl implements DMaaPVESMsgConsumer {
while (running) {
try {
boolean noData = true;
+ MRConsumerResponse consumerResponse = null;
consumerResponse = consumer.fetchWithReturnConsumerResponse(timeout, -1);
for (String msg : consumerResponse.getActualMessages()) {
noData = false;
- LOG.debug(name + " received ActualMessage from DMaaP VES Message topic:\n" + msg);
+ LOG.debug("{} received ActualMessage from DMaaP VES Message topic {}", name,msg);
processMsg(msg);
}
if (noData) {
- LOG.debug(name + " received ResponseCode: " + consumerResponse.getResponseCode());
- LOG.debug(name + " received ResponseMessage: " + consumerResponse.getResponseMessage());
+ LOG.debug("{} received ResponseCode: {}", name, consumerResponse.getResponseCode());
+ LOG.debug("{} received ResponseMessage: {}", name, consumerResponse.getResponseMessage());
if ((consumerResponse.getResponseCode() == null)
&& (consumerResponse.getResponseMessage().contains("SocketTimeoutException"))) {
LOG.warn("Client timeout while waiting for response from Server {}",
@@ -82,7 +80,7 @@ public abstract class DMaaPVESMsgConsumerImpl implements DMaaPVESMsgConsumer {
}
/*
- * Create a consumer by specifying properties containing information such as topic name, timeout, URL etc
+ * Create a consumer by specifying properties containing information such as topic name, timeout, URL etc
*/
@Override
public void init(Properties properties) {
@@ -90,23 +88,23 @@ public abstract class DMaaPVESMsgConsumerImpl implements DMaaPVESMsgConsumer {
try {
String timeoutStr = properties.getProperty("timeout");
- LOG.debug("timeoutStr: " + timeoutStr);
+ LOG.debug("timeoutStr: {}", timeoutStr);
if ((timeoutStr != null) && (timeoutStr.length() > 0)) {
timeout = parseTimeOutValue(timeoutStr);
}
String fetchPauseStr = properties.getProperty("fetchPause");
- LOG.debug("fetchPause(Str): " + fetchPauseStr);
+ LOG.debug("fetchPause(Str): {}",fetchPauseStr);
if ((fetchPauseStr != null) && (fetchPauseStr.length() > 0)) {
fetchPause = parseFetchPause(fetchPauseStr);
}
- LOG.debug("fetchPause: " + fetchPause);
+ LOG.debug("fetchPause: {} ",fetchPause);
this.consumer = MRClientFactory.createConsumer(properties);
ready = true;
} catch (Exception e) {
- LOG.error("Error initializing DMaaP VES Message consumer from file " + properties, e);
+ LOG.error("Error initializing DMaaP VES Message consumer from file {} {}",properties, e);
}
}
@@ -114,7 +112,7 @@ public abstract class DMaaPVESMsgConsumerImpl implements DMaaPVESMsgConsumer {
try {
return Integer.parseInt(timeoutStr);
} catch (NumberFormatException e) {
- LOG.error("Non-numeric value specified for timeout (" + timeoutStr + ")");
+ LOG.error("Non-numeric value specified for timeout ({})",timeoutStr);
}
return timeout;
}
@@ -123,14 +121,14 @@ public abstract class DMaaPVESMsgConsumerImpl implements DMaaPVESMsgConsumer {
try {
return Integer.parseInt(fetchPauseStr);
} catch (NumberFormatException e) {
- LOG.error("Non-numeric value specified for fetchPause (" + fetchPauseStr + ")");
+ LOG.error("Non-numeric value specified for fetchPause ({})",fetchPauseStr);
}
return fetchPause;
}
private void pauseThread() throws InterruptedException {
if (fetchPause > 0) {
- LOG.debug(String.format("No data received from fetch. Pausing %d ms before retry", fetchPause));
+ LOG.debug("No data received from fetch. Pausing {} ms before retry", fetchPause);
Thread.sleep(fetchPause);
} else {
LOG.debug("No data received from fetch. No fetch pause specified - retrying immediately");
@@ -156,6 +154,7 @@ public abstract class DMaaPVESMsgConsumerImpl implements DMaaPVESMsgConsumer {
running = false;
}
- public abstract void processMsg(String msg) throws Exception;
+ /*@Override
+ public abstract void processMsg(String msg) throws Exception;*/
}
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerMain.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerMain.java
index 97dd79577..3503aed8c 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerMain.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerMain.java
@@ -29,15 +29,18 @@ import org.slf4j.LoggerFactory;
public class DMaaPVESMsgConsumerMain implements Runnable {
private static final Logger LOG = LoggerFactory.getLogger(DMaaPVESMsgConsumerMain.class);
- private static final String pnfRegClass =
+ private static final String _PNFREG_CLASS =
"org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPPNFRegVESMsgConsumer";
- private static final String faultClass =
+ private static final String _FAULT_CLASS =
"org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPFaultVESMsgConsumer";
+ private static final String _PNFREG_DOMAIN = "pnfRegistration";
+ private static final String _FAULT_DOMAIN = "fault";
+
boolean threadsRunning = false;
List<DMaaPVESMsgConsumer> consumers = new LinkedList<>();
- public PNFRegistrationConfig pnfRegistrationConfig;
- public FaultConfig faultConfig;
- public GeneralConfig generalConfig;
+ private PNFRegistrationConfig pnfRegistrationConfig;
+ private FaultConfig faultConfig;
+ private GeneralConfig generalConfig;
public DMaaPVESMsgConsumerMain(Map<String, Configuration> configMap, GeneralConfig generalConfig) {
this.generalConfig = generalConfig;
@@ -48,11 +51,11 @@ public class DMaaPVESMsgConsumerMain implements Runnable {
LOG.debug("In initialize method : Domain = {} and domainConfig = {}", domain, domainConfig);
String consumerClass = null;
Properties consumerProperties = new Properties();
- if (domain.equalsIgnoreCase("pnfregistration")) {
+ if (domain.equalsIgnoreCase(_PNFREG_DOMAIN)) {
this.pnfRegistrationConfig = (PNFRegistrationConfig) domainConfig;
- consumerClass = pnfRegistrationConfig.getConsumerClass();
- LOG.debug("Consumer class = " + consumerClass);
+ consumerClass = _PNFREG_CLASS;
+ LOG.debug("Consumer class = {}",consumerClass);
consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_TRANSPORTTYPE,
pnfRegistrationConfig.getTransportType());
@@ -80,10 +83,10 @@ public class DMaaPVESMsgConsumerMain implements Runnable {
pnfRegistrationConfig.getClientReadTimeout());
consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT,
pnfRegistrationConfig.getClientConnectTimeout());
- threadsRunning = createConsumer("pnfRegistration", consumerProperties);
- } else if (domain.equalsIgnoreCase("fault")) {
+ threadsRunning = createConsumer(_PNFREG_DOMAIN, consumerProperties);
+ } else if (domain.equalsIgnoreCase(_FAULT_DOMAIN)) {
this.faultConfig = (FaultConfig) domainConfig;
- consumerClass = faultConfig.getConsumerClass();
+ consumerClass = _FAULT_CLASS;
LOG.debug("Consumer class = {}", consumerClass);
consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_TRANSPORTTYPE, faultConfig.getTransportType());
consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_HOST_PORT, faultConfig.getHostPort());
@@ -101,7 +104,7 @@ public class DMaaPVESMsgConsumerMain implements Runnable {
faultConfig.getClientReadTimeout());
consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT,
faultConfig.getClientConnectTimeout());
- threadsRunning = createConsumer("fault", consumerProperties);
+ threadsRunning = createConsumer(_FAULT_DOMAIN, consumerProperties);
}
}
@@ -118,9 +121,9 @@ public class DMaaPVESMsgConsumerMain implements Runnable {
public boolean createConsumer(String consumerType, Properties properties) {
DMaaPVESMsgConsumerImpl consumer = null;
- if (consumerType.equalsIgnoreCase("pnfRegistration"))
+ if (consumerType.equalsIgnoreCase(_PNFREG_DOMAIN))
consumer = new DMaaPPNFRegVESMsgConsumer(generalConfig);
- else if (consumerType.equalsIgnoreCase("fault"))
+ else if (consumerType.equalsIgnoreCase(_FAULT_DOMAIN))
consumer = new DMaaPFaultVESMsgConsumer(generalConfig);
handleConsumer(consumer, properties, consumers);
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/FaultConfig.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/FaultConfig.java
index 6477ebbec..dfdb1c00b 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/FaultConfig.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/FaultConfig.java
@@ -23,10 +23,6 @@ import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRep
public class FaultConfig implements Configuration {
private static final String SECTION_MARKER = "fault";
- private static final String PROPERTY_KEY_CONSUMER_CLASS = "faultConsumerClass";
- private static final String DEFAULT_VALUE_CONSUMER_CLASS =
- "org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPFaultVESMsgConsumer";
-
public static final String PROPERTY_KEY_CONSUMER_TRANSPORTTYPE = "TransportType";
private static final String DEFAULT_VALUE_CONSUMER_TRANSPORTTYPE = "HTTPNOAUTH";
@@ -85,8 +81,6 @@ public class FaultConfig implements Configuration {
@Override
public void defaults() {
- configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLASS,
- DEFAULT_VALUE_CONSUMER_CLASS);
configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_TRANSPORTTYPE,
DEFAULT_VALUE_CONSUMER_TRANSPORTTYPE);
configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_PROTOCOL,
@@ -117,10 +111,6 @@ public class FaultConfig implements Configuration {
}
- public String getConsumerClass() {
- return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLASS);
- }
-
public String getHostPort() {
return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_HOST_PORT);
}
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/FaultNotificationClient.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/FaultNotificationClient.java
index 3fdbb6f20..11f46fff7 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/FaultNotificationClient.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/FaultNotificationClient.java
@@ -68,7 +68,7 @@ public class FaultNotificationClient extends BaseHTTPClient {
message = updateFaultPayload(faultNodeId, faultCounter, faultOccurrenceTime, faultObjectId, faultReason,
faultSeverity);
- LOG.debug("Payload after updating values is: " + message);
+ LOG.debug("Payload after updating values is: {}",message);
return sendFaultRequest("POST", message) == 200;
@@ -88,7 +88,7 @@ public class FaultNotificationClient extends BaseHTTPClient {
private int sendFaultRequest(String method, String message) {
- LOG.debug("In sendFaultRequest - " + method + " " + message);
+ LOG.debug("In sendFaultRequest - {}-{}",method,message);
BaseHTTPResponse response;
try {
String uri = FAULT_NOTIFICATION_URI;
@@ -96,7 +96,7 @@ public class FaultNotificationClient extends BaseHTTPClient {
LOG.debug("finished with responsecode {}", response.code);
return response.code;
} catch (IOException e) {
- LOG.warn("problem sending fault message {} : {}", e.getMessage());
+ LOG.warn("problem sending fault message {}", e.getMessage());
return -1;
}
}
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/GeneralConfig.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/GeneralConfig.java
index 2ad5431be..eec4e7a9e 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/GeneralConfig.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/GeneralConfig.java
@@ -32,7 +32,7 @@ public class GeneralConfig implements Configuration {
private static final String SECTION_MARKER = "general";
- private static final String PROPERTY_KEY_ENABLED = "dmaapEnabled"; //"enabled";
+ private static final String PROPERTY_KEY_ENABLED = "dmaapEnabled";
private static final String PROPERTY_KEY_USER = "sdnrUser";
private static final String DEFAULT_VALUE_USER = "${SDNRUSERNAME}";
@@ -53,8 +53,7 @@ public class GeneralConfig implements Configuration {
}
public Boolean getEnabled() {
- Boolean enabled = configuration.getPropertyBoolean(SECTION_MARKER, PROPERTY_KEY_ENABLED);
- return enabled;
+ return configuration.getPropertyBoolean(SECTION_MARKER, PROPERTY_KEY_ENABLED);
}
public String getBaseUrl() {
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MountpointRegistrarImpl.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MountpointRegistrarImpl.java
index 94b15a54c..53454ac03 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MountpointRegistrarImpl.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/MountpointRegistrarImpl.java
@@ -102,8 +102,6 @@ public class MountpointRegistrarImpl implements AutoCloseable, IConfigChangedLis
@Override
public void close() throws Exception {
LOG.info("{} closing ...", this.getClass().getName());
- //close(updateService, configService, mwtnService); issue#1
- //close(updateService, mwtnService);
LOG.info("{} closing done", APPLICATION_NAME);
}
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFMountPointClient.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFMountPointClient.java
index f8653ca75..22b4e5f22 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFMountPointClient.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFMountPointClient.java
@@ -57,21 +57,21 @@ public class PNFMountPointClient extends BaseHTTPClient {
+ " <host xmlns=\"urn:opendaylight:netconf-node-topology\">@device-ip@</host>\n"
+ " <port xmlns=\"urn:opendaylight:netconf-node-topology\">@device-port@</port>\n"
+ " <key-based xmlns=\"urn:opendaylight:netconf-node-topology\">\n"
- + " <username xmlns=\"urn:opendaylight:netconf-node-topology\">@username@</username>\n"
- + " <key-id>@key-id@</key-id>\n"
+ + " <username xmlns=\"urn:opendaylight:netconf-node-topology\">@username@</username>\n"
+ + " <key-id>@key-id@</key-id>\n"
+ " </key-based>\n"
+ " <tcp-only xmlns=\"urn:opendaylight:netconf-node-topology\">false</tcp-only>\n"
+ " <protocol xmlns=\"urn:opendaylight:netconf-node-topology\">\n"
- + " <name>TLS</name>\n"
+ + " <name>TLS</name>\n"
+ " </protocol>\n"
- + " <!-- non-mandatory fields with default values, you can safely remove these if you do not wish to override any of these values-->\n"
- + " <reconnect-on-changed-schema xmlns=\"urn:opendaylight:netconf-node-topology\">false</reconnect-on-changed-schema>\n"
- + " <connection-timeout-millis xmlns=\"urn:opendaylight:netconf-node-topology\">20000</connection-timeout-millis>\n"
- + " <max-connection-attempts xmlns=\"urn:opendaylight:netconf-node-topology\">0</max-connection-attempts>\n"
- + " <between-attempts-timeout-millis xmlns=\"urn:opendaylight:netconf-node-topology\">2000</between-attempts-timeout-millis>\n"
- + " <sleep-factor xmlns=\"urn:opendaylight:netconf-node-topology\">1.5</sleep-factor>\n"
- + " <!-- keepalive-delay set to 0 turns off keepalives-->\n"
- + " <keepalive-delay xmlns=\"urn:opendaylight:netconf-node-topology\">120</keepalive-delay>\n"
+ + "<!-- non-mandatory fields with default values, you can safely remove these if you do not wish to override any of these values-->\n"
+ + "<reconnect-on-changed-schema xmlns=\"urn:opendaylight:netconf-node-topology\">false</reconnect-on-changed-schema>\n"
+ + "<connection-timeout-millis xmlns=\"urn:opendaylight:netconf-node-topology\">20000</connection-timeout-millis>\n"
+ + "<max-connection-attempts xmlns=\"urn:opendaylight:netconf-node-topology\">0</max-connection-attempts>\n"
+ + "<between-attempts-timeout-millis xmlns=\"urn:opendaylight:netconf-node-topology\">2000</between-attempts-timeout-millis>\n"
+ + "<sleep-factor xmlns=\"urn:opendaylight:netconf-node-topology\">1.5</sleep-factor>\n"
+ + "<!-- keepalive-delay set to 0 turns off keepalives-->\n"
+ + "<keepalive-delay xmlns=\"urn:opendaylight:netconf-node-topology\">120</keepalive-delay>\n"
+ "</node>";
// @formatter:on
@@ -128,7 +128,6 @@ public class PNFMountPointClient extends BaseHTTPClient {
LOG.info("In pnfRequest - {} : {} : {}", pnfName, method, message);
BaseHTTPResponse response;
try {
- //String uri = "http://localhost:8181/restconf/config/network-topology:network-topology/topology/topology-netconf/node/" + pnfName;
String uri = MOUNTPOINT_URI + pnfName;
response = this.sendRequest(uri, method, message, headerMap);
LOG.debug("finished with responsecode {}", response.code);
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFRegistrationConfig.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFRegistrationConfig.java
index dd4d2864a..636df4104 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFRegistrationConfig.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/PNFRegistrationConfig.java
@@ -24,10 +24,6 @@ import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRep
public class PNFRegistrationConfig implements Configuration {
private static final String SECTION_MARKER = "pnfRegistration";
- private static final String PROPERTY_KEY_CONSUMER_CLASS = "pnfRegConsumerClass";
- private static final String DEFAULT_VALUE_CONSUMER_CLASS =
- "org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPPNFRegVESMsgConsumer";
-
public static final String PROPERTY_KEY_CONSUMER_TRANSPORTTYPE = "TransportType";
private static final String DEFAULT_VALUE_CONSUMER_TRANSPORTTYPE = "HTTPNOAUTH";
@@ -86,8 +82,6 @@ public class PNFRegistrationConfig implements Configuration {
@Override
public void defaults() {
- configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLASS,
- DEFAULT_VALUE_CONSUMER_CLASS);
configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_TRANSPORTTYPE,
DEFAULT_VALUE_CONSUMER_TRANSPORTTYPE);
configuration.setPropertyIfNotAvailable(SECTION_MARKER, PROPERTY_KEY_CONSUMER_PROTOCOL,
@@ -117,10 +111,6 @@ public class PNFRegistrationConfig implements Configuration {
DEFAULT_VALUE_CONSUMER_CLIENT_CONNECTTIMEOUT);
}
- public String getConsumerClass() {
- return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_CLASS);
- }
-
public String getHostPort() {
return configuration.getProperty(SECTION_MARKER, PROPERTY_KEY_CONSUMER_HOST_PORT);
}
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/PNFRegistrationConfigTest.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/PNFRegistrationConfigTest.java
index 80e037da6..87a70d795 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/PNFRegistrationConfigTest.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/PNFRegistrationConfigTest.java
@@ -32,7 +32,6 @@ public class PNFRegistrationConfigTest {
// @formatter:off
private static final String TESTCONFIG_CONTENT = "[pnfRegistration]\n"
- + "pnfRegConsumerClass=org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPPNFRegVESMsgConsumer\n"
+ "TransportType=HTTPNOAUTH\n"
+ "Protocol=http\n"
+ "username=username\n"
@@ -59,8 +58,6 @@ public class PNFRegistrationConfigTest {
cfg = new ConfigurationFileRepresentation(configFile);
PNFRegistrationConfig pnfCfg = new PNFRegistrationConfig(cfg);
assertEquals("pnfRegistration", pnfCfg.getSectionName());
- assertEquals("org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPPNFRegVESMsgConsumer",
- pnfCfg.getConsumerClass());
assertEquals("HTTPNOAUTH", pnfCfg.getTransportType());
assertEquals("onap-dmap:3904", pnfCfg.getHostPort());
assertEquals("unauthenticated.VES_PNFREG_OUTPUT", pnfCfg.getTopic());
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestFaultConfig.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestFaultConfig.java
index 3caa864d5..f44bebcee 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestFaultConfig.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestFaultConfig.java
@@ -32,7 +32,6 @@ public class TestFaultConfig {
// @formatter:off
private static final String TESTCONFIG_CONTENT = "[fault]\n"
- + "faultConsumerClass=org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPFaultVESMsgConsumer\n"
+ "TransportType=HTTPNOAUTH\n"
+ "Protocol=http\n"
+ "username=username\n"
@@ -60,8 +59,6 @@ public class TestFaultConfig {
cfg = new ConfigurationFileRepresentation(CONFIGURATIONFILE);
FaultConfig faultCfg = new FaultConfig(cfg);
assertEquals("fault", faultCfg.getSectionName());
- assertEquals("org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPFaultVESMsgConsumer",
- faultCfg.getConsumerClass());
assertEquals("HTTPNOAUTH", faultCfg.getTransportType());
assertEquals("onap-dmap:3904", faultCfg.getHostPort());
assertEquals("unauthenticated.SEC_FAULT_OUTPUT", faultCfg.getTopic());
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestFaultNotificationClient.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestFaultNotificationClient.java
index 7e7bece17..9fb35e6ba 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestFaultNotificationClient.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestFaultNotificationClient.java
@@ -19,12 +19,9 @@
package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test;
import static org.junit.Assert.assertEquals;
-
import java.io.IOException;
import java.util.Map;
-
import javax.annotation.Nonnull;
-
import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.common.http.BaseHTTPResponse;
import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.FaultNotificationClient;
@@ -51,7 +48,8 @@ public class TestFaultNotificationClient extends FaultNotificationClient {
}
@Override
- public @Nonnull BaseHTTPResponse sendRequest(String uri, String method, String body, Map<String, String> headers)
+ @Nonnull
+ public BaseHTTPResponse sendRequest(String uri, String method, String body, Map<String, String> headers)
throws IOException {
System.out.println("In overridden sendRequest in TestFaultNotificationClient");
return new BaseHTTPResponse(200, body);
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestPNFMountPointClient.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestPNFMountPointClient.java
index 8694963a9..591ed5b24 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestPNFMountPointClient.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestPNFMountPointClient.java
@@ -19,12 +19,9 @@
package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.test;
import static org.junit.Assert.assertEquals;
-
import java.io.IOException;
import java.util.Map;
-
import javax.annotation.Nonnull;
-
import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.common.http.BaseHTTPResponse;
import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.PNFMountPointClient;
@@ -52,7 +49,8 @@ public class TestPNFMountPointClient extends PNFMountPointClient {
}
@Override
- public @Nonnull BaseHTTPResponse sendRequest(String uri, String method, String body, Map<String, String> headers)
+ @Nonnull
+ public BaseHTTPResponse sendRequest(String uri, String method, String body, Map<String, String> headers)
throws IOException {
System.out.println("In overridden sendRequest in TestPNFMountPointClient");
return new BaseHTTPResponse(200, body);
diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/Constants.java b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/Constants.java
new file mode 100644
index 000000000..12dd160de
--- /dev/null
+++ b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/Constants.java
@@ -0,0 +1,35 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
+ * All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+package org.onap.ccsdk.features.sdnr.wt.mountpointstateprovider.impl;
+
+public class Constants {
+
+ public static final String NODEID = "NodeId";
+ public static final String NETCONFNODESTATE = "NetConfNodeState";
+ public static final String TIMESTAMP = "TimeStamp";
+
+ public static final String VES_DOMAIN = "notification";
+ public static final String VES_PRIORITY = "Normal";
+ public static final String VES_CHANGETYPE = "ConnectionState";
+
+
+}
diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeConnectListenerImpl.java b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeConnectListenerImpl.java
index 5cdf5abc6..466d4f4ef 100644
--- a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeConnectListenerImpl.java
+++ b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeConnectListenerImpl.java
@@ -51,13 +51,13 @@ public class MountpointNodeConnectListenerImpl implements NetconfNodeConnectList
NodeId nNodeId = accessor.getNodeId();
NetconfNode netconfNode = accessor.getNetconfNode();
- LOG.debug("In onEnterConnected of MountpointNodeConnectListenerImpl - nNodeId = " + nNodeId.getValue()
- + " IP Address = " + netconfNode.getHost().getIpAddress().getIpv4Address().getValue());
+ LOG.debug("In onEnterConnected of MountpointNodeConnectListenerImpl - nNodeId = {}, IP Address = {}",nNodeId.getValue()
+ ,netconfNode.getHost().getIpAddress().getIpv4Address().getValue());
JSONObject obj = new JSONObject();
- obj.put("NodeId", nNodeId.getValue());
- obj.put("NetConfNodeState", netconfNode.getConnectionStatus().toString());
- obj.put("TimeStamp", java.time.Clock.systemUTC().instant());
+ obj.put(Constants.NODEID, nNodeId.getValue());
+ obj.put(Constants.NETCONFNODESTATE, netconfNode.getConnectionStatus().toString());
+ obj.put(Constants.TIMESTAMP, java.time.Clock.systemUTC().instant());
mountpointStatePublisher.addToPublish(obj);
}
@@ -65,12 +65,12 @@ public class MountpointNodeConnectListenerImpl implements NetconfNodeConnectList
@Override
public void onLeaveConnected(NodeId nNodeId, Optional<NetconfNode> optionalNetconfNode) {
- LOG.debug("In onLeaveConnected of MountpointNodeConnectListenerImpl - nNodeId = " + nNodeId);
+ LOG.debug("In onLeaveConnected of MountpointNodeConnectListenerImpl - nNodeId = {}",nNodeId);
JSONObject obj = new JSONObject();
- obj.put("NodeId", nNodeId.getValue());
- obj.put("NetConfNodeState", "Unmounted");
- obj.put("TimeStamp", java.time.Clock.systemUTC().instant());
+ obj.put(Constants.NODEID, nNodeId.getValue());
+ obj.put(Constants.NETCONFNODESTATE, "Unmounted");
+ obj.put(Constants.TIMESTAMP, java.time.Clock.systemUTC().instant());
mountpointStatePublisher.addToPublish(obj);
}
diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeStateListenerImpl.java b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeStateListenerImpl.java
index d8b5a85de..46b17eb15 100644
--- a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeStateListenerImpl.java
+++ b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointNodeStateListenerImpl.java
@@ -46,12 +46,12 @@ public class MountpointNodeStateListenerImpl implements NetconfNodeStateListener
@Override
public void onCreated(NodeId nNodeId, NetconfNode netconfNode) {
- LOG.info("In onCreated of MountpointNodeStateListenerImpl - nNodeId = " + nNodeId.getValue() + " IP Address = "
- + netconfNode.getHost().getIpAddress().getIpv4Address().toString());
+ LOG.info("In onCreated of MountpointNodeStateListenerImpl - nNodeId = {}, IP Address = {}",nNodeId.getValue(),
+ netconfNode.getHost().getIpAddress().getIpv4Address().toString());
JSONObject obj = new JSONObject();
- obj.put("NodeId", nNodeId.getValue());
- obj.put("NetConfNodeState", netconfNode.getConnectionStatus().toString());
- obj.put("TimeStamp", java.time.Clock.systemUTC().instant());
+ obj.put(Constants.NODEID, nNodeId.getValue());
+ obj.put(Constants.NETCONFNODESTATE, netconfNode.getConnectionStatus().toString());
+ obj.put(Constants.TIMESTAMP, java.time.Clock.systemUTC().instant());
mountpointStatePublisher.addToPublish(obj);
}
@@ -59,12 +59,12 @@ public class MountpointNodeStateListenerImpl implements NetconfNodeStateListener
@Override
public void onStateChange(NodeId nNodeId, NetconfNode netconfNode) {
- LOG.info("In onStateChange of MountpointNodeStateListenerImpl - nNodeId = " + nNodeId.getValue()
- + " IP Address = " + netconfNode.getHost().getIpAddress().getIpv4Address().getValue());
+ LOG.info("In onStateChange of MountpointNodeStateListenerImpl - nNodeId = {}, IP Address = {}",nNodeId.getValue(),
+ netconfNode.getHost().getIpAddress().getIpv4Address().getValue());
JSONObject obj = new JSONObject();
- obj.put("NodeId", nNodeId.getValue());
- obj.put("NetConfNodeState", netconfNode.getConnectionStatus().toString());
- obj.put("TimeStamp", java.time.Clock.systemUTC().instant());
+ obj.put(Constants.NODEID, nNodeId.getValue());
+ obj.put(Constants.NETCONFNODESTATE, netconfNode.getConnectionStatus().toString());
+ obj.put(Constants.TIMESTAMP, java.time.Clock.systemUTC().instant());
mountpointStatePublisher.addToPublish(obj);
}
@@ -72,11 +72,11 @@ public class MountpointNodeStateListenerImpl implements NetconfNodeStateListener
@Override
public void onRemoved(NodeId nNodeId) {
- LOG.info("In onRemoved of MountpointNodeStateListenerImpl - nNodeId = " + nNodeId);
+ LOG.info("In onRemoved of MountpointNodeStateListenerImpl - nNodeId = {}",nNodeId);
JSONObject obj = new JSONObject();
- obj.put("NodeId", nNodeId.getValue());
- obj.put("NetConfNodeState", "Removed");
- obj.put("TimeStamp", java.time.Clock.systemUTC().instant());
+ obj.put(Constants.NODEID, nNodeId.getValue());
+ obj.put(Constants.NETCONFNODESTATE, "Removed");
+ obj.put(Constants.TIMESTAMP, java.time.Clock.systemUTC().instant());
mountpointStatePublisher.addToPublish(obj);
}
diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStatePublisher.java b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStatePublisher.java
index 9df37e305..e05b3f1ba 100644
--- a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStatePublisher.java
+++ b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStatePublisher.java
@@ -35,7 +35,7 @@ import org.slf4j.LoggerFactory;
public class MountpointStatePublisher implements Runnable {
private static final Logger LOG = LoggerFactory.getLogger(MountpointStatePublisher.class);
- private List<JSONObject> stateObjects = new LinkedList<JSONObject>();
+ private List<JSONObject> stateObjects = new LinkedList<>();
private boolean publish = true;
private int publishPause = 5000; // Default pause between fetch - 5 seconds
private VESCollectorService vesCollectorService;
@@ -68,15 +68,14 @@ public class MountpointStatePublisher implements Runnable {
public String createVESMessage(JSONObject msg, VESCollectorCfgService vesCfg) {
MountpointStateVESMessageFormatter vesFormatter = new MountpointStateVESMessageFormatter(vesCfg);
- String vesMsg = vesFormatter.createVESMessage(msg);
- return vesMsg;
+ return vesFormatter.createVESMessage(msg);
}
@Override
public void run() {
while (publish) {
try {
- if (getStateObjects().size() > 0) {
+ if (!getStateObjects().isEmpty()) {
JSONObject obj = ((LinkedList<JSONObject>) getStateObjects()).removeFirst();
String vesMsg = createVESMessage(obj, vesCollectorService.getConfig());
this.vesCollectorService.publishVESMessage(vesMsg);
diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStateVESMessageFormatter.java b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStateVESMessageFormatter.java
index 918438e55..4ab1a9a85 100644
--- a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStateVESMessageFormatter.java
+++ b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/MountpointStateVESMessageFormatter.java
@@ -31,9 +31,6 @@ import org.slf4j.LoggerFactory;
public class MountpointStateVESMessageFormatter {
private static final Logger LOG = LoggerFactory.getLogger(MountpointStateVESMessageFormatter.class);
- private static final String VES_DOMAIN = "notification";
- private static final String VES_PRIORITY = "Normal";
- private static final String VES_CHANGETYPE = "ConnectionState";
private VESCollectorCfgService vesCfg;
static long sequenceNo = 0;
@@ -42,10 +39,20 @@ public class MountpointStateVESMessageFormatter {
this.vesCfg = vesCfg;
}
+ private static void incrSequenceNo() {
+ sequenceNo++;
+ }
+
+ private long getSequenceNo() {
+ return sequenceNo;
+ }
+
public String createVESMessage(JSONObject obj) {
- LOG.debug("JSON Object to format to VES is - {}", obj.toString());
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("JSON Object to format to VES is - {0}", obj);
+ }
String vesMsg = "{}";
- sequenceNo++;
+ MountpointStateVESMessageFormatter.incrSequenceNo();
VESCommonEventHeaderPOJO vesCommonEventHeader = createVESCommonEventHeader(obj);
VESNotificationFieldsPOJO vesNotificationFields = createVESNotificationFields(obj);
@@ -59,7 +66,7 @@ public class MountpointStateVESMessageFormatter {
vesMsg = objMapper.writeValueAsString(vesEvent);
LOG.debug("VES message to be published - {}", vesMsg);
} catch (JsonProcessingException e) {
- e.printStackTrace();
+ LOG.warn("Exception {} while processing JSON Message - {}", e, obj);
}
return vesMsg;
@@ -69,9 +76,9 @@ public class MountpointStateVESMessageFormatter {
private VESNotificationFieldsPOJO createVESNotificationFields(JSONObject obj) {
VESNotificationFieldsPOJO vesNotificationFields = new VESNotificationFieldsPOJO();
- vesNotificationFields.setChangeIdentifier(obj.getString("NodeId"));
- vesNotificationFields.setChangeType(VES_CHANGETYPE);
- vesNotificationFields.setNewState(obj.getString("NetConfNodeState"));
+ vesNotificationFields.setChangeIdentifier(obj.getString(Constants.NODEID));
+ vesNotificationFields.setChangeType(Constants.VES_CHANGETYPE);
+ vesNotificationFields.setNewState(obj.getString(Constants.NETCONFNODESTATE));
return vesNotificationFields;
}
@@ -79,17 +86,17 @@ public class MountpointStateVESMessageFormatter {
private VESCommonEventHeaderPOJO createVESCommonEventHeader(JSONObject obj) {
VESCommonEventHeaderPOJO vesCommonEventHeader = new VESCommonEventHeaderPOJO();
- vesCommonEventHeader.setDomain(VES_DOMAIN);
+ vesCommonEventHeader.setDomain(Constants.VES_DOMAIN);
vesCommonEventHeader
- .setEventId(obj.getString("NodeId") + "_" + obj.getString("NetConfNodeState") + "_" + sequenceNo);
+ .setEventId(obj.getString(Constants.NODEID) + "_" + obj.getString(Constants.NETCONFNODESTATE) + "_" + getSequenceNo());
vesCommonEventHeader
- .setEventName(obj.getString("NodeId") + "_" + obj.getString("NetConfNodeState") + "_" + sequenceNo);
- vesCommonEventHeader.setSourceName(obj.getString("NodeId"));
- vesCommonEventHeader.setPriority(VES_PRIORITY);
+ .setEventName(obj.getString(Constants.NODEID) + "_" + obj.getString(Constants.NETCONFNODESTATE) + "_" + getSequenceNo());
+ vesCommonEventHeader.setSourceName(obj.getString(Constants.NODEID));
+ vesCommonEventHeader.setPriority(Constants.VES_PRIORITY);
vesCommonEventHeader.setReportingEntityName(this.vesCfg.getReportingEntityName());
- vesCommonEventHeader.setSequence(sequenceNo);
+ vesCommonEventHeader.setSequence(getSequenceNo());
- Instant time = (Instant) obj.get("TimeStamp");
+ Instant time = (Instant) obj.get(Constants.TIMESTAMP);
vesCommonEventHeader.setLastEpochMicrosec(time.toEpochMilli() * 100);
vesCommonEventHeader.setStartEpochMicrosec(time.toEpochMilli() * 100);
diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/VESEvent.java b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/VESEvent.java
index 13017d46c..7989166f6 100644
--- a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/VESEvent.java
+++ b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/VESEvent.java
@@ -21,7 +21,7 @@ import java.util.HashMap;
import java.util.Map;
public class VESEvent {
- public Map<String, Object> event = new HashMap<String, Object>();
+ private Map<String, Object> event = new HashMap<>();
public void addEventObjects(Object eventObject) {
if (eventObject instanceof VESCommonEventHeaderPOJO)
diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/VESNotificationFieldsPOJO.java b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/VESNotificationFieldsPOJO.java
index 1963cd6ca..1d2c2dcb5 100644
--- a/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/VESNotificationFieldsPOJO.java
+++ b/sdnr/wt/mountpoint-state-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/impl/VESNotificationFieldsPOJO.java
@@ -21,15 +21,17 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
@JsonPropertyOrder({"arrayOfNamedHashMap", "changeContact", "changeIdentifier", "changeType", "newState", "oldState", "notificationFieldsVersion"})
public class VESNotificationFieldsPOJO {
- private ArrayList<HashMap<String, Object>> arrayOfNamedHashMap = new ArrayList<HashMap<String, Object>>();
+ private List<HashMap<String, Object>> arrayOfNamedHashMap = new ArrayList<>();
@JsonIgnore
- private HashMap<String, Object> namedHashMap = new HashMap<String, Object>();
+ private Map<String, Object> namedHashMap = new HashMap<>();
@JsonIgnore
- private HashMap<String, String> hashMap = new HashMap<String, String>();
+ private Map<String, String> hashMap = new HashMap<>();
@JsonIgnore
private String changeContact = "";
private String changeIdentifier = "";
@@ -42,11 +44,11 @@ public class VESNotificationFieldsPOJO {
private String stateInterface = "";
private String notificationFieldsVersion = "2.0";
- public ArrayList<HashMap<String, Object>> getArrayOfNamedHashMap() {
+ public List<HashMap<String, Object>> getArrayOfNamedHashMap() {
return arrayOfNamedHashMap;
}
- public void setArrayOfNamedHashMap(ArrayList<HashMap<String, Object>> arrayOfNamedHashMap) {
+ public void setArrayOfNamedHashMap(List<HashMap<String, Object>> arrayOfNamedHashMap) {
this.arrayOfNamedHashMap = arrayOfNamedHashMap;
}
diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointNodeStateListenerImpl.java b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointNodeStateListenerImpl.java
index c6a9d11e5..60841ec69 100644
--- a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointNodeStateListenerImpl.java
+++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointNodeStateListenerImpl.java
@@ -74,6 +74,7 @@ public class TestMountpointNodeStateListenerImpl {
@Test
public void testOnRemoved() {
nodeStateListener.onRemoved(nNodeId);
+ assertNotEquals(mountpointStatePublisher.getStateObjects().size(), 0);
}
}
diff --git a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointStateProviderImpl.java b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointStateProviderImpl.java
index 1cebeb697..4e4ac3064 100644
--- a/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointStateProviderImpl.java
+++ b/sdnr/wt/mountpoint-state-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointstateprovider/test/TestMountpointStateProviderImpl.java
@@ -42,7 +42,7 @@ public class TestMountpointStateProviderImpl {
@Test
- public void before() throws InterruptedException, IOException {
+ public void test() throws InterruptedException, IOException {
NetconfNodeStateService netconfNodeStateService = mock(NetconfNodeStateService.class);
DeviceManagerServiceProvider serviceProvider = mock(DeviceManagerServiceProvider.class);
VESCollectorService vesCollectorService = mock(VESCollectorService.class);
@@ -57,13 +57,4 @@ public class TestMountpointStateProviderImpl {
mountpointStateProvider.init();
}
- /* @After
- public void after() throws InterruptedException, IOException {
-
- try {
- mountpointStateProvider.close();
- } catch (Exception e) {
- System.out.println(e);
- }
- }*/
}