aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr')
-rw-r--r--sdnr/wt/devicemanager/model/src/main/yang/devicemanager.yang292
-rw-r--r--sdnr/wt/devicemanager/provider/pom.xml34
-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/ClusterRoleInfoCollection.java45
-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/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/ClusterSingletonServiceProviderMock.java)25
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java420
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAkkaConfig.java136
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceMonitor.java71
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java207
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestGeoConfig.java63
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java29
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestToggleAlarmFilter.java (renamed from sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestNotification.java)5
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestXmlNotification.java90
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerMountpointMock.java77
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerNetconfMock.java76
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataProviderMock.java105
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointMock.java90
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointServiceMock.java54
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NetconfNodeStateServiceMock.java71
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NotificationPublishServiceMock.java49
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcConsumerRegistryMock.java39
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderServiceMock.java (renamed from sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderRegistryMock.java)12
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/DBCleanServiceHelper.java83
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/ZipFile.java63
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/resources/simplelogger.properties2
56 files changed, 1227 insertions, 2989 deletions
diff --git a/sdnr/wt/devicemanager/model/src/main/yang/devicemanager.yang b/sdnr/wt/devicemanager/model/src/main/yang/devicemanager.yang
index b1dea1357..e8d29641a 100644
--- a/sdnr/wt/devicemanager/model/src/main/yang/devicemanager.yang
+++ b/sdnr/wt/devicemanager/model/src/main/yang/devicemanager.yang
@@ -1,157 +1,191 @@
module devicemanager {
- yang-version 1;
- namespace "urn:opendaylight:params:xml:ns:yang:devicemanager";
- prefix "devicemanager";
+ yang-version 1;
+ namespace "urn:opendaylight:params:xml:ns:yang:devicemanager";
+ prefix devicemanager;
- import data-provider { prefix "data-provider"; }
+ import data-provider {
+ prefix data-provider;
+ }
+ organization
+ "highstreet technologies GmbH";
+ contact
+ "Web: <https://highstreet-technologies.com>
+ ONAP: <https://wiki.onap.org/display/DW/ODLUX+DB+API>";
+
+ description
+ "DeviceManager Api Module
+
+ Copyright 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.";
+
+ revision 2019-01-09 {
description
- "DeviceManager Api Module";
+ "Initial revision";
+ reference
+ "https://jira.onap.org/browse/SDNC-877";
+ }
- revision "2019-01-09" {
- description
- "Initial revision";
+ rpc set-maintenance-mode {
+ description
+ "Set maintenance mode for network element";
+ input {
+ uses data-provider:maintenance-entity;
+ }
+ output {
+ uses data-provider:maintenance-entity;
}
+ }
- rpc set-maintenance-mode{
+ rpc get-maintenance-mode {
+ description
+ "Get maintenance mode Configuration";
+ input {
+ leaf mountpoint-name {
+ type string;
description
- "Set maintenance mode for network element";
- input{
- uses data-provider:maintenance-entity;
- }
- output {
- uses data-provider:maintenance-entity;
- }
+ "Mountpoint-name as key of node";
+ }
+ }
+ output {
+ uses data-provider:maintenance-entity;
}
- rpc get-maintenance-mode{
+ }
+
+ rpc test-maintenance-mode {
+ description
+ "Send test pattern similar to notification that are test from algorithm";
+ input {
+ leaf mountpoint-name {
+ type string;
+ mandatory true;
description
- "Get maintenance mode Configuration";
- input{
- leaf mountpoint-name{
- mandatory true;
- type string;
- description
- "Mountpoint-name as key of node";
- }
- }
- output {
- uses data-provider:maintenance-entity;
- }
+ "mountpoint for test";
+ }
+ leaf object-id-ref {
+ type string;
+ mandatory true;
+ description
+ "object id for test";
+ }
+ leaf problem-name {
+ type string;
+ mandatory true;
+ description
+ "problem for test";
+ }
+ leaf test-date {
+ type string;
+ mandatory true;
+ description
+ "point in time used for the test";
+ }
}
- rpc test-maintenance-mode{
+ output {
+ leaf result-string {
+ type string;
+ mandatory true;
description
- "Send test pattern similar to notification that are test from algorithm";
- input{
- leaf mountpoint-name {
- mandatory true;
- type string;
- description "mountpoint for test";
- }
- leaf object-id-ref {
- mandatory true;
- type string;
- description "object id for test";
- }
- leaf problem-name {
- mandatory true;
- type string;
- description "problem for test";
- }
- leaf test-date {
- mandatory true;
- type string;
- description "point in time used for the test";
- }
-
- }
- output {
- leaf result-string {
- mandatory true;
- type string;
- description "Describin if mountpoint was found and result of maintenance mode testing";
- }
- uses data-provider:maintenance-entity;
- }
+ "Describin if mountpoint was found and result of maintenance mode testing";
+ }
+ uses data-provider:maintenance-entity;
}
- rpc show-required-network-element {
+ }
+
+ rpc show-required-network-element {
+ description
+ "Get information for required network element";
+ input {
+ leaf mountpoint-name {
+ type string;
+ mandatory true;
description
- "Get information for required network element";
-
- input {
- leaf mountpoint-name {
- mandatory true;
- type string;
- description
- "Mountpoint-name as key of the node to be displayed.";
- }
+ "Mountpoint-name as key of the node to be displayed.";
+ }
+ }
+ output {
+ container required-network-element {
+ leaf mountpoint-name {
+ type string;
+ description
+ "The name of the mountpoint";
+ }
+ leaf status {
+ type string;
+ description
+ "Status: pre-provisoning, installed, end-of-life (Later enum)";
}
- output {
- container required-network-element {
- leaf mountpoint-name {
- type string;
- description
- "The name of the mountpoint";
- }
- leaf status {
- type string;
- description
- "Status: pre-provisoning, installed, end-of-life (Later enum)";
- }
- leaf description {
- type string;
- description "Device description";
- }
- }
+ leaf description {
+ type string;
+ description
+ "Device description";
}
+ description
+ "An output object presenting a network element (or device, NetConf
+ server, network function) which is expected to be connected.";
+ }
}
+ }
- rpc get-required-network-element-keys {
+ rpc get-required-network-element-keys {
+ description
+ "Returns a list of netconf nodes for each data store space";
+ output {
+ leaf-list mountpoint-names {
+ type string;
description
- "Returns a list of netconf nodes for each data store space";
-
- output {
- leaf-list mountpoint-names {
- type string;
- description
- "List of required-network-element keys that are the mountpoint-names";
- }
- }
+ "List of required-network-element keys that are the mountpoint-names";
+ }
}
+ }
- rpc clear-current-fault-by-nodename {
+ rpc clear-current-fault-by-nodename {
+ description
+ "try to clear alarms and sync the alarm with the devices currently connected";
+ input {
+ leaf-list nodenames {
+ type string;
description
- "try to clear alarms and sync the alarm with the devices currently connected";
- input {
- leaf-list nodenames {
- type string;
- description
- "list of network-elements to clear alarms for nodenames, if list empty then all";
- }
- }
- output {
- leaf-list nodenames {
- type string;
- description
- "list of network-elements alarms cleared";
- }
- }
+ "list of network-elements to clear alarms for nodenames, if list empty then all";
+ }
}
- rpc push-fault-notification {
+ output {
+ leaf-list nodenames {
+ type string;
description
- "Forward fault problem notification of a network-element";
- input {
- uses data-provider:object-change-reference;
- uses data-provider:fault;
- }
+ "list of network-elements alarms cleared";
+ }
}
- rpc push-attribute-change-notification {
- description
- "Forward attribute change notification of a network-element";
- input {
- uses data-provider:object-change-reference;
- uses data-provider:attribute-change;
- }
+ }
+
+ rpc push-fault-notification {
+ description
+ "Forward fault problem notification of a network-element";
+ input {
+ uses data-provider:object-change-reference;
+ uses data-provider:fault;
}
-}
+ }
+ rpc push-attribute-change-notification {
+ description
+ "Forward attribute change notification of a network-element";
+ input {
+ uses data-provider:object-change-reference;
+ uses data-provider:attribute-change;
+ }
+ }
+}
diff --git a/sdnr/wt/devicemanager/provider/pom.xml b/sdnr/wt/devicemanager/provider/pom.xml
index 28ca6c18b..5a76795af 100644
--- a/sdnr/wt/devicemanager/provider/pom.xml
+++ b/sdnr/wt/devicemanager/provider/pom.xml
@@ -176,40 +176,6 @@
</excludes>
</configuration>
</plugin>
- <plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>generateDTOs</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>exec</goal>
- </goals>
- <configuration>
- <executable>bash</executable>
- <arguments>
- <argument>${basedir}/../../data-provider/provider/src/main/resources/es-init.sh</argument>
- <argument>initfile</argument>
- <argument>-f</argument>
- <argument>${project.build.directory}/EsInit.script</argument>
- </arguments>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <configuration>
- <systemProperties>
- <property>
- <name>databaseport</name>
- <value>${databaseport}</value>
- </property>
- </systemProperties>
- </configuration>
- </plugin>
</plugins>
</build>
</project>
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/ClusterRoleInfoCollection.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlGeo/ClusterRoleInfoCollection.java
deleted file mode 100644
index 089bf33f2..000000000
--- a/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/conf/odlGeo/ClusterRoleInfoCollection.java
+++ /dev/null
@@ -1,45 +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.ArrayList;
-
-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;
- }
-
- public boolean contains(ClusterRoleInfo info) {
- if (info == null) {
- return false;
- }
- for (ClusterRoleInfo i : this) {
- if (i.equals(info)) {
- return true;
- }
- }
- return false;
- }
-}
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/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/ClusterSingletonServiceProviderMock.java b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/ToggleAlarmFilterable.java
index a215e1883..7a172f784 100644
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/ClusterSingletonServiceProviderMock.java
+++ b/sdnr/wt/devicemanager/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/toggleAlarmFilter/ToggleAlarmFilterable.java
@@ -15,23 +15,18 @@
* the License.
* ============LICENSE_END==========================================================================
******************************************************************************/
+package org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter;
-package org.onap.ccsdk.features.sdnr.wt.devicemanager.test.mock;
-
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonService;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
-import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegistration;
-
-public class ClusterSingletonServiceProviderMock implements ClusterSingletonServiceProvider {
-
- @Override
- public void close() throws Exception {
+/**
+ * @author herbert
+ *
+ */
+public interface ToggleAlarmFilterable {
- }
- @Override
- public ClusterSingletonServiceRegistration registerClusterSingletonService(ClusterSingletonService service) {
- return null;
- }
+ /** Provide id for toggle alarm filter that is unique for the mountpoint/nodeId**/
+ String getUuidForMountpoint();
+ /** Provide indication if cleared **/
+ boolean isCleared();
}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java
index c1d24b4d1..69ac9e893 100644
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java
@@ -20,6 +20,8 @@
******************************************************************************/
package org.onap.ccsdk.features.sdnr.wt.devicemanager.test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import com.google.common.io.Files;
@@ -36,7 +38,9 @@ import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import org.junit.After;
+import org.junit.AfterClass;
import org.junit.Before;
+import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
import org.onap.ccsdk.features.sdnr.wt.common.util.ResourceFileLoader;
@@ -46,196 +50,228 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.InventoryInformationD
public class TestAai {
- private static final String CONFIGURATIONTESTFILE = "test.properties"; // for
- private static final String ENABLEDAAI_TESTCONFIG_FILENAME = "test2.properties";
- private static final File ENABLEDAAI_TESTCONFIG_FILE = new File(ENABLEDAAI_TESTCONFIG_FILENAME);
- private static final int AAI_SERVER_PORT=45454;
- private static final String TESTCONFIG_CONTENT="[dcae]\n" +
- "dcaeUserCredentials=admin:admin\n" +
- "dcaeUrl=off\n" +
- "dcaeHeartbeatPeriodSeconds=120\n" +
- "dcaeTestCollector=no\n" +
- "\n" +
- "[aots]\n" +
- "userPassword=passwd\n" +
- "soapurladd=off\n" +
- "soapaddtimeout=10\n" +
- "soapinqtimeout=20\n" +
- "userName=user\n" +
- "inqtemplate=inqreq.tmpl.xml\n" +
- "assignedto=userid\n" +
- "addtemplate=addreq.tmpl.xml\n" +
- "severitypassthrough=critical,major,minor,warning\n" +
- "systemuser=user\n" +
- "prt-offset=1200\n" +
- "soapurlinq=off\n" +
- "#smtpHost=\n" +
- "#smtpPort=\n" +
- "#smtpUsername=\n" +
- "#smtpPassword=\n" +
- "#smtpSender=\n" +
- "#smtpReceivers=\n" +
- "\n" +
- "[es]\n" +
- "esCluster=sendateodl5\n" +
- "\n" +
- "[aai]\n" +
- "#keep comment\n" +
- "aaiHeaders=[\"X-TransactionId: 9999\"]\n" +
- "aaiUrl=http://localhost:"+AAI_SERVER_PORT+"\n" +
- "aaiUserCredentials=AAI:AAI\n" +
- "aaiDeleteOnMountpointRemove=true\n" +
- "aaiTrustAllCerts=false\n" +
- "aaiApiVersion=aai/v13\n" +
- "aaiPropertiesFile=aaiclient.properties\n" +
- "aaiApplicationId=SDNR\n" +
- "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n" +
- "aaiPcks12ClientCertPassphrase=adminadmin\n" +
- "aaiClientConnectionTimeout=30000\n" +
- "\n" +
- "[pm]\n" +
- "pmCluster=sendateodl5\n" +
- "pmEnabled=true\n" +
- "\n" +
- "";
- private HttpServer server;
- private ExecutorService httpThreadPool;
- private ConfigurationFileRepresentation globalCfg;
-
- @Test
- public void test() {
-
- String testConfigurationFileName = ResourceFileLoader.getFile(this, CONFIGURATIONTESTFILE).getAbsolutePath();
- ConfigurationFileRepresentation cfg=new ConfigurationFileRepresentation(testConfigurationFileName);
-
- AaiProviderClient provider = new AaiProviderClient(cfg, null);
-
- String mountPointName = "testDevice 01";
- String type="Unit";
- String model="Horizon Compact+";
- String vendor="DragonWave-X";
- String ipv4="127.0.0.1";
- String ipv6="::1";
- List<String> ifInfos = new ArrayList<>();
- ifInfos.add("LP-MWPS-RADIO");
- InventoryInformationDcae ii=new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos);
- System.out.println("registering device");
- provider.onDeviceRegistered(mountPointName,ii);
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- System.out.println("unregistering device");
- provider.onDeviceUnregistered(mountPointName);
- System.out.println("finished");
- try {
- provider.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- @Test
- public void test2() {
- try {
- Thread.sleep(3000);
- } catch (InterruptedException e1) {
- e1.printStackTrace();
- }
- AaiProviderClient provider = new AaiProviderClient(globalCfg, null);
-
- String mountPointName = "testDevice 01";
- String type="Unit";
- String model="Horizon Compact+";
- String vendor="DragonWave-X";
- String ipv4="127.0.0.1";
- String ipv6="::1";
- List<String> ifInfos = new ArrayList<>();
- ifInfos.add("LP-MWPS-RADIO");
- InventoryInformationDcae ii=new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos);
- System.out.println("registering device");
- provider.onDeviceRegistered(mountPointName);
- provider.onDeviceRegistered(mountPointName,ii);
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- System.out.println("unregistering device");
- provider.onDeviceUnregistered(mountPointName);
- System.out.println("finished");
- try {
- provider.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- @Before
- public void initAaiTestWebserver() throws IOException {
- try {
- Files.asCharSink(ENABLEDAAI_TESTCONFIG_FILE, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT);
- } catch (IOException e1) {
- fail(e1.getMessage());
- }
- //globalCfg=HtDevicemanagerConfiguration.getTestConfiguration(ENABLEDAAI_TESTCONFIG_FILENAME,true);
- globalCfg = new ConfigurationFileRepresentation(ENABLEDAAI_TESTCONFIG_FILENAME);
- this.server = HttpServer.create(new InetSocketAddress(AAI_SERVER_PORT), 0);
- this.httpThreadPool = Executors.newFixedThreadPool(5);
- this.server.setExecutor(this.httpThreadPool);
- AaiConfig config = new AaiConfig(globalCfg);
- this.server.createContext(config.getBaseUri(), new MyHandler());
- //server.createContext("/", new MyRootHandler());
- this.server.setExecutor(null); // creates a default executor
- this.server.start();
- System.out.println("http server started");
- }
-
- @After
- public void stopTestWebserver() {
- if (this.server != null) {
- this.server.stop(0);
- this.httpThreadPool.shutdownNow();
- System.out.println("http server stopped" );
- }
- if (ENABLEDAAI_TESTCONFIG_FILE.exists()) {
- ENABLEDAAI_TESTCONFIG_FILE.delete();
- }
-
- }
- static class MyHandler implements HttpHandler {
- @Override
- public void handle(HttpExchange t) throws IOException {
- String method = t.getRequestMethod();
- System.out.println("req method: " + method);
- OutputStream os = null;
- try {
- String res="";
- if (method.equals("GET")) {
- t.sendResponseHeaders(404,res.length() );
- os = t.getResponseBody();
- os.write(res.getBytes());
- } else if (method.equals("DELETE")) {
- t.sendResponseHeaders(200, res.length());
- os = t.getResponseBody();
- os.write(res.getBytes());
- } else if (method.equals("PUT")) {
- t.sendResponseHeaders(200, res.length());
- os = t.getResponseBody();
- os.write(res.getBytes());
- } else {
- t.sendResponseHeaders(404, 0);
- }
- System.out.println("req handled successful");
-
- } catch (Exception e) {
- System.out.println(e.getMessage());
- }
- finally {
- if (os != null)
- {
- os.close();
- }
- }
- }
- }
+ private static final String CONFIGURATIONTESTFILE = "test.properties"; // for
+ private static final String ENABLEDAAI_TESTCONFIG_FILENAME = "test2.properties";
+ private static final File ENABLEDAAI_TESTCONFIG_FILE = new File(ENABLEDAAI_TESTCONFIG_FILENAME);
+ private static final int AAI_SERVER_PORT = 45454;
+ private static final String TESTCONFIG_CONTENT = "[dcae]\n" + "dcaeUserCredentials=admin:admin\n" + "dcaeUrl=off\n"
+ + "dcaeHeartbeatPeriodSeconds=120\n" + "dcaeTestCollector=no\n" + "\n" + "[aots]\n"
+ + "userPassword=passwd\n" + "soapurladd=off\n" + "soapaddtimeout=10\n" + "soapinqtimeout=20\n"
+ + "userName=user\n" + "inqtemplate=inqreq.tmpl.xml\n" + "assignedto=userid\n"
+ + "addtemplate=addreq.tmpl.xml\n" + "severitypassthrough=critical,major,minor,warning\n"
+ + "systemuser=user\n" + "prt-offset=1200\n" + "soapurlinq=off\n" + "#smtpHost=\n" + "#smtpPort=\n"
+ + "#smtpUsername=\n" + "#smtpPassword=\n" + "#smtpSender=\n" + "#smtpReceivers=\n" + "\n" + "[es]\n"
+ + "esCluster=sendateodl5\n" + "\n" + "[aai]\n" + "#keep comment\n"
+ + "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + "aaiUrl=http://localhost:" + AAI_SERVER_PORT + "\n"
+ + "aaiUserCredentials=AAI:AAI\n" + "aaiDeleteOnMountpointRemove=true\n" + "aaiTrustAllCerts=false\n"
+ + "aaiApiVersion=aai/v13\n" + "aaiPropertiesFile=aaiclient.properties\n" + "aaiApplicationId=SDNR\n"
+ + "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n"
+ + "aaiPcks12ClientCertPassphrase=adminadmin\n" + "aaiClientConnectionTimeout=30000\n" + "\n" + "[pm]\n"
+ + "pmCluster=sendateodl5\n" + "pmEnabled=true\n" + "\n" + "";
+
+ private static final String EXT_TEST_URL="https://testaai.onap.org:8443";
+ private static final String EXT_TEST_KEY="test.key";
+ private static final String EXT_TEST_PASSWD="test123";
+ private static final String EXT_TEST_APPLICATIONID="SDNC";
+ private static final long EXT_TEST_CONN_TIMEOUT=6000;
+
+
+ private static final CharSequence TESTCONFIG_CONTENT_EXT = "[aai]\n" + "#keep comment\n"
+ + "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + "aaiUrl=http://localhost:" + AAI_SERVER_PORT + "\n"
+ + "aaiUserCredentials=AAI:AAI\n" + "aaiDeleteOnMountpointRemove=true\n" + "aaiTrustAllCerts=false\n"
+ + "aaiApiVersion=aai/v13\n" + "aaiPropertiesFile=aaiclient.properties\n" +
+ // "aaiApplicationId=SDNR\n" +
+ // "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n" +
+ // "aaiPcks12ClientCertPassphrase=adminadmin\n" +
+ // "aaiClientConnectionTimeout=30000\n" +
+ "\n";
+ private static final CharSequence TESTCONFIG_CONTENT_EXT2 = "org.onap.ccsdk.sli.adaptors.aai.ssl.key="+EXT_TEST_KEY+"\n"
+ + "org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd="+EXT_TEST_PASSWD+"\n"
+ + "org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore=false\n"
+ + "org.onap.ccsdk.sli.adaptors.aai.application="+EXT_TEST_APPLICATIONID+"\n"
+ + "org.onap.ccsdk.sli.adaptors.aai.uri="+EXT_TEST_URL+"\n"
+ + "connection.timeout="+EXT_TEST_CONN_TIMEOUT+"\n";
+ private static HttpServer server;
+ private static ExecutorService httpThreadPool;
+ private static ConfigurationFileRepresentation globalCfg;
+
+ @Test
+ public void test() {
+
+ String testConfigurationFileName = ResourceFileLoader.getFile(this, CONFIGURATIONTESTFILE).getAbsolutePath();
+ ConfigurationFileRepresentation cfg = new ConfigurationFileRepresentation(testConfigurationFileName);
+
+ AaiProviderClient provider = new AaiProviderClient(cfg, null);
+
+ String mountPointName = "testDevice 01";
+ String type = "Unit";
+ String model = "Horizon Compact+";
+ String vendor = "DragonWave-X";
+ String ipv4 = "127.0.0.1";
+ String ipv6 = "::1";
+ List<String> ifInfos = new ArrayList<>();
+ ifInfos.add("LP-MWPS-RADIO");
+ InventoryInformationDcae ii = new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos);
+ System.out.println("registering device");
+ provider.onDeviceRegistered(mountPointName, ii);
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ System.out.println("unregistering device");
+ provider.onDeviceUnregistered(mountPointName);
+ System.out.println("finished");
+ try {
+ provider.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void test2() {
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
+ AaiProviderClient provider = new AaiProviderClient(globalCfg, null);
+
+ String mountPointName = "testDevice 01";
+ String type = "Unit";
+ String model = "Horizon Compact+";
+ String vendor = "DragonWave-X";
+ String ipv4 = "127.0.0.1";
+ String ipv6 = "::1";
+ List<String> ifInfos = new ArrayList<>();
+ ifInfos.add("LP-MWPS-RADIO");
+ InventoryInformationDcae ii = new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos);
+ System.out.println("registering device");
+ provider.onDeviceRegistered(mountPointName);
+ provider.onDeviceRegistered(mountPointName, ii);
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ System.out.println("unregistering device");
+ provider.onDeviceUnregistered(mountPointName);
+ System.out.println("finished");
+ try {
+ provider.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+
+ @Test
+ public void testExtendedProperties() {
+ File testConfigurationFileName = new File("abbsads.properties");
+ File extfile = new File("aaiclient.properties");
+ if (testConfigurationFileName.exists()) {
+ testConfigurationFileName.delete();
+ }
+ if (extfile.exists()) {
+ extfile.delete();
+ }
+ try {
+ Files.asCharSink(testConfigurationFileName, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT_EXT);
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("problem writing a test config file: " + e.getMessage());
+ }
+ try {
+ Files.asCharSink(extfile, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT_EXT2);
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("problem writing a second test config file: " + e.getMessage());
+ }
+
+ ConfigurationFileRepresentation cfg = new ConfigurationFileRepresentation(testConfigurationFileName);
+ AaiConfig config = new AaiConfig(cfg);
+ System.out.println(config.toString());
+
+ assertTrue(config.getBaseUrl().startsWith(EXT_TEST_URL));
+ assertEquals(EXT_TEST_KEY,config.getPcks12CertificateFilename());
+ assertEquals(EXT_TEST_PASSWD,config.getPcks12CertificatePassphrase());
+ assertEquals(EXT_TEST_APPLICATIONID,config.getHeaders().get("X-FromAppId"));
+ assertEquals(EXT_TEST_CONN_TIMEOUT,config.getConnectionTimeout());
+
+ if (testConfigurationFileName.exists()) {
+ testConfigurationFileName.delete();
+ }
+ if (extfile.exists()) {
+ extfile.delete();
+ }
+
+ }
+
+ @BeforeClass
+ public static void initAaiTestWebserver() throws IOException {
+ try {
+ Files.asCharSink(ENABLEDAAI_TESTCONFIG_FILE, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT);
+ } catch (IOException e1) {
+ fail(e1.getMessage());
+ }
+ //globalCfg=HtDevicemanagerConfiguration.getTestConfiguration(ENABLEDAAI_TESTCONFIG_FILENAME,true);
+ globalCfg = new ConfigurationFileRepresentation(ENABLEDAAI_TESTCONFIG_FILENAME);
+ server = HttpServer.create(new InetSocketAddress(AAI_SERVER_PORT), 0);
+ httpThreadPool = Executors.newFixedThreadPool(5);
+ server.setExecutor(httpThreadPool);
+ AaiConfig config = new AaiConfig(globalCfg);
+ server.createContext(config.getBaseUri(), new MyHandler());
+ //server.createContext("/", new MyRootHandler());
+ server.setExecutor(null); // creates a default executor
+ server.start();
+ System.out.println("http server started");
+ }
+
+ @AfterClass
+ public static void stopTestWebserver() {
+ if (server != null) {
+ server.stop(0);
+ httpThreadPool.shutdownNow();
+ System.out.println("http server stopped");
+ }
+ if (ENABLEDAAI_TESTCONFIG_FILE.exists()) {
+ ENABLEDAAI_TESTCONFIG_FILE.delete();
+ }
+
+ }
+
+ static class MyHandler implements HttpHandler {
+ @Override
+ public void handle(HttpExchange t) throws IOException {
+ String method = t.getRequestMethod();
+ System.out.println("req method: " + method);
+ OutputStream os = null;
+ try {
+ String res = "";
+ if (method.equals("GET")) {
+ t.sendResponseHeaders(404, res.length());
+ os = t.getResponseBody();
+ os.write(res.getBytes());
+ } else if (method.equals("DELETE")) {
+ t.sendResponseHeaders(200, res.length());
+ os = t.getResponseBody();
+ os.write(res.getBytes());
+ } else if (method.equals("PUT")) {
+ t.sendResponseHeaders(200, res.length());
+ os = t.getResponseBody();
+ os.write(res.getBytes());
+ } else {
+ t.sendResponseHeaders(404, 0);
+ }
+ System.out.println("req handled successful");
+
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ } finally {
+ if (os != null) {
+ os.close();
+ }
+ }
+ }
+ }
}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAkkaConfig.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAkkaConfig.java
deleted file mode 100644
index 7bc30550f..000000000
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAkkaConfig.java
+++ /dev/null
@@ -1,136 +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.test;
-
-import static org.junit.Assert.fail;
-import java.io.File;
-import org.junit.Test;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.conf.odlAkka.AkkaConfig;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.conf.odlAkka.ClusterNodeInfo;
-
-public class TestAkkaConfig {
-
- private static String getAkkaConfigSingleNodeText() {
- return "\n" + "odl-cluster-data {\n" + " akka {\n" + " remote {\n" + " artery {\n"
- + " enabled = off\n" + " canonical.hostname = \"127.0.0.1\"\n"
- + " canonical.port = 2550\n" + " }\n" + " netty.tcp {\n"
- + " hostname = \"127.0.0.1\"\n" + " port = 2550\n" + " }\n"
- + " # when under load we might trip a false positive on the failure detector\n"
- + " # transport-failure-detector {\n" + " # heartbeat-interval = 4 s\n"
- + " # acceptable-heartbeat-pause = 16s\n" + " # }\n" + " }\n" + "\n" + " cluster {\n"
- + " # Remove \".tcp\" when using artery.\n"
- + " seed-nodes = [\"akka.tcp://opendaylight-cluster-data@127.0.0.1:2550\"]\n" + "\n"
- + " roles = [\n" + " \"member-1\"\n" + " ]\n" + "\n" + " }\n" + "\n"
- + " persistence {\n"
- + " # By default the snapshots/journal directories live in KARAF_HOME. You can choose to put it somewhere else by\n"
- + " # modifying the following two properties. The directory location specified may be a relative or absolute path. \n"
- + " # The relative path is always relative to KARAF_HOME.\n" + "\n"
- + " # snapshot-store.local.dir = \"target/snapshots\"\n"
- + " # journal.leveldb.dir = \"target/journal\"\n" + "\n" + " journal {\n"
- + " leveldb {\n" + " # Set native = off to use a Java-only implementation of leveldb.\n"
- + " # Note that the Java-only version is not currently considered by Akka to be production quality.\n"
- + "\n" + " # native = off\n" + " }\n" + " }\n" + " }\n" + " }\n" + "}";
- }
-
- private static String getAkkaConfigClusterNodeText() {
- return "\n" + "odl-cluster-data {\n" + "\n" + " akka {\n" + " loglevel = \"\"\n" + " remote {\n"
- + " netty.tcp {\n" + " hostname = \"zltcmtn23arbc01.2f0377.mtn23a.tci.att.com\"\n"
- + " port = 2550\n" + " }\n" + " }\n" + " actor {\n" + " debug{\n"
- + " autoreceive = on\n" + " lifecycle = on\n" + " unhandled = on\n"
- + " fsm = on\n" + " event-stream = on\n" + " }\n" + " }\n" + " cluster {\n"
- + " seed-nodes = [\"akka.tcp://opendaylight-cluster-data@zltcmtn23arbc01.2f0377.mtn23a.tci.att.com:2550\", \"akka.tcp://opendaylight-cluster-data@zltcmtn23arbc02.2f0377.mtn23a.tci.att.com:2550\", \"akka.tcp://opendaylight-cluster-data@zltcmtn23arbc03.2f0377.mtn23a.tci.att.com:2550\", \"akka.tcp://opendaylight-cluster-data@zltcmtn23brbc01.f84e7a.mtn23b.tci.att.com:2550\", \"akka.tcp://opendaylight-cluster-data@zltcmtn23brbc02.f84e7a.mtn23b.tci.att.com:2550\", \"akka.tcp://opendaylight-cluster-data@zltcmtn23brbc03.f84e7a.mtn23b.tci.att.com:2550\"]\n"
- + " seed-node-timeout = 15s\n" + " roles = [\"member-1\"]\n" + "\n" + " }\n"
- + " persistence {\n" + " journal-plugin-fallback {\n" + " circuit-breaker {\n"
- + " max-failures = 10\n" + " call-timeout = 60s\n"
- + " reset-timeout = 30s\n" + " }\n" + " }\n" + " }\n" + " }\n" + "}\n" + "\n"
- + "odl-cluster-rpc {\n" + "\n" + " akka {\n" + " loglevel = \"\"\n" + " remote {\n"
- + " netty.tcp {\n" + " hostname = \"zltcmtn23arbc01.2f0377.mtn23a.tci.att.com\"\n"
- + " port = 2551\n" + " }\n" + " }\n" + " actor {\n" + " debug{\n"
- + " autoreceive = on\n" + " lifecycle = on\n" + " unhandled = on\n"
- + " fsm = on\n" + " event-stream = on\n" + " }\n" + " }\n" + " cluster {\n"
- + " seed-nodes = [\"akka.tcp://odl-cluster-rpc@zltcmtn23arbc01.2f0377.mtn23a.tci.att.com:2551\", \"akka.tcp://odl-cluster-rpc@zltcmtn23arbc02.2f0377.mtn23a.tci.att.com:2551\", \"akka.tcp://odl-cluster-rpc@zltcmtn23arbc03.2f0377.mtn23a.tci.att.com:2551\", \"akka.tcp://odl-cluster-rpc@zltcmtn23brbc01.f84e7a.mtn23b.tci.att.com:2551\", \"akka.tcp://odl-cluster-rpc@zltcmtn23brbc02.f84e7a.mtn23b.tci.att.com:2551\", \"akka.tcp://odl-cluster-rpc@zltcmtn23brbc03.f84e7a.mtn23b.tci.att.com:2551\"]\n"
- + " seed-node-timeout = 15s\n" + " }\n" + " persistence {\n"
- + " journal-plugin-fallback {\n" + " circuit-breaker {\n" + " max-failures = 10\n"
- + " call-timeout = 60s\n" + " reset-timeout = 30s\n" + " }\n" + " }\n"
- + " }\n" + " }\n" + "}\n" + "\n" + "";
- }
-
- @Test
- public void test1() {
- AkkaConfig cfg;
- try {
- System.out.println("testing clusternode config1");
- System.out.println("===========================");
- cfg = AkkaConfig.parse(getAkkaConfigClusterNodeText());
- System.out.println("succeeded: ");
- System.out.println(cfg.toString());
- System.out.println(String.format("found %d cluster nodes", cfg.getClusterConfig().getSeedNodes().size()));
- for (ClusterNodeInfo n : cfg.getClusterConfig().getSeedNodes()) {
- System.out.println(n.toString());
- }
- } catch (Exception e) {
- String failMessage = "failed: " + e.getMessage();
- System.out.println(failMessage);
- fail(failMessage);
- }
- }
-
- @Test
- public void test2() {
- AkkaConfig cfg;
- try {
- System.out.println("testing singlenode config1");
- System.out.println("===========================");
- cfg = AkkaConfig.parse(getAkkaConfigSingleNodeText());
- System.out.println("succeeded: ");
- System.out.println(cfg.toString());
- } catch (Exception e) {
- String failMessage = "failed: " + e.getMessage();
- System.out.println(failMessage);
- fail(failMessage);
- }
- }
-
- @Test
- public void test3() {
- AkkaConfig cfg;
-
- ClassLoader classLoader = getClass().getClassLoader();
- File file = new File(classLoader.getResource("captured-akka.conf").getFile());
- System.out.println(file.getAbsolutePath());
-
- try {
- System.out.println("testing clusternode config1");
- System.out.println("===========================");
- cfg = AkkaConfig.load(file.getAbsolutePath());
- System.out.println("succeeded: "+cfg.hashCode());
- System.out.println(cfg.toString());
- System.out.println(String.format("found %d cluster nodes", cfg.getClusterConfig().getSeedNodes().size()));
- for (ClusterNodeInfo n : cfg.getClusterConfig().getSeedNodes()) {
- System.out.println(n.toString());
- }
- } catch (Exception e) {
- String failMessage = "failed: " + e.getMessage();
- System.out.println(failMessage);
- fail(failMessage);
- }
- }
-}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceMonitor.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceMonitor.java
new file mode 100644
index 000000000..7fb417838
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceMonitor.java
@@ -0,0 +1,71 @@
+/*******************************************************************************
+ * ============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.test;
+
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.devicemonitor.impl.DeviceMonitorImpl;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.eventdatahandler.ODLEventListenerHandler;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+
+public class TestDeviceMonitor extends Mockito {
+
+ private static final String CONFIGURATIONTESTFILE = "test.properties"; // for
+ private static final String mountPointNodeName = "TestMountpoint";
+
+ private static DeviceMonitorImpl deviceMonitor;
+
+ @BeforeClass
+ public static void before() {
+
+ DataBroker dataBroker = mock(DataBroker.class);
+ ODLEventListenerHandler odlEventListenerHandler = mock(ODLEventListenerHandler.class);
+ ConfigurationFileRepresentation config = new ConfigurationFileRepresentation(CONFIGURATIONTESTFILE);
+
+ deviceMonitor = new DeviceMonitorImpl(dataBroker, odlEventListenerHandler, config);
+
+ }
+
+ @Test
+ public void testDeviceMonitor() {
+
+ deviceMonitor.deviceConnectSlaveIndication(mountPointNodeName);
+ deviceMonitor.refreshAlarmsInDb();
+ deviceMonitor.taskTestRun();
+ deviceMonitor.deviceDisconnectIndication(mountPointNodeName);
+ deviceMonitor.removeMountpointIndication(mountPointNodeName);
+ }
+
+ @Test
+ public void testDeviceMonitorTask() {
+
+
+ }
+
+ @AfterClass
+ public static void after() throws Exception {
+ deviceMonitor.close();
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java
new file mode 100644
index 000000000..a86bfc277
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java
@@ -0,0 +1,207 @@
+/*******************************************************************************
+ * ============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.test;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import org.junit.AfterClass;
+import org.junit.BeforeClass;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtDatabaseMaintenance;
+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.impl.DeviceManagerImpl;
+import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalDateAndTime;
+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.test.mock.RpcProviderServiceMock;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeConnectListener;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateListener;
+import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateService;
+import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.MountPointService;
+import org.opendaylight.mdsal.binding.api.NotificationPublishService;
+import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceProvider;
+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.FaultlogBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.MaintenanceBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ClearCurrentFaultByNodenameInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.DevicemanagerService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.GetRequiredNetworkElementKeysInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushAttributeChangeNotificationInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushFaultNotificationInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ShowRequiredNetworkElementInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.websocketmanager.rev150105.WebsocketmanagerService;
+import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
+import org.opendaylight.yangtools.concepts.ListenerRegistration;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+@SuppressWarnings("deprecation")
+public class TestDevicemanager extends Mockito {
+
+ private static final Logger log = LoggerFactory.getLogger(TestDevicemanager.class);
+
+ private static DeviceManagerImpl deviceManager = new DeviceManagerImpl();
+ private static DevicemanagerService apiService;
+ private static HtDatabaseMaintenance htDataBaseMaintenance = mock(HtDatabaseMaintenance.class);
+
+ @BeforeClass
+ public static void before() throws Exception {
+
+ DataBroker dataBroker = mock(DataBroker.class);
+ RpcProviderServiceMock rpcProviderRegistry = new RpcProviderServiceMock();
+ NotificationPublishService notificationPublishService = mock(NotificationPublishService.class);
+ MountPointService mountPointService = mock(MountPointService.class);
+ ClusterSingletonServiceProvider clusterSingletonService = mock(ClusterSingletonServiceProvider.class);
+ NetconfNodeStateService netconfNodeStateService = mock(NetconfNodeStateService.class);
+
+ @SuppressWarnings("unchecked")
+ ListenerRegistration<NetconfNodeConnectListener> lr1 = mock(ListenerRegistration.class);
+ //doNothing().when(lr1).close();
+ when(netconfNodeStateService.registerNetconfNodeConnectListener(mock(NetconfNodeConnectListener.class))).thenReturn(lr1);
+
+ @SuppressWarnings("unchecked")
+ ListenerRegistration<NetconfNodeStateListener> lr2 = mock(ListenerRegistration.class);
+ //doNothing().when(lr2).close();
+ when(netconfNodeStateService.registerNetconfNodeStateListener(mock(NetconfNodeStateListener.class))).thenReturn(lr2);
+
+ WebsocketmanagerService websocketmanagerService = mock(WebsocketmanagerService.class);
+
+ IEntityDataProvider iEntityDataProvider = mock(IEntityDataProvider.class);
+ doNothing().when(iEntityDataProvider).setReadyStatus(isA(Boolean.class));
+
+ DataProvider dataProvider = mock(DataProvider.class);
+ when(iEntityDataProvider.getDataProvider()).thenReturn(dataProvider);
+
+ when(iEntityDataProvider.getHtDatabaseMaintenance()).thenReturn(htDataBaseMaintenance);
+
+
+ IEsConfig esConfig = mock(IEsConfig.class);
+ when(iEntityDataProvider.getEsConfig()).thenReturn(esConfig);
+
+
+ deviceManager.setDataBroker(dataBroker);
+ deviceManager.setRpcProviderRegistry(rpcProviderRegistry);
+ deviceManager.setNotificationPublishService(notificationPublishService);
+ deviceManager.setMountPointService(mountPointService);
+ deviceManager.setClusterSingletonService(clusterSingletonService);
+ deviceManager.setNetconfNodeStateService(netconfNodeStateService);
+ deviceManager.setWebsocketmanagerService(websocketmanagerService);
+ deviceManager.setEntityDataProvider(iEntityDataProvider);
+
+ deviceManager.init();
+
+ apiService = rpcProviderRegistry.getDeviceManagerApiService();
+
+ }
+
+
+ @Test
+ public void testInit() {
+ assertTrue(deviceManager.isDevicemanagerInitializationOk());
+ }
+
+ @Test
+ public void testChangeNotification() {
+ NotificationService n = deviceManager.getNotificationService();
+
+ n.creationNotification(new NodeId("NodeTest1"), 1, InternalDateAndTime.getTestpatternDateAndTime(), "ObjTest1");
+
+ n.changeNotification(new NodeId("NodeTest1"), 2, InternalDateAndTime.getTestpatternDateAndTime(), "ObjTest1", "AtrributeTest1", "NewTest1");
+
+ n.deletionNotification(new NodeId("NodeTest1"), 3, InternalDateAndTime.getTestpatternDateAndTime(), "ObjTest1");
+
+ }
+
+ @Test
+ public void testFaultNotification() {
+ log.info("testFaultNotification");
+
+ MaintenanceBuilder mb = new MaintenanceBuilder();
+ when(htDataBaseMaintenance
+ .getMaintenance(""))
+ .thenReturn(mb.build());
+
+ FaultService n = deviceManager.getFaultService();
+ FaultlogBuilder faultLogEntityBuilder = new FaultlogBuilder();
+ n.faultNotification(faultLogEntityBuilder.build());
+
+ }
+
+ @Test
+ public void testGet() {
+ log.info("testGet");
+ GetRequiredNetworkElementKeysInputBuilder inputBuilder = new GetRequiredNetworkElementKeysInputBuilder();
+ apiService.getRequiredNetworkElementKeys(inputBuilder.build());
+
+ }
+
+ @Test
+ public void testShow() {
+ log.info("testShow");
+ ShowRequiredNetworkElementInputBuilder inputBuilder = new ShowRequiredNetworkElementInputBuilder();
+ inputBuilder.setMountpointName("test");
+ apiService.showRequiredNetworkElement(inputBuilder.build());
+
+ }
+
+ @Test
+ public void testResync() {
+ log.info("testResync");
+
+ ClearCurrentFaultByNodenameInputBuilder inputBuilder = new ClearCurrentFaultByNodenameInputBuilder();
+ inputBuilder.setNodenames(Arrays.asList("test1", "test2"));
+ apiService.clearCurrentFaultByNodename(inputBuilder.build());
+
+ }
+
+ @Test
+ public void testPushFault() {
+ log.info("testPushFault");
+
+ PushFaultNotificationInputBuilder inputBuilder = new PushFaultNotificationInputBuilder();
+ inputBuilder.setNodeId("NodeTest23");
+ inputBuilder.setTimestamp(new DateAndTime("2020-01-01T01:02:03.4Z"));
+ apiService.pushFaultNotification(inputBuilder.build());
+
+ }
+
+ @Test
+ public void testPushChange() {
+ log.info("testPushChange");
+
+ PushAttributeChangeNotificationInputBuilder inputBuilder = new PushAttributeChangeNotificationInputBuilder();
+ inputBuilder.setNodeId("NodeTest24");
+ apiService.pushAttributeChangeNotification(inputBuilder.build());
+
+ }
+
+
+ @AfterClass
+ public static void after() {
+ deviceManager.close();
+ }
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestGeoConfig.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestGeoConfig.java
deleted file mode 100644
index 6474a1eb6..000000000
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestGeoConfig.java
+++ /dev/null
@@ -1,63 +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.test;
-
-import static org.junit.Assert.*;
-import org.junit.Test;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.conf.odlGeo.GeoConfig;
-
-public class TestGeoConfig {
-
- @Test
- public void test() {
- GeoConfig config;
- try {
- System.out.println("testing clusternode geo config1");
- System.out.println("===========================");
- config = GeoConfig.parse(getClusterGeoConfigContent());
- System.out.println("succeeded: ");
- System.out.println(config.toString());
- System.out.println("primary roles:");
- System.out.println(config.getPrimaryRoles().toString());
- System.out.println("secondary roles:");
- System.out.println(config.getSecondaryRoles().toString());
-
- } catch (Exception e) {
- fail("failed: " + e.getMessage());
- }
- }
-
-
-
- private static String getClusterGeoConfigContent() {
- return "\n" + "lumina-geo-cluster {\n" + " primary_roles = [\n"
- + " \"member-1\",\"member-2\",\"member-3\"\n" + " ]\n" + " secondary_roles = [\n"
- + " \"member-4\",\"member-5\",\"member-6\"\n" + " ]\n" + " ip_roles_table = [\n" + "\n"
- + " {\n" + "role=\"member-1\"\n" + "ip=\"zltcmtn23arbc01.2f0377.mtn23a.tci.att.com\"\n" + "},\n"
- + "{\n" + "role=\"member-2\"\n" + "ip=\"zltcmtn23arbc02.2f0377.mtn23a.tci.att.com\"\n" + "},\n" + "{\n"
- + "role=\"member-3\"\n" + "ip=\"zltcmtn23arbc03.2f0377.mtn23a.tci.att.com\"\n" + "},\n" + "{\n"
- + "role=\"member-4\"\n" + "ip=\"zltcmtn23brbc01.f84e7a.mtn23b.tci.att.com\"\n" + "},\n" + "{\n"
- + "role=\"member-5\"\n" + "ip=\"zltcmtn23brbc02.f84e7a.mtn23b.tci.att.com\"\n" + "},\n" + "{\n"
- + "role=\"member-6\"\n" + "ip=\"zltcmtn23brbc03.f84e7a.mtn23b.tci.att.com\"\n" + "}\n" + " \n"
- + " ]\n" + "}\n" + "\n" + "\n" + "\n" + "\n" + "";
- }
-
-}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java
index 932ad52d2..3d8571659 100644
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java
@@ -22,11 +22,11 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.test;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
import java.time.ZonedDateTime;
import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.maintenance.impl.MaintenanceCalculator;
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.MaintenanceBuilder;
public class TestMaintenanceTimeFilter {
@@ -34,7 +34,7 @@ public class TestMaintenanceTimeFilter {
private static String DEFAULT2 = "EsMaintenanceFilter [start=1970-01-01T00:00Z[UTC], end=2018-01-01T10:00+05:00, definition=EsMaintenanceFilterDefinition [objectIdRef=, problem=], description=]";
@Test
- public void test1() {
+ public void testBasic() {
boolean res;
@@ -59,4 +59,29 @@ public class TestMaintenanceTimeFilter {
}
+ @Test
+ public void testBasic2() {
+
+ MaintenanceBuilder mb = new MaintenanceBuilder();
+
+ mb.setActive(true);
+ mb.setStart(new DateAndTime("1999-01-01T00:00:00Z"));
+ mb.setEnd(new DateAndTime("2001-01-01T00:00:00Z"));
+ mb.setId("id1");
+ mb.setObjectIdRef("Interface1");
+ mb.setProblem("Problem1");
+
+ boolean res;
+ ZonedDateTime now;
+
+ now = MaintenanceCalculator.valueOf("2000-01-01T00:00Z");
+ res = MaintenanceCalculator.isONFObjectInMaintenance(mb.build(), "", "", now);
+ assertTrue("within period",res);
+
+ now = MaintenanceCalculator.valueOf("2002-01-01T00:00Z");
+ res = MaintenanceCalculator.isONFObjectInMaintenance(mb.build(), "", "", now);
+ assertFalse("outside period",res);
+
+ }
+
}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestNotification.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestToggleAlarmFilter.java
index 7e54f16b1..766b25e6d 100644
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestNotification.java
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestToggleAlarmFilter.java
@@ -23,10 +23,10 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.test;
import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter.NotificationWithServerTimeStamp;
-public class TestNotification {
+public class TestToggleAlarmFilter {
@Test
- public void test() {
+ public void testNotification() {
NotificationWithServerTimeStamp<Integer> test = new NotificationWithServerTimeStamp<>(1000);
@@ -37,5 +37,4 @@ public class TestNotification {
}
-
}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestXmlNotification.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestXmlNotification.java
new file mode 100644
index 000000000..f1822768d
--- /dev/null
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestXmlNotification.java
@@ -0,0 +1,90 @@
+/*******************************************************************************
+ * ============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.test;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import java.util.Arrays;
+import org.junit.Test;
+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.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.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SourceType;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class TestXmlNotification {
+
+ private static final Logger log = LoggerFactory.getLogger(TestXmlNotification.class);
+
+ @Test
+ public void test() {
+
+ ProblemNotificationXml notification = new ProblemNotificationXml("TestMointpoint", "network-element",
+ "problemName", InternalSeverity.Critical, 123, InternalDateAndTime.getTestpattern());
+
+ notification.getFaultlog(SourceType.Unknown);
+
+ notification.getFaultcurrent();
+
+ notification.isNotManagedAsCurrentProblem();
+
+ ProblemNotificationXml.debugResultList(log, "uuid", Arrays.asList(notification), 0);
+
+ }
+
+ @Test
+ public void testNoAlarm() {
+
+ ProblemNotificationXml notification;
+ notification = new ProblemNotificationXml("TestMointpoint", "network-element",
+ "problemName", InternalSeverity.Critical, 123, InternalDateAndTime.getTestpattern());
+
+ assertFalse("Critical", notification.isNoAlarmIndication());
+
+ notification = new ProblemNotificationXml("TestMointpoint", "network-element",
+ "problemName", InternalSeverity.NonAlarmed, 123, InternalDateAndTime.getTestpattern());
+
+ assertTrue("NonAlarm", notification.isNoAlarmIndication());
+
+ }
+
+ @Test
+ public void testObjectCreationNotification() {
+
+ ObjectCreationNotificationXml notification;
+ notification = new ObjectCreationNotificationXml("TestMointpoint1", 1, InternalDateAndTime.getTestpattern(), "Id1");
+
+ }
+
+ @Test
+ public void testDeletionCreationNotification() {
+
+ ObjectDeletionNotificationXml notification;
+ notification = new ObjectDeletionNotificationXml("TestMointpoint2", 2, InternalDateAndTime.getTestpattern(), "Id2");
+
+ }
+
+
+}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerMountpointMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerMountpointMock.java
deleted file mode 100644
index 2bd5a9272..000000000
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerMountpointMock.java
+++ /dev/null
@@ -1,77 +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.test.mock;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.binding.api.BindingService;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
-import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
-import org.opendaylight.mdsal.binding.api.ReadTransaction;
-import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
-import org.opendaylight.mdsal.binding.api.TransactionChain;
-import org.opendaylight.mdsal.binding.api.TransactionChainListener;
-import org.opendaylight.mdsal.binding.api.WriteTransaction;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-
-/**
- * @author herbert
- *
- */
-@SuppressWarnings("deprecation")
-public class DataBrokerMountpointMock implements DataBroker, BindingService {
-
- ReadTransaction readOnlyTransaction;
-
- public void setReadOnlyTransaction(ReadTransaction readOnlyTransaction) {
- this.readOnlyTransaction = readOnlyTransaction;
- }
-
- @Override
- public @NonNull ReadTransaction newReadOnlyTransaction() {
- return readOnlyTransaction;
- }
-
- @Override
- public @NonNull ReadWriteTransaction newReadWriteTransaction() {
- return null;
- }
-
- @Override
- public @NonNull WriteTransaction newWriteOnlyTransaction() {
- return null;
- }
-
- @Override
- public <T extends DataObject, L extends DataTreeChangeListener<T>> @NonNull ListenerRegistration<L> registerDataTreeChangeListener(
- @NonNull DataTreeIdentifier<T> treeId, @NonNull L listener) {
- return null;
- }
-
- @Override
- public @NonNull TransactionChain createTransactionChain(@NonNull TransactionChainListener listener) {
- return null;
- }
-
-
-
-}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerNetconfMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerNetconfMock.java
deleted file mode 100644
index 0b5052632..000000000
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataBrokerNetconfMock.java
+++ /dev/null
@@ -1,76 +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.test.mock;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.opendaylight.mdsal.binding.api.DataBroker;
-import org.opendaylight.mdsal.binding.api.DataTreeChangeListener;
-import org.opendaylight.mdsal.binding.api.DataTreeIdentifier;
-import org.opendaylight.mdsal.binding.api.ReadTransaction;
-import org.opendaylight.mdsal.binding.api.ReadWriteTransaction;
-import org.opendaylight.mdsal.binding.api.TransactionChain;
-import org.opendaylight.mdsal.binding.api.TransactionChainListener;
-import org.opendaylight.mdsal.binding.api.WriteTransaction;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.DataObject;
-
-/**
- * @author herbert
- *
- */
-@SuppressWarnings("deprecation")
-public class DataBrokerNetconfMock implements DataBroker {
-
-
- ReadTransaction readOnlyTransaction;
-
- public void setReadOnlyTransaction(ReadTransaction readOnlyTransaction) {
- this.readOnlyTransaction = readOnlyTransaction;
- }
-
- @Override
- public @NonNull ReadTransaction newReadOnlyTransaction() {
- return readOnlyTransaction;
- }
-
- @Override
- public @NonNull ReadWriteTransaction newReadWriteTransaction() {
- return null;
- }
-
- @Override
- public @NonNull WriteTransaction newWriteOnlyTransaction() {
- return null;
- }
-
- @Override
- public <T extends DataObject, L extends DataTreeChangeListener<T>> @NonNull ListenerRegistration<L> registerDataTreeChangeListener(
- @NonNull DataTreeIdentifier<T> treeId, @NonNull L listener) {
- return null;
- }
-
- @Override
- public @NonNull TransactionChain createTransactionChain(@NonNull TransactionChainListener listener) {
- return null;
- }
-
-
-}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataProviderMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataProviderMock.java
deleted file mode 100644
index 00edbe2ed..000000000
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/DataProviderMock.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START=======================================================
- * ONAP : ccsdk feature sdnr wt sdnr-wt-devicemanager-provider
- * ================================================================================
- * 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.test.mock;
-
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.ConnectionlogEntity;
-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.data.provider.rev190801.FaultcurrentEntity;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.FaultlogEntity;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Inventory;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.NetworkElementConnectionEntity;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.PmdataEntity;
-
-public class DataProviderMock implements DataProvider {
-
- @Override
- public void writeConnectionLog(ConnectionlogEntity event) {
- }
-
- @Override
- public void writeEventLog(EventlogEntity event) {
- }
-
- @Override
- public void writeFaultLog(FaultlogEntity fault) {
- }
-
- @Override
- public void updateFaultCurrent(FaultcurrentEntity fault) {
- }
-
- @Override
- public int clearFaultsCurrentOfNode(String nodeName) {
- return 0;
- }
-
- @Override
- public int clearFaultsCurrentOfNodeWithObjectId(String nodeName, String objectId) {
- return 0;
- }
-
- @Override
- public List<String> getAllNodesWithCurrentAlarms() {
- return new ArrayList<>();
- }
-
- @Override
- public void writeInventory(Inventory internalEquipment) {
- }
-
- @Override
- public void updateNetworkConnectionDeviceType(NetworkElementConnectionEntity networkElementConnectionEntitiy,
- String nodeId) {
- }
-
- @Override
- public void updateNetworkConnection22(NetworkElementConnectionEntity networkElementConnectionEntitiy,
- String nodeId) {
- }
-
- @Override
- public void removeNetworkConnection(String nodeId) {
- }
-
- @Override
- public int doIndexClean(Date olderAreOutdated) {
- return 0;
- }
-
- @Override
- public int getNumberOfOldObjects(Date olderAreOutdated) {
- return 0;
- }
-
- @Override
- public List<NetworkElementConnectionEntity> getNetworkElementConnections() {
- return new ArrayList<>();
- }
-
- @Override
- public void doWritePerformanceData(List<PmdataEntity> list) {
- }
-}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointMock.java
deleted file mode 100644
index 73d32e418..000000000
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointMock.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START=======================================================
- * ONAP : ccsdk feature sdnr wt sdnr-wt-devicemanager-provider
- * ================================================================================
- * 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.test.mock;
-
-import java.util.Optional;
-import org.opendaylight.mdsal.binding.api.BindingService;
-import org.opendaylight.mdsal.binding.api.MountPoint;
-import org.opendaylight.mdsal.binding.api.NotificationService;
-import org.opendaylight.mdsal.binding.api.ReadTransaction;
-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.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.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * @author herbert
- *
- */
-@SuppressWarnings("deprecation")
-public class MountPointMock implements MountPoint {
-
- private boolean databrokerAbsent = true;
- private final DataBrokerMountpointMock dataBroker = new DataBrokerMountpointMock();
- private final RpcConsumerRegistryMock rpcConsumerRegistry = new RpcConsumerRegistryMock();
- private NotificationService setReadOnlyTransaction;
-
- private static final InstanceIdentifier<Topology> NETCONF_TOPO_IID =
- InstanceIdentifier.create(NetworkTopology.class).child(Topology.class,
- new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName())));
-
- @Override
- public InstanceIdentifier<?> getIdentifier() {
- return NETCONF_TOPO_IID;
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public <T extends BindingService> Optional<T> getService(Class<T> service) {
-
- System.out.println("Requested mountpoint service: "+service.getSimpleName()+" databrokerAbsent state: "+databrokerAbsent);
-
- Optional<?> res;
- if (service.isInstance(dataBroker)) {
- System.out.println("Delivering databroker");
- res = databrokerAbsent ? Optional.empty() : Optional.of(dataBroker);
- } else if (service.isInstance(rpcConsumerRegistry)) {
- System.out.println("Delivering RpcConsumerRegistryMock");
- res = Optional.of(rpcConsumerRegistry);
- } else if (service.isInstance(setReadOnlyTransaction)) {
- System.out.println("Delivering notificationService");
- res = Optional.of(setReadOnlyTransaction);
- } else {
- System.out.println("Delivering no service");
- res = Optional.empty();
- }
- return (Optional<T>)res;
- }
-
- public void setDatabrokerAbsent( boolean state) {
- this.databrokerAbsent = state;
- }
-
- public <T extends NotificationService&ReadTransaction>void setReadOnlyTransaction(T readOnlyTransaction) {
- this.setReadOnlyTransaction = readOnlyTransaction;
- dataBroker.setReadOnlyTransaction(readOnlyTransaction);
- }
-
-
-}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointServiceMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointServiceMock.java
deleted file mode 100644
index 113ead29f..000000000
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/MountPointServiceMock.java
+++ /dev/null
@@ -1,54 +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.test.mock;
-
-import java.util.Optional;
-import org.opendaylight.mdsal.binding.api.MountPoint;
-import org.opendaylight.mdsal.binding.api.MountPointService;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
-
-/**
- * @author herbert
- *
- */
-public class MountPointServiceMock implements MountPointService {
-
- private final MountPoint mountpoint;
-
- public MountPointServiceMock(MountPoint mountpoint) {
- this.mountpoint = mountpoint;
- }
-
- @Override
- public Optional<MountPoint> getMountPoint(InstanceIdentifier<?> instanceId) {
-
- Optional<MountPoint> optional = Optional.of(mountpoint);
- return optional;
- }
-
- @Override
- public <T extends MountPointListener> ListenerRegistration<T> registerListener(InstanceIdentifier<?> path,
- T listener) {
- return null;
- }
-
-}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NetconfNodeStateServiceMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NetconfNodeStateServiceMock.java
deleted file mode 100644
index 5a000a52a..000000000
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NetconfNodeStateServiceMock.java
+++ /dev/null
@@ -1,71 +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.test.mock;
-
-import org.eclipse.jdt.annotation.NonNull;
-import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeConnectListener;
-import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateListener;
-import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.NetconfNodeStateService;
-import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.VesNotificationListener;
-import org.opendaylight.yangtools.concepts.ListenerRegistration;
-
-/**
- * @author herbert
- *
- */
-public class NetconfNodeStateServiceMock implements NetconfNodeStateService {
-
- Object object = new Object();
- private final ListenerRegistration<? extends NetconfNodeConnectListener> lr = new ListenerRegistration() {
-
- @Override
- public @NonNull Object getInstance() {
- return object;
- }
-
- @Override
- public void close() {
- }
-
- };
-
-
- @Override
- public void close() {
- }
-
- @Override
- public <L extends NetconfNodeConnectListener> @NonNull ListenerRegistration<L> registerNetconfNodeConnectListener(
- @NonNull L netconfNodeConnectListener) {
- return (ListenerRegistration<L>) lr;
- }
-
- @Override
- public <L extends NetconfNodeStateListener> @NonNull ListenerRegistration<L> registerNetconfNodeStateListener(
- @NonNull L netconfNodeStateListener) {
- return (ListenerRegistration<L>) lr;
- }
-
- @Override
- public <L extends VesNotificationListener> @NonNull ListenerRegistration<L> registerVesNotifications(
- @NonNull L netconfNodeStateListener) {
- return (ListenerRegistration<L>) lr;
- }
-
-
-}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NotificationPublishServiceMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NotificationPublishServiceMock.java
deleted file mode 100644
index fc3318b9e..000000000
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/NotificationPublishServiceMock.java
+++ /dev/null
@@ -1,49 +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.test.mock;
-
-import com.google.common.util.concurrent.ListenableFuture;
-import java.util.concurrent.TimeUnit;
-import org.opendaylight.mdsal.binding.api.NotificationPublishService;
-import org.opendaylight.yangtools.yang.binding.Notification;
-
-/**
- * @author herbert
- *
- */
-public class NotificationPublishServiceMock implements NotificationPublishService {
-
- @Override
- public ListenableFuture<?> offerNotification(Notification notification) {
- return null;
- }
-
- @Override
- public ListenableFuture<?> offerNotification(Notification notification, int timeout, TimeUnit unit)
- throws InterruptedException {
- return null;
- }
-
- @Override
- public void putNotification(Notification notification) throws InterruptedException {
- }
-
-}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcConsumerRegistryMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcConsumerRegistryMock.java
deleted file mode 100644
index 89864c2c5..000000000
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcConsumerRegistryMock.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*******************************************************************************
- * ============LICENSE_START=======================================================
- * ONAP : ccsdk feature sdnr wt sdnr-wt-devicemanager-provider
- * ================================================================================
- * 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.test.mock;
-
-import org.opendaylight.controller.sal.binding.api.RpcConsumerRegistry;
-import org.opendaylight.yangtools.yang.binding.RpcService;
-
-/**
- * @author herbert
- *
- */
-@SuppressWarnings("deprecation")
-public class RpcConsumerRegistryMock implements RpcConsumerRegistry {
-
- @Override
- public <T extends RpcService> T getRpcService(Class<T> serviceInterface) {
- return null;
- }
-
-}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderRegistryMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderServiceMock.java
index 4aaa1ed48..6ecafea9f 100644
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderRegistryMock.java
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderServiceMock.java
@@ -22,16 +22,22 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.test.mock;
import java.util.Set;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.DevicemanagerService;
import org.opendaylight.yangtools.concepts.ObjectRegistration;
import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
import org.opendaylight.yangtools.yang.binding.RpcService;
-public class RpcProviderRegistryMock implements RpcProviderService {
+public class RpcProviderServiceMock implements RpcProviderService {
+
+ private DevicemanagerService deviceManagerApi;
@Override
public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(Class<S> type,
T implementation) {
System.out.println("Register class "+implementation);
+ if (implementation instanceof DevicemanagerService) {
+ deviceManagerApi = (DevicemanagerService)implementation;
+ }
return null;
}
@@ -41,4 +47,8 @@ public class RpcProviderRegistryMock implements RpcProviderService {
return null;
}
+ public DevicemanagerService getDeviceManagerApiService() {
+ return deviceManagerApi;
+ }
+
}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/DBCleanServiceHelper.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/DBCleanServiceHelper.java
deleted file mode 100644
index 79688280e..000000000
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/DBCleanServiceHelper.java
+++ /dev/null
@@ -1,83 +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.test.util;
-
-import java.util.Date;
-import java.util.concurrent.TimeUnit;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.DataProvider;
-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.DeviceManagerImpl;
-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.impl.xml.ObjectCreationNotificationXml;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SourceType;
-
-public class DBCleanServiceHelper {
-
- private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStampImpl.getConverter();
-
- private final DataProvider databaseEventService;
-
- /**
- * Helper to fill data into the database
- * @param deviceManager devicemanger to get services
- */
- public DBCleanServiceHelper(DeviceManagerImpl deviceManager) {
- this.databaseEventService = deviceManager.getDatabaseClientEvents();
- }
-
- /**
- * Write data into database with specific date and content profile.
- * @param number of data to be written for each log
- * @param days starting day, relative to actual date
- * @param hours starting hour ... increased by one hour for each write
- * @return integer with the amount of written data
- */
- public int writeDataToLogs(int number, int days, int hours) {
- int res = 0;
- for (Integer t=0; t < number; t++) { //Test "sdnevents", "eventlog"
- ObjectCreationNotificationXml notificationXml = new ObjectCreationNotificationXml(
- "Testpoint"+t, t, getInternalDateAndTime(days, hours+t), "ObjectId"+t);
- databaseEventService.writeConnectionLog(notificationXml.getConnectionlogEntity());
- res++;
- }
-
- for (Integer t=0; t < number; t++) { //Test "sdnevents", "faultlog"
- ProblemNotificationXml fault = new ProblemNotificationXml(
- "ProblemNode"+t, "Problemuuid", "Problemname", InternalSeverity.Major, t, getInternalDateAndTime(days, hours+t));
- databaseEventService.writeFaultLog(fault.getFaultlog(SourceType.Unknown));
- res++;
- }
-
- return res;
- }
-
- /**************************************************************
- * Private section
- */
-
- private InternalDateAndTime getInternalDateAndTime(int days, int hours) {
- Date actual = new Date(new Date().getTime() - TimeUnit.MILLISECONDS.convert(days, TimeUnit.DAYS) - TimeUnit.MILLISECONDS.convert(hours, TimeUnit.HOURS));
- InternalDateAndTime timeStamp = InternalDateAndTime.valueOf(NETCONFTIME_CONVERTER.getTimeStamp(actual));
- return timeStamp;
- }
-
-
-}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/ZipFile.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/ZipFile.java
deleted file mode 100644
index 9a926fd64..000000000
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/ZipFile.java
+++ /dev/null
@@ -1,63 +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.test.util;
-
-import java.io.FileNotFoundException;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipOutputStream;
-
-public class ZipFile implements AutoCloseable {
-
- private final ZipOutputStream zos;
- private final FileOutputStream fos;
-
- public ZipFile(String zipPath) throws FileNotFoundException {
- fos = new FileOutputStream(zipPath);
- zos = new ZipOutputStream(fos);
- }
-
- public void addToZipFile(String fileName) throws FileNotFoundException, IOException {
-
- System.out.println("Writing '" + fileName + "' to zip file");
-
- InputStream fis = ZipFile.class.getClassLoader().getResourceAsStream(fileName);
- if (fis == null) {
- throw new FileNotFoundException("Resource not found: " + fileName);
- }
-
- ZipEntry zipEntry = new ZipEntry(fileName);
- zos.putNextEntry(zipEntry);
- byte[] bytes = new byte[1024];
- int length;
- while ((length = fis.read(bytes)) >= 0) {
- zos.write(bytes, 0, length);
- }
- zos.closeEntry();
- fis.close();
- }
-
- @Override
- public void close() throws IOException {
- zos.close();
- fos.close();
- }
-
-}
diff --git a/sdnr/wt/devicemanager/provider/src/test/resources/simplelogger.properties b/sdnr/wt/devicemanager/provider/src/test/resources/simplelogger.properties
index 9af26dc96..1c2f131c5 100644
--- a/sdnr/wt/devicemanager/provider/src/test/resources/simplelogger.properties
+++ b/sdnr/wt/devicemanager/provider/src/test/resources/simplelogger.properties
@@ -25,7 +25,7 @@
# Default logging detail level for all instances of SimpleLogger.
# Must be one of ("trace", "debug", "info", "warn", or "error").
# If not specified, defaults to "info".
-org.slf4j.simpleLogger.defaultLogLevel=info
+org.slf4j.simpleLogger.defaultLogLevel=debug
# Logging detail level for a SimpleLogger instance named "xxx.yyy.zzz".
# Must be one of ("trace", "debug", "info", "warn", or "error").