summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/devicemanager/provider/src/main/java
diff options
context:
space:
mode:
authorherbert <herbert.eiselt@highstreet-technologies.com>2020-02-14 13:46:48 +0100
committerherbert <herbert.eiselt@highstreet-technologies.com>2020-02-14 13:47:15 +0100
commit9751ab7122a05e9ca10dde1348869f06899fa0cc (patch)
tree7da2573af7f7051fdb2c40d99dfcfcf782680e73 /sdnr/wt/devicemanager/provider/src/main/java
parentd0fc4329aa47fa3fdcc3a9f3af31e977ad21b979 (diff)
SDN-R code coverage
add unit test to devicemanager Issue-ID: SDNC-1071 Signed-off-by: herbert <herbert.eiselt@highstreet-technologies.com> Change-Id: I794a86defde37e62f555c4e34acaa499c21788ca
Diffstat (limited to 'sdnr/wt/devicemanager/provider/src/main/java')
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/config/AaiConfig.java466
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorImpl.java13
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorTask.java2
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/DeviceManagerDatabaseNotificationService.java (renamed from sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/datamanager/DeviceManagerDatabaseNotificationService.java)81
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/ODLEventListenerHandler.java (renamed from sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/handler/ODLEventListenerHandler.java)2
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/RpcPushNotificationsHandler.java (renamed from sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/handler/RpcPushNotificationsHandler.java)3
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ConnectionStatusHousekeepingService.java8
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementHouskeepingService.java2
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java2
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java24
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfConnectHandler.java10
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlAkka/AkkaConfig.java86
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlAkka/ClusterConfig.java137
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlAkka/ClusterNodeInfo.java81
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlGeo/ClusterRoleInfo.java91
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlGeo/GeoConfig.java162
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/HtDataBaseReaderAndWriter.java258
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/HtMapper.java140
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/JsonMapperBase.java137
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/NetconfChangeListener.java156
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/InternalDateAndTime.java59
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetconfNotification.java70
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/FaultEntityManager.java (renamed from sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/FaultEntityManager.java)2
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/MwtNotificationBase.java1
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ProblemNotificationXml.java17
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientDummyImpl.java2
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl2.java2
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceCalculator.java2
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java2
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayFilter.java56
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayService.java2
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayedListener.java2
-rw-r--r--sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/ToggleAlarmFilterable.java (renamed from sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlGeo/ClusterRoleInfoCollection.java)33
33 files changed, 427 insertions, 1684 deletions
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/config/AaiConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/config/AaiConfig.java
index d30ee9d67..68e5dd940 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/config/AaiConfig.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/config/AaiConfig.java
@@ -20,6 +20,7 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.aaiconnector.impl.config;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
+import java.io.InputStream;
import java.util.Base64;
import java.util.HashMap;
import java.util.Map;
@@ -35,233 +36,242 @@ import org.slf4j.LoggerFactory;
public class AaiConfig implements Configuration {
- private static Logger LOG = LoggerFactory.getLogger(AaiConfig.class);
-
- private static final String SECTION_MARKER_AAI = "aai";
-
- private enum Config {
- AAIPROP_FILE("aaiPropertiesFile", "null"),
- BASEURL("aaiUrl", "off", "org.onap.ccsdk.sli.adaptors.aai.uri"),
- USERCREDENTIALS("aaiUserCredentials",""),
- HEADERS("aaiHeaders","[\"X-TransactionId: 9999\"]"),
- DELETEONMOUNTPOINTREMOVED("aaiDeleteOnMountpointRemove",false),
- TRUSTALLCERTS("aaiTrustAllCerts",false, "org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore"),
- APIVERSION("aaiApiVersion", "aai/v13"),
- PCKS12CERTFILENAME("aaiPcks12ClientCertFile","", "org.onap.ccsdk.sli.adaptors.aai.ssl.key"),
- PCKS12PASSPHRASE("aaiPcks12ClientCertPassphrase","", "org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd"),
- CONNECTIONTIMEOUT("aaiClientConnectionTimeout",String.valueOf(DEFAULT_VALUE_CONNECTION_TIMEOUT), "connection.timeout"), //in ms;
- APPLICATIONID("aaiApplicationId","SDNR", "org.onap.ccsdk.sli.adaptors.aai.application"),
- HTTPREADTIMEOUT("aaiReadTimeout", "60000", "read.timeout");
-
- private String propertyKey;
- private String propertyValue;
- private Optional<String> propertyKeySecondFile;
-
- Config(String propertyKey, Object propertyValue) {
- this.propertyKey = propertyKey;
- this.propertyValue = propertyValue.toString();
- this.propertyKeySecondFile = Optional.empty();
- }
-
- Config(String propertyKey, Object propertyValue, String propertyKeySecondFile) {
- this(propertyKey, propertyValue);
- this.propertyKeySecondFile = Optional.of(propertyKeySecondFile);
- }
- }
-
- private static final long DEFAULT_VALUE_CONNECTION_TIMEOUT = 30000; //in ms
- private static final String HEADER_KEY_APPLICATION = "X-FromAppId";
-
- private final ConfigurationFileRepresentation configuration;
-
- public AaiConfig(ConfigurationFileRepresentation configuration) {
- HtAssert.nonnull(configuration);
- this.configuration = configuration;
- this.configuration.addSection(SECTION_MARKER_AAI);
- defaults();
- }
-
- /*
- * Getter
- */
-
- public boolean doDeleteOnMountPointRemoved() {
- return configuration.getPropertyBoolean(SECTION_MARKER_AAI, Config.DELETEONMOUNTPOINTREMOVED.propertyKey);
- }
-
- public boolean getTrustAll() {
- return configuration.getPropertyBoolean(SECTION_MARKER_AAI, Config.TRUSTALLCERTS.propertyKey);
- }
-
- public String getPcks12CertificateFilename() {
- return configuration.getProperty(SECTION_MARKER_AAI, Config.PCKS12CERTFILENAME.propertyKey);
- }
-
- public String getPcks12CertificatePassphrase() {
- return configuration.getProperty(SECTION_MARKER_AAI, Config.PCKS12PASSPHRASE.propertyKey);
- }
-
- public int getConnectionTimeout() {
- long res = configuration.getPropertyLong(SECTION_MARKER_AAI, Config.PCKS12PASSPHRASE.propertyKey).orElse(DEFAULT_VALUE_CONNECTION_TIMEOUT);
- return (int)res;
- }
-
- public boolean isOff() {
- return configuration.getProperty(SECTION_MARKER_AAI, Config.BASEURL.propertyKey).equalsIgnoreCase("off");
- }
-
- public String getBaseUri() {
- String res = configuration.getProperty(SECTION_MARKER_AAI, Config.APIVERSION.propertyKey);
- if (!res.startsWith("/")) {
- res = "/" + res;
- }
- return res;
- }
-
- public String getBaseUrl() {
- if (isOff()) {
- return "";
- } else {
- String url = configuration.getProperty(SECTION_MARKER_AAI, Config.BASEURL.propertyKey);
- if (!url.endsWith("/")) {
- url += "/";
- }
- String apiVersion = configuration.getProperty(SECTION_MARKER_AAI, Config.APIVERSION.propertyKey);
- if (apiVersion.startsWith("/")) {
- apiVersion = apiVersion.substring(1);
- }
- return url + apiVersion;
- }
- }
-
- public Map<String, String> getHeaders() {
-
- Map<String,String> headers = _parseHeadersMap(configuration.getProperty(SECTION_MARKER_AAI, Config.HEADERS.propertyKey));
- headers.put(HEADER_KEY_APPLICATION, configuration.getProperty(SECTION_MARKER_AAI, Config.APPLICATIONID.propertyKey));
-
- String credentials = configuration.getProperty(SECTION_MARKER_AAI, Config.USERCREDENTIALS.propertyKey);
- if (!nullorempty(credentials)) {
- String credentialParts[] = credentials.split(":");
- if (credentialParts.length == 2) {
- // 0:username 1:password
- String s = headers.getOrDefault("Authorization", null);
- if (nullorempty(s) && !nullorempty(credentialParts[0]) && !nullorempty(credentialParts[1])) {
- headers.put("Authorization",
- "Basic " + new String(Base64.getEncoder().encode(credentials.getBytes())));
- }
- }
- }
- return headers;
- }
-
- @Override
- public String getSectionName() {
- return SECTION_MARKER_AAI;
- }
-
- @Override
- public void defaults() {
- for (Config conf : Config.values()) {
- configuration.setPropertyIfNotAvailable(SECTION_MARKER_AAI, conf.propertyKey, conf.propertyValue);
- }
- // If file is available, the content is assigned to related parameters.
- getAaiPropertiesFile();
- }
-
- @Override
- public String toString() {
- return "AaiConfig [doDeleteOnMountPointRemoved()=" + doDeleteOnMountPointRemoved() + ", getTrustAll()="
- + getTrustAll() + ", getPcks12CertificateFilename()=" + getPcks12CertificateFilename()
- + ", getPcks12CertificatePassphrase()=" + getPcks12CertificatePassphrase() + ", getConnectionTimeout()="
- + getConnectionTimeout() + ", isOff()=" + isOff() + ", getBaseUri()=" + getBaseUri() + ", getBaseUrl()="
- + getBaseUrl() + ", getHeaders()=" + getHeaders() + ", getSectionName()=" + getSectionName() + "]";
- }
-
- /*
- * Private
- */
-
- private boolean nullorempty(String s) {
- return s == null || s.isEmpty();
- }
-
- /**
- * Convert headers to configuration string.
- * @param headers
- * @return
- */
- @SuppressWarnings("unused")
- private static String _printHeadersMap(Map<String, String> headers) {
- String r = "[";
- if (headers != null) {
- int i = 0;
- for (Entry<String, String> entry : headers.entrySet()) {
- if (i > 0) {
- r += ",";
- }
- r += "\"" + entry.getKey() + ":" + entry.getValue() + "\"";
- i++;
- }
- }
- r += "]";
- return r;
- }
-
- private static Map<String, String> _parseHeadersMap(String s) {
-
- LOG.info("Parse: '{}'",s);
- Map<String, String> r = new HashMap<>();
- if (s != null) {
- s = s.trim();
- if (!s.isEmpty()) {
- JSONArray a;
- try {
- a = new JSONArray(s);
- if (a.length() > 0) {
- for (int i = 0; i < a.length(); i++) {
- String item = a.getString(i);
- String[] hlp = item.split(":");
- if (hlp.length > 1) {
- r.put(hlp[0], hlp[1]);
- }
- }
- }
- } catch (Exception e) {
- LOG.debug("Unparsable '{}'", s);
- }
- }
- }
- return r;
- }
-
- /**
- * Read file if available and assign to configuration
- */
- private void getAaiPropertiesFile() {
- String aaiPropertiesFileName = configuration.getProperty(SECTION_MARKER_AAI, Config.AAIPROP_FILE.propertyKey);
- File f = new File(aaiPropertiesFileName);
- if (f.exists()) {
- try {
- FileInputStream in = new FileInputStream(f);
- Properties defaultProps = new Properties();
- defaultProps.load(in);
-
- for (Config conf : Config.values()) {
- if (conf.propertyKeySecondFile.isPresent()) {
- String config = defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.ssl.key", conf.propertyValue);
- LOG.debug("Property file assign {} = {} ",conf.propertyKey, config );
- configuration.setPropertyIfNotAvailable(
- SECTION_MARKER_AAI,
- conf.propertyKey,
- config);
- }
- }
-
- in.close();
- } catch (IOException e) {
- LOG.warn("Problem during file read {} {}", f.getAbsoluteFile(), e);
- }
- }
- }
+ private static Logger LOG = LoggerFactory.getLogger(AaiConfig.class);
+
+ private static final String SECTION_MARKER_AAI = "aai";
+
+ private enum Config {
+ AAIPROP_FILE("aaiPropertiesFile", "null"), BASEURL("aaiUrl", "off", "org.onap.ccsdk.sli.adaptors.aai.uri"),
+ USERCREDENTIALS("aaiUserCredentials", ""), HEADERS("aaiHeaders", "[\"X-TransactionId: 9999\"]"),
+ DELETEONMOUNTPOINTREMOVED("aaiDeleteOnMountpointRemove", false),
+ TRUSTALLCERTS("aaiTrustAllCerts", false, "org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore"),
+ APIVERSION("aaiApiVersion", "aai/v13"),
+ PCKS12CERTFILENAME("aaiPcks12ClientCertFile", "", "org.onap.ccsdk.sli.adaptors.aai.ssl.key"),
+ PCKS12PASSPHRASE("aaiPcks12ClientCertPassphrase", "", "org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd"),
+ CONNECTIONTIMEOUT("aaiClientConnectionTimeout", String.valueOf(DEFAULT_VALUE_CONNECTION_TIMEOUT),
+ "connection.timeout"), //in ms;
+ APPLICATIONID("aaiApplicationId", "SDNR", "org.onap.ccsdk.sli.adaptors.aai.application"),
+ HTTPREADTIMEOUT("aaiReadTimeout", "60000", "read.timeout");
+
+ private String propertyKey;
+ private String propertyValue;
+ private Optional<String> propertyKeySecondFile;
+
+ Config(String propertyKey, Object propertyValue) {
+ this.propertyKey = propertyKey;
+ this.propertyValue = propertyValue.toString();
+ this.propertyKeySecondFile = Optional.empty();
+ }
+
+ Config(String propertyKey, Object propertyValue, String propertyKeySecondFile) {
+ this(propertyKey, propertyValue);
+ this.propertyKeySecondFile = Optional.of(propertyKeySecondFile);
+ }
+ }
+
+ private static final long DEFAULT_VALUE_CONNECTION_TIMEOUT = 30000; //in ms
+ private static final String HEADER_KEY_APPLICATION = "X-FromAppId";
+
+ private final ConfigurationFileRepresentation configuration;
+
+ public AaiConfig(ConfigurationFileRepresentation configuration) {
+ HtAssert.nonnull(configuration);
+ this.configuration = configuration;
+ this.configuration.addSection(SECTION_MARKER_AAI);
+ defaults();
+ }
+
+ /*
+ * Getter
+ */
+
+ public boolean doDeleteOnMountPointRemoved() {
+ return configuration.getPropertyBoolean(SECTION_MARKER_AAI, Config.DELETEONMOUNTPOINTREMOVED.propertyKey);
+ }
+
+ public boolean getTrustAll() {
+ return configuration.getPropertyBoolean(SECTION_MARKER_AAI, Config.TRUSTALLCERTS.propertyKey);
+ }
+
+ public String getPcks12CertificateFilename() {
+ return configuration.getProperty(SECTION_MARKER_AAI, Config.PCKS12CERTFILENAME.propertyKey);
+ }
+
+ public String getPcks12CertificatePassphrase() {
+ return configuration.getProperty(SECTION_MARKER_AAI, Config.PCKS12PASSPHRASE.propertyKey);
+ }
+
+ public int getConnectionTimeout() {
+ long res = configuration.getPropertyLong(SECTION_MARKER_AAI, Config.CONNECTIONTIMEOUT.propertyKey)
+ .orElse(DEFAULT_VALUE_CONNECTION_TIMEOUT);
+ return (int) res;
+ }
+
+ public boolean isOff() {
+ return configuration.getProperty(SECTION_MARKER_AAI, Config.BASEURL.propertyKey).equalsIgnoreCase("off");
+ }
+
+ public String getBaseUri() {
+ String res = configuration.getProperty(SECTION_MARKER_AAI, Config.APIVERSION.propertyKey);
+ if (!res.startsWith("/")) {
+ res = "/" + res;
+ }
+ return res;
+ }
+
+ public String getBaseUrl() {
+ if (isOff()) {
+ return "";
+ }
+
+ String url = configuration.getProperty(SECTION_MARKER_AAI, Config.BASEURL.propertyKey);
+ if (!url.endsWith("/")) {
+ url += "/";
+ }
+ String apiVersion = configuration.getProperty(SECTION_MARKER_AAI, Config.APIVERSION.propertyKey);
+ if (apiVersion.startsWith("/")) {
+ apiVersion = apiVersion.substring(1);
+ }
+ return url + apiVersion;
+
+ }
+
+ public Map<String, String> getHeaders() {
+
+ Map<String, String> headers = _parseHeadersMap(
+ configuration.getProperty(SECTION_MARKER_AAI, Config.HEADERS.propertyKey));
+ headers.put(HEADER_KEY_APPLICATION,
+ configuration.getProperty(SECTION_MARKER_AAI, Config.APPLICATIONID.propertyKey));
+
+ String credentials = configuration.getProperty(SECTION_MARKER_AAI, Config.USERCREDENTIALS.propertyKey);
+ if (!nullorempty(credentials)) {
+ String credentialParts[] = credentials.split(":");
+ if (credentialParts.length == 2) {
+ // 0:username 1:password
+ String s = headers.getOrDefault("Authorization", null);
+ if (nullorempty(s) && !nullorempty(credentialParts[0]) && !nullorempty(credentialParts[1])) {
+ headers.put("Authorization",
+ "Basic " + new String(Base64.getEncoder().encode(credentials.getBytes())));
+ }
+ }
+ }
+ return headers;
+ }
+
+ @Override
+ public String getSectionName() {
+ return SECTION_MARKER_AAI;
+ }
+
+ @Override
+ public void defaults() {
+ for (Config conf : Config.values()) {
+ configuration.setPropertyIfNotAvailable(SECTION_MARKER_AAI, conf.propertyKey, conf.propertyValue);
+ }
+ // If file is available, the content is assigned to related parameters.
+ getAaiPropertiesFile();
+ }
+
+ @Override
+ public String toString() {
+ return "AaiConfig [doDeleteOnMountPointRemoved()=" + doDeleteOnMountPointRemoved() + ", getTrustAll()="
+ + getTrustAll() + ", getPcks12CertificateFilename()=" + getPcks12CertificateFilename()
+ + ", getPcks12CertificatePassphrase()=" + getPcks12CertificatePassphrase() + ", getConnectionTimeout()="
+ + getConnectionTimeout() + ", isOff()=" + isOff() + ", getBaseUri()=" + getBaseUri() + ", getBaseUrl()="
+ + getBaseUrl() + ", getHeaders()=" + getHeaders() + ", getSectionName()=" + getSectionName() + "]";
+ }
+
+ /*
+ * Private
+ */
+
+ private boolean nullorempty(String s) {
+ return s == null || s.isEmpty();
+ }
+
+ /**
+ * Convert headers to configuration string.
+ * @param headers
+ * @return
+ */
+ @SuppressWarnings("unused")
+ private static String _printHeadersMap(Map<String, String> headers) {
+ String r = "[";
+ if (headers != null) {
+ int i = 0;
+ for (Entry<String, String> entry : headers.entrySet()) {
+ if (i > 0) {
+ r += ",";
+ }
+ r += "\"" + entry.getKey() + ":" + entry.getValue() + "\"";
+ i++;
+ }
+ }
+ r += "]";
+ return r;
+ }
+
+ private static Map<String, String> _parseHeadersMap(String s) {
+
+ LOG.info("Parse: '{}'", s);
+ Map<String, String> r = new HashMap<>();
+ if (s != null) {
+ s = s.trim();
+ if (!s.isEmpty()) {
+ JSONArray a;
+ try {
+ a = new JSONArray(s);
+ if (a.length() > 0) {
+ for (int i = 0; i < a.length(); i++) {
+ String item = a.getString(i);
+ String[] hlp = item.split(":");
+ if (hlp.length > 1) {
+ r.put(hlp[0], hlp[1]);
+ }
+ }
+ }
+ } catch (Exception e) {
+ LOG.debug("Unparsable '{}'", s);
+ }
+ }
+ }
+ return r;
+ }
+
+ /**
+ * Read file if available and assign to configuration
+ */
+ private void getAaiPropertiesFile() {
+ String aaiPropertiesFileName = configuration.getProperty(SECTION_MARKER_AAI, Config.AAIPROP_FILE.propertyKey);
+ File f = new File(aaiPropertiesFileName);
+ if (f.exists()) {
+ InputStream in = null;
+ try {
+ in = new FileInputStream(f);
+ Properties defaultProps = new Properties();
+ defaultProps.load(in);
+
+ for (Config conf : Config.values()) {
+ if (conf.propertyKeySecondFile.isPresent()) {
+ String config = defaultProps.getProperty(conf.propertyKeySecondFile.get(),
+ conf.propertyValue);
+ LOG.debug("Property file assign {} = {} ", conf.propertyKey, config);
+ configuration.setProperty(SECTION_MARKER_AAI, conf.propertyKey, config);
+ }
+ }
+
+ } catch (IOException e) {
+ LOG.warn("Problem during file read {} {}", f.getAbsoluteFile(), e);
+ } finally {
+ if (in != null) {
+ try {
+ in.close();
+ } catch (IOException e) {
+ LOG.warn("problem closing file string for {}: {}",f.getAbsoluteFile(),e);
+ }
+ }
+ }
+ }
+ }
}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorImpl.java
index 11e86e896..66caf0df7 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorImpl.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorImpl.java
@@ -29,7 +29,7 @@ import java.util.concurrent.ScheduledExecutorService;
import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
import org.onap.ccsdk.features.sdnr.wt.common.configuration.filechange.IConfigChangedListener;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl.config.DmConfig;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.handler.ODLEventListenerHandler;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler.ODLEventListenerHandler;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.DeviceMonitoredNe;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfAccessor;
@@ -215,6 +215,17 @@ public class DeviceMonitorImpl implements DeviceMonitor, IConfigChangedListener
}
}
+ /**
+ * For test run the tasks
+ */
+ public void taskTestRun() {
+ synchronized(queue) {
+ for (DeviceMonitorTask task : queue.values()) {
+ task.run();
+ }
+ }
+ }
+
/*-------------------------------------------------------------
* Private functions
*/
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorTask.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorTask.java
index fc7af5a92..b25f3fd8b 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorTask.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/devicemonitor/impl/DeviceMonitorTask.java
@@ -31,7 +31,7 @@ import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.handler.ODLEventListenerHandler;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler.ODLEventListenerHandler;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalSeverity;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.DeviceMonitoredNe;
import org.slf4j.Logger;
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/datamanager/DeviceManagerDatabaseNotificationService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/DeviceManagerDatabaseNotificationService.java
index e65a42720..1db1e2ca5 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/datamanager/DeviceManagerDatabaseNotificationService.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/DeviceManagerDatabaseNotificationService.java
@@ -15,21 +15,27 @@
* the License.
* ============LICENSE_END==========================================================================
******************************************************************************/
-package org.onap.ccsdk.features.sdnr.wt.devicemanager.datamanager;
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler;
import java.util.List;
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.onap.ccsdk.features.sdnr.wt.common.HtAssert;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl.DcaeForwarderInternal;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalSeverity;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.AttributeValueChangedNotificationXml;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectCreationNotificationXml;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ObjectDeletionNotificationXml;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClientInternal;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.impl.MaintenanceServiceImpl;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EquipmentService;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.FaultService;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NotificationService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter.DevicemanagerNotificationDelayService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter.NotificationDelayFilter;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter.NotificationDelayedListener;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.EquipmentData;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.EventlogNotificationBuilder;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.FaultData;
@@ -43,28 +49,41 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SourceType;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
-/**
- * @author herbert
- *
- */
-public class DeviceManagerDatabaseNotificationService implements NotificationService, EquipmentService, FaultService {
+public class DeviceManagerDatabaseNotificationService implements NotificationService, EquipmentService, FaultService,NotificationDelayedListener<ProblemNotificationXml> {
+
+ private static final Logger LOG = LoggerFactory.getLogger(DeviceManagerDatabaseNotificationService.class);
- private final DataProvider databaseService;
- private final WebSocketServiceClientInternal webSocketService;
+ private final @NonNull DataProvider databaseService;
+ private final @NonNull WebSocketServiceClientInternal webSocketService;
+ private @NonNull
+ final DevicemanagerNotificationDelayService notificationDelayService;
+ private @NonNull
+ final DcaeForwarderInternal aotsDcaeForwarder;
+
+ private final @NonNull MaintenanceServiceImpl maintenanceService;
/**
* @param databaseService to access database
+ * @param maintenanceService
* @param webSocketService to send notifications
+ * @param notificationDelayService filter to prevent toggle alarms
+ * @param aotsDcaeForwarder
*/
- public DeviceManagerDatabaseNotificationService(DataProvider databaseService,
- WebSocketServiceClientInternal webSocketService) {
+ public DeviceManagerDatabaseNotificationService(@NonNull DataProvider databaseService,
+ @NonNull MaintenanceServiceImpl maintenanceService, @NonNull WebSocketServiceClientInternal webSocketService,
+ @NonNull DevicemanagerNotificationDelayService notificationDelayService,
+ @NonNull DcaeForwarderInternal aotsDcaeForwarder) {
super();
- HtAssert.nonnull(databaseService);
- HtAssert.nonnull(webSocketService);
+ HtAssert.nonnull(databaseService, maintenanceService,webSocketService, notificationDelayService);
this.databaseService = databaseService;
+ this.maintenanceService = maintenanceService;
this.webSocketService = webSocketService;
+ this.notificationDelayService = notificationDelayService;
+ this.aotsDcaeForwarder = aotsDcaeForwarder;
}
@Override
@@ -120,16 +139,40 @@ public class DeviceManagerDatabaseNotificationService implements NotificationSer
ProblemNotificationXml notificationXml = new ProblemNotificationXml(faultNotification);
String nodeName = faultNotification.getNodeId();
+ if(NotificationDelayFilter.isEnabled())
+ {
+ if(notificationXml.getSeverity() == InternalSeverity.NonAlarmed) {
+ this.notificationDelayService.getInstance(nodeName, this).clearAlarmNotification(notificationXml);
+ } else {
+ this.notificationDelayService.getInstance(nodeName, this).pushAlarmNotification(notificationXml);
+ }
+ }
+ else
+ {
+ this.pushAlarmIfNotInMaintenance(nodeName,notificationXml);
+ }
// ToggleAlarmFilter functionality
-// if (delayFilter.processNotification(notificationXml.getSeverity() == InternalSeverity.NonAlarmed, notificationXml.getProblem(), notificationXml))
-// {
-// dcaeForwarder.sendProblemNotificationUsingMaintenanceFilter(nodeName, notificationXml);
+// if (notificationDelayService.processNotification(notificationXml.getSeverity() == InternalSeverity.NonAlarmed,
+// notificationXml.getProblem(), notificationXml)) {
+// if (notificationDelayService.processNotification(notificationXml)) {
+// aotsDcaeForwarder.sendProblemNotificationUsingMaintenanceFilter(nodeName, notificationXml);
+// }
// }
// end of ToggleAlarmFilter
this.webSocketService.sendViaWebsockets(nodeName, notificationXml);
}
-
+ private void pushAlarmIfNotInMaintenance(String nodeName,ProblemNotificationXml notificationXml)
+ {
+ if(!this.maintenanceService.isONFObjectInMaintenance(nodeName, notificationXml.getObjectId(), notificationXml.getProblem()))
+ {
+ this.aotsDcaeForwarder.sendProblemNotification(nodeName, notificationXml);
+ }
+ else
+ {
+ LOG.debug("Notification will not be sent to external services. Device "+nodeName+" is in maintenance mode");
+ }
+ }
@Override
public void faultNotification(@NonNull NodeId nodeId, @Nullable Integer counter, @Nullable DateAndTime timeStamp,
@Nullable String objectId, @Nullable String problem, @Nullable SeverityType severity) {
@@ -165,4 +208,10 @@ public class DeviceManagerDatabaseNotificationService implements NotificationSer
return bFaultcurrent.build();
}
+
+ @Override
+ public void onNotificationDelay(String nodeName,ProblemNotificationXml notification) {
+ LOG.debug("Got delayed event of type :: {}", ProblemNotificationXml.class.getSimpleName());
+ this.pushAlarmIfNotInMaintenance(nodeName,notification);
+ }
}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/handler/ODLEventListenerHandler.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/ODLEventListenerHandler.java
index 1b31a4e98..003a30c72 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/handler/ODLEventListenerHandler.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/ODLEventListenerHandler.java
@@ -15,7 +15,7 @@
* the License.
* ============LICENSE_END==========================================================================
******************************************************************************/
-package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.handler;
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp;
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/handler/RpcPushNotificationsHandler.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/RpcPushNotificationsHandler.java
index 9a0deae85..7c04ffc54 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/handler/RpcPushNotificationsHandler.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/RpcPushNotificationsHandler.java
@@ -21,8 +21,7 @@
* ============LICENSE_END=======================================================
*
*/
-
-package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.handler;
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl.DcaeForwarderInternal;
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ConnectionStatusHousekeepingService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ConnectionStatusHousekeepingService.java
index 1628fba1b..3335a88de 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ConnectionStatusHousekeepingService.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ConnectionStatusHousekeepingService.java
@@ -36,6 +36,7 @@ import org.eclipse.jdt.annotation.NonNull;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.InternalConnectionStatus;
import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.ReadTransaction;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
import org.opendaylight.mdsal.singleton.common.api.ServiceGroupIdentifier;
@@ -142,8 +143,8 @@ public class ConnectionStatusHousekeepingService implements ClusterSingletonServ
@SuppressWarnings("null")
@NonNull InstanceIdentifier<Node> instanceIdentifier = NETCONF_TOPO_IID.child(Node.class,
new NodeKey(new NodeId(nodeId)));
- FluentFuture<Optional<Node>> optionalNode = this.dataBroker.newReadOnlyTransaction()
- .read(LogicalDatastoreType.OPERATIONAL, instanceIdentifier);
+ ReadTransaction trans = this.dataBroker.newReadOnlyTransaction();
+ FluentFuture<Optional<Node>> optionalNode =trans.read(LogicalDatastoreType.OPERATIONAL, instanceIdentifier);
try {
Node node = optionalNode.get(5, TimeUnit.SECONDS).get();
LOG.debug("node is {}", node);
@@ -157,6 +158,9 @@ public class ConnectionStatusHousekeepingService implements ClusterSingletonServ
} catch (ExecutionException | InterruptedException | TimeoutException e) {
LOG.warn("unable to get node info: {}", e);
}
+ finally {
+ trans.close();
+ }
return null;
}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementHouskeepingService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementHouskeepingService.java
index 73a3e7c24..ef666966f 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementHouskeepingService.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ResyncNetworkElementHouskeepingService.java
@@ -27,8 +27,8 @@ import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.Nullable;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl.DeviceMonitor;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler.ODLEventListenerHandler;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.DeviceManagerImpl;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.handler.ODLEventListenerHandler;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement;
import org.opendaylight.mdsal.binding.api.MountPoint;
import org.opendaylight.mdsal.binding.api.MountPointService;
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java
index 9a2b81cbb..11fba81f4 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java
@@ -67,7 +67,7 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl
private @Nullable
final ResyncNetworkElementsListener resyncCallbackListener;
- DeviceManagerApiServiceImpl(final RpcProviderService rpcProviderRegistry,
+ public DeviceManagerApiServiceImpl(final RpcProviderService rpcProviderRegistry,
MaintenanceServiceImpl maintenanceService, ResyncNetworkElementsListener listener,
PushNotifications pushNotificationsListener) {
this.maintenanceService = maintenanceService;
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java
index bf467cf9c..d202def5e 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerImpl.java
@@ -28,18 +28,16 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.IEntityDataProvider;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.IEsConfig;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.aaiconnector.impl.AaiProviderClient;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.archiveservice.ArchiveCleanService;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.datamanager.DeviceManagerDatabaseNotificationService;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl.DcaeForwarderImpl;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl.DcaeForwarderInternal;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.dcaeconnector.impl.DcaeProviderClient;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl.DeviceMonitor;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl.DeviceMonitorImpl;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler.DeviceManagerDatabaseNotificationService;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler.ODLEventListenerHandler;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler.RpcPushNotificationsHandler;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.housekeeping.ConnectionStatusHousekeepingService;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.housekeeping.ResyncNetworkElementHouskeepingService;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.handler.ODLEventListenerHandler;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.handler.RpcPushNotificationsHandler;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.listener.NetconfChangeListener;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClientDummyImpl;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClientImpl2;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClientInternal;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.impl.MaintenanceServiceImpl;
@@ -100,7 +98,7 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa
// Devicemanager common services for network element handler
private @Nullable WebSocketServiceClientInternal webSocketService;
private ODLEventListenerHandler odlEventListenerHandler; //EventHandlingService
- private NetconfChangeListener netconfChangeListener;
+ //private NetconfChangeListener netconfChangeListener;
private DeviceManagerApiServiceImpl rpcApiService;
private PerformanceManagerImpl performanceManager;
private DcaeProviderClient dcaeProviderClient;
@@ -200,14 +198,7 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa
this.maintenanceService = new MaintenanceServiceImpl(iEntityDataProvider.getHtDatabaseMaintenance());
// Websockets
- try {
- this.webSocketService = new WebSocketServiceClientImpl2(websocketmanagerService);
- } catch (Exception e) {
- LOG.error("Can not start websocket service. Loading mock class.", e);
- this.webSocketService = new WebSocketServiceClientDummyImpl();
- }
-
- this.deviceManagerDatabaseAndNotificationService = new DeviceManagerDatabaseNotificationService(dataProvider, webSocketService);
+ this.webSocketService = new WebSocketServiceClientImpl2(websocketmanagerService);
IEsConfig esConfig = iEntityDataProvider.getEsConfig();
// DCAE
@@ -218,6 +209,9 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa
String myDbKeyNameExtended = MYDBKEYNAMEBASE + "-" + esConfig.getCluster();
this.aotsDcaeForwarder = new DcaeForwarderImpl(null, dcaeProviderClient, maintenanceService);
+
+ this.deviceManagerDatabaseAndNotificationService = new DeviceManagerDatabaseNotificationService(dataProvider, maintenanceService,webSocketService, notificationDelayService, aotsDcaeForwarder);
+
this.rpcPushNotificationsHandler = new RpcPushNotificationsHandler(webSocketService,
dataProvider, aotsDcaeForwarder);
this.odlEventListenerHandler = new ODLEventListenerHandler(myDbKeyNameExtended, webSocketService,
@@ -279,7 +273,7 @@ public class DeviceManagerImpl implements NetconfNetworkElementService, DeviceMa
close(aaiProviderClient);
close(deviceMonitor);
//close(htDatabaseClient);
- close(netconfChangeListener);
+ //close(netconfChangeListener);
close(maintenanceService);
close(rpcApiService);
close(notificationDelayService);
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfConnectHandler.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfConnectHandler.java
index 2d949e59a..9065ffd4b 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfConnectHandler.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerNetconfConnectHandler.java
@@ -24,7 +24,7 @@ import java.util.concurrent.ConcurrentHashMap;
import org.eclipse.jdt.annotation.NonNull;
import org.onap.ccsdk.features.sdnr.wt.common.HtAssert;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl.DeviceMonitor;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.handler.ODLEventListenerHandler;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler.ODLEventListenerHandler;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.factory.NetworkElementFactory;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.ne.service.NetworkElement;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServiceProvider;
@@ -149,8 +149,12 @@ public class DeviceManagerNetconfConnectHandler implements NetconfNodeConnectLis
@Override
public void close() {
- registerNetconfNodeConnectListener.close();
- registerNetconfNodeStateListener.close();
+ if (registerNetconfNodeConnectListener != null) {
+ registerNetconfNodeConnectListener.close();
+ }
+ if (registerNetconfNodeStateListener != null) {
+ registerNetconfNodeStateListener.close();
+ }
}
/*--------------------------------------------
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlAkka/AkkaConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlAkka/AkkaConfig.java
deleted file mode 100644
index 7e54881ed..000000000
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlAkka/AkkaConfig.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START========================================================================
- * ONAP : ccsdk feature sdnr wt
- * =================================================================================================
- * Copyright (C) 2019 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.devicemanager.impl.conf.odlAkka;
-
-import java.io.File;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.typesafe.config.Config;
-import com.typesafe.config.ConfigFactory;
-
-public class AkkaConfig {
-
- @SuppressWarnings("unused")
- private static final Logger LOG = LoggerFactory.getLogger(AkkaConfig.class);
-
- private static final String DEFAULT_FILENAME = "configuration/initial/akka.conf";
- private final String filename;
- private ClusterConfig cluserConfig;
-
- public ClusterConfig getClusterConfig() {
- return this.cluserConfig;
- }
-
- private AkkaConfig(String filename) {
- this.filename = filename;
- }
-
- public AkkaConfig() {
- this(null);
- }
-
- @Override
- public String toString() {
- return "AkkaConfig [filename=" + filename + ", cluserConfig=" + cluserConfig + "]";
- }
-
- private void loadFromFile() throws Exception {
- Config cfg = ConfigFactory.parseFile(new File(this.filename));
- this.cluserConfig = new ClusterConfig(cfg.getConfig("odl-cluster-data").getConfig("akka").getConfig("cluster"));
- }
-
- public boolean isCluster() {
- return this.cluserConfig != null ? this.cluserConfig.isCluster() : false;
- }
-
- public boolean isClusterAndFirstNode() {
- return isSingleNode() || isCluster() && getClusterConfig().getRoleMemberIndex() == 1;
- }
-
- public static AkkaConfig load() throws Exception {
- return load(DEFAULT_FILENAME);
- }
-
- public static AkkaConfig load(String filename) throws Exception {
- AkkaConfig cfg = new AkkaConfig(filename);
- cfg.loadFromFile();
- return cfg;
- }
-
- public boolean isSingleNode() {
- return !this.isCluster();
- }
- public static AkkaConfig parse(String content) throws Exception {
- Config cfg = ConfigFactory.parseString(content);
- AkkaConfig c = new AkkaConfig();
- c.cluserConfig=new ClusterConfig(cfg.getConfig("odl-cluster-data").getConfig("akka").getConfig("cluster"));
- return c;
- }
-}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlAkka/ClusterConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlAkka/ClusterConfig.java
deleted file mode 100644
index c6c8c1533..000000000
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlAkka/ClusterConfig.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START========================================================================
- * ONAP : ccsdk feature sdnr wt
- * =================================================================================================
- * Copyright (C) 2019 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.devicemanager.impl.conf.odlAkka;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.conf.odlGeo.ClusterRoleInfo;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.conf.odlGeo.ClusterRoleInfoCollection;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.typesafe.config.Config;
-
-public class ClusterConfig {
-
- private static final Logger LOG = LoggerFactory.getLogger(ClusterConfig.class);
-
- private final List<ClusterNodeInfo> seedNodes;
- private final ClusterRoleInfoCollection roles;
- private ClusterNodeInfo ismeInfo;
-
- public static ClusterConfig defaultSingleNodeConfig()
- {
- ClusterConfig cfg=new ClusterConfig();
- cfg.ismeInfo=ClusterNodeInfo.defaultSingleNodeInfo();
- cfg.seedNodes.add(cfg.ismeInfo);
- cfg.roles.add(ClusterRoleInfo.defaultSingleNodeRole());
- return cfg;
- }
- public ClusterConfig()
- {
- this.seedNodes = new ArrayList<>();
- this.roles = new ClusterRoleInfoCollection();
-
- }
- public ClusterConfig(Config o) throws Exception {
- {
- this.seedNodes = new ArrayList<>();
- this.roles = new ClusterRoleInfoCollection();
- List<String> a = o.getStringList("seed-nodes");
- for (int i = 0; i < a.size(); i++) {
- ClusterNodeInfo info = new ClusterNodeInfo(a.get(i));
- this.seedNodes.add(info);
- }
- a = o.getStringList("roles");
- for (int i = 0; i < a.size(); i++) {
- ClusterRoleInfo s = new ClusterRoleInfo(a.get(i));
- this.roles.add(s);
- }
- int idx = this.roles.get(0).getIndex() - 1;
- if (idx >= 0 && idx < this.seedNodes.size()) {
- this.ismeInfo = this.seedNodes.get(idx);
- } else {
- this.ismeInfo = null;
- }
- }
-
- }
-
- public boolean isCluster() {
- return this.seedNodes != null ? this.seedNodes.size() > 1 : false;
- }
-
- public boolean isMe(ClusterNodeInfo i) {
- return this.ismeInfo != null ? this.ismeInfo.equals(i) : false;
- }
-
- public List<ClusterNodeInfo> getSeedNodes() {
- return this.seedNodes;
- }
-
- public String getHostName(String defaultValue) {
- if (getRoleMemberIndex() > 0 && getRoleMemberIndex() <= seedNodes.size()) {
- return this.seedNodes.get(getRoleMemberIndex()-1).getRemoteAddress();
- } else {
- LOG.warn("Seednode not available for roleMemberIndex {}. Using default {}",getRoleMember(), defaultValue);
- return defaultValue;
- }
- }
-
- public String getDBClusterName(String defaultValue) {
- String r = null;
- if (this.seedNodes != null && this.seedNodes.size() > 0) {
- r = String.format("cluster-%s.%d", this.seedNodes.get(0).getRemoteAddress(), this.seedNodes.get(0).getPort());
- }
- if (r == null || r.isEmpty()) {
- r = defaultValue;
- }
- return r;
- }
- public String getClusterSeedNodeName() {
- return this.getClusterSeedNodeName("");
- }
- public String getClusterSeedNodeName(String defaultValue) {
- int idx=this.getRoleMemberIndex()-1;
- String r=null;
- if(this.seedNodes!=null && idx>=0 && this.seedNodes.size()>0 && this.seedNodes.size()>idx)
- {
- r=this.seedNodes.get(idx).getSeedNodeName();
- }
- if (r == null || r.isEmpty()) {
- r = defaultValue;
- }
- return r;
- }
- public int getRoleMemberIndex() {
-
- ClusterRoleInfo role=this.roles.get("member");
- return role!=null?role.getIndex():0;
- }
- public ClusterRoleInfo getRoleMember() {
- return this.roles.get("member");
- }
-
- @Override
- public String toString() {
- return "ClusterConfig [seedNodes=" + seedNodes + ", roles=" + roles + ", ismeInfo=" + ismeInfo + "]";
- }
-
-
-}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlAkka/ClusterNodeInfo.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlAkka/ClusterNodeInfo.java
deleted file mode 100644
index 7bc015fed..000000000
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlAkka/ClusterNodeInfo.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START========================================================================
- * ONAP : ccsdk feature sdnr wt
- * =================================================================================================
- * Copyright (C) 2019 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.devicemanager.impl.conf.odlAkka;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class ClusterNodeInfo {
- private final String protocol;
- private final String clusterName;
- private final String remoteAdr;
- private final int port;
- private final String seedNodeName;
-
- public static ClusterNodeInfo defaultSingleNodeInfo() {
- return new ClusterNodeInfo("akka.tcp","opendaylight-cluster-data","127.0.0.1",2550);
- }
-
- public ClusterNodeInfo(String s) throws Exception {
- final String regex = "([a-z.]*):\\/\\/([a-zA-Z0-9-]*)@([a-zA-Z0-9.-]*):([0-9]*)";
- final Pattern pattern = Pattern.compile(regex);
- final Matcher matcher = pattern.matcher(s);
- if (!matcher.find()) {
- throw new Exception("invalid seedNode format");
- }
- this.seedNodeName = matcher.group();
- this.protocol = matcher.group(1);
- this.clusterName = matcher.group(2);
- this.remoteAdr = matcher.group(3);
- this.port = Integer.parseInt(matcher.group(4));
- }
-
- public ClusterNodeInfo(String protocol, String clustername, String remoteadr, int port) {
- this.protocol=protocol;
- this.clusterName=clustername;
- this.remoteAdr=remoteadr;
- this.port=port;
- this.seedNodeName=this.protocol+"://"+this.clusterName+"@"+this.remoteAdr+":"+this.port;
- }
-
- public String getProtocol() {
- return protocol;
- }
-
- public String getClusterName() {
- return clusterName;
- }
-
- public String getRemoteAddress() {
- return remoteAdr;
- }
- public String getSeedNodeName() {
- return seedNodeName;
- }
-
- public int getPort() {
- return port;
- }
-
- @Override
- public String toString() {
- return "ClusterNodeInfo [protocol=" + protocol + ", clusterName=" + clusterName + ", remoteAdr=" + remoteAdr
- + ", port=" + port + ", seedNodeName=" + seedNodeName + "]";
- }
-
-}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlGeo/ClusterRoleInfo.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlGeo/ClusterRoleInfo.java
deleted file mode 100644
index 9a9793b89..000000000
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlGeo/ClusterRoleInfo.java
+++ /dev/null
@@ -1,91 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START========================================================================
- * ONAP : ccsdk feature sdnr wt
- * =================================================================================================
- * Copyright (C) 2019 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.devicemanager.impl.conf.odlGeo;
-
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-public class ClusterRoleInfo {
- private final String Role;
- private final int Index;
-
- public ClusterRoleInfo(String s) throws Exception {
- final String regex = "([a-zA-Z]*)-([0-9]*)";
- final Pattern pattern = Pattern.compile(regex);
- final Matcher matcher = pattern.matcher(s);
- if (!matcher.find()) {
- throw new Exception("unexpected role format:"+s);
- }
- this.Role = matcher.group(1);
- this.Index = Integer.parseInt(matcher.group(2));
- }
-
- private ClusterRoleInfo(String role, int idx) {
- this.Role=role;
- this.Index=idx;
- }
-
- public static ClusterRoleInfo defaultSingleNodeRole() {
- return new ClusterRoleInfo("member",1);
- }
-
- public String getRole() {
- return Role;
- }
- public int getIndex() {
- return Index;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + Index;
- result = prime * result + (Role == null ? 0 : Role.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- ClusterRoleInfo other = (ClusterRoleInfo) obj;
- if (Index != other.Index) {
- return false;
- }
- if (Role == null) {
- if (other.Role != null) {
- return false;
- }
- } else if (!Role.equals(other.Role)) {
- return false;
- }
- return true;
- }
- @Override
- public String toString() {
- return "ClusterRoleInfo [Role=" + Role + ", Index=" + Index + "]";
- }
-}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlGeo/GeoConfig.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlGeo/GeoConfig.java
deleted file mode 100644
index 25e7fe265..000000000
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlGeo/GeoConfig.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START========================================================================
- * ONAP : ccsdk feature sdnr wt
- * =================================================================================================
- * Copyright (C) 2019 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.devicemanager.impl.conf.odlGeo;
-
-import java.io.File;
-import java.util.ArrayList;
-import java.util.List;
-
-import com.typesafe.config.Config;
-import com.typesafe.config.ConfigFactory;
-
-public class GeoConfig {
-
- private static final String DEFAULT_FILENAME = "configuration/initial/geo.conf";
- private static final String LUMINA_ROOTNODENAME = "lumina-geo-cluster";
- private final String filename;
- private final String rootNodename;
- private ClusterRoleInfoCollection primaryRoles;
- private ClusterRoleInfoCollection secondayRoles;
- private RolesTable rolesTable;
-
- private GeoConfig() {
- this(null);
- }
-
- private GeoConfig(String filename) {
- this(filename, LUMINA_ROOTNODENAME);
- }
-
- private GeoConfig(String filename, String rootNodeName) {
- this.filename = filename;
- this.rootNodename = rootNodeName;
- }
-
- public static boolean fileExists() {
- File f = new File(DEFAULT_FILENAME);
- return f.exists();
- }
-
- public static GeoConfig load() throws Exception {
- return load(DEFAULT_FILENAME);
- }
-
- public static GeoConfig load(String filename) throws Exception {
- GeoConfig cfg = new GeoConfig(filename);
- cfg._load();
- return cfg;
- }
-
- private void _load() throws Exception {
- this._load(ConfigFactory.parseFile(new File(this.filename)));
- }
-
- private void _load(Config cfg) throws Exception {
- this.primaryRoles = new ClusterRoleInfoCollection();
- List<String> a = cfg.getConfig(this.rootNodename).getStringList("primary_roles");
-
- for (int i = 0; i < a.size(); i++) {
- ClusterRoleInfo s = new ClusterRoleInfo(a.get(i));
- this.primaryRoles.add(s);
- }
- this.secondayRoles = new ClusterRoleInfoCollection();
- a = cfg.getConfig(this.rootNodename).getStringList("secondary_roles");
- for (int i = 0; i < a.size(); i++) {
- ClusterRoleInfo s = new ClusterRoleInfo(a.get(i));
- this.secondayRoles.add(s);
- }
- this.checkDuplicateRoleEntries();
- this.rolesTable = new RolesTable(cfg.getConfig(this.rootNodename).getConfigList("ip_roles_table"));
- }
-
- private void checkDuplicateRoleEntries() throws Exception {
- ClusterRoleInfoCollection duplicateEntries = new ClusterRoleInfoCollection();
- for (ClusterRoleInfo primaryRole : this.primaryRoles) {
- if (this.secondayRoles.contains(primaryRole)) {
- duplicateEntries.add(primaryRole);
- }
- }
- if (duplicateEntries.size() > 0) {
- throw new Exception("duplicate entries found: " + duplicateEntries.toString());
- }
-
- }
-
- public static GeoConfig parse(String content) throws Exception {
- GeoConfig cfg = new GeoConfig();
- cfg._load(ConfigFactory.parseString(content));
- return cfg;
- }
-
- public ClusterRoleInfoCollection getPrimaryRoles() {
- return this.primaryRoles;
- }
-
- public ClusterRoleInfoCollection getSecondaryRoles() {
- return this.secondayRoles;
- }
-
- public boolean isPrimary(ClusterRoleInfo roleMember) {
- return !this.isSecondary(roleMember);
- }
-
- private boolean isSecondary(ClusterRoleInfo roleMember) {
- if (roleMember == null) {
- return false;
- }
- for (ClusterRoleInfo info : this.secondayRoles) {
- if (info.equals(roleMember)) {
- return true;
- }
- }
- return false;
- }
-
- @Override
- public String toString() {
- return "GeoConfig [filename=" + filename + ", rootNodename=" + rootNodename + ", primaryRoles=" + primaryRoles
- + ", secondayRoles=" + secondayRoles + ", rolesTable=" + rolesTable + "]";
- }
-
- public static class RolesTableEntry {
- private final ClusterRoleInfo role;
- private final String ip;
-
- public RolesTableEntry(Config c) throws Exception {
- this.role = new ClusterRoleInfo(c.getString("role"));
- this.ip = c.getString("ip");
- }
-
- @Override
- public String toString() {
- return "RolesTableEntry [role=" + role + ", ip=" + ip + "]";
- }
- }
- public static class RolesTable extends ArrayList<RolesTableEntry> {
- private static final long serialVersionUID = -9146218864237487506L;
-
- public RolesTable(List<? extends Config> configList) throws Exception {
- for (Config c : configList) {
- this.add(new RolesTableEntry(c));
- }
- }
-
- }
-
-
-}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/HtDataBaseReaderAndWriter.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/HtDataBaseReaderAndWriter.java
deleted file mode 100644
index 919156b20..000000000
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/HtDataBaseReaderAndWriter.java
+++ /dev/null
@@ -1,258 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START========================================================================
- * ONAP : ccsdk feature sdnr wt
- * =================================================================================================
- * Copyright (C) 2019 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.devicemanager.impl.database;
-
-import java.util.Collection;
-import java.util.List;
-import org.eclipse.jdt.annotation.Nullable;
-import org.onap.ccsdk.features.sdnr.wt.common.database.DatabaseClient;
-import org.onap.ccsdk.features.sdnr.wt.common.database.IsEsObject;
-import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
-import org.onap.ccsdk.features.sdnr.wt.common.database.SearchResult;
-import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * Generic class to write lists of model classes to the database.
- *
- */
-public class HtDataBaseReaderAndWriter<T extends IsEsObject> {
-
- private static final Logger log = LoggerFactory.getLogger(HtDataBaseReaderAndWriter.class);
-
-
- private final DatabaseClient db;
- private final String dataTypeName;
- private final HtMapper<T> mapper;
-
- /**
- * Class specific access to database
- * @param db ES database descriptor
- * @param dataTypeName datatype name
- * @param clazz class of datatype
- */
- public HtDataBaseReaderAndWriter(DatabaseClient db, String dataTypeName, Class<? extends T> clazz) {
-
- this.db = db;
- this.dataTypeName = dataTypeName;
- this.mapper = new HtMapper<>( clazz );
-
- }
- public boolean isExistsIndex() {
- return this.db.isExistsIndex(this.dataTypeName);
- }
- /**
- * @return dataTypeName
- */
- public String getDataTypeName() {
- return this.dataTypeName;
- }
- /**
- * Remove Object from database
- * @param object Object with content
- * @return true if remove is done
- */
- public boolean doRemove( T object) {
-
- return db.doRemove(dataTypeName, object );
-
- }
-
- /**
- * Remove all data that match the filter
- * @param query to specify data to be deleted
- * @return number of removed objects
- */
- public int doRemoveByQuery(QueryBuilder query) {
-
- int idx = 0; //Idx for getAll
- int iterateLength = 100; //Step width for iterate
-
- List<SearchHit> hits;
- do {
- hits = db.doReadByQueryJsonData( dataTypeName, query).getHits();
- log.debug("Found: {} elements: {} Failures: {}",dataTypeName,hits.size(), mapper.getMappingFailures());
-
- T object;
- idx += hits.size();
- for (SearchHit hit : hits) {
-
- object = mapper.getObjectFromJson( hit.getSourceAsString() );
-
- log.debug("Mapp Object: {}\nSource: '{}'\nResult: '{}'\n Failures: {}", hit.getId(), hit.getSourceAsString(), object, mapper.getMappingFailures());
- if (object != null) {
- object.setEsId( hit.getId() );
- doRemove(object);
- } else {
- log.warn("Mapp result null Object: {}\n Source: '{}'\n : '", hit.getId(), hit.getSourceAsString());
- }
- }
- } while (hits.size() == iterateLength); //Do it until end indicated, because less hits than iterateLength allows.
-
- return idx;
- }
-
- /**
- * Do the mapping for test purpose
- * @param object object for test purpose
- * @return json String
- */
- public String getJson( T object ) {
- String json = mapper.objectToJson(object);
- return json;
- }
-
- /**
- * Write one object into Database
- * @param object Object with content
- * @return This object for chained call pattern.
- */
- public T doWrite( T object) {
-
- String json = mapper.objectToJson(object);
- return doWrite(object, json);
-
- }
-
- /**
- * Write one object into Database
- * @param object Object with content
- * @param json string
- * @return This object for chained call pattern.
- */
- public T doWrite( T object, String json) {
-
- log.debug("doWrite {} {}",object.getClass().getSimpleName(), object.getEsId());
-
- if (json != null) {
- String esId = db.doWriteJsonString(dataTypeName, object, json);
- object.setEsId(esId);
- log.debug("doWrite done for {} {}",object.getClass().getSimpleName(), object.getEsId());
- return esId == null ? null : object;
- } else {
- log.warn("Can not map object and write to database. {} {}",object.getClass().getSimpleName(), object);
- return null;
- }
-
- }
-
-
- /**
- * Write a list of Objects to the database.
- * @param list Object list with content
- * @return This object for chained call pattern.
- */
- public HtDataBaseReaderAndWriter<T> doWrite( Collection<T> list) {
-
- int writeError = 0;
- log.debug("Write to ES database {} Class: {} {} elements",dataTypeName, mapper.getClazz().getSimpleName(), list.size());
-
- if (list != null && !list.isEmpty()) {
- for( T s : list ) {
- if ( doWrite(s) == null ) {
- if ( ++writeError > 5 ) {
- log.warn("Leave because of to >5 write errors");
- break;
- }
- }
- }
- }
-
- return this;
- }
-
- /**
- * Read one object via the object class specific ID
- * @param object Object refrenced by idString
- * @return The Object if found or null
- */
- public @Nullable T doRead( IsEsObject object ) {
- T res = mapper.getObjectFromJson( db.doReadJsonData( dataTypeName, object) );
- if (res != null) {
- res.setEsId(object.getEsId());
- }
- return res;
- }
-
- /**
- * Read one object via the object class specific ID
- * @param objectEsId Object refrence
- * @return The Object if found or null
- */
- public @Nullable T doRead( String objectEsId ) {
- T res = mapper.getObjectFromJson( db.doReadJsonData( dataTypeName, objectEsId ) );
- if (res != null) {
- res.setEsId(objectEsId);
- }
- return res;
- }
- /**
- * Get all elements of related type
- * @return all Elements
- */
- public SearchResult<T> doReadAll() {
- return doReadAll(null);
- }
-
- /**
- * Read all existing objects of a type
- * @param query for the elements
- * @return the list of all objects
- */
-
- public SearchResult<T> doReadAll(QueryBuilder query) {
-
- SearchResult<T> res = new SearchResult<>();
- int idx = 0; //Idx for getAll
- int iterateLength = 100; //Step width for iterate
-
- SearchResult<SearchHit> result;
- List<SearchHit> hits;
- do {
- if(query!=null) {
- log.debug("read data in {} with query {}",dataTypeName,query.toJSON());
- result=db.doReadByQueryJsonData( dataTypeName, query);
- }
- else {
- result = db.doReadAllJsonData( dataTypeName);
- }
- hits=result.getHits();
- log.debug("Read: {} elements: {} Failures: {}",dataTypeName,hits.size(), mapper.getMappingFailures());
-
- T object;
- idx += result.getHits().size();
- for (SearchHit hit : hits) {
-
-// object = mapper.getObjectFromJson( hit.getSourceRef() );
- object = mapper.getObjectFromJson( hit.getSourceAsString() );
-
- log.debug("Mapp Object: {}\nSource: '{}'\nResult: '{}'\n Failures: {}", hit.getId(), hit.getSourceAsString(), object, mapper.getMappingFailures());
- if (object != null) {
- object.setEsId( hit.getId() );
- res.add( object );
- } else {
- log.warn("Mapp result null Object: {}\n Source: '{}'\n : '", hit.getId(), hit.getSourceAsString());
- }
- }
- } while (hits.size() == iterateLength); //Do it until end indicated, because less hits than iterateLength allows.
- res.setTotal(idx);
- return res;
- }
-
-}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/HtMapper.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/HtMapper.java
deleted file mode 100644
index dc2e4d768..000000000
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/HtMapper.java
+++ /dev/null
@@ -1,140 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START========================================================================
- * ONAP : ccsdk feature sdnr wt
- * =================================================================================================
- * Copyright (C) 2019 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.devicemanager.impl.database;
-
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.core.JsonParseException;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import java.io.IOException;
-import org.eclipse.jdt.annotation.Nullable;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-/**
- * @author Herbert
- *
- */
-public class HtMapper<T> {
-
- private static final Logger log = LoggerFactory.getLogger(HtMapper.class);
-
- private final Class<? extends T> clazz;
-
- private final JsonMapperBase objectMapperRead;
- private final JsonMapperBase objectMapperWrite;
-
- private int mappingFailures;
-
- public HtMapper(Class<? extends T> clazz) {
-
- this.mappingFailures = 0;
- this.clazz = clazz;
-
- this.objectMapperRead = new JsonMapperBase();
- this.objectMapperWrite = this.objectMapperRead;
- }
-
- public Class<? extends T> getClazz() {
- return clazz;
- }
-
- public int getMappingFailures() {
- return mappingFailures;
- }
-
- public String objectToJson(T object) {
- return objectMapperWrite.objectToJson(object);
- }
-
- /**
- * Do the mapping from Json to class Block further mapping if there is are to
- * many failures
- *
- * @param json String with Objects JSON representation
- * @return The Object
- */
- public @Nullable T getObjectFromJson(byte[] json) {
-
- if (json == null) {
- return null;
- } else if (mappingFailures < 10) {
- try {
- T object = objectMapperRead.readValue(json, clazz);
- return object;
- } catch (JsonParseException e) {
- mappingFailures++;
- log.warn(e.toString());
- } catch (JsonMappingException e) {
- mappingFailures++;
- log.warn(e.toString());
- } catch (IOException e) {
- mappingFailures++;
- log.warn(e.toString());
- } catch (Exception e) {
- mappingFailures++;
- log.warn(e.toString());
- }
- }
- log.warn("Problems parsing : {} {}", clazz, json);
- return null;
- }
-
- /**
- * Do the mapping from Json to class Block further mapping if there is are to
- * many failures
- *
- * @param json String with Objects JSON representation
- * @return The Object
- */
- public @Nullable T getObjectFromJson(String json) {
-
- if (json == null) {
- return null;
- } else if (mappingFailures < 10) {
- try {
- T object = objectMapperRead.readValue(json, clazz);
- return object;
- } catch (JsonParseException e) {
- mappingFailures++;
- log.warn(e.toString());
- } catch (JsonMappingException e) {
- mappingFailures++;
- log.warn(e.toString());
- } catch (IOException e) {
- mappingFailures++;
- log.warn(e.toString());
- } catch (Exception e) {
- mappingFailures++;
- log.warn(e.toString());
- }
- }
- log.warn("Problems parsing : {} {}", clazz, json);
- return null;
- }
-
- public void setSerializationInclusion(Include incl) {
- this.objectMapperRead.setSerializationInclusion(incl);
-
- }
- public void resetSerializationInclusion() {
- this.objectMapperRead.setSerializationInclusion(Include.USE_DEFAULTS);
-
-
- }
-
-}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/JsonMapperBase.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/JsonMapperBase.java
deleted file mode 100644
index 848004b39..000000000
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/JsonMapperBase.java
+++ /dev/null
@@ -1,137 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START========================================================================
- * ONAP : ccsdk feature sdnr wt
- * =================================================================================================
- * Copyright (C) 2019 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.devicemanager.impl.database;
-
-import java.io.IOException;
-import java.io.StringWriter;
-import java.util.List;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-import com.fasterxml.jackson.annotation.JsonAutoDetect.Visibility;
-import com.fasterxml.jackson.annotation.PropertyAccessor;
-import com.fasterxml.jackson.core.JsonGenerationException;
-import com.fasterxml.jackson.core.JsonGenerator.Feature;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.JsonMappingException;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.SerializationFeature;
-
-/**
- * This class is used to define default for JSON Serialization and Deserialization for the project at a single place
- */
-public class JsonMapperBase extends ObjectMapper {
-
- private static final long serialVersionUID = 1L;
- private static final Logger LOG = LoggerFactory.getLogger(JsonMapperBase.class);
-
- public JsonMapperBase() {
-
- setVisibility(PropertyAccessor.ALL, Visibility.NONE);
- setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
-
- // Deserialization
- configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true);
-
- // Serialization
- configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
- getFactory().configure(Feature.ESCAPE_NON_ASCII, true);
- }
-
- public JsonMapperBase(int t) {
-
- switch(t) {
- case 0:
- break;
- case 1:
- setVisibility(PropertyAccessor.ALL, Visibility.NONE);
- setVisibility(PropertyAccessor.FIELD, Visibility.DEFAULT);
- break;
- case 2:
- setVisibility(PropertyAccessor.ALL, Visibility.NONE);
- setVisibility(PropertyAccessor.FIELD, Visibility.PROTECTED_AND_PUBLIC);
- break;
- case 3:
- setVisibility(PropertyAccessor.ALL, Visibility.NONE);
- setVisibility(PropertyAccessor.GETTER, Visibility.ANY);
- setVisibility(PropertyAccessor.IS_GETTER, Visibility.ANY);
- break;
- default:
- setVisibility(PropertyAccessor.ALL, Visibility.NONE);
- setVisibility(PropertyAccessor.FIELD, Visibility.ANY);
- break;
-
- }
-
- // Deserialization
- configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- configure(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL, true);
-
- // Serialization
- configure(SerializationFeature.FAIL_ON_EMPTY_BEANS, false);
- getFactory().configure(Feature.ESCAPE_NON_ASCII, true);
- }
-
-
-
- public String objectToJson( Object object ) {
- String res = null;
-
- try {
-
- res = writeValueAsString(object);
-
- } catch (JsonGenerationException e) {
- LOG.debug(e.toString());
- } catch (JsonMappingException e) {
- LOG.debug(e.toString());
- } catch (IOException e) {
- LOG.debug(e.toString());
- } catch (Exception e) {
- LOG.debug(e.toString());
- }
-
- return res;
- }
-
- public String objectListToJson( List<? extends Object> objectList ) {
- String res = null;
-
- try {
-
- StringWriter stringEmp = new StringWriter();
- writeValue(stringEmp, objectList);
- res = stringEmp.toString();
- stringEmp.close();
-
- } catch (JsonGenerationException e) {
- LOG.debug(e.toString());
- } catch (JsonMappingException e) {
- LOG.debug(e.toString());
- } catch (IOException e) {
- LOG.debug(e.toString());
- } catch (Exception e) {
- LOG.debug(e.toString());
- }
-
- return res;
- }
-
-}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/NetconfChangeListener.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/NetconfChangeListener.java
deleted file mode 100644
index 2334bd181..000000000
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/listener/NetconfChangeListener.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START========================================================================
- * ONAP : ccsdk feature sdnr wt
- * =================================================================================================
- * Copyright (C) 2019 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.devicemanager.impl.listener;
-
-import java.util.Collection;
-
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.NetconfNodeService;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.NetconfNodeService.Action;
-import org.opendaylight.mdsal.binding.api.ClusteredDataTreeChangeListener;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataObjectModification;
-import org.opendaylight.mdsal.binding.api.DataObjectModification.ModificationType;
-import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
-import org.opendaylight.mdsal.binding.api.DataTreeModification;
-import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.NetconfNode;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.network.topology.topology.topology.types.TopologyNetconf;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NetworkTopology;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.TopologyId;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.Topology;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.TopologyKey;
-import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.network.topology.topology.Node;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-// 07.09.18 Switched to DataTreeChangeListener from ClusteredDataTreeChangeListener -> DM Service is
-// running at all nodes
-// This is not correct
-public class NetconfChangeListener implements ClusteredDataTreeChangeListener<Node>, AutoCloseable {
-
- private static final Logger LOG = LoggerFactory.getLogger(NetconfChangeListener.class);
-
- private static final InstanceIdentifier<Node> NETCONF_NODE_TOPO_IID =
- InstanceIdentifier.create(NetworkTopology.class)
- .child(Topology.class, new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName())))
- .child(Node.class);
- // Name of ODL controller NETCONF instance
- private static final NodeId CONTROLLER = new NodeId("controller-config");
-
- private final NetconfNodeService deviceManagerService;
- private final DataBroker dataBroker;
- private ListenerRegistration<NetconfChangeListener> dlcReg;
-
- public NetconfChangeListener(NetconfNodeService deviceManagerService, DataBroker dataBroker) {
- this.deviceManagerService = deviceManagerService;
- this.dataBroker = dataBroker;
- }
-
- public void register() {
- DataTreeIdentifier<Node> treeId = DataTreeIdentifier.create(LogicalDatastoreType.OPERATIONAL, NETCONF_NODE_TOPO_IID);
-
- dlcReg = dataBroker.registerDataTreeChangeListener(treeId, this);
- }
-
- @Override
- public void close() {
- if (dlcReg != null) {
- dlcReg.close();
- }
- }
- /**
- * Listener function to select the right node from DataObjectModification
- */
- @Override
- public void onDataTreeChanged(Collection<DataTreeModification<Node>> changes) {
- LOG.debug("OnDataChange, TreeChange, changes:{}", changes.size());
-
- for (final DataTreeModification<Node> change : changes) {
- final DataObjectModification<Node> root = change.getRootNode();
- final ModificationType modificationType = root.getModificationType();
- if (LOG.isTraceEnabled()) {
- LOG.trace("Handle this modificationType:{} path:{} root:{}", modificationType, change.getRootPath(),
- root);
- }
- switch (modificationType) {
- case SUBTREE_MODIFIED:
- // Change of subtree information
- // update(change); OLD
- doProcessing(Action.UPDATE, root.getDataAfter());
- break;
- case WRITE:
- // Create or modify top level node
- // Treat an overwrite as an update
- boolean update = root.getDataBefore() != null;
- if (update) {
- // update(change);
- doProcessing(Action.UPDATE, root.getDataAfter());
- } else {
- // add(change);
- doProcessing(Action.CREATE, root.getDataAfter());
- }
- break;
- case DELETE:
- // Node removed
- // remove(change);
- doProcessing(Action.REMOVE, root.getDataBefore());
- break;
- }
- }
- }
-
- /*
- * ----------------------------------------------------------------
- */
-
- /**
- * Process event and forward to clients if Node is a NetconfNode
- * @param action
- * @param node Basis node
- */
- private void doProcessing(Action action, Node node) {
-
- NodeId nodeId = null;
- NetconfNode nnode = null;
-
- try {
- if (node != null) {
- nodeId = node.key().getNodeId(); //Never null
- nnode = node.augmentation(NetconfNode.class);
- }
-
- if (node == null || nnode == null) {
- LOG.warn("Unexpected node {}, netconf node {} id {}", node, nnode, nodeId);
- } else {
- // Do not forward any controller related events to devicemanager
- if (nodeId.equals(CONTROLLER)) {
- LOG.debug("Stop processing for [{}]", nodeId);
- } else {
- // Action forwarded to devicehandler
- deviceManagerService.netconfNodeChangeHandler(action, nodeId, nnode);
- }
- }
- } catch (NullPointerException e) {
- LOG.warn("Unexpected null .. stop processing.", e);
- }
- }
-
-}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/InternalDateAndTime.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/InternalDateAndTime.java
index b04a49bca..c52853280 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/InternalDateAndTime.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/InternalDateAndTime.java
@@ -15,36 +15,30 @@
* the License.
* ============LICENSE_END==========================================================================
******************************************************************************/
-/**
- *
- */
package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util;
+import org.eclipse.jdt.annotation.Nullable;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.NetconfTimeStamp;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl;
+import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
/**
* Converts time stamps into internal format according to ONF1.2 and ISO 8601.
- * @author herbert
- *
+ * To be replaced by NetconfTimeStampImpl
*/
+@Deprecated
public class InternalDateAndTime {
- private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStampImpl.getConverter();
-
- private static final InternalDateAndTime TESTPATTERN = new InternalDateAndTime("2017-01-01T00:00:00.0Z");
+ private static final String TESTPATTERNSTRING = "2017-01-01T00:00:00.0Z";
private static final String INITIALPATTERN = "0000-00-00T00:00:00.0Z";
- String internalDateAndTime = INITIALPATTERN;
+ private static final InternalDateAndTime TESTPATTERN = new InternalDateAndTime(TESTPATTERNSTRING);
+ private static final DateAndTime TESTPATTERN2 = new DateAndTime(TESTPATTERNSTRING);
- /**
- * Static builder ONF1.2
- * @param time in ONF1.2 yang format
- * @return InternalDateAndTime
- */
-// public static InternalDateAndTime valueOf(DateAndTime time) {
-// return new InternalDateAndTime(time);
-// }
+ private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStampImpl.getConverter();
+
+ /** Internal variable to hold the value, that is converted **/
+ private final String internalDateAndTime;
/**
* Static builder ONF1.0
@@ -63,17 +57,24 @@ public class InternalDateAndTime {
return internalDateAndTime;
}
- /*----------------------------------------------------------------
- * Private constructors and functions
+ /**
+ * Get a testpattern
+ * @return testpattern
*/
+ public static InternalDateAndTime getTestpattern() {
+ return TESTPATTERN;
+ }
/**
- * Convert ONF 1.2 DateAndTime to String
- * @param time as input
+ * @return DateAndTime testpattern
+ */
+ public static @Nullable DateAndTime getTestpatternDateAndTime() {
+ return TESTPATTERN2;
+ }
+
+ /*----------------------------------------------------------------
+ * Private constructors
*/
-// private InternalDateAndTime(DateAndTime time) {
-// internalDateAndTime = NETCONFTIME_CONVERTER.getTimeStampFromNetconf(time.getValue());
-// }
/**
* Convert ONF 1.2 DateAndTime to String
@@ -95,14 +96,4 @@ public class InternalDateAndTime {
this.internalDateAndTime = internalDateAndTime;
}
- /**
- * Get a testpattern
- * @return testpattern
- */
- public static InternalDateAndTime getTestpattern() {
- return TESTPATTERN;
- }
-
-
-
}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetconfNotification.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetconfNotification.java
deleted file mode 100644
index 95d6b89c4..000000000
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/util/NetconfNotification.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/**
- * ============LICENSE_START========================================================================
- * ONAP : ccsdk feature sdnr wt
- * =================================================================================================
- * Copyright (C) 2019 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.devicemanager.impl.util;
-
-import java.util.Optional;
-import javax.annotation.Nonnull;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.DeviceManagerImpl;
-import org.opendaylight.mdsal.binding.api.MountPoint;
-import org.opendaylight.mdsal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionInput;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.CreateSubscriptionInputBuilder;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.NotificationsService;
-import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.netconf.notification._1._0.rev080714.StreamNameType;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class NetconfNotification {
-
- private static final Logger log = LoggerFactory.getLogger(DeviceManagerImpl.class);
-
- /**
- * Do the stream creation for the device.
- * @param nodeId node-id of device
- * @param mountpoint information
- * @param streamName to register
- */
- public static void registerNotificationStream(String nodeId, MountPoint mountpoint, String streamName) {
-
- final Optional<RpcConsumerRegistry> optionalRpcConsumerService =
- mountpoint.getService(RpcConsumerRegistry.class);
- if (optionalRpcConsumerService.isPresent()) {
- final RpcConsumerRegistry rpcConsumerRegitry = optionalRpcConsumerService.get();
- @Nonnull
- final NotificationsService rpcService = rpcConsumerRegitry.getRpcService(NotificationsService.class);
-
- final CreateSubscriptionInputBuilder createSubscriptionInputBuilder = new CreateSubscriptionInputBuilder();
- createSubscriptionInputBuilder.setStream(new StreamNameType(streamName));
- log.info("Event listener triggering notification stream {} for node {}", streamName, nodeId);
- try {
- CreateSubscriptionInput createSubscriptionInput = createSubscriptionInputBuilder.build();
- if (createSubscriptionInput == null) {
- log.warn("createSubscriptionInput is null for mountpoint {}", nodeId);
- } else {
- rpcService.createSubscription(createSubscriptionInput);
- }
- } catch (NullPointerException e) {
- log.warn("createSubscription failed");
- }
- } else {
- log.warn("No RpcConsumerRegistry avaialble.");
- }
-
- }
-
-}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/FaultEntityManager.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/FaultEntityManager.java
index 5b7057b81..ef30e4f28 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/database/FaultEntityManager.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/FaultEntityManager.java
@@ -15,7 +15,7 @@
* the License.
* ============LICENSE_END==========================================================================
******************************************************************************/
-package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database;
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/MwtNotificationBase.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/MwtNotificationBase.java
index 156f9226e..fa67ff660 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/MwtNotificationBase.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/MwtNotificationBase.java
@@ -38,6 +38,7 @@ public class MwtNotificationBase {
public MwtNotificationBase() {
// For Jaxb
+ this.objectId = EMPTY;
}
public MwtNotificationBase(String nodeName, Integer counter, InternalDateAndTime timeStamp, String objectId) {
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ProblemNotificationXml.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ProblemNotificationXml.java
index dcb299a8e..fbb7b6a28 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ProblemNotificationXml.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/ProblemNotificationXml.java
@@ -21,9 +21,9 @@ import com.fasterxml.jackson.annotation.JsonIgnore;
import java.util.List;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.database.FaultEntityManager;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalDateAndTime;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalSeverity;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter.ToggleAlarmFilterable;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Faultcurrent;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultcurrentBuilder;
@@ -34,7 +34,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
import org.slf4j.Logger;
@XmlRootElement(name = "ProblemNotification")
-public class ProblemNotificationXml extends MwtNotificationBase implements GetEventType {
+public class ProblemNotificationXml extends MwtNotificationBase implements GetEventType, ToggleAlarmFilterable {
private static String EVENTTYPE = "ProblemNotification";
@@ -87,6 +87,17 @@ public class ProblemNotificationXml extends MwtNotificationBase implements GetEv
return severity.isNoAlarmIndication();
}
+ @Override
+ public String getUuidForMountpoint() {
+ return genSpecificEsId();
+ }
+
+ @Override
+ public boolean isCleared() {
+ return !isNotManagedAsCurrentProblem() && isNoAlarmIndication();
+ }
+
+
/**
* Create a specific ES id for the current log.
* @return a string with the generated ES Id
@@ -118,6 +129,7 @@ public class ProblemNotificationXml extends MwtNotificationBase implements GetEv
+ super.toString() + "]";
}
+
@Override
public String getEventType() {
return EVENTTYPE;
@@ -143,4 +155,5 @@ public class ProblemNotificationXml extends MwtNotificationBase implements GetEv
log.debug("Found problems {} {}", uuid, sb.toString());
}
}
+
}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientDummyImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientDummyImpl.java
index fa6bb1887..bc77e2d1a 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientDummyImpl.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientDummyImpl.java
@@ -18,7 +18,7 @@
package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml;
import org.eclipse.jdt.annotation.NonNull;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.handler.ODLEventListenerHandler;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler.ODLEventListenerHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl2.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl2.java
index 8c01438ca..cdbbdf2df 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl2.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/WebSocketServiceClientImpl2.java
@@ -19,7 +19,7 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml;
import java.util.concurrent.Future;
import org.eclipse.jdt.annotation.NonNull;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.handler.ODLEventListenerHandler;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler.ODLEventListenerHandler;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.EventlogEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.websocketmanager.rev150105.WebsocketEventInputBuilder;
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceCalculator.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceCalculator.java
index 8771b4c2f..40ef82a15 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceCalculator.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceCalculator.java
@@ -128,7 +128,7 @@ public class MaintenanceCalculator {
* @param zoneTimeString with time
* @return ZonedDateTime string
*/
- static ZonedDateTime valueOf(String zoneTimeString) {
+ public static ZonedDateTime valueOf(String zoneTimeString) {
if (zoneTimeString == null || zoneTimeString.isEmpty()) {
LOG.warn("Null or empty zoneTimeString");
return EMPTYDATETIME;
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java
index 6f68589f2..1368de081 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/maintenance/impl/MaintenanceServiceImpl.java
@@ -44,7 +44,7 @@ public class MaintenanceServiceImpl implements MaintenanceService, MaintenanceRP
private final HtDatabaseMaintenance database;
- public MaintenanceServiceImpl(HtDatabaseMaintenance client) throws ClassNotFoundException {
+ public MaintenanceServiceImpl(HtDatabaseMaintenance client) {
LOG.info("Create {} start", MaintenanceServiceImpl.class);
database = client;
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayFilter.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayFilter.java
index 92af68bc0..0d3b8bcb8 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayFilter.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayFilter.java
@@ -22,19 +22,32 @@ import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
+import org.eclipse.jdt.annotation.NonNull;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class NotificationDelayFilter<T> implements AutoCloseable {
+public class NotificationDelayFilter<T extends ToggleAlarmFilterable> implements AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(NotificationDelayFilter.class);
+ private static long delay;
+ private static boolean enabled;
+
private final ConcurrentHashMap <String, NotificationWithServerTimeStamp<T>> problemItems;
// private final HashMap<String, NotificationWithServerTimeStamp<T>> nonProblemItems;
private final NotificationDelayedListener<T> timeoutListener;
- private static long delay;
- private static boolean enabled;
+ private final ScheduledExecutorService scheduler;
+ private final Runnable timerRunner = () -> onTick();
+ private final String nodeName;
+
+ public NotificationDelayFilter(String nodeName, NotificationDelayedListener<T> timeoutListener) {
+ this.nodeName = nodeName;
+ this.timeoutListener = timeoutListener;
+ this.problemItems = new ConcurrentHashMap <>();
+ this.scheduler = Executors.newScheduledThreadPool(1);
+ this.startTimer();
+ }
public static void setDelay(long l) {
NotificationDelayFilter.delay = l;
@@ -52,30 +65,17 @@ public class NotificationDelayFilter<T> implements AutoCloseable {
NotificationDelayFilter.enabled = enabled;
}
- private final ScheduledExecutorService scheduler;
- private final Runnable timerRunner = () -> onTick();
-
- private final String nodeName;
-
- public NotificationDelayFilter(String nodeName, NotificationDelayedListener<T> timeoutListener) {
- this.nodeName = nodeName;
- this.timeoutListener = timeoutListener;
- this.problemItems = new ConcurrentHashMap <>();
- this.scheduler = Executors.newScheduledThreadPool(1);
- this.startTimer();
- }
-
/**
* If process the notification
* @return true if other processing is required, false if not
*/
- public boolean processNotification(boolean cleared, String problemName, T notificationXml) {
+ public boolean processNotification(@NonNull T notificationXml) {
// ToggleAlarmFilter functionality
if (NotificationDelayFilter.isEnabled()) {
- if (cleared) {
- clearAlarmNotification(problemName, notificationXml);
+ if (notificationXml.isCleared()) {
+ clearAlarmNotification(notificationXml);
} else {
- pushAlarmNotification(problemName, notificationXml);
+ pushAlarmNotification(notificationXml);
}
return false;
} else {
@@ -86,12 +86,11 @@ public class NotificationDelayFilter<T> implements AutoCloseable {
/**
* Push notification with a specific severity (everything except non-alarmed)
- * @param problemName key
* @param notification related notification
*/
- public void pushAlarmNotification(String problemName, T notification) {
+ public void pushAlarmNotification(@NonNull T notification) {
synchronized (problemItems) {
-
+ String problemName = notification.getUuidForMountpoint();
boolean cp = this.problemItems.containsKey(problemName);
if (!cp) {
// no alarm in entries => create entry and push the alarm currently
@@ -101,7 +100,7 @@ public class NotificationDelayFilter<T> implements AutoCloseable {
+ item.toString());
this.problemItems.put(problemName, item);
if (this.timeoutListener != null) {
- this.timeoutListener.onNotificationDelay(notification);
+ this.timeoutListener.onNotificationDelay(this.nodeName,notification);
}
} else {
LOG.debug("clear contra event for node " + this.nodeName + " for alarm " + problemName);
@@ -113,12 +112,11 @@ public class NotificationDelayFilter<T> implements AutoCloseable {
/**
* Push notification with severity non-alarmed
- * @param problemName key
* @param notification related notification
*/
- public void clearAlarmNotification(String problemName, T notification) {
+ public void clearAlarmNotification(@NonNull T notification) {
synchronized (problemItems) {
-
+ String problemName = notification.getUuidForMountpoint();
boolean cp = this.problemItems.containsKey(problemName);
if (cp) {
LOG.debug("set contra event for alarm " + problemName);
@@ -126,7 +124,7 @@ public class NotificationDelayFilter<T> implements AutoCloseable {
} else {
// not in list => push directly through
if (this.timeoutListener != null) {
- this.timeoutListener.onNotificationDelay(notification);
+ this.timeoutListener.onNotificationDelay(this.nodeName,notification);
}
}
}
@@ -156,7 +154,7 @@ public class NotificationDelayFilter<T> implements AutoCloseable {
// send contra Alarm if exists
if (value.getContraAlarmNotification() != null) {
if (this.timeoutListener != null) {
- this.timeoutListener.onNotificationDelay(value.getContraAlarmNotification());
+ this.timeoutListener.onNotificationDelay(this.nodeName,value.getContraAlarmNotification());
}
}
problemItems.remove(entry.getKey());
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayService.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayService.java
index 0768ffda8..2ad6a27bc 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayService.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayService.java
@@ -26,7 +26,7 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter.conf.Togg
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class NotificationDelayService<T> implements DeviceManagerService, AutoCloseable, IConfigChangedListener {
+public class NotificationDelayService<T extends ToggleAlarmFilterable> implements DeviceManagerService, AutoCloseable, IConfigChangedListener {
private static final Logger LOG = LoggerFactory.getLogger(NotificationDelayService.class);
private final HashMap<String, NotificationDelayFilter<T>> filters;
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayedListener.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayedListener.java
index eab541d13..61a913874 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayedListener.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/NotificationDelayedListener.java
@@ -19,7 +19,7 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter;
public interface NotificationDelayedListener<T> {
- public void onNotificationDelay(T notification);
+ public void onNotificationDelay(String nodeName,T notification);
}
diff --git a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlGeo/ClusterRoleInfoCollection.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/ToggleAlarmFilterable.java
index 089bf33f2..7a172f784 100644
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlGeo/ClusterRoleInfoCollection.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/ToggleAlarmFilterable.java
@@ -15,31 +15,18 @@
* the License.
* ============LICENSE_END==========================================================================
******************************************************************************/
-package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.conf.odlGeo;
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter;
-import java.util.ArrayList;
+/**
+ * @author herbert
+ *
+ */
+public interface ToggleAlarmFilterable {
-public class ClusterRoleInfoCollection extends ArrayList<ClusterRoleInfo> {
- private static final long serialVersionUID = 1L;
- public ClusterRoleInfo get(String role) {
- for (ClusterRoleInfo info : this) {
- if (info.getRole().equals(role)) {
- return info;
- }
- }
- return null;
- }
+ /** Provide id for toggle alarm filter that is unique for the mountpoint/nodeId**/
+ String getUuidForMountpoint();
+ /** Provide indication if cleared **/
+ boolean isCleared();
- public boolean contains(ClusterRoleInfo info) {
- if (info == null) {
- return false;
- }
- for (ClusterRoleInfo i : this) {
- if (i.equals(info)) {
- return true;
- }
- }
- return false;
- }
}