summaryrefslogtreecommitdiffstats
path: root/sdnr/wt
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/wt')
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/DatabaseDataProvider.java8
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/SqlDBConfig.java10
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/HtUserdataManagerBase.java126
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/HtUserdataManagerImpl.java142
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/SqlDBDataProvider.java43
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/Userdata.java135
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/UserdataBuilder.java207
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/entity/DatabaseIdGenerator.java8
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/entity/HtDatabaseEventsService.java14
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriterUserdata.java37
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/SelectQuery.java36
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/filters/DBKeyValuePair.java11
-rw-r--r--sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/filters/RangeSqlDBFilter.java12
-rw-r--r--sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestConfig.java133
-rw-r--r--sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestMariaDataProvider.java49
-rw-r--r--sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestObjectIds.java7
-rw-r--r--sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestQuerySyntax.java39
-rw-r--r--sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/util/MariaDBTestBase.java4
-rw-r--r--sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/DataProvider.java5
-rw-r--r--sdnr/wt/data-provider/model/src/main/yang/data-provider@2020-11-10.yang139
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/FaultEntityManager.java12
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseEventsService.java39
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/ElasticSearchDataProvider.java32
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/HtUserdataManagerImpl.java102
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java2
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java4
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFileProvider.java45
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFilename.java2
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangSchemaHttpServlet.java10
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java20
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java133
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java62
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestUserdata.java11
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java11
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/MariaDBTestBase.java4
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java3
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentName.java4
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DatabaseInfo7.java4
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java7
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ReleaseGroup.java5
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/database/MariaDbDataMigrationProvider.java5
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/istanbul/IstanbulReleaseInformation.java34
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/jakarta/JakartaReleaseInformation.java123
-rw-r--r--sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/MariaDBTestBase.java4
-rw-r--r--sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestBaseReleaseInformation.java34
-rw-r--r--sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestHonoluluReleaseInformation.java34
-rw-r--r--sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestJakartaReleaseInformation.java46
-rw-r--r--sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMariaDBJakarta.java (renamed from sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMariaDBIstanbul.java)4
-rw-r--r--sdnr/wt/devicemanager-core/model/src/main/yang/devicemanager.yang11
-rw-r--r--sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/config/AaiClientPropertiesFile.java31
-rw-r--r--sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/ODLEventListenerHandler.java16
-rw-r--r--sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/RpcPushNotificationsHandler.java15
-rw-r--r--sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ConnectionStatusHousekeepingService.java20
-rw-r--r--sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java21
-rw-r--r--sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/PushNotifications.java5
-rw-r--r--sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/FaultEntityManager.java17
-rw-r--r--sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java9
-rw-r--r--sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java5
-rw-r--r--sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevMgrPropertiesFile.java1
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/CMBasicHeaderFieldsNotification.java100
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/CMNotification.java113
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/CMNotificationClient.java81
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPCMVESMsgConsumer.java95
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java3
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerMain.java377
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestCMBasicHeaderFieldsNotification.java45
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestCMNotificationBuilder.java79
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestCMNotificationClient.java70
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPCMVESMsgConsumer.java157
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_invalid_type.json49
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_moi_attribute_value_changes.json45
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_moi_creation.json42
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_moi_deletion.json42
-rw-r--r--sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_valid_two_element_moi_changes_array.json61
74 files changed, 2959 insertions, 512 deletions
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/DatabaseDataProvider.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/DatabaseDataProvider.java
index 9d4beb71b..20b86e661 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/DatabaseDataProvider.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/DatabaseDataProvider.java
@@ -5,6 +5,8 @@
* Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
* All rights reserved.
* ================================================================================
+ * Update Copyright (C) 2021 Samsung Electronics 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
@@ -27,6 +29,7 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
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.HtDatabaseMediatorserver;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtUserdataManager;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMediatorServerInput;
@@ -40,6 +43,7 @@ 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.rev201110.DeleteNetworkElementConnectionOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EntityInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadCmlogListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadConnectionlogListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadEventlogListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadFaultcurrentListOutputBuilder;
@@ -72,6 +76,8 @@ public interface DatabaseDataProvider {
ReadFaultlogListOutputBuilder readFaultLogList(EntityInput input);
+ ReadCmlogListOutputBuilder readCMLogList(EntityInput input);
+
ReadMaintenanceListOutputBuilder readMaintenanceList(EntityInput input);
ReadMediatorServerListOutputBuilder readMediatorServerList(EntityInput input);
@@ -129,4 +135,6 @@ public interface DatabaseDataProvider {
HtDatabaseMediatorserver getHtDatabaseMediatorServer();
+ HtUserdataManager getUserManager();
+
}
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/SqlDBConfig.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/SqlDBConfig.java
index 8c7e7b1cb..ecf5f4e4a 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/SqlDBConfig.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/SqlDBConfig.java
@@ -39,8 +39,8 @@ public class SqlDBConfig implements Configuration {
private static final String DEFAULT_VALUE_DBURL = "${SDNRDBURL}";
private static final String DEFAULT_VALUE_DBUSERNAME = "${SDNRDBUSERNAME}";
private static final String DEFAULT_VALUE_DBPASSWORD = "${SDNRDBPASSWORD}";
- private static final String DEFAULT_VALUE_CONTROLLERID = DatabaseIdGenerator.getControllerId();
- private static final String DEFAULT_VALUE_DBSUFFIX = "-v6";
+ private static final String DEFAULT_VALUE_CONTROLLERID = "${SDNRCONTROLLERID}";
+ private static final String DEFAULT_VALUE_DBSUFFIX = "-v7";
private final ConfigurationFileRepresentation configuration;
@@ -99,6 +99,12 @@ public class SqlDBConfig implements Configuration {
DEFAULT_VALUE_CONTROLLERID);
configuration.setPropertyIfNotAvailable(SECTION_MARKER_MARIADB, PROPERTY_KEY_DBSUFFIX, DEFAULT_VALUE_DBSUFFIX);
+ String v = this.configuration.getProperty(SECTION_MARKER_MARIADB, PROPERTY_KEY_CONTROLLERID);
+ // if is set to "null" then it is valid, otherwise if not set or env is empty generate one
+ if (!"null".equals(v) && (v == null || v.isEmpty())) {
+ this.setControllerId(DatabaseIdGenerator.getControllerId());
+ }
+
}
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/HtUserdataManagerBase.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/HtUserdataManagerBase.java
new file mode 100644
index 000000000..60f28d95c
--- /dev/null
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/HtUserdataManagerBase.java
@@ -0,0 +1,126 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
+ * All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.file.Files;
+import org.json.JSONException;
+import org.json.JSONObject;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtUserdataManager;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public abstract class HtUserdataManagerBase implements HtUserdataManager {
+
+ private static final Logger LOG = LoggerFactory.getLogger(HtUserdataManagerBase.class);
+
+ private static final String USERDATA_DEFAULTS_FILENAME = "etc/userdata-defaults.json";
+ private static final JSONObject USERDATA_DEFAULTS_CONTENT = loadDefaults();
+
+ protected static JSONObject loadDefaults() {
+ File f = new File(USERDATA_DEFAULTS_FILENAME);
+ String content;
+ JSONObject o = null;
+ if (f.exists()) {
+ try {
+ content = Files.readString(f.toPath());
+ o = new JSONObject(content);
+ } catch (IOException e) {
+ LOG.warn("problem loading defaults: ", e);
+ } catch (JSONException e) {
+ LOG.warn("problem parsing defaults: ", e);
+ }
+ }
+ return o;
+ }
+
+ protected abstract String readUserdata(String username, String defaultValue);
+
+ @Override
+ public String getUserdata(String username) {
+ String json = this.readUserdata(username, "{}");
+ if (USERDATA_DEFAULTS_CONTENT != null) {
+ JSONObject merge = mergeData(new JSONObject(json), USERDATA_DEFAULTS_CONTENT);
+ json = merge.toString();
+ }
+ return json;
+ }
+
+ @Override
+ public String getUserdata(String username, String key) {
+ JSONObject o = new JSONObject(this.getUserdata(username));
+ return o.has(key) ? o.get(key).toString() : "{}";
+ }
+
+ @Override
+ public boolean setUserdata(String username, String key, String data) {
+ JSONObject o = new JSONObject();
+ o.put(key, new JSONObject(data));
+ return this.setUserdata(username, o.toString());
+ }
+
+ @Override
+ public boolean removeUserdata(String username, String key) {
+ JSONObject o = new JSONObject(this.getUserdata(username));
+ if (o.has(key)) {
+ o.remove(key);
+ return this.setUserdata(username, o.toString());
+ }
+ return true;
+ }
+
+ protected static JSONObject mergeData(JSONObject o, String key, JSONObject subObject) {
+ if (!o.has(key)) {
+ o.put(key, subObject);
+ } else {
+ JSONObject tmp = new JSONObject();
+ tmp.put(key, subObject);
+ o = mergeData(tmp, o);
+ }
+ return o;
+ }
+
+ protected static JSONObject mergeData(JSONObject source, JSONObject target) throws JSONException {
+ String[] keys = JSONObject.getNames(source);
+ if (keys == null) {
+ return target;
+ }
+ for (String key : keys) {
+ Object value = source.get(key);
+ if (!target.has(key)) {
+ // new value for "key":
+ target.put(key, value);
+ } else {
+ // existing value for "key" - recursively deep merge:
+ if (value instanceof JSONObject) {
+ JSONObject valueJson = (JSONObject) value;
+ mergeData(valueJson, target.getJSONObject(key));
+ } else {
+ target.put(key, value);
+ }
+ }
+ }
+ return target;
+ }
+
+}
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/HtUserdataManagerImpl.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/HtUserdataManagerImpl.java
index 9dd1adb50..79d963751 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/HtUserdataManagerImpl.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/HtUserdataManagerImpl.java
@@ -21,130 +21,48 @@
*/
package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data;
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import org.json.JSONException;
-import org.json.JSONObject;
-import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
-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.QueryBuilders;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtUserdataManager;
-import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class HtUserdataManagerImpl implements HtUserdataManager {
-
- private static final Logger LOG = LoggerFactory.getLogger(HtUserdataManagerImpl.class);
-
- private static final String USERDATA_DEFAULTS_FILENAME = "etc/userdata-defaults.json";
- private static final JSONObject USERDATA_DEFAULTS_CONTENT = loadDefaults();
-
- private static JSONObject loadDefaults() {
- File f = new File(USERDATA_DEFAULTS_FILENAME);
- String content;
- JSONObject o = null;
- if (f.exists()) {
- try {
- content = Files.readString(f.toPath());
- o = new JSONObject(content);
- } catch (IOException e) {
- LOG.warn("problem loading defaults: ", e);
- } catch (JSONException e) {
- LOG.warn("problem parsing defaults: ", e);
- }
- }
- return o;
- }
-
-
- private final HtDatabaseClient dbClient;
-
- public HtUserdataManagerImpl(HtDatabaseClient rawClient) {
- this.dbClient = rawClient;
- }
-
- @Override
- public String getUserdata(String username) {
- SearchResult<SearchHit> result = this.dbClient.doReadByQueryJsonData(Entity.Userdata.getName(),
- QueryBuilders.matchQuery("_id", username));
- String json = result.getHits().size() > 0 ? result.getHits().get(0).getSourceAsString() : "{}";
- if (USERDATA_DEFAULTS_CONTENT != null) {
- JSONObject merge = mergeData(new JSONObject(json), USERDATA_DEFAULTS_CONTENT);
- json = merge.toString();
- }
- return json;
- }
-
- @Override
- public String getUserdata(String username, String key) {
- JSONObject o = new JSONObject(this.getUserdata(username));
- return o.has(key) ? o.get(key).toString() : "{}";
+import java.util.Arrays;
+import java.util.List;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.rpctypehelper.QueryResult;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database.SqlDBReaderWriterUserdata;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EntityInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadFaultcurrentListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.FilterBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.PaginationBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
+
+public class HtUserdataManagerImpl extends HtUserdataManagerBase {
+
+ private final SqlDBReaderWriterUserdata rw;
+
+ public HtUserdataManagerImpl(SqlDBReaderWriterUserdata rw) {
+ this.rw = rw;
}
@Override
public boolean setUserdata(String username, String data) {
- JSONObject o = new JSONObject(this.getUserdata(username));
- JSONObject merge = mergeData(o, new JSONObject(data));
- return this.dbClient.doWriteRaw(Entity.Userdata.getName(), username, merge.toString()) != null;
- }
-
- @Override
- public boolean setUserdata(String username, String key, String data) {
- JSONObject o = new JSONObject(this.getUserdata(username));
- o = mergeData(o, key, new JSONObject(data));
- return this.dbClient.doWriteRaw(Entity.Userdata.getName(), username, o.toString()) != null;
+ return this.rw.write(new UserdataBuilder().setId(username).setValue(data).build(), username) != null;
}
@Override
public boolean removeUserdata(String username) {
- return this.dbClient.doRemove(Entity.Userdata.getName(), username);
+ return this.rw.remove(username) > 0;
}
@Override
- public boolean removeUserdata(String username, String key) {
- JSONObject o = new JSONObject(this.getUserdata(username));
- if (o.has(key)) {
- o.remove(key);
- return this.setUserdata(username, o.toString());
- }
- return true;
- }
-
- private static JSONObject mergeData(JSONObject o, String key, JSONObject subObject) {
- if (!o.has(key)) {
- o.put(key, subObject);
- } else {
- JSONObject tmp = new JSONObject();
- tmp.put(key, subObject);
- o = mergeData(tmp, o);
- }
- return o;
- }
-
- private static JSONObject mergeData(JSONObject source, JSONObject target) throws JSONException {
- String[] keys = JSONObject.getNames(source);
- if (keys == null) {
- return target;
- }
- for (String key : keys) {
- Object value = source.get(key);
- if (!target.has(key)) {
- // new value for "key":
- target.put(key, value);
- } else {
- // existing value for "key" - recursively deep merge:
- if (value instanceof JSONObject) {
- JSONObject valueJson = (JSONObject) value;
- mergeData(valueJson, target.getJSONObject(key));
- } else {
- target.put(key, value);
- }
- }
+ protected String readUserdata(String username, String defaultValue) {
+ EntityInput input = new ReadFaultcurrentListInputBuilder()
+ .setFilter(Arrays.asList(new FilterBuilder().setProperty("id").setFiltervalue(username).build()))
+ .setPagination(new PaginationBuilder().setPage(Uint64.valueOf(1)).setSize(Uint32.valueOf(1)).build())
+ .build();
+ QueryResult<Userdata> result = this.rw.getData(input);
+ if (result != null) {
+ List<Userdata> data = result.getResult();
+ Userdata user = (data != null && !data.isEmpty()) ? data.get(0) : null;
+ return user == null ? defaultValue : user.getValue();
}
- return target;
+ return defaultValue;
}
}
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/SqlDBDataProvider.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/SqlDBDataProvider.java
index 4165c85a0..b6df73b89 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/SqlDBDataProvider.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/SqlDBDataProvider.java
@@ -5,6 +5,8 @@
* Copyright (C) 2021 highstreet technologies GmbH Intellectual Property.
* All rights reserved.
* ================================================================================
+ * Update Copyright (C) 2021 Samsung Electronics 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
@@ -33,11 +35,13 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.entity.H
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.entity.HtDatabaseMaintenanceService;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.rpctypehelper.QueryResult;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database.SqlDBReaderWriter;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database.SqlDBReaderWriterUserdata;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database.SqlDBStatusReader;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.query.DeleteQuery;
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.HtDatabaseMediatorserver;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtUserdataManager;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMediatorServerInput;
@@ -54,6 +58,7 @@ 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.rev201110.MaintenanceEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.MediatorServerEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadCmlogListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadConnectionlogListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadEventlogListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadFaultcurrentListOutputBuilder;
@@ -95,6 +100,8 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa
private final SqlDBReaderWriter<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.mediator.server.list.output.Data> mediatorserverRW;
private final SqlDBReaderWriter<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.maintenance.list.output.Data> maintenanceRW;
private final SqlDBStatusReader readStatus;
+ private final HtUserdataManager usermanager;
+
public SqlDBReaderWriter<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.maintenance.list.output.Data> getMaintenanceReaderWriter() {
return this.maintenanceRW;
@@ -107,6 +114,7 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa
public SqlDBDataProvider(SqlDBConfig config) {
this(config, true);
}
+
public SqlDBDataProvider(SqlDBConfig config, boolean initControllerId) {
super(config);
@@ -128,7 +136,9 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa
}
};
this.dbMaintenanceService = new HtDatabaseMaintenanceService(this);
- if(initControllerId) {
+ this.usermanager = new HtUserdataManagerImpl(new SqlDBReaderWriterUserdata(this.dbClient,
+ Entity.Userdata, config.getDbSuffix(), this.dbClient.getDatabaseName(), this.controllerId));
+ if (initControllerId) {
try {
this.setControllerId();
} catch (SQLException e) {
@@ -169,6 +179,19 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa
}
@Override
+ public ReadCmlogListOutputBuilder readCMLogList(EntityInput input) {
+ ReadCmlogListOutputBuilder outputBuilder = new ReadCmlogListOutputBuilder();
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.cmlog.list.output.Data>
+ result =
+ this.eventRWCMLog.getData(input);
+ outputBuilder.setData(result.getResult());
+ outputBuilder.setPagination(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.cmlog.list.output.PaginationBuilder(
+ result.getPagination()).build());
+ return outputBuilder;
+ }
+
+ @Override
public ReadMaintenanceListOutputBuilder readMaintenanceList(EntityInput input) {
ReadMaintenanceListOutputBuilder outputBuilder = new ReadMaintenanceListOutputBuilder();
QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.maintenance.list.output.Data> result =
@@ -480,18 +503,17 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa
return true;
}
LOG.info("set controllerId {}", this.controllerId);
- String query = String.format("SELECT * FROM `%s` WHERE `id`='%s';", this.controllerTableName,
- this.controllerId);
+ String query =
+ String.format("SELECT * FROM `%s` WHERE `id`='%s';", this.controllerTableName, this.controllerId);
LOG.trace(query);
ResultSet data = this.dbClient.read(query);
- if (!data.next()) {
- query = String.format("INSERT INTO `%s` (`id`,`desc`) VALUES ('%s','%s')",
- this.controllerTableName, this.controllerId, "");
+ if (data == null || !data.next()) {
+ query = String.format("INSERT INTO `%s` (`id`,`desc`) VALUES ('%s','%s')", this.controllerTableName,
+ this.controllerId, "");
LOG.trace(query);
return this.dbClient.write(query);
- }
- else {
+ } else {
LOG.trace("controllerId already set");
}
return true;
@@ -505,5 +527,10 @@ public class SqlDBDataProvider extends HtDatabaseEventsService implements Databa
return this.controllerId;
}
+ @Override
+ public HtUserdataManager getUserManager() {
+ return this.usermanager;
+ }
+
}
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/Userdata.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/Userdata.java
new file mode 100644
index 000000000..658b112bd
--- /dev/null
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/Userdata.java
@@ -0,0 +1,135 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
+ * All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data;
+
+import com.google.common.base.MoreObjects;
+import java.util.Objects;
+import javax.annotation.processing.Generated;
+import org.opendaylight.yangtools.yang.binding.Augmentable;
+import org.opendaylight.yangtools.yang.binding.CodeHelpers;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
+/**
+ *
+ * <p>
+ * This class represents the following YANG schema fragment defined in module <b>data-provider</b>
+ *
+ * <pre>
+ * container userdata {
+ * leaf id {
+ * type string;
+ * }
+ * leaf value {
+ * type string;
+ * }
+ * }
+ * </pre>
+ *
+ * The schema path to identify an instance is <i>data-provider/userdata</i>
+ *
+ * <p>
+ * To create instances of this class use {@link UserdataBuilder}.
+ *
+ * @see UserdataBuilder
+ *
+ */
+@Generated("mdsal-binding-generator")
+public interface Userdata extends Augmentable<Userdata>, DataObject {
+
+ /**
+ * Default implementation of {@link Object#hashCode()} contract for this interface. Implementations of this
+ * interface are encouraged to defer to this method to get consistent hashing results across all implementations.
+ *
+ * @param obj Object for which to generate hashCode() result.
+ * @return Hash code value of data modeled by this interface.
+ * @throws NullPointerException if {@code obj} is null
+ */
+ static int bindingHashCode(final Userdata obj) {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + Objects.hashCode(obj.getId());
+ result = prime * result + Objects.hashCode(obj.getValue());
+ result = prime * result + obj.augmentations().hashCode();
+ return result;
+ }
+
+ /**
+ * Default implementation of {@link Object#equals(Object)} contract for this interface. Implementations of this
+ * interface are encouraged to defer to this method to get consistent equality results across all implementations.
+ *
+ * @param thisObj Object acting as the receiver of equals invocation
+ * @param obj Object acting as argument to equals invocation
+ * @return True if thisObj and obj are considered equal
+ * @throws NullPointerException if {@code thisObj} is null
+ */
+ static boolean bindingEquals(final Userdata thisObj, final Object obj) {
+ if (thisObj == obj) {
+ return true;
+ }
+ final Userdata other = CodeHelpers.checkCast(Userdata.class, obj);
+ if (other == null) {
+ return false;
+ }
+ if (!Objects.equals(thisObj.getId(), other.getId())) {
+ return false;
+ }
+ if (!Objects.equals(thisObj.getValue(), other.getValue())) {
+ return false;
+ }
+ return thisObj.augmentations().equals(other.augmentations());
+ }
+
+ /**
+ * Default implementation of {@link Object#toString()} contract for this interface. Implementations of this
+ * interface are encouraged to defer to this method to get consistent string representations across all
+ * implementations.
+ *
+ * @param obj Object for which to generate toString() result.
+ * @return {@link String} value of data modeled by this interface.
+ * @throws NullPointerException if {@code obj} is null
+ */
+ static String bindingToString(final Userdata obj) {
+ final MoreObjects.ToStringHelper helper = MoreObjects.toStringHelper("Userdata");
+ CodeHelpers.appendValue(helper, "id", obj.getId());
+ CodeHelpers.appendValue(helper, "value", obj.getValue());
+ CodeHelpers.appendValue(helper, "augmentation", obj.augmentations().values());
+ return helper.toString();
+ }
+
+ /**
+ * Return id, or {@code null} if it is not present.
+ *
+ * @return {@code java.lang.String} id, or {@code null} if it is not present.
+ *
+ */
+ String getId();
+
+ /**
+ * Return value, or {@code null} if it is not present.
+ *
+ * @return {@code java.lang.String} value, or {@code null} if it is not present.
+ *
+ */
+ String getValue();
+
+}
+
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/UserdataBuilder.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/UserdataBuilder.java
new file mode 100644
index 000000000..bb1268cc9
--- /dev/null
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/UserdataBuilder.java
@@ -0,0 +1,207 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
+ * All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data;
+
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Objects;
+import javax.annotation.processing.Generated;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.yang.binding.AbstractAugmentable;
+import org.opendaylight.yangtools.yang.binding.Augmentation;
+import org.opendaylight.yangtools.yang.binding.DataObject;
+
+/**
+ * Class that builds {@link UserdataBuilder} instances. Overall design of the class is that of a
+ * <a href="https://en.wikipedia.org/wiki/Fluent_interface">fluent interface</a>, where method chaining is used.
+ *
+ * <p>
+ * In general, this class is supposed to be used like this template:
+ *
+ * <pre>
+ * <code>
+ * UserdataBuilder createTarget(int fooXyzzy, int barBaz) {
+ * return new UserdataBuilderBuilder()
+ * .setFoo(new FooBuilder().setXyzzy(fooXyzzy).build())
+ * .setBar(new BarBuilder().setBaz(barBaz).build())
+ * .build();
+ * }
+ * </code>
+ * </pre>
+ *
+ * <p>
+ * This pattern is supported by the immutable nature of UserdataBuilder, as instances can be freely passed around
+ * without worrying about synchronization issues.
+ *
+ * <p>
+ * As a side note: method chaining results in:
+ * <ul>
+ * <li>very efficient Java bytecode, as the method invocation result, in this case the Builder reference, is on the
+ * stack, so further method invocations just need to fill method arguments for the next method invocation, which is
+ * terminated by {@link #build()}, which is then returned from the method</li>
+ * <li>better understanding by humans, as the scope of mutable state (the builder) is kept to a minimum and is very
+ * localized</li>
+ * <li>better optimization oportunities, as the object scope is minimized in terms of invocation (rather than method)
+ * stack, making <a href="https://en.wikipedia.org/wiki/Escape_analysis">escape analysis</a> a lot easier. Given enough
+ * compiler (JIT/AOT) prowess, the cost of th builder object can be completely eliminated</li>
+ * </ul>
+ *
+ * @see UserdataBuilder
+ * @see Builder
+ *
+ */
+@Generated("mdsal-binding-generator")
+public class UserdataBuilder implements Builder<Userdata> {
+
+ private String _id;
+ private String _value;
+
+
+ Map<Class<? extends Augmentation<Userdata>>, Augmentation<Userdata>> augmentation = Collections.emptyMap();
+
+ public UserdataBuilder() {}
+
+
+
+ public UserdataBuilder(Userdata base) {
+ Map<Class<? extends Augmentation<Userdata>>, Augmentation<Userdata>> aug = base.augmentations();
+ if (!aug.isEmpty()) {
+ this.augmentation = new HashMap<>(aug);
+ }
+ this._id = base.getId();
+ this._value = base.getValue();
+ }
+
+
+ public String getId() {
+ return _id;
+ }
+
+ public String getValue() {
+ return _value;
+ }
+
+ @SuppressWarnings({"unchecked", "checkstyle:methodTypeParameterName"})
+ public <E$$ extends Augmentation<Userdata>> E$$ augmentation(Class<E$$> augmentationType) {
+ return (E$$) augmentation.get(Objects.requireNonNull(augmentationType));
+ }
+
+
+ public UserdataBuilder setId(final String value) {
+ this._id = value;
+ return this;
+ }
+
+ public UserdataBuilder setValue(final String value) {
+ this._value = value;
+ return this;
+ }
+
+ /**
+ * Add an augmentation to this builder's product.
+ *
+ * @param augmentation augmentation to be added
+ * @return this builder
+ * @throws NullPointerException if {@code augmentation} is null
+ */
+ public UserdataBuilder addAugmentation(Augmentation<Userdata> augmentation) {
+ Class<? extends Augmentation<Userdata>> augmentationType = augmentation.implementedInterface();
+ if (!(this.augmentation instanceof HashMap)) {
+ this.augmentation = new HashMap<>();
+ }
+
+ this.augmentation.put(augmentationType, augmentation);
+ return this;
+ }
+
+ /**
+ * Remove an augmentation from this builder's product. If this builder does not track such an augmentation type,
+ * this method does nothing.
+ *
+ * @param augmentationType augmentation type to be removed
+ * @return this builder
+ */
+ public UserdataBuilder removeAugmentation(Class<? extends Augmentation<Userdata>> augmentationType) {
+ if (this.augmentation instanceof HashMap) {
+ this.augmentation.remove(augmentationType);
+ }
+ return this;
+ }
+
+ @Override
+ public Userdata build() {
+ return new UserdataImpl(this);
+ }
+
+ private static final class UserdataImpl extends AbstractAugmentable<Userdata> implements Userdata {
+
+ private final String _id;
+ private final String _value;
+
+ UserdataImpl(UserdataBuilder base) {
+ super(base.augmentation);
+ this._id = base.getId();
+ this._value = base.getValue();
+ }
+
+ @Override
+ public String getId() {
+ return _id;
+ }
+
+ @Override
+ public String getValue() {
+ return _value;
+ }
+
+ private int hash = 0;
+ private volatile boolean hashValid = false;
+
+ @Override
+ public int hashCode() {
+ if (hashValid) {
+ return hash;
+ }
+
+ final int result = Userdata.bindingHashCode(this);
+ hash = result;
+ hashValid = true;
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return Userdata.bindingEquals(this, obj);
+ }
+
+ @Override
+ public String toString() {
+ return Userdata.bindingToString(this);
+ }
+
+ @Override
+ public Class<? extends DataObject> implementedInterface() {
+ return Userdata.class;
+ }
+ }
+}
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/entity/DatabaseIdGenerator.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/entity/DatabaseIdGenerator.java
index 2b07dfae2..6244894e5 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/entity/DatabaseIdGenerator.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/entity/DatabaseIdGenerator.java
@@ -60,7 +60,7 @@ public class DatabaseIdGenerator {
return UUID.randomUUID().toString();
}
- public static String getFaultcurrentId(String nodeId, String objectId, String problemName) {
+ public static String extractUuid(String objectId) {
String uuId;
Matcher matcher = FAULTPATTERN.matcher(objectId);
@@ -69,6 +69,12 @@ public class DatabaseIdGenerator {
} else {
uuId = objectId;
}
+ return uuId;
+ }
+
+ public static String getFaultcurrentId(String nodeId, String objectId, String problemName) {
+ String uuId = extractUuid(objectId);
+
return String.format(FORMAT_FAULTDATA_ID, nodeId, uuId, problemName);
}
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/entity/HtDatabaseEventsService.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/entity/HtDatabaseEventsService.java
index 84786b0cd..88aaa583d 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/entity/HtDatabaseEventsService.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/data/entity/HtDatabaseEventsService.java
@@ -5,6 +5,8 @@
* Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
* All rights reserved.
* ================================================================================
+ * Update Copyright (C) 2021 Samsung Electronics 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
@@ -37,6 +39,7 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database.SqlD
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.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmlogEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionlogEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogEntity;
@@ -73,6 +76,7 @@ public class HtDatabaseEventsService implements DataProvider {
protected final SqlDBReaderWriter<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.network.element.connection.list.output.Data> networkelementConnectionRW;
protected final SqlDBReaderWriterPm<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._15m.list.output.Data> pm15mRW;
protected final SqlDBReaderWriterPm<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._24h.list.output.Data> pm24hRW;
+ protected final SqlDBReaderWriter<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.cmlog.list.output.Data> eventRWCMLog;
protected final String controllerTableName;
public HtDatabaseEventsService(SqlDBConfig config) {
@@ -117,6 +121,10 @@ public class HtDatabaseEventsService implements DataProvider {
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.pmdata._24h.list.output.Data.class,
this.dbClient.getDatabaseName(), this.controllerId);
+ this.eventRWCMLog = new SqlDBReaderWriter<>(dbClient, Entity.Cmlog, config.getDbSuffix(),
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.cmlog.list.output.Data.class,
+ this.dbClient.getDatabaseName(), this.controllerId);
+
}
@Override
@@ -136,6 +144,11 @@ public class HtDatabaseEventsService implements DataProvider {
}
@Override
+ public void writeCMLog(CmlogEntity cm) {
+ this.eventRWCMLog.write(cm, cm.getId());
+ }
+
+ @Override
public void updateFaultCurrent(FaultcurrentEntity fault) {
final String id = fault.getId() != null ? fault.getId() : DatabaseIdGenerator.getFaultcurrentId(fault);
if (FaultEntityManager.isManagedAsCurrentProblem(fault)) {
@@ -220,6 +233,7 @@ public class HtDatabaseEventsService implements DataProvider {
removed += this.eventlogRW.remove(filter);
removed += this.eventRWFaultLog.remove(filter);
+ removed += this.eventRWCMLog.remove(filter);
return removed;
}
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriterUserdata.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriterUserdata.java
new file mode 100644
index 000000000..2c849ac67
--- /dev/null
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/database/SqlDBReaderWriterUserdata.java
@@ -0,0 +1,37 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
+ * All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database;
+
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.SqlDBClient;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.Userdata;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity;
+
+public class SqlDBReaderWriterUserdata extends SqlDBReaderWriter<Userdata> {
+
+ public SqlDBReaderWriterUserdata(SqlDBClient dbService, Entity e, String dbSuffix, String dbName,
+ String controllerId) {
+ super(dbService, e, dbSuffix, Userdata.class, dbName, controllerId);
+ }
+
+
+
+}
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/SelectQuery.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/SelectQuery.java
index 6afcae077..2b3f9f3fa 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/SelectQuery.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/SelectQuery.java
@@ -25,6 +25,7 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
import org.eclipse.jdt.annotation.Nullable;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database.SqlDBMapper;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EntityInput;
@@ -35,9 +36,13 @@ 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.rev201110.entity.input.Pagination;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.Sortorder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.SortorderKey;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class SelectQuery implements SqlQuery {
+ private static final Logger LOG = LoggerFactory.getLogger(SelectQuery.class);
+
private static final long DEFAULT_PAGESIZE = 20;
private static final long DEFAULT_PAGE = 1;
private final String tableName;
@@ -78,7 +83,7 @@ public class SelectQuery implements SqlQuery {
Map<FilterKey, Filter> filter = input != null ? input.getFilter() : null;
if (filter != null && filter.size() > 0) {
for (Filter f : filter.values()) {
- this.addFilter(f.getProperty(), f.getFiltervalue());
+ this.addFilter(f);
}
}
if (controllerId != null) {
@@ -101,8 +106,35 @@ public class SelectQuery implements SqlQuery {
}
public void addFilter(String property, String filtervalue) {
- this.filters.add(new FilterBuilder().setProperty(property).setFiltervalue(filtervalue).build());
+ this.addFilter(new FilterBuilder().setProperty(property).setFiltervalue(filtervalue).build());
+ }
+ private static Filter cleanFilter(Filter filter) {
+ if (filter.getFiltervalue() != null
+ && (filter.getFiltervalues() == null || filter.getFiltervalues().isEmpty())) {
+ return "*".equals(filter.getFiltervalue()) ? null : filter;
+ } else {
+ List<String> list = new ArrayList<>(filter.getFiltervalues());
+ if (filter.getFiltervalue() != null && !filter.getFiltervalue().isEmpty()) {
+ list.add(filter.getFiltervalue());
+ }
+ if (list.size() == 1 && "*".equals(list.get(0))) {
+ return null;
+ } ;
+ return new FilterBuilder().setProperty(filter.getProperty()).setFiltervalue(filter.getFiltervalue())
+ .setFiltervalues(
+ filter.getFiltervalues().stream().filter(e -> !"*".equals(e)).collect(Collectors.toList()))
+ .build();
+ }
+ }
+
+ public void addFilter(Filter filter) {
+ Filter tmp = cleanFilter(filter);
+ if (tmp == null) {
+ LOG.debug("ignore unneccessary filter for {}", filter);
+ } else {
+ this.filters.add(tmp);
+ }
}
public void addSortOrder(String col, String order) {
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/filters/DBKeyValuePair.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/filters/DBKeyValuePair.java
index 1dd9516e6..70b683a1a 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/filters/DBKeyValuePair.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/filters/DBKeyValuePair.java
@@ -52,8 +52,15 @@ public class DBKeyValuePair<T> implements SqlDBFilter {
@Override
public String getFilterExpression() {
- if (isNumericValue(this.value)) {
- return String.format("`%s`=%d", this.key, this.value);
+ // remove isNumericValue and add cast to remove sonar issue
+ if (this.getValue() instanceof Long) {
+ return String.format("`%s`=%d", this.key, (Long)this.value);
+ } else if (this.getValue() instanceof Integer) {
+ return String.format("`%s`=%d", this.key, (Integer)this.value);
+ } else if (this.getValue() instanceof Byte) {
+ return String.format("`%s`=%d", this.key, (Byte)this.value);
+ } else if (this.getValue() instanceof BigInteger) {
+ return String.format("`%s`=%d", this.key, (BigInteger)this.value);
} else {
return String.format("`%s`='%s'", this.key, this.value);
}
diff --git a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/filters/RangeSqlDBFilter.java b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/filters/RangeSqlDBFilter.java
index c4a5d8abc..83cd94964 100644
--- a/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/filters/RangeSqlDBFilter.java
+++ b/sdnr/wt/data-provider/dblib/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/sqldb/query/filters/RangeSqlDBFilter.java
@@ -21,6 +21,7 @@
*/
package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.query.filters;
+import java.math.BigInteger;
import org.eclipse.jdt.annotation.Nullable;
public class RangeSqlDBFilter extends DBKeyValuePair<Object> implements SqlDBFilter {
@@ -34,8 +35,15 @@ public class RangeSqlDBFilter extends DBKeyValuePair<Object> implements SqlDBFil
@Override
public String getFilterExpression() {
- if (isNumericValue(this.getValue())) {
- return String.format("`%s`%s%d", this.getKey(), this.comparator, this.getValue());
+ // remove isNumericValue and add cast to remove sonar issue
+ if (this.getValue() instanceof Long) {
+ return String.format("`%s`%s%d", this.getKey(), this.comparator, (Long)this.getValue());
+ } else if (this.getValue() instanceof Integer) {
+ return String.format("`%s`%s%d", this.getKey(), this.comparator, (Integer)this.getValue());
+ } else if (this.getValue() instanceof Byte) {
+ return String.format("`%s`%s%d", this.getKey(), this.comparator, (Byte)this.getValue());
+ } else if (this.getValue() instanceof BigInteger) {
+ return String.format("`%s`%s%d", this.getKey(), this.comparator, (BigInteger)this.getValue());
} else {
return String.format("`%s`%s'%s'", this.getKey(), this.comparator, this.getValue());
}
diff --git a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestConfig.java b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestConfig.java
new file mode 100644
index 000000000..676be4178
--- /dev/null
+++ b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestConfig.java
@@ -0,0 +1,133 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
+ * All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.dblib.test;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import com.google.common.io.Files;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.common.configuration.ConfigurationFileRepresentation;
+import org.onap.ccsdk.features.sdnr.wt.common.configuration.subtypes.Section;
+import org.onap.ccsdk.features.sdnr.wt.common.configuration.subtypes.Section.EnvGetter;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.SqlDBConfig;
+
+public class TestConfig {
+
+
+ private static final String TEST_CONFIG1 = "test.properties";
+ private static final String TEST_CONFIG2 = "test2.properties";
+ private static final String TEST_CONFIG3 = "test3.properties";
+ protected static final String SDNR_CONTROLLERID_ENV_VALUE = "903f3091-24f6-11ec-9cc3-0242ac130003";
+ private static final String CONTENT_CONTROLLER_NULL = "dbType=${SDNRDBTYPE}\n"
+ + "\n"
+ + "[mariadb]\n"
+ + "url=${SDNRDBURL}\n"
+ + "username=${SDNRDBUSERNAME}\n"
+ + "password=${SDNRDBPASSWORD}\n"
+ + "controllerId=null\n"
+ + "suffix=-v6";
+
+ @Test
+ public void testEnvControllerId() {
+
+ ConfigurationFileRepresentation cfg = new ConfigurationFileRepresentation(TEST_CONFIG1);
+ Section.setEnvGetter(new EnvGetter() {
+
+ @Override
+ public String getenv(String substring) {
+ if("SDNRCONTROLLERID".equals(substring)) {
+ return SDNR_CONTROLLERID_ENV_VALUE;
+ }
+ return "";
+ }
+ });
+ SqlDBConfig config = new SqlDBConfig(cfg);
+ assertEquals(SDNR_CONTROLLERID_ENV_VALUE, config.getControllerId());
+ }
+
+ @Test
+ public void testGeneratedControllerId() {
+ ConfigurationFileRepresentation cfg = new ConfigurationFileRepresentation(TEST_CONFIG2);
+ Section.setEnvGetter(new EnvGetter() {
+
+ @Override
+ public String getenv(String substring) {
+ return "";
+ }
+ });
+ SqlDBConfig config = new SqlDBConfig(cfg);
+ final String controllerId = config.getControllerId();
+ assertNotNull(controllerId);
+ assertFalse(controllerId.isBlank());
+ final String controllerId2 = config.getControllerId();
+ assertEquals(controllerId, controllerId2);
+ }
+
+ @Test
+ public void testNullControllerId() throws IOException {
+ Files.asCharSink(new File(TEST_CONFIG3), StandardCharsets.UTF_8).write(CONTENT_CONTROLLER_NULL);
+ ConfigurationFileRepresentation cfg = new ConfigurationFileRepresentation(TEST_CONFIG3);
+ Section.setEnvGetter(new EnvGetter() {
+
+ @Override
+ public String getenv(String substring) {
+ return "";
+ }
+ });
+ SqlDBConfig config = new SqlDBConfig(cfg);
+ final String controllerId = config.getControllerId();
+ assertNull(controllerId);
+ final String controllerId2 = config.getControllerId();
+ assertNull(controllerId2);
+ }
+
+ @Before
+ @After
+ public void after() throws InterruptedException, IOException {
+
+ delete(new File(TEST_CONFIG1));
+ delete(new File(TEST_CONFIG2));
+ delete(new File(TEST_CONFIG3));
+
+ }
+
+ private static void delete(File f) throws IOException {
+ if (f.isDirectory()) {
+ for (File c : f.listFiles()) {
+ delete(c);
+ }
+ }
+ if (f.exists()) {
+ if (!f.delete()) {
+ throw new FileNotFoundException("Failed to delete file: " + f);
+ }
+ }
+ }
+}
diff --git a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestMariaDataProvider.java b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestMariaDataProvider.java
index da7450089..b4e0584b0 100644
--- a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestMariaDataProvider.java
+++ b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestMariaDataProvider.java
@@ -5,6 +5,8 @@
* Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
* All rights reserved.
* ================================================================================
+ * Update Copyright (C) 2021 Samsung Electronics 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
@@ -43,6 +45,10 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.dblib.test.util.MariaDBTestB
import org.onap.ccsdk.features.sdnr.wt.yang.mapper.YangToolsMapper;
import org.opendaylight.netconf.shaded.sshd.common.util.io.IoUtils;
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.rev201110.CmNotificationType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmSourceIndicator;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmlogBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmlogEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionLogStatus;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionlogBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionlogEntity;
@@ -70,6 +76,7 @@ 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.rev201110.NetworkElementConnectionEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementDeviceType;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.PmdataEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadCmlogListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadConnectionlogListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadEventlogListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadFaultcurrentListInputBuilder;
@@ -113,6 +120,7 @@ public class TestMariaDataProvider {
private static final String URI1 = "http://localhost:8181";
private static final String URI2 = "http://localhost:8181";
private static final String URI3 = "http://localhost:8181";
+ private static final String PATH = "https://samsung.com/3GPP/simulation/network-function/ves";
private static MariaDBTestBase testBase;
private static SqlDBDataProvider dbProvider;
private static SqlDBClient dbClient;
@@ -199,6 +207,47 @@ public class TestMariaDataProvider {
}
@Test
+ public void testCMlog() {
+ ReadCmlogListOutputBuilder cmlogs = dbProvider.readCMLogList(createInput(1, 20));
+ assertEquals(0, cmlogs.getData().size());
+
+ CmlogEntity cm1 = new CmlogBuilder()
+ .setNodeId(NODEID2)
+ .setCounter(1)
+ .setTimestamp(DateAndTime.getDefaultInstance(TIME1))
+ .setObjectId("obj")
+ .setNotificationType(CmNotificationType.NotifyMOIChanges)
+ .setNotificationId("1")
+ .setSourceIndicator(CmSourceIndicator.MANAGEMENTOPERATION)
+ .setPath(PATH)
+ .setValue("pnf-registration: true")
+ .build();
+ CmlogEntity cm2 = new CmlogBuilder()
+ .setNodeId(NODEID2)
+ .setCounter(2)
+ .setTimestamp(DateAndTime.getDefaultInstance(TIME2))
+ .setObjectId("obj")
+ .setNotificationType(CmNotificationType.NotifyMOIChanges)
+ .setNotificationId("2")
+ .setSourceIndicator(CmSourceIndicator.UNKNOWN)
+ .setPath(PATH)
+ .setValue("pnf-registration: false")
+ .build();
+
+ dbProvider.writeCMLog(cm1);
+ dbProvider.writeCMLog(cm2);
+ cmlogs = dbProvider.readCMLogList(createInput("node-id", NODEID2, 1, 20));
+ assertEquals(2, cmlogs.getData().size());
+
+ List<CmlogEntity> cmLogEntityList = List.of(cm1, cm2);
+ assertEquals("node2",cmLogEntityList.get(0).getNodeId());
+ assertEquals("obj",cmLogEntityList.get(0).getObjectId());
+ assertEquals(CmNotificationType.NotifyMOIChanges,cmLogEntityList.get(0).getNotificationType());
+ assertEquals("2",cmLogEntityList.get(1).getNotificationId());
+
+ }
+
+ @Test
public void testConnectionlog() {
try {
dbClient.delete(new DeleteQuery(Entity.Connectionlog, null).toSql());
diff --git a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestObjectIds.java b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestObjectIds.java
index 7a37345f2..2316e444a 100644
--- a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestObjectIds.java
+++ b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestObjectIds.java
@@ -22,6 +22,8 @@
package org.onap.ccsdk.features.sdnr.wt.dataprovider.dblib.test;
import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+
import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.entity.DatabaseIdGenerator;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl;
@@ -49,6 +51,11 @@ public class TestObjectIds {
@Test
public void testGenerator() {
+ assertEquals(FAULTCURRENTID1, DatabaseIdGenerator.getFaultcurrentId(NODEID1, "toto[layerProtocol="+OBJECTID1+"]", PROBLEMNAME1));
+ assertEquals(FAULTCURRENTID1, DatabaseIdGenerator.getFaultcurrentId(NODEID1, "[layerProtocol="+OBJECTID1+"]", PROBLEMNAME1));
+ assertEquals(FAULTCURRENTID1, DatabaseIdGenerator.getFaultcurrentId(NODEID1, "[layerPtoto[layerProtocol="+OBJECTID1+"]", PROBLEMNAME1));
+ assertNotEquals(FAULTCURRENTID1, DatabaseIdGenerator.getFaultcurrentId(NODEID1, "[layerProtocol="+OBJECTID1+"]aaa", PROBLEMNAME1));
+
assertEquals(FAULTCURRENTID1, DatabaseIdGenerator.getFaultcurrentId(NODEID1, OBJECTID1, PROBLEMNAME1));
assertEquals(INVENTORY_ID1, DatabaseIdGenerator
.getInventoryId(new InventoryBuilder().setNodeId(NODEID1).setUuid(EQUIPMENT_UUID1).build()));
diff --git a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestQuerySyntax.java b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestQuerySyntax.java
index 758b72f9c..24347c7db 100644
--- a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestQuerySyntax.java
+++ b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/TestQuerySyntax.java
@@ -21,16 +21,22 @@
*/
package org.onap.ccsdk.features.sdnr.wt.dataprovider.dblib.test;
+import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.query.SelectQuery;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EntityInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadEventlogListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadGuiCutThroughEntryInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.Filter;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.FilterBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.FilterKey;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.entity.input.PaginationBuilder;
+import org.opendaylight.yangtools.yang.common.Uint32;
+import org.opendaylight.yangtools.yang.common.Uint64;
public class TestQuerySyntax {
@@ -154,4 +160,37 @@ public class TestQuerySyntax {
final String sql = query.toSql();
assertTrue(sql.contains("`timestamp`<='2022-01-01 00:00:00.000'"));
}
+
+ @Test
+ public void testSelectForFilterValues() {
+ EntityInput input = new ReadGuiCutThroughEntryInputBuilder()
+ .setFilter(Arrays.asList(
+ new FilterBuilder().setProperty("id").setFiltervalues(Arrays.asList("das", "das2")).build()))
+ .setPagination(new PaginationBuilder().setSize(Uint32.valueOf(20)).setPage(Uint64.valueOf(1)).build())
+ .build();
+ SelectQuery query = new SelectQuery(TABLENAME1, input, CONTROLLERID);
+ System.out.println(query.toSql());
+ }
+ @Test
+ public void testSelectForFilterValues2() {
+ EntityInput input = new ReadGuiCutThroughEntryInputBuilder()
+ .setFilter(Arrays.asList(
+ new FilterBuilder().setProperty("id").setFiltervalue("*").build()))
+ .setPagination(new PaginationBuilder().setSize(Uint32.valueOf(20)).setPage(Uint64.valueOf(1)).build())
+ .build();
+ SelectQuery query = new SelectQuery(TABLENAME1, input, CONTROLLERID);
+ System.out.println(query.toSql());
+ assertFalse(query.toSql().contains("RLIKE"));
+ }
+ @Test
+ public void testSelectForFilterValues3() {
+ EntityInput input = new ReadGuiCutThroughEntryInputBuilder()
+ .setFilter(Arrays.asList(
+ new FilterBuilder().setProperty("id").setFiltervalues(Arrays.asList("*","abc")).build()))
+ .setPagination(new PaginationBuilder().setSize(Uint32.valueOf(20)).setPage(Uint64.valueOf(1)).build())
+ .build();
+ SelectQuery query = new SelectQuery(TABLENAME1, input, CONTROLLERID);
+ System.out.println(query.toSql());
+ assertFalse(query.toSql().contains("RLIKE"));
+ }
}
diff --git a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/util/MariaDBTestBase.java b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/util/MariaDBTestBase.java
index b065519f8..3360d3ed8 100644
--- a/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/util/MariaDBTestBase.java
+++ b/sdnr/wt/data-provider/dblib/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/dblib/test/util/MariaDBTestBase.java
@@ -5,6 +5,8 @@
* Copyright (C) 2021 highstreet technologies GmbH Intellectual Property.
* All rights reserved.
* ================================================================================
+ * Update Copyright (C) 2021 Samsung Electronics 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
@@ -34,6 +36,7 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.SqlDBConfig;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.SqlDBDataProvider;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database.SqlDBMapper;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database.SqlDBMapper.UnableToMapClassException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmlogEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionlogEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogEntity;
@@ -163,6 +166,7 @@ public class MariaDBTestBase {
createTable(dbService, FaultcurrentEntity.class, Entity.Faultcurrent, false);
createTable(dbService, FaultlogEntity.class, Entity.Faultlog, true);
createTable(dbService, GuicutthroughEntity.class, Entity.Guicutthrough, false);
+ createTable(dbService, CmlogEntity.class, Entity.Cmlog, true);
createTable(dbService, Pmdata15mEntity.class, Entity.Historicalperformance15min, false);
createTable(dbService, Pmdata24hEntity.class, Entity.Historicalperformance24h, false);
createTable(dbService, InventoryEntity.class, Entity.Inventoryequipment, false);
diff --git a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/DataProvider.java b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/DataProvider.java
index 128138ee3..8a5e91c63 100644
--- a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/DataProvider.java
+++ b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/DataProvider.java
@@ -4,6 +4,8 @@
* =================================================================================================
* Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
* =================================================================================================
+ * Update Copyright (C) 2021 Samsung Electronics 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
*
@@ -19,6 +21,7 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.model;
import java.util.List;
import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmlogEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionlogEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultcurrentEntity;
@@ -38,6 +41,8 @@ public interface DataProvider extends ArchiveCleanProvider {
void writeFaultLog(FaultlogEntity fault);
+ void writeCMLog(CmlogEntity cm);
+
void updateFaultCurrent(FaultcurrentEntity fault);
/**
diff --git a/sdnr/wt/data-provider/model/src/main/yang/data-provider@2020-11-10.yang b/sdnr/wt/data-provider/model/src/main/yang/data-provider@2020-11-10.yang
index be2c638e2..8b905f49e 100644
--- a/sdnr/wt/data-provider/model/src/main/yang/data-provider@2020-11-10.yang
+++ b/sdnr/wt/data-provider/model/src/main/yang/data-provider@2020-11-10.yang
@@ -28,6 +28,8 @@ module data-provider {
Copyright 2019 highstreet technologies GmbH Intellectual Property.
All rights reserved.
+ Update Copyright 2021 Samsung Electronics 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.
@@ -75,6 +77,10 @@ module data-provider {
description
"faultlog information";
}
+ enum cmlog {
+ description
+ "CMlog information";
+ }
enum historicalperformance15min {
description
"performance data";
@@ -267,6 +273,69 @@ module data-provider {
"According to ITU-T M.3160";
}
+ typedef cm-notification-type {
+ type enumeration {
+ enum notifyMOICreation {
+ description
+ "notification type";
+ }
+ enum notifyMOIDeletion {
+ description
+ "notification type";
+ }
+ enum notifyMOIAttributeValueChanges {
+ description
+ "notification type";
+ }
+ enum notifyMOIChanges {
+ description
+ "notification type";
+ }
+ }
+ }
+
+ typedef cm-source-indicator {
+ type enumeration {
+ enum RESOURCE_OPERATION {
+ description
+ "source indicator type";
+ }
+ enum MANAGEMENT_OPERATION {
+ description
+ "source indicator type";
+ }
+ enum SON_OPERATION {
+ description
+ "source indicator type";
+ }
+ enum UNKNOWN {
+ description
+ "source indicator type";
+ }
+ }
+ }
+
+ typedef cm-operation {
+ type enumeration {
+ enum CREATE {
+ description
+ "source operation type";
+ }
+ enum DELETE {
+ description
+ "source operation type";
+ }
+ enum REPLACE {
+ description
+ "source operation type";
+ }
+ enum NULL {
+ description
+ "source operation type for other than notifyMOIChanges notification type";
+ }
+ }
+ }
+
typedef source-type {
type enumeration {
enum Ves {
@@ -409,6 +478,41 @@ module data-provider {
}
}
+ grouping cm {
+ description
+ "CM event of an object";
+ leaf notification-type {
+ type cm-notification-type;
+ description
+ "The reported CM notification type.";
+ }
+ leaf notification-id {
+ type string;
+ description
+ "CM notification id";
+ }
+ leaf source-indicator {
+ type cm-source-indicator;
+ description
+ "CM source indicator.";
+ }
+ leaf path {
+ type string;
+ description
+ "CM path.";
+ }
+ leaf operation {
+ type cm-operation;
+ description
+ "CM operation.";
+ }
+ leaf value {
+ type string;
+ description
+ "CM JSON output value";
+ }
+ }
+
grouping attribute-change {
description
"update change of an attribute";
@@ -463,6 +567,21 @@ module data-provider {
uses faultlog-entity;
}
+ grouping cmlog-entity {
+ description
+ "Changed cm indication";
+ uses source-reference;
+ uses object-change-reference;
+ uses cm;
+ uses entity-id;
+ }
+
+ container cmlog {
+ description
+ "builder";
+ uses cmlog-entity;
+ }
+
grouping eventlog-entity {
description
"One change event of devices";
@@ -1543,6 +1662,26 @@ module data-provider {
}
}
+ rpc read-cmlog-list {
+ description
+ "Get list of CM entries according to filter";
+ input {
+ uses entity-input;
+ }
+ output {
+ container pagination {
+ uses pagination-output-g;
+ description
+ "The pagination details used by the provider to filter the data.";
+ }
+ list data {
+ uses cmlog-entity;
+ description
+ "The output data as list of cm entities.";
+ }
+ }
+ }
+
rpc read-eventlog-list {
description
"Get list of event log entities according to filter";
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/FaultEntityManager.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/FaultEntityManager.java
index 36ab39845..64156dc07 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/FaultEntityManager.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/FaultEntityManager.java
@@ -24,14 +24,13 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.annotation.Nonnull;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.entity.DatabaseIdGenerator;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Fault;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultcurrentEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.SeverityType;
public class FaultEntityManager {
- private static final Pattern pattern = Pattern.compile(".*\\[layerProtocol=(.*)\\]");
-
/**
* The leading indication for notification or events that are not in the currentProblem data of the ONF Coremodel
*/
@@ -68,14 +67,7 @@ public class FaultEntityManager {
*/
public static String genSpecificEsId(String nodeName, String objectId, String problemName) {
- String uuId;
-
- Matcher matcher = pattern.matcher(objectId);
- if (matcher.matches() && matcher.groupCount() == 1) {
- uuId = matcher.group(1);
- } else {
- uuId = objectId;
- }
+ String uuId = DatabaseIdGenerator.extractUuid(objectId);
StringBuffer strBuf = new StringBuffer();
strBuf.append(nodeName);
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseEventsService.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseEventsService.java
index ea3296acb..13438ef15 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseEventsService.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/data/entity/HtDatabaseEventsService.java
@@ -5,6 +5,8 @@
* Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
* All rights reserved.
* ================================================================================
+ * Update Copyright (C) 2021 Samsung Electronics 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
@@ -44,6 +46,8 @@ 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.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.rev201110.CmlogBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmlogEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionLogStatus;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionlogBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionlogEntity;
@@ -87,6 +91,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
private EsDataObjectReaderWriter2<InventoryEntity> eventRWEquipment;
private EsDataObjectReaderWriter2<FaultcurrentEntity> eventRWFaultCurrentDB;
private EsDataObjectReaderWriter2<FaultlogEntity> eventRWFaultLogDB;
+ private EsDataObjectReaderWriter2<CmlogEntity> eventRWFCMLogDB;
private EsDataObjectReaderWriter2<ConnectionlogEntity> eventRWConnectionLogDB;
private final EsDataObjectReaderWriter2<NetworkElementConnectionEntity> networkelementConnectionDB;
private final EsDataObjectReaderWriter2<GuicutthroughEntity> guiCutThroughDB;
@@ -119,6 +124,9 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
eventRWFaultLogDB = new EsDataObjectReaderWriter2<>(client, Entity.Faultlog, FaultlogEntity.class,
FaultlogBuilder.class);
+ eventRWFCMLogDB = new EsDataObjectReaderWriter2<>(client, Entity.Cmlog, CmlogEntity.class,
+ CmlogBuilder.class);
+
eventRWConnectionLogDB = new EsDataObjectReaderWriter2<>(client, Entity.Connectionlog,
ConnectionlogEntity.class, ConnectionlogBuilder.class);
@@ -179,6 +187,18 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
eventRWFaultLogDB.write(fault, null);
}
+ //-- CM log
+
+ @Override
+ public void writeCMLog(CmlogEntity cm) {
+ if (assertIfClientNull(cm)) {
+ return;
+ }
+
+ LOG.debug("Write CM to cmlog: {}", cm.toString());
+ eventRWFCMLogDB.write(cm, null);
+ }
+
// -- Fault current
@Override
@@ -491,6 +511,10 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
QueryBuilder queryFaultLog = EsFaultLogDevicemanager.getQueryForTimeStamp(netconfTimeStamp);
removed += eventRWFaultLogDB.remove(queryFaultLog);
+
+ QueryBuilder queryCMLog = EsCMLogDevicemanager.getQueryForTimeStamp(netconfTimeStamp);
+ removed += eventRWFCMLogDB.remove(queryCMLog);
+
return removed;
}
@@ -506,6 +530,9 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
QueryBuilder queryFaultLog = EsFaultLogDevicemanager.getQueryForTimeStamp(netconfTimeStamp);
numberOfElements += eventRWFaultLogDB.doReadAll(queryFaultLog).getTotal();
+ QueryBuilder queryCMLog = EsCMLogDevicemanager.getQueryForTimeStamp(netconfTimeStamp);
+ numberOfElements += eventRWFCMLogDB.doReadAll(queryCMLog).getTotal();
+
return numberOfElements;
}
@@ -565,6 +592,18 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
}
}
+ private static class EsCMLogDevicemanager {
+ /**
+ * Get older Elements
+ *
+ * @param netconfTimeStamp to identify query elements older than this timestamp.
+ * @return QueryBuilder for related elements
+ */
+ public static QueryBuilder getQueryForTimeStamp(String netconfTimeStamp) {
+ return new RangeQueryBuilder("timestamp").lte(netconfTimeStamp);
+ }
+ }
+
public static class EsFaultCurrent {
/**
* @param nodeName name of the node
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/ElasticSearchDataProvider.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/ElasticSearchDataProvider.java
index 53b21e0ed..38ea8044e 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/ElasticSearchDataProvider.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/ElasticSearchDataProvider.java
@@ -5,6 +5,8 @@
* Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
* All rights reserved.
* ================================================================================
+ * Update Copyright (C) 2021 Samsung Electronics 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
@@ -39,6 +41,7 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.
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.HtDatabaseMediatorserver;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtUserdataManager;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMediatorServerInput;
@@ -56,6 +59,7 @@ 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.rev201110.MaintenanceEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.MediatorServerEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.NetworkElementConnectionEntity;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadCmlogListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadConnectionlogListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadEventlogListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadFaultcurrentListOutputBuilder;
@@ -92,6 +96,7 @@ public class ElasticSearchDataProvider implements DatabaseDataProvider {
private final HtDatabaseClient dbClient;
private final DataObjectAcessorWithId<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.faultcurrent.list.output.Data> eventRWFaultCurrent;
private final DataObjectAcessorWithId<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.faultlog.list.output.Data> eventRWFaultLog;
+ private final DataObjectAcessorWithId<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.cmlog.list.output.Data> eventRWCMLog;
private final DataObjectAcessorWithId<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.mediator.server.list.output.Data> mediatorserverRW;
private final DataObjectAcessorWithId<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.maintenance.list.output.Data> maintenanceRW;
private final DataObjectAcessorWithId<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.gui.cut.through.entry.output.Data> guicutthroughRW;
@@ -105,6 +110,7 @@ public class ElasticSearchDataProvider implements DatabaseDataProvider {
private final DataObjectAcessorStatus readStatus;
private final HtDatabaseEventsService databaseService;
private final HtDatabaseMaintenanceService databaseMaintenanceService;
+ private final HtUserdataManager usermanager;
private final HtDatabaseMediatorserver dbMediatorServerService = new HtDatabaseMediatorserver() {
@@ -114,6 +120,7 @@ public class ElasticSearchDataProvider implements DatabaseDataProvider {
}
};
+
@Override
public HtDatabaseClient getRawClient() {
return this.dbClient;
@@ -163,6 +170,10 @@ public class ElasticSearchDataProvider implements DatabaseDataProvider {
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.faultlog.list.output.Data.class,
doFullsizeRequests);
+ this.eventRWCMLog = new DataObjectAcessorWithId<>(dbClient, Entity.Cmlog,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.cmlog.list.output.Data.class,
+ doFullsizeRequests);
+
this.connnectionlogRW = new DataObjectAcessorWithId<>(dbClient, Entity.Connectionlog,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.connectionlog.list.output.Data.class,
doFullsizeRequests);
@@ -188,6 +199,7 @@ public class ElasticSearchDataProvider implements DatabaseDataProvider {
this.databaseService = new HtDatabaseEventsService(dbClient, this);
this.databaseMaintenanceService = new HtDatabaseMaintenanceService(dbClient);
+ this.usermanager = new HtUserdataManagerImpl(this.dbClient);
}
/*-------------------------
@@ -222,6 +234,19 @@ public class ElasticSearchDataProvider implements DatabaseDataProvider {
}
@Override
+ public ReadCmlogListOutputBuilder readCMLogList(EntityInput input) {
+ ReadCmlogListOutputBuilder outputBuilder = new ReadCmlogListOutputBuilder();
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.cmlog.list.output.Data> result =
+ this.eventRWCMLog.getData(input);
+ outputBuilder.setData(result.getResult().getHits());
+ outputBuilder.setPagination(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.cmlog.list.output.PaginationBuilder(
+ result.getPagination()).build());
+ return outputBuilder;
+ }
+
+
+ @Override
public ReadMaintenanceListOutputBuilder readMaintenanceList(EntityInput input) {
ReadMaintenanceListOutputBuilder outputBuilder = new ReadMaintenanceListOutputBuilder();
QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.maintenance.list.output.Data> result =
@@ -393,7 +418,7 @@ public class ElasticSearchDataProvider implements DatabaseDataProvider {
}
CreateNetworkElementConnectionOutputBuilder builder = new CreateNetworkElementConnectionOutputBuilder();
builder.setId(id).setNodeId(input.getNodeId()).setHost(input.getHost()).setPort(input.getPort())
- .setUsername(input.getUsername()).setPassword(input.getPassword()).setIsRequired(input.isIsRequired())
+ .setUsername(input.getUsername()).setPassword(input.getPassword()).setIsRequired(input.getIsRequired())
.setCoreModelCapability(input.getCoreModelCapability()).setDeviceType(input.getDeviceType());
return builder;
}
@@ -516,5 +541,10 @@ public class ElasticSearchDataProvider implements DatabaseDataProvider {
return dbMediatorServerService;
}
+ @Override
+ public HtUserdataManager getUserManager() {
+ return this.usermanager;
+ }
+
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/HtUserdataManagerImpl.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/HtUserdataManagerImpl.java
index 9dbdb136a..7b7dccc96 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/HtUserdataManagerImpl.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/elasticsearch/impl/HtUserdataManagerImpl.java
@@ -21,44 +21,15 @@
*/
package org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.impl;
-import java.io.File;
-import java.io.IOException;
-import java.nio.file.Files;
-import org.json.JSONException;
import org.json.JSONObject;
import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
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.QueryBuilders;
-import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.HtUserdataManager;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.HtUserdataManagerBase;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-
-public class HtUserdataManagerImpl implements HtUserdataManager {
-
- private static final Logger LOG = LoggerFactory.getLogger(HtUserdataManagerImpl.class);
-
- private static final String USERDATA_DEFAULTS_FILENAME = "etc/userdata-defaults.json";
- private static final JSONObject USERDATA_DEFAULTS_CONTENT = loadDefaults();
-
- private static JSONObject loadDefaults() {
- File f = new File(USERDATA_DEFAULTS_FILENAME);
- String content;
- JSONObject o = null;
- if (f.exists()) {
- try {
- content = Files.readString(f.toPath());
- o = new JSONObject(content);
- } catch (IOException e) {
- LOG.warn("problem loading defaults: ", e);
- } catch (JSONException e) {
- LOG.warn("problem parsing defaults: ", e);
- }
- }
- return o;
- }
+public class HtUserdataManagerImpl extends HtUserdataManagerBase {
private final HtDatabaseClient dbClient;
@@ -67,84 +38,23 @@ public class HtUserdataManagerImpl implements HtUserdataManager {
}
@Override
- public String getUserdata(String username) {
+ protected String readUserdata(String username, String defaultValue) {
+
SearchResult<SearchHit> result = this.dbClient.doReadByQueryJsonData(Entity.Userdata.getName(),
QueryBuilders.matchQuery("_id", username));
- String json = result.getHits().size() > 0 ? result.getHits().get(0).getSourceAsString() : "{}";
- if (USERDATA_DEFAULTS_CONTENT != null) {
- JSONObject merge = mergeData(new JSONObject(json), USERDATA_DEFAULTS_CONTENT);
- json = merge.toString();
- }
- return json;
- }
-
- @Override
- public String getUserdata(String username, String key) {
- JSONObject o = new JSONObject(this.getUserdata(username));
- return o.has(key) ? o.get(key).toString() : "{}";
+ return result.getHits().size() > 0 ? result.getHits().get(0).getSourceAsString() : defaultValue;
}
@Override
public boolean setUserdata(String username, String data) {
JSONObject o = new JSONObject(this.getUserdata(username));
- JSONObject merge = mergeData(o, new JSONObject(data));
+ JSONObject merge = mergeData(new JSONObject(data), o);
return this.dbClient.doWriteRaw(Entity.Userdata.getName(), username, merge.toString()) != null;
}
@Override
- public boolean setUserdata(String username, String key, String data) {
- JSONObject o = new JSONObject(this.getUserdata(username));
- o = mergeData(o, key, new JSONObject(data));
- return this.dbClient.doWriteRaw(Entity.Userdata.getName(), username, o.toString()) != null;
- }
-
- @Override
public boolean removeUserdata(String username) {
return this.dbClient.doRemove(Entity.Userdata.getName(), username);
}
- @Override
- public boolean removeUserdata(String username, String key) {
- JSONObject o = new JSONObject(this.getUserdata(username));
- if (o.has(key)) {
- o.remove(key);
- return this.setUserdata(username, o.toString());
- }
- return true;
- }
-
- private static JSONObject mergeData(JSONObject o, String key, JSONObject subObject) {
- if (!o.has(key)) {
- o.put(key, subObject);
- } else {
- JSONObject tmp = new JSONObject();
- tmp.put(key, subObject);
- o = mergeData(tmp, o);
- }
- return o;
- }
-
- private static JSONObject mergeData(JSONObject source, JSONObject target) throws JSONException {
- String[] keys = JSONObject.getNames(source);
- if (keys == null) {
- return target;
- }
- for (String key : keys) {
- Object value = source.get(key);
- if (!target.has(key)) {
- // new value for "key":
- target.put(key, value);
- } else {
- // existing value for "key" - recursively deep merge:
- if (value instanceof JSONObject) {
- JSONObject valueJson = (JSONObject) value;
- mergeData(valueJson, target.getJSONObject(key));
- } else {
- target.put(key, value);
- }
- }
- }
- return target;
- }
-
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java
index cd75ca2a8..310444fd6 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/AboutHttpServlet.java
@@ -120,7 +120,7 @@ public class AboutHttpServlet extends HttpServlet {
final String mdsalVersion = SystemInfo.getMdSalVersion(UNKNOWN);
this.data.put(PLACEHOLDER_ONAP_RELEASENAME, ODLVersionLUT.getONAPReleaseName(ccsdkVersion, UNKNOWN));
this.data.put(PLACEHOLDER_ODL_RELEASENAME, ODLVersionLUT.getOdlVersion(mdsalVersion, UNKNOWN));
- this.data.put(PLACEHOLDER_BUILD_TIMESTAMP, props != null ? props.getBuildDate().toString() : "");
+ this.data.put(PLACEHOLDER_BUILD_TIMESTAMP, props != null ? String.valueOf(props.getBuildDate()) : "");
this.data.put(PLACEHOLDER_PACAKGE_VERSION, this.getManifestValue("Bundle-Version"));
this.data.put(PLACEHOLDER_CCSDK_VERSION, ccsdkVersion);
this.data.put(PLACEHOLDER_ONAP_RELEASEVERSION, SystemInfo.getOnapVersion(UNKNOWN));
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java
index 0e43cd251..5211030eb 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/about/ODLVersionLUT.java
@@ -32,6 +32,9 @@ public class ODLVersionLUT {
if (onapCCSDKVersion == null) {
return def;
}
+ if (onapCCSDKVersion.startsWith("2.3.")) {
+ return "ONAP Jakarta";
+ }
if (onapCCSDKVersion.startsWith("2.2.")) {
return "ONAP Istanbul";
}
@@ -63,6 +66,7 @@ public class ODLVersionLUT {
}
if(odlMdsalVersionLUT==null) {
odlMdsalVersionLUT = new HashMap<>();
+ odlMdsalVersionLUT.put("7.0.9","silicon-SR2 (0.14.2)");
odlMdsalVersionLUT.put("7.0.7","silicon-SR1 (0.14.1)");
odlMdsalVersionLUT.put("7.0.6","silicon-SR0 (0.14.0)");
odlMdsalVersionLUT.put("6.0.8","aluminium-SR3 (0.13.3)");
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFileProvider.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFileProvider.java
index c6758e240..797e8d72b 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFileProvider.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFileProvider.java
@@ -27,6 +27,8 @@ import java.io.FilenameFilter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.nio.file.DirectoryStream;
+import java.nio.file.Files;
import java.nio.file.Path;
import java.text.ParseException;
import java.util.ArrayList;
@@ -53,10 +55,12 @@ public class YangFileProvider {
private static final int BUFFER_SIZE = 1024;
private final Path mainSourcePath;
+ private final Path basePath;
private final List<Path> additionalSources;
- public YangFileProvider(String path) {
- this.mainSourcePath = new File(path).toPath();
+ public YangFileProvider(String path, String primaryPath) {
+ this.mainSourcePath = new File(primaryPath).toPath();
+ this.basePath = new File(path).toPath();
this.additionalSources = new ArrayList<>();
}
@@ -83,7 +87,17 @@ public class YangFileProvider {
LOG.warn("unable to handle yangfile {}: {}", fn, e);
}
}
-
+ List<String> filesInSeperateSubfolders = this.getSubFolderYangfiles();
+ for (String file : filesInSeperateSubfolders) {
+ try {
+ yangfile = new YangFilename(file);
+ if (yangfile.getModule().equals(module)) {
+ list.add(yangfile);
+ }
+ } catch (ParseException e) {
+ LOG.warn("unable to handle yangfile {}: {}", file, e);
+ }
+ }
for (Path addPath : this.additionalSources) {
files = addPath.toFile().list(yangFilenameFilter);
for (String file : files) {
@@ -100,6 +114,30 @@ public class YangFileProvider {
return list;
}
+ private List<String> getSubFolderYangfiles() {
+
+ return this.getSubFolderYangfiles(new ArrayList<>(), this.basePath);
+ }
+
+ private List<String> getSubFolderYangfiles(List<String> list, Path root) {
+ try (DirectoryStream<Path> stream = Files.newDirectoryStream(root)) {
+ for (Path path : stream) {
+ if (path.toFile().isDirectory()) {
+ this.getSubFolderYangfiles(list, path);
+ } else {
+
+ if (yangFilenameFilter.accept(root.toFile(), path.toString())) {
+ list.add(path.toAbsolutePath().toString());
+ }
+
+ }
+ }
+ } catch (IOException e) {
+ LOG.warn("unable to scan directory {} for yang files", root);
+ }
+ return list;
+ }
+
/**
* get yang file from source with specified version or least newer one if version is null then the latest one
*
@@ -201,5 +239,4 @@ public class YangFileProvider {
public boolean hasFileOrNewerForModule(String module, String version) throws ParseException {
return this.getYangFile(module, version) != null;
}
-
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFilename.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFilename.java
index eb4961a66..70cddee58 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFilename.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangFilename.java
@@ -29,7 +29,7 @@ import java.util.regex.Pattern;
public class YangFilename {
- private static final String REGEX = "([^\\/]*)@([0-9]{4}-[0-9]{2}-[0-9]{2}).yang";
+ private static final String REGEX = "([^\\/]{1,2048})@([0-9]{4}-[0-9]{2}-[0-9]{2}).yang";
private static final Pattern pattern = Pattern.compile(REGEX, Pattern.MULTILINE);
private final String filename;
private final Matcher matcher;
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangSchemaHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangSchemaHttpServlet.java
index 83518ecb2..86f67b1de 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangSchemaHttpServlet.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/yangschema/YangSchemaHttpServlet.java
@@ -23,28 +23,26 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.http.yangschema;
import java.io.IOException;
import java.text.ParseException;
-
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class YangSchemaHttpServlet extends HttpServlet {
/**
- *
+ *
*/
private static final long serialVersionUID = 1L;
private static final Logger LOG = LoggerFactory.getLogger(YangSchemaHttpServlet.class);
-
- private static final String schemaCachePath = "cache/schema/";
+ private static final String CACHEPATH = "cache/";
+ private static final String SCHEMACACHEPATH_PRIMARY = CACHEPATH+"schema/";
private final YangFileProvider fileProvider;
public YangSchemaHttpServlet() {
- this.fileProvider = new YangFileProvider(schemaCachePath);
+ this.fileProvider = new YangFileProvider(CACHEPATH, SCHEMACACHEPATH_PRIMARY);
}
@Override
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java
index 5a99c8ab3..251ba90f2 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java
@@ -5,6 +5,8 @@
* Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
* All rights reserved.
* ================================================================================
+ * Update Copyright (C) 2021 Samsung Electronics 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
@@ -64,6 +66,8 @@ 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.rev201110.DeleteMediatorServerOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.DeleteNetworkElementConnectionInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.DeleteNetworkElementConnectionOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadCmlogListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadCmlogListOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadConnectionlogListInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadConnectionlogListOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadEventlogListInput;
@@ -146,12 +150,12 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
this.mediatorServerServlet = mediatorServerServlet;
if (this.dbConfig.getDbType() == SdnrDbType.ELASTICSEARCH) {
this.dataProvider = new ElasticSearchDataProvider(this.dbConfig.getEsConfig());
- } else {
+ } else {
this.dataProvider = new SqlDBDataProvider(this.dbConfig.getMariadbConfig());
}
+ this.dbUserManager = this.dataProvider.getUserManager();
this.dataProvider.waitForYellowDatabaseStatus(DATABASE_TIMEOUT_MS, TimeUnit.MILLISECONDS);
mediatorServerServlet.setDataProvider(this.dataProvider.getHtDatabaseMediatorServer());
- this.dbUserManager = new HtUserdataManagerImpl(this.dataProvider.getRawClient());
// Register ourselves as the REST API RPC implementation
LOG.info("Register RPC Service {}", DataProviderServiceImpl.class.getSimpleName());
this.rpcReg = rpcProviderService.registerRpcImplementation(DataProviderService.class, this);
@@ -213,6 +217,14 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
}
@Override
+ public ListenableFuture<RpcResult<ReadCmlogListOutput>> readCmlogList(ReadCmlogListInput input) {
+ LOG.debug("RPC Request: readCMlogList with input {}", input);
+ RpcResultBuilder<ReadCmlogListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readCMLogList(input));
+ return result.buildFuture();
+ }
+
+ @Override
public ListenableFuture<RpcResult<ReadMaintenanceListOutput>> readMaintenanceList(ReadMaintenanceListInput input) {
LOG.debug("RPC Request: readMaintenanceList with input {}", input);
RpcResultBuilder<ReadMaintenanceListOutput> result =
@@ -427,7 +439,9 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
private ReadTlsKeyEntryOutputBuilder readTlsKeys(ReadTlsKeyEntryInput input) {
Optional<Keystore> result = Optional.empty();
- try (ReadTransaction transaction = this.dataBroker.newReadOnlyTransaction()) {
+ // The implicite close is not handled correctly by underlaying opendaylight netconf service
+ ReadTransaction transaction = this.dataBroker.newReadOnlyTransaction();
+ try {
result = transaction.read(LogicalDatastoreType.CONFIGURATION, KEYSTORE_IIF).get();
} catch (ExecutionException e) {
LOG.warn("problem reading netconf-keystore: ", e);
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java
index c407859d5..d59a0784f 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java
@@ -5,6 +5,8 @@
* Copyright (C) 2019 highstreet technologies GmbH Intellectual Property.
* All rights reserved.
* ================================================================================
+ * Update Copyright (C) 2021 Samsung Electronics 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
@@ -47,6 +49,9 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.YangHelper2;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.test.util.HostInfoForTest;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.DataProviderYangToolsMapper;
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.rev201110.CmNotificationType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmOperation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmSourceIndicator;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateMaintenanceOutputBuilder;
@@ -66,6 +71,9 @@ 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.rev201110.Faultlog;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultlogBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.GranularityPeriodType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadCmlogListInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadCmlogListInputBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadCmlogListOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadConnectionlogListInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadConnectionlogListInputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ReadConnectionlogListOutputBuilder;
@@ -588,6 +596,92 @@ public class TestCRUDforDatabase {
}
@Test
+ public void testCMLog() {
+ System.out.println("Starting CM log test...");
+ String dbId = clearAndCreateCMEntity("1", Entity.Cmlog.getName(),
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CreateCmlogInput");
+ // ==READ===========================
+ System.out.println("try to read entry");
+
+ ReadCmlogListInput readinput = new ReadCmlogListInputBuilder()
+ .setFilter(YangHelper2.getListOrMap(FilterKey.class,
+ new FilterBuilder().setProperty("id").setFiltervalue(dbId).build()))
+ .setPagination(getPagination(20, 1)).build();
+
+ ReadCmlogListOutputBuilder readResult = null;
+ try {
+ readResult = dbProvider.readCMLogList(readinput);
+
+ } catch (Exception e) {
+ fail("CM log not read: " + e.getMessage());
+ }
+
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.read.cmlog.list.output.Data>
+ data = readResult.getData();
+
+ assertNotNull(data);
+ assertEquals("1", dbId);
+ assertEquals(1, data.size());
+ assertEquals("node-1", data.get(0).getNodeId());
+ assertEquals(1, data.get(0).getCounter().intValue());
+ assertEquals(CmNotificationType.NotifyMOIChanges, data.get(0).getNotificationType());
+ assertEquals("123", data.get(0).getNotificationId());
+ assertEquals(CmSourceIndicator.MANAGEMENTOPERATION, data.get(0).getSourceIndicator());
+ assertEquals(CmOperation.REPLACE, data.get(0).getOperation());
+ assertEquals("pnf-registration:true", data.get(0).getValue());
+
+ //== UPDATE ================================
+ System.out.println("try to update entry");
+
+ dbRawProvider.doUpdateOrCreate(Entity.Cmlog.getName(), "1",
+ "{'node-id': 'test4657-78','operation': 'CREATE', 'notification-id': '1'}");
+
+ System.out.println("try to search entry 1");
+ readinput = new ReadCmlogListInputBuilder()
+ .setFilter(YangHelper2.getListOrMap(FilterKey.class,
+ new FilterBuilder().setProperty("node-id").setFiltervalue("test").build()))
+ .setPagination(getPagination(20, 1)).build();
+
+ //== VERIFY UPDATE ================================
+ readResult = dbProvider.readCMLogList(readinput);
+ data = readResult.getData();
+
+ assertNotNull(data);
+ System.out.println(data);
+ assertEquals(0, data.size());
+
+ System.out.println("try to search entry 2");
+ readinput = new ReadCmlogListInputBuilder()
+ .setFilter(YangHelper2.getListOrMap(FilterKey.class,
+ new FilterBuilder().setProperty("node-id").setFiltervalue("test*").build()))
+ .setPagination(getPagination(20, 1)).build();
+
+ readResult = dbProvider.readCMLogList(readinput);
+ data = readResult.getData();
+
+ assertEquals(1, data.size());
+ assertEquals("test4657-78", data.get(0).getNodeId());
+ assertEquals("CREATE", data.get(0).getOperation().toString());
+ assertEquals("1", data.get(0).getNotificationId());
+
+ //== DELETE ================================
+
+ System.out.println("try to clear entry");
+ try {
+ dbRawProvider.doRemove(Entity.Cmlog.getName(), dbId);
+ } catch (Exception e) {
+ fail("problem deleting entry: " + e.getMessage());
+ }
+
+ //== VERIFY DELETE ===========================
+ System.out.println("verify entries deleted");
+ readResult = dbProvider
+ .readCMLogList(new ReadFaultlogListInputBuilder().setPagination(getPagination(20, 1)).build());
+ data = readResult.getData();
+ assertEquals(0, data.size());
+ }
+
+ @Test
public void testFaultCurrent() {
System.out.println("Starting faultCurrent test...");
String dbId = null;
@@ -1459,6 +1553,45 @@ public class TestCRUDforDatabase {
return dbId;
}
+ private String clearAndCreateCMEntity(String initialDbId, String entityType, String implementedInterface) {
+ // ==CLEAR BEFORE TEST============================
+ System.out.println("try to clear entry");
+ try {
+ dbRawProvider.doRemove(entityType, QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting: " + e.getMessage());
+ }
+ return createCMEntity(initialDbId, entityType, implementedInterface);
+ }
+
+ private String createCMEntity(String initialDbId, String entityType, String implementedInterface) {
+ // ==CREATE============================
+ System.out.println("try to create entry");
+ String dbId = null;
+
+ try {
+ dbId = dbRawProvider.doUpdateOrCreate(entityType, initialDbId,
+ "{\n" + "\"timestamp\": \"2019-10-28T11:55:58.3Z\",\n"
+ + "\" object-id\": \"LP-MWPS-RADIO\",\n"
+ + "\"node-id\": \"node-1\",\n"
+ + "\"counter\": 1,\n"
+ + "\"notification-type\": \"" + CmNotificationType.NotifyMOIChanges.toString() + "\",\n"
+ + "\"notification-id\": 123,\n"
+ + "\"source-indicator\": \"" + CmSourceIndicator.MANAGEMENTOPERATION.toString() + "\",\n"
+ + "\" path\": \"https://samsung.com/3GPP/simulation/network-function/ves=1\",\n"
+ + "\"operation\": \"" + CmOperation.REPLACE.toString() + "\",\n"
+ + "\"value\": \"pnf-registration:true\",\n"
+ + "\"implemented-interface\": \"" + implementedInterface + "\"\n"
+ + "}");
+
+ } catch (Exception e) {
+ fail("Problem creating CM log entry" + e.getMessage());
+ }
+
+ return dbId;
+ }
+
+
private String createPerformanceData(String initialDbId, GranularityPeriodType timeInterval, String scannerId,
String uuidInterface, String nodename) {
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java
index dc5e049fd..0db019005 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java
@@ -5,6 +5,8 @@
* Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
* All rights reserved.
* ================================================================================
+ * Update Copyright (C) 2021 Samsung Electronics 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
@@ -38,12 +40,18 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo;
import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders;
import org.onap.ccsdk.features.sdnr.wt.common.database.requests.DeleteByQueryRequest;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.DatabaseDataProvider;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.entity.FaultEntityManager;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.data.entity.HtDatabaseEventsService;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.elasticsearch.impl.ElasticSearchDataProvider;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.YangHelper2;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.test.util.HostInfoForTest;
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.rev201110.CmNotificationType;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmOperation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmSourceIndicator;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmlogBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmlogEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionLogStatus;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionlogBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionlogEntity;
@@ -77,6 +85,7 @@ public class TestEventService {
private static final String NODEID = "node1";
private static final String NODEID2 = "node2";
+ private static final String NODEID3 = "node3";
private static final String OBJECTREFID1 = "objid1";
private static final String OBJECTREFID2 = "objid2";
@@ -122,6 +131,19 @@ public class TestEventService {
assertTrue(nodeIds.size() == 1);
}
+
+ @Test
+ public void testGenSpecificEsId() {
+ String objectRefOld = FaultEntityManager.genSpecificEsId(createFault(NODEID, "[layerProtocol="+OBJECTREFID1+"]", "abc", SeverityType.Major));
+ assertEquals(String.format("%s/%s/%s", NODEID, OBJECTREFID1, "abc"), objectRefOld);
+ String objectRefOld2 = FaultEntityManager.genSpecificEsId(createFault(NODEID2, "[layerProtocol="+OBJECTREFID2+"]", "abcde", SeverityType.Major));
+ assertEquals(String.format("%s/%s/%s", NODEID2, OBJECTREFID2, "abcde"), objectRefOld2);
+ String objectRef = FaultEntityManager.genSpecificEsId(createFault(NODEID, OBJECTREFID1, "abc", SeverityType.Major));
+ assertEquals(String.format("%s/%s/%s", NODEID, OBJECTREFID1, "abc"), objectRef);
+ String objectRef2 = FaultEntityManager.genSpecificEsId(createFault(NODEID2, OBJECTREFID2, "abcde", SeverityType.Major));
+ assertEquals(String.format("%s/%s/%s", NODEID2, OBJECTREFID2, "abcde"), objectRef2);
+ }
+
private static FaultcurrentEntity createFault(String nodeId, String objectRefId, String problem,
SeverityType severity) {
return createFault(nodeId, objectRefId, problem, severity, NetconfTimeStampImpl.getConverter().getTimeStamp());
@@ -146,6 +168,7 @@ public class TestEventService {
service.doIndexClean(now);
clearDbEntity(Entity.Eventlog);
clearDbEntity(Entity.Faultlog);
+ clearDbEntity(Entity.Cmlog);
TestCRUDforDatabase.trySleep(1000);
service.writeEventLog(createEventLog(NODEID, OBJECTREFID1, "aaa", "abc", 1));
service.writeEventLog(createEventLog(NODEID, OBJECTREFID1, "aaa", "avasvas", 2));
@@ -153,19 +176,27 @@ public class TestEventService {
service.writeFaultLog(createFaultLog(NODEID, OBJECTREFID2, "problem", SeverityType.Major, 1));
service.writeFaultLog(createFaultLog(NODEID, OBJECTREFID2, "problem", SeverityType.NonAlarmed, 2));
service.writeFaultLog(createFaultLog(NODEID2, OBJECTREFID2, "problem", SeverityType.Major, 1));
+
+ service.writeCMLog(createCMLog(NODEID3, 1, CmNotificationType.NotifyMOIChanges,
+ "1", CmSourceIndicator.MANAGEMENTOPERATION, CmOperation.CREATE, "value"));
+
TestCRUDforDatabase.trySleep(100);
now = new Date();
long numOlds = service.getNumberOfOldObjects(now);
- assertEquals(5, numOlds);
+ assertEquals(6, numOlds);
TestCRUDforDatabase.trySleep(100);
service.writeFaultLog(createFaultLog(NODEID, OBJECTREFID2, "problem", SeverityType.Major, 3));
service.writeFaultLog(createFaultLog(NODEID, OBJECTREFID2, "problem", SeverityType.NonAlarmed, 5));
service.writeFaultLog(createFaultLog(NODEID, OBJECTREFID2, "problem", SeverityType.Major, 6));
+
+ service.writeCMLog(createCMLog(NODEID3, 2, CmNotificationType.NotifyMOIChanges,
+ "2", CmSourceIndicator.SONOPERATION, CmOperation.REPLACE, "value2"));
+
numOlds = service.getNumberOfOldObjects(now);
- assertEquals(5, numOlds);
+ assertEquals(6, numOlds);
now = new Date();
numOlds = service.getNumberOfOldObjects(now);
- assertEquals(8, numOlds);
+ assertEquals(10, numOlds);
service.doIndexClean(now);
numOlds = service.getNumberOfOldObjects(now);
assertEquals(0, numOlds);
@@ -292,6 +323,31 @@ public class TestEventService {
/**
* @param nodeId
+ * @param counter
+ * @param notificationType
+ * @param notificationId
+ * @param sourceIndicator
+ * @param operation
+ * @param value
+ * @return
+ */
+ private static CmlogEntity createCMLog(String nodeId, int counter, CmNotificationType notificationType,
+ String notificationId, CmSourceIndicator sourceIndicator,
+ CmOperation operation, String value) {
+ return new CmlogBuilder()
+ .setNodeId(nodeId)
+ .setCounter(counter)
+ .setNotificationType(notificationType)
+ .setNotificationId(notificationId)
+ .setSourceIndicator(sourceIndicator)
+ .setOperation(operation)
+ .setValue(value)
+ .setTimestamp(NetconfTimeStampImpl.getConverter().getTimeStamp())
+ .build();
+ }
+
+ /**
+ * @param nodeId
* @param objectId
* @param problem
* @param severity
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestUserdata.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestUserdata.java
index 3fcbdb84c..ce4044780 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestUserdata.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestUserdata.java
@@ -21,11 +21,11 @@
*/
package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
+import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
import org.apache.sshd.common.util.io.IoUtils;
import org.junit.BeforeClass;
-import org.junit.Ignore;
import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo;
@@ -35,7 +35,7 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.test.util.HostInfoForTest;
public class TestUserdata {
- private static final String USERNAME = "admin";
+ private static final String USERNAME = "admin132";
private static HtDatabaseClient dbRawProvider;
private static HtUserdataManagerImpl userDbProvider;
@@ -55,17 +55,18 @@ public class TestUserdata {
}
}
- @Ignore
@Test
public void test1() {
String fullContent = "";
+ boolean success = false;
try {
fullContent = getFileContent("/userdata/full.json");
- userDbProvider.setUserdata(USERNAME, fullContent);
+ success = userDbProvider.setUserdata(USERNAME, fullContent);
} catch (IOException e) {
e.printStackTrace();
fail(e.getMessage());
}
+ assertTrue("problem writing data into db",success);
trySleep(2000);
@@ -89,6 +90,6 @@ public class TestUserdata {
}
private static String getFileContent(String filename) throws IOException {
- return String.join("\n", IoUtils.readAllLines(TestTree.class.getResourceAsStream(filename)));
+ return String.join("\n", IoUtils.readAllLines(TestUserdata.class.getResourceAsStream(filename)));
}
}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java
index f3171d3b1..adcb523c0 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java
@@ -54,6 +54,8 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.http.yangschema.YangSchemaHt
public class TestYangProvider {
private static final String TESTPATH = "cache/schema/";
+ private static final String TESTPATH_BASE = "cache/";
+ private static final String TESTPATH_SEPERATE_1 = TESTPATH_BASE+"abc1/";
@BeforeClass
@@ -76,7 +78,9 @@ public class TestYangProvider {
new File(TESTPATH + new YangFilename("module4", "2010-05-01").getFilename()).createNewFile();
new File(TESTPATH + new YangFilename("module5", "2010-01-11").getFilename()).createNewFile();
new File(TESTPATH + new YangFilename("module6", "2010-01-01").getFilename()).createNewFile();
- } catch (IOException | ParseException e) {
+ Files.createDirectories(new File(TESTPATH_SEPERATE_1).toPath(), attr);
+ new File(TESTPATH_SEPERATE_1 + new YangFilename("module7", "2011-01-01").getFilename()).createNewFile();
+ } catch (IOException | ParseException e) {
}
}
@@ -93,17 +97,18 @@ public class TestYangProvider {
@Test
public void testExisting() {
- YangFileProvider provider = new YangFileProvider(TESTPATH);
+ YangFileProvider provider = new YangFileProvider(TESTPATH_BASE, TESTPATH);
assertTrue(provider.hasFileForModule("module1", "2010-01-01"));
assertTrue(provider.hasFileForModule("module2"));
assertTrue(provider.hasFileForModule("module3"));
assertFalse(provider.hasFileForModule("module5", "2010-01-01"));
+ assertTrue(provider.hasFileForModule("module7"));
}
@Test
public void testRevision() throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
- YangFileProvider provider = new YangFileProvider(TESTPATH);
+ YangFileProvider provider = new YangFileProvider(TESTPATH_BASE, TESTPATH);
YangFilename f1 = provider.getFileForModule("module1", "2010-01-01");
assertEquals("module1", f1.getModule());
assertEquals(sdf.parse("2010-01-01"), f1.getRevision());
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/MariaDBTestBase.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/MariaDBTestBase.java
index 276bcf4a1..18efde235 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/MariaDBTestBase.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/util/MariaDBTestBase.java
@@ -5,6 +5,8 @@
* Copyright (C) 2021 highstreet technologies GmbH Intellectual Property.
* All rights reserved.
* ================================================================================
+ * Update Copyright (C) 2021 Samsung Electronics 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
@@ -34,6 +36,7 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.SqlDBConfig;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.SqlDBDataProvider;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database.SqlDBMapper;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database.SqlDBMapper.UnableToMapClassException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmlogEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionlogEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogEntity;
@@ -127,6 +130,7 @@ public class MariaDBTestBase {
createTable(dbService, EventlogEntity.class, Entity.Eventlog, true);
createTable(dbService, FaultcurrentEntity.class, Entity.Faultcurrent, false);
createTable(dbService, FaultlogEntity.class, Entity.Faultlog, true);
+ createTable(dbService, CmlogEntity.class, Entity.Cmlog, true);
createTable(dbService, GuicutthroughEntity.class, Entity.Guicutthrough, true);
createTable(dbService, Pmdata15mEntity.class, Entity.Historicalperformance15min, false);
createTable(dbService, Pmdata24hEntity.class, Entity.Historicalperformance24h, false);
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java
index 6e5bdc522..5e6520c08 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java
@@ -40,6 +40,7 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.frankfurt.FrankfurtRel
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.guilin.GuilinReleaseInformation;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.honolulu.HonoluluReleaseInformation;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.istanbul.IstanbulReleaseInformation;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.jakarta.JakartaReleaseInformation;
public abstract class ReleaseInformation {
@@ -175,6 +176,8 @@ public abstract class ReleaseInformation {
return new HonoluluReleaseInformation();
case ISTANBUL_R1:
return new IstanbulReleaseInformation();
+ case JAKARTA_R1:
+ return new JakartaReleaseInformation();
default:
return null;
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentName.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentName.java
index 956f74b2d..c01e37abd 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentName.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentName.java
@@ -5,6 +5,8 @@
* Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
* All rights reserved.
* ================================================================================
+ * Update Copyright (C) 2021 Samsung Electronics 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
@@ -29,7 +31,7 @@ public enum ComponentName {
"inventorytoplevel"), MAINTENANCE("maintenance"), MEDIATOR_SERVER(
"mediator-server"), REQUIRED_NETWORKELEMENT(
"required-networkelement"), GUICUTTHROUGH(
- "guicutthrough"), USERDATA("userdata");
+ "guicutthrough"), USERDATA("userdata"),CMLOG("cmlog");
private final String value;
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DatabaseInfo7.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DatabaseInfo7.java
index 58b98c2aa..87fc07ef9 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DatabaseInfo7.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DatabaseInfo7.java
@@ -30,7 +30,9 @@ public class DatabaseInfo7 extends DatabaseInfo {
public DatabaseInfo7(String alias, String doctype, String mapping) {
super(alias, alias, doctype, mapping);
}
-
+ public DatabaseInfo7(String alias, String doctype, String mapping, String settingsformat) {
+ super(alias, alias, doctype, mapping, settingsformat);
+ }
public DatabaseInfo7(String index, String alias, String doctype, String mapping, String settingsformat) {
super(index, alias, doctype, mapping, settingsformat);
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java
index 22338e89a..12cbe4f1f 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java
@@ -34,9 +34,12 @@ public enum Release {
GUILIN_R1("guilin-R1", "-v4", new DatabaseVersion(7,1,1), new DatabaseVersion(7,6,1)),
HONOLULU_R1("honolulu-R1", "-v5", new DatabaseVersion(7,1,1), new DatabaseVersion(8,0,0), false),
ISTANBUL_R1("istanbul-R1", "-v6", new DatabaseVersion(7,1,1), new DatabaseVersion(8,0,0), false,
- new DatabaseVersion(10,2,7), new DatabaseVersion(10,6,0), false);
+ new DatabaseVersion(10,2,7), new DatabaseVersion(10,6,0), false),
+ JAKARTA_R1("jakarta-R1", "-v7", new DatabaseVersion(7,1,1), new DatabaseVersion(8,0,0), false,
+ new DatabaseVersion(10,2,7), new DatabaseVersion(10,6,0), false);
- public static final Release CURRENT_RELEASE = Release.ISTANBUL_R1;
+
+ public static final Release CURRENT_RELEASE = Release.JAKARTA_R1;
private final String value;
private final String dbSuffix;
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ReleaseGroup.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ReleaseGroup.java
index 58e8d2055..91ad437f9 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ReleaseGroup.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ReleaseGroup.java
@@ -34,9 +34,10 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.SdnrDbType;
public enum ReleaseGroup {
EL_ALTO(Release.EL_ALTO), FRANKFURT(Release.FRANKFURT_R1, Release.FRANKFURT_R2), GUILIN(
- Release.GUILIN_R1), HONOLULU(Release.HONOLULU_R1), ISTANBUL(Release.ISTANBUL_R1);
+ Release.GUILIN_R1), HONOLULU(Release.HONOLULU_R1), ISTANBUL(Release.ISTANBUL_R1),
+ JAKARTA(Release.JAKARTA_R1);
- public static final ReleaseGroup CURRENT_RELEASE = ISTANBUL;
+ public static final ReleaseGroup CURRENT_RELEASE = JAKARTA;
private final List<Release> releases;
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/database/MariaDbDataMigrationProvider.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/database/MariaDbDataMigrationProvider.java
index 55ba66ba6..ff93079a4 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/database/MariaDbDataMigrationProvider.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/database/MariaDbDataMigrationProvider.java
@@ -161,8 +161,9 @@ public class MariaDbDataMigrationProvider implements DataMigrationProviderServic
boolean componentsSucceeded = true;
for (ComponentName c : ri.getComponents()) {
ComponentData data = new ComponentData(c);
- SearchResult<SearchHit> result = null;//this.dbClient.doReadAllJsonData(ri.getAlias(c), ri.getDataType(c), false);
- data.addAll(result.getHits());
+ // TODO : check why doReadAllJsonData are comment
+ //SearchResult<SearchHit> result = null;//this.dbClient.doReadAllJsonData(ri.getAlias(c), ri.getDataType(c), false);
+ //data.addAll(result.getHits());
container.addComponent(c, data);
}
try {
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/istanbul/IstanbulReleaseInformation.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/istanbul/IstanbulReleaseInformation.java
index 0dcd3ae3c..8a0aeb05e 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/istanbul/IstanbulReleaseInformation.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/istanbul/IstanbulReleaseInformation.java
@@ -21,9 +21,12 @@
*/
package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.istanbul;
+import java.io.IOException;
import java.util.HashMap;
import java.util.Map;
import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
+import org.onap.ccsdk.features.sdnr.wt.common.database.requests.ClusterSettingsRequest;
+import org.onap.ccsdk.features.sdnr.wt.common.database.responses.ClusterSettingsResponse;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.SqlDBClient;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName;
@@ -35,13 +38,17 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.SearchHitConverter;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.honolulu.HonoluluReleaseInformation;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class IstanbulReleaseInformation extends ReleaseInformation {
- private static final String TIMEZONE_TYPE_FORMAT =
+ private final Logger LOG = LoggerFactory.getLogger(IstanbulReleaseInformation.class);
+
+ public static final String TIMEZONE_TYPE_FORMAT =
"CHAR(6) DEFAULT NULL CHECK (`%s` regexp '^[+-]\\\\d\\\\d:\\\\d\\\\d$')";
- private static final String TABLENAME_CONTROLLER_FORMAT = "controller%s";
- private static final String TABLEMAPPING_CONTROLLER =
+ public static final String TABLENAME_CONTROLLER_FORMAT = "controller%s";
+ public static final String TABLEMAPPING_CONTROLLER =
"`id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,`desc` VARCHAR(255) CHARACTER SET utf8 ,primary key(id)";
private static final String TABLEMAPPING_CONNECTIONLOG_FORMAT = "`id` int(11) NOT NULL AUTO_INCREMENT,\n"
+ "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n" + "`timestamp` DATETIME(3) ,\n"
@@ -93,7 +100,7 @@ public class IstanbulReleaseInformation extends ReleaseInformation {
private static final String TABLEMAPPING_INVENTORY_FORMAT = "`id` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\n"
+ "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n"
+ "`version` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`type-name` VARCHAR(255) CHARACTER SET utf8 ,\n"
- + "`date` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`description` VARCHAR(255) CHARACTER SET utf8 ,\n"
+ + "`date` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`description` VARCHAR(1024) CHARACTER SET utf8 ,\n"
+ "`node-id` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`uuid` VARCHAR(255) CHARACTER SET utf8 ,\n"
+ "`part-type-id` VARCHAR(255) CHARACTER SET utf8 ,\n"
+ "`model-identifier` VARCHAR(255) CHARACTER SET utf8 ,\n"
@@ -103,7 +110,7 @@ public class IstanbulReleaseInformation extends ReleaseInformation {
+ "primary key(id),foreign key(`controller-id`) references `controller%s`(id)";
private static final String TABLEMAPPING_MAINTENANCE_FORMAT = "`id` VARCHAR(255) CHARACTER SET utf8 NOT NULL,\n"
+ "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n" + "`active` BOOLEAN ,\n"
- + "`node-id` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`description` VARCHAR(255) CHARACTER SET utf8 ,\n"
+ + "`node-id` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`description` VARCHAR(1024) CHARACTER SET utf8 ,\n"
+ "`problem` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`start` DATETIME(3) ,\n" + "`start-tz` "
+ String.format(TIMEZONE_TYPE_FORMAT, "start-tz") + " ,\n" + "`end` DATETIME(3) ,\n" + "`end-tz` "
+ String.format(TIMEZONE_TYPE_FORMAT, "end-tz") + " ,\n"
@@ -132,7 +139,7 @@ public class IstanbulReleaseInformation extends ReleaseInformation {
super(Release.ISTANBUL_R1, createDBMap(), createMariaDBMap(Release.ISTANBUL_R1.getDBSuffix()));
}
- private static Map<ComponentName, MariaDBTableInfo> createMariaDBMap(String suffix) {
+ public static Map<ComponentName, MariaDBTableInfo> createMariaDBMap(String suffix) {
Map<ComponentName, MariaDBTableInfo> map = new HashMap<>();
map.put(ComponentName.CONNECTIONLOG,
new MariaDBTableInfo(Entity.Connectionlog.getName(), TABLEMAPPING_CONNECTIONLOG_FORMAT));
@@ -158,7 +165,7 @@ public class IstanbulReleaseInformation extends ReleaseInformation {
return map;
}
- private static Map<ComponentName, DatabaseInfo> createDBMap() {
+ public static Map<ComponentName, DatabaseInfo> createDBMap() {
Map<ComponentName, DatabaseInfo> map = HonoluluReleaseInformation.createDBMap();
map.put(ComponentName.USERDATA, new DatabaseInfo7("userdata", "userdata", "{}"));
map.put(ComponentName.REQUIRED_NETWORKELEMENT, new DatabaseInfo7("networkelement-connection",
@@ -168,7 +175,10 @@ public class IstanbulReleaseInformation extends ReleaseInformation {
+ "\"core-model-capability\": {\"type\": \"keyword\"},\"device-type\": {\"type\": \"keyword\"},"
+ "\"device-function\": {\"type\": \"keyword\"},\"is-required\": {\"type\": \"boolean\"},"
+ "\"status\": {\"type\": \"keyword\"},\"tls-key\": {\"type\": \"keyword\"},"
- + "\"mount-method\": {\"type\":\"keyword\"}}"));
+ + "\"mount-method\": {\"type\":\"keyword\"}}",
+ "{\"index\":{\"max_result_window\": 20000,\"number_of_shards\":%d,\"number_of_replicas\":%d},"
+ +"\"analysis\":{\"analyzer\":{\"content\":{\"type\":\"custom\",\"tokenizer\":\"whitespace\"}}}}"
+ ));
return map;
}
@@ -182,7 +192,13 @@ public class IstanbulReleaseInformation extends ReleaseInformation {
@Override
public boolean runPreInitCommands(HtDatabaseClient dbClient) {
- return true;
+ ClusterSettingsResponse response = null;
+ try {
+ response = dbClient.setupClusterSettings(new ClusterSettingsRequest(false).maxCompilationsPerMinute(400));
+ } catch (IOException e) {
+ LOG.warn("problem setting up cluster: {}", e);
+ }
+ return response == null ? false : response.isAcknowledged();
}
@Override
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/jakarta/JakartaReleaseInformation.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/jakarta/JakartaReleaseInformation.java
new file mode 100644
index 000000000..03033edad
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/jakarta/JakartaReleaseInformation.java
@@ -0,0 +1,123 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
+ * All rights reserved.
+ * ================================================================================
+ * Update Copyright (C) 2021 Samsung Electronics Intellectual Property. All rights reserved.
+ * =================================================================================================
+c * 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.dataprovider.setup.jakarta;
+
+import java.io.IOException;
+import java.util.Map;
+import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
+import org.onap.ccsdk.features.sdnr.wt.common.database.requests.ClusterSettingsRequest;
+import org.onap.ccsdk.features.sdnr.wt.common.database.responses.ClusterSettingsResponse;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.SqlDBClient;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DatabaseInfo;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DatabaseInfo7;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.KeepDataSearchHitConverter;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.MariaDBTableInfo;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.SearchHitConverter;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.istanbul.IstanbulReleaseInformation;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class JakartaReleaseInformation extends ReleaseInformation {
+
+ private static final String TABLENAME_CONTROLLER_FORMAT = IstanbulReleaseInformation.TABLENAME_CONTROLLER_FORMAT;
+ private static final String TABLEMAPPING_CONTROLLER = IstanbulReleaseInformation.TABLEMAPPING_CONTROLLER;
+ private static final String TIMEZONE_TYPE_FORMAT = IstanbulReleaseInformation.TIMEZONE_TYPE_FORMAT;
+ private final Logger LOG = LoggerFactory.getLogger(JakartaReleaseInformation.class);
+
+ private static final String TABLEMAPPING_CMLOG_FORMAT =
+ "`id` int(11) NOT NULL AUTO_INCREMENT,\n" + "`controller-id` VARCHAR(40) CHARACTER SET utf8 NOT NULL,\n"
+ + "`source-type` VARCHAR(100) CHARACTER SET utf8 ,\n"
+ + "`object-id` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`timestamp` DATETIME(3) ,\n"
+ + "`timestamp-tz` " + String.format(TIMEZONE_TYPE_FORMAT, "timestamp-tz")
+ + " ,\n" + "`node-id` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`counter` INTEGER ,\n"
+ + "`notification-type` VARCHAR(100) CHARACTER SET utf8 ,\n"
+ + "`notification-id` VARCHAR(40) CHARACTER SET utf8 ,\n"
+ + "`source-indicator` VARCHAR(100) CHARACTER SET utf8 ,\n"
+ + "`path` VARCHAR(255) CHARACTER SET utf8 ,\n" + "`operation` VARCHAR(100) CHARACTER SET utf8 ,\n"
+ + "`value` VARCHAR(255) CHARACTER SET utf8 ,\n" + "primary key(id)";
+
+ public JakartaReleaseInformation() {
+ super(Release.JAKARTA_R1, createDBMap(), createMariaDBMap());
+ }
+
+ private static Map<ComponentName, DatabaseInfo> createDBMap() {
+ Map<ComponentName, DatabaseInfo> map = IstanbulReleaseInformation.createDBMap();
+ map.put(ComponentName.CMLOG, new DatabaseInfo7("cmlog", "cmlog",
+ "{\"node-id\": {\"type\": \"keyword\"},\"counter\": {\"type\": \"long\"},"
+ + "\"notification-id\": {\"type\": \"date\"},\"notification-type\": {\"type\": \"keyword\"},"
+ + "\"object-id\": {\"type\": \"long\"},\"operation\":{\"type\": \"keyword\"},"
+ + "\"path\": {\"type\": \"long\"},\"source-indicator\":{\"type\": \"keyword\"},"
+ + "\"source-type\": {\"type\": \"long\"},\"timestamp\":{\"type\": \"keyword\"},"
+ + "\"value\":{\"type\": \"keyword\"}}"));
+ return map;
+ }
+
+ private static Map<ComponentName, MariaDBTableInfo> createMariaDBMap() {
+ Map<ComponentName, MariaDBTableInfo> map =
+ IstanbulReleaseInformation.createMariaDBMap(Release.JAKARTA_R1.getDBSuffix());
+ map.put(ComponentName.CMLOG, new MariaDBTableInfo(Entity.Cmlog.getName(), TABLEMAPPING_CMLOG_FORMAT));
+ return map;
+ }
+
+ @Override
+ public SearchHitConverter getConverter(Release dst, ComponentName comp) {
+ if (dst == Release.JAKARTA_R1) {
+ return new KeepDataSearchHitConverter(comp);
+ }
+ return null;
+ }
+
+ @Override
+ public boolean runPreInitCommands(HtDatabaseClient dbClient) {
+ ClusterSettingsResponse response = null;
+ try {
+ response = dbClient.setupClusterSettings(new ClusterSettingsRequest(false).maxCompilationsPerMinute(400));
+ } catch (IOException e) {
+ LOG.warn("problem setting up cluster: {}", e);
+ }
+ return response == null ? false : response.isAcknowledged();
+ }
+
+ @Override
+ public boolean runPostInitCommands(HtDatabaseClient dbClient) {
+ return true;
+ }
+
+ @Override
+ public boolean runPreInitCommands(SqlDBClient dbClient) {
+ boolean success = dbClient.createTable(
+ String.format(TABLENAME_CONTROLLER_FORMAT, this.getReleas().getDBSuffix()), TABLEMAPPING_CONTROLLER);
+ return success;
+ }
+
+ @Override
+ public boolean runPostInitCommands(SqlDBClient dbClient) {
+ return true;
+ }
+
+}
diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/MariaDBTestBase.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/MariaDBTestBase.java
index 264f1203c..6fd4a40a4 100644
--- a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/MariaDBTestBase.java
+++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/MariaDBTestBase.java
@@ -5,6 +5,8 @@
* Copyright (C) 2021 highstreet technologies GmbH Intellectual Property.
* All rights reserved.
* ================================================================================
+ * Update Copyright (C) 2021 Samsung Electronics 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
@@ -35,6 +37,7 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.SqlDBConfig;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.data.SqlDBDataProvider;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database.SqlDBMapper;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.database.SqlDBMapper.UnableToMapClassException;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmlogEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.ConnectionlogEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogEntity;
@@ -136,6 +139,7 @@ public class MariaDBTestBase {
createTable(dbService, EventlogEntity.class, Entity.Eventlog, true);
createTable(dbService, FaultcurrentEntity.class, Entity.Faultcurrent, false);
createTable(dbService, FaultlogEntity.class, Entity.Faultlog, true);
+ createTable(dbService, CmlogEntity.class, Entity.Cmlog, true);
createTable(dbService, GuicutthroughEntity.class, Entity.Guicutthrough, true);
createTable(dbService, Pmdata15mEntity.class, Entity.Historicalperformance15min, false);
createTable(dbService, Pmdata24hEntity.class, Entity.Historicalperformance24h, false);
diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestBaseReleaseInformation.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestBaseReleaseInformation.java
new file mode 100644
index 000000000..143611f36
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestBaseReleaseInformation.java
@@ -0,0 +1,34 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
+ * All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup;
+
+import static org.junit.Assert.assertNotNull;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName;
+
+public class TestBaseReleaseInformation {
+
+ protected void assertValidComponents(ReleaseInformation ri) {
+
+ assertNotNull(ri.getComponents());
+ assertNotNull(ri.getConverter(ri.getReleas(),ComponentName.FAULTCURRENT));
+ }
+}
diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestHonoluluReleaseInformation.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestHonoluluReleaseInformation.java
new file mode 100644
index 000000000..727d116fd
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestHonoluluReleaseInformation.java
@@ -0,0 +1,34 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
+ * All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup;
+
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.honolulu.HonoluluReleaseInformation;
+
+public class TestHonoluluReleaseInformation extends TestBaseReleaseInformation{
+
+ @Test
+ public void test() {
+ this.assertValidComponents(new HonoluluReleaseInformation());
+ }
+
+}
diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestJakartaReleaseInformation.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestJakartaReleaseInformation.java
new file mode 100644
index 000000000..6258e31c2
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestJakartaReleaseInformation.java
@@ -0,0 +1,46 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2021 Samsung Electronics 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.dataprovider.setup;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+import java.util.Set;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.jakarta.JakartaReleaseInformation;
+
+public class TestJakartaReleaseInformation {
+
+ @Test
+ public void testReleaseInformation() {
+ JakartaReleaseInformation ri = new JakartaReleaseInformation();
+ Set<ComponentName> components = ri.getComponents();
+ assertTrue(components.contains(ComponentName.USERDATA));
+ assertTrue(components.contains(ComponentName.REQUIRED_NETWORKELEMENT));
+ assertTrue(components.contains(ComponentName.CMLOG));
+ assertEquals("userdata", ri.getAlias(ComponentName.USERDATA));
+ assertEquals("networkelement-connection", ri.getAlias(ComponentName.REQUIRED_NETWORKELEMENT));
+ assertEquals("cmlog", ri.getAlias(ComponentName.CMLOG));
+ assertEquals("cmlog-v7", ri.getIndex(ComponentName.CMLOG));
+ }
+
+}
diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMariaDBIstanbul.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMariaDBJakarta.java
index 072ce2f6b..d657704fb 100644
--- a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMariaDBIstanbul.java
+++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMariaDBJakarta.java
@@ -34,7 +34,7 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.SdnrDbType;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release;
import ch.vorburger.exec.ManagedProcessException;
-public class TestMariaDBIstanbul {
+public class TestMariaDBJakarta {
private static final String MARIADB_USERNAME = "sdnrdb";
private static final String MARIADB_PASSWORD = "sdnrdb";
@@ -78,7 +78,7 @@ public class TestMariaDBIstanbul {
e.printStackTrace();
fail(e.getMessage());
}
- boolean success = provider.initDatabase(Release.ISTANBUL_R1, 1, 1, "", false, 1000);
+ boolean success = provider.initDatabase(Release.JAKARTA_R1, 1, 1, "", false, 1000);
assertTrue("init database failed",success);
try {
dbProvider.setControllerId();
diff --git a/sdnr/wt/devicemanager-core/model/src/main/yang/devicemanager.yang b/sdnr/wt/devicemanager-core/model/src/main/yang/devicemanager.yang
index a34ea49a4..e12991b29 100644
--- a/sdnr/wt/devicemanager-core/model/src/main/yang/devicemanager.yang
+++ b/sdnr/wt/devicemanager-core/model/src/main/yang/devicemanager.yang
@@ -22,6 +22,8 @@ module devicemanager {
Copyright 2019 highstreet technologies GmbH Intellectual Property.
All rights reserved.
+ Update Copyright 2021 Samsung Electronics 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.
@@ -313,6 +315,15 @@ module devicemanager {
}
}
+ rpc push-cm-notification {
+ description
+ "Forward CM notification";
+ input {
+ uses data-provider:object-change-reference;
+ uses data-provider:cm;
+ }
+ }
+
rpc push-attribute-change-notification {
description
"Forward attribute change notification of a network-element";
diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/config/AaiClientPropertiesFile.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/config/AaiClientPropertiesFile.java
index 8329ec0e9..1e9629b03 100644
--- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/config/AaiClientPropertiesFile.java
+++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/aaiconnector/impl/config/AaiClientPropertiesFile.java
@@ -19,11 +19,16 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.aaiconnector.impl.config;
import java.io.File;
import java.io.FileInputStream;
+import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class AaiClientPropertiesFile {
+ private static final Logger log = LoggerFactory.getLogger(AaiClientPropertiesFile.class);
+
private final File mFile;
private String mPCKS12CertFilename;
private String mPCKS12Passphrase;
@@ -73,19 +78,21 @@ public class AaiClientPropertiesFile {
this.mFile = new File(filename);
}
- public void load() throws IOException, NumberFormatException {
+ public void load() throws IOException {
Properties defaultProps = new Properties();
- FileInputStream in = new FileInputStream(this.mFile);
- defaultProps.load(in);
- this.mPCKS12CertFilename = defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.ssl.key", null);
- this.mPCKS12Passphrase = defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd", null);
- this.mTrustInsecureSSL = defaultProps
+
+ try (FileInputStream in = new FileInputStream(this.mFile)) {
+ defaultProps.load(in);
+ this.mPCKS12CertFilename = defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.ssl.key", null);
+ this.mPCKS12Passphrase = defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd", null);
+ this.mTrustInsecureSSL = defaultProps
.getProperty("org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore", "false").equals("true");
- this.mApplicationIdentifier = defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.application", null);
- this.mRemoteUrl = defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.uri", null);
- this.mConnectionTimeout = Integer.parseInt(defaultProps.getProperty("connection.timeout", "60000"));
- this.mReadTimeout = Integer.parseInt(defaultProps.getProperty("read.timeout", "60000"));
- in.close();
+ this.mApplicationIdentifier = defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.application", null);
+ this.mRemoteUrl = defaultProps.getProperty("org.onap.ccsdk.sli.adaptors.aai.uri", null);
+ this.mConnectionTimeout = Integer.parseInt(defaultProps.getProperty("connection.timeout", "60000"));
+ this.mReadTimeout = Integer.parseInt(defaultProps.getProperty("read.timeout", "60000"));
+ } catch (FileNotFoundException fnfe) {
+ log.error("File - {} not found",getFilename());
+ }
}
-
}
diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/ODLEventListenerHandler.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/ODLEventListenerHandler.java
index 037f09778..4543ab0b4 100644
--- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/ODLEventListenerHandler.java
+++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/ODLEventListenerHandler.java
@@ -22,6 +22,7 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
+import org.eclipse.jdt.annotation.NonNull;
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;
@@ -33,6 +34,7 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificatio
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClientInternal;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.EventHandlingService;
import org.opendaylight.mdsal.binding.api.DataBroker;
+import org.opendaylight.mdsal.binding.api.ReadTransaction;
import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
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.netconf.node.topology.rev150114.NetconfNode;
@@ -158,12 +160,16 @@ public class ODLEventListenerHandler implements EventHandlingService, AutoClosea
.child(Topology.class, new TopologyKey(new TopologyId(TopologyNetconf.QNAME.getLocalName())))
.child(Node.class, new NodeKey(nodeId)).augmentation(NetconfNode.class);
+ //Implicit close of try with resource is not handled correctly by underlying opendaylight NETCONF service
+ @NonNull
+ ReadTransaction readTransaction = this.dataBroker.newReadOnlyTransaction();
try {
- Optional<NetconfNode> onode =
- this.dataBroker.newReadOnlyTransaction().read(LogicalDatastoreType.CONFIGURATION, iif).get();
- return onode;
- } catch (InterruptedException | ExecutionException e) {
- LOG.warn("problem requesting netconfnode again:", e);
+ return readTransaction.read(LogicalDatastoreType.CONFIGURATION, iif).get();
+ } catch (InterruptedException e) {
+ LOG.warn("InterruptedException occurred - problem requesting netconfnode again:", e);
+ Thread.currentThread().interrupt();
+ } catch (ExecutionException e) {
+ LOG.warn("ExecutionException occurred - problem requesting netconfnode again:", e);
}
}
return Optional.empty();
diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/RpcPushNotificationsHandler.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/RpcPushNotificationsHandler.java
index 90e07e666..a9c043e03 100644
--- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/RpcPushNotificationsHandler.java
+++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/eventdatahandler/RpcPushNotificationsHandler.java
@@ -7,6 +7,8 @@
* ================================================================================
* Update Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
* ================================================================================
+ * Update Copyright (C) 2021 Samsung Electronics 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
@@ -29,6 +31,8 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.PushNotifications;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalSeverity;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.ProblemNotificationXml;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml.WebSocketServiceClientInternal;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmlogBuilder;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmlogEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.EventlogEntity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultcurrentBuilder;
@@ -41,6 +45,7 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicema
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ProblemNotification;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.ProblemNotificationBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushAttributeChangeNotificationInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushCmNotificationInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushFaultNotificationInput;
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
import org.slf4j.Logger;
@@ -106,4 +111,14 @@ public class RpcPushNotificationsHandler implements PushNotifications {
webSocketService.sendViaWebsockets(new NodeId(input.getNodeId()!=null?input.getNodeId():OWNKEYNAME), notification, ProblemNotification.QNAME, input.getTimestamp());
}
+ @Override
+ public void pushCMNotification(PushCmNotificationInput input) {
+ LOG.debug("Got CM event {}", input);
+
+ CmlogBuilder cmlogBuilder = new CmlogBuilder();
+ cmlogBuilder.setSourceType(SourceType.Ves);
+ cmlogBuilder.fieldsFrom(input);
+ CmlogEntity cmlogEntity = cmlogBuilder.build();
+ databaseService.writeCMLog(cmlogEntity);
+ }
}
diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ConnectionStatusHousekeepingService.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ConnectionStatusHousekeepingService.java
index 49c678ebc..02c32d91b 100644
--- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ConnectionStatusHousekeepingService.java
+++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/housekeeping/ConnectionStatusHousekeepingService.java
@@ -192,15 +192,20 @@ public class ConnectionStatusHousekeepingService
private ConnectionLogStatus getMDSalConnectionStatus(String nodeId) {
- @SuppressWarnings("null")
@NonNull
InstanceIdentifier<Node> instanceIdentifier =
NETCONF_TOPO_IID.child(Node.class, new NodeKey(new NodeId(nodeId)));
+ //Implicit close of try with resource is not handled correctly by underlying opendaylight NETCONF service
ReadTransaction trans = this.dataBroker.newReadOnlyTransaction();
- FluentFuture<Optional<Node>> optionalNode = trans.read(LogicalDatastoreType.OPERATIONAL, instanceIdentifier);
try {
- //Node node = optionalNode.get(5, TimeUnit.SECONDS).get();
- Node node = optionalNode.get().get();
+ FluentFuture<Optional<Node>> optionalNode =
+ trans.read(LogicalDatastoreType.OPERATIONAL, instanceIdentifier);
+ Optional<Node> nodeOpt = optionalNode.get();
+ if (nodeOpt.isEmpty()) {
+ LOG.warn("unable to get node info");
+ return null;
+ }
+ Node node = nodeOpt.get();
LOG.debug("node is {}", node);
NetconfNode nNode = node.augmentation(NetconfNode.class);
LOG.debug("nnode is {}", nNode);
@@ -209,8 +214,11 @@ public class ConnectionStatusHousekeepingService
}
} catch (NoSuchElementException e) {
return ConnectionLogStatus.Disconnected;
- } catch (ExecutionException | InterruptedException e) {// | TimeoutException e) {
- LOG.warn("unable to get node info: {}", e);
+ } catch (InterruptedException e) {
+ LOG.warn("InterruptedException unable to get node info: ", e);
+ Thread.currentThread().interrupt();
+ } catch (ExecutionException e) {// | TimeoutException e) {
+ LOG.warn("ExecutionException unable to get node info: ", e);
} finally {
trans.close();
}
diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java
index 266bb04ba..e31b79aea 100644
--- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java
+++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/DeviceManagerApiServiceImpl.java
@@ -4,6 +4,8 @@
* =================================================================================================
* Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
* =================================================================================================
+ * Update Copyright (C) 2021 Samsung Electronics 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
*
@@ -17,6 +19,7 @@
*/
package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl;
+import com.google.common.util.concurrent.ListenableFuture;
import java.util.List;
import org.eclipse.jdt.annotation.Nullable;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.housekeeping.ResyncNetworkElementsListener;
@@ -35,6 +38,8 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicema
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.GetRequiredNetworkElementKeysOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushAttributeChangeNotificationInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushAttributeChangeNotificationOutput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushCmNotificationInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushCmNotificationOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushFaultNotificationInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushFaultNotificationOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.SetMaintenanceModeInput;
@@ -53,8 +58,6 @@ import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.util.concurrent.ListenableFuture;
-
public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(DevicemanagerService.class);
@@ -220,6 +223,20 @@ public class DeviceManagerApiServiceImpl implements DevicemanagerService, AutoCl
}
@Override
+ public ListenableFuture<RpcResult<PushCmNotificationOutput>> pushCmNotification(PushCmNotificationInput input) {
+ LOG.info("RPC Received CM notification {}", input);
+ RpcResultBuilder<PushCmNotificationOutput> result;
+ try {
+ pushNotificationsListener.pushCMNotification(input);
+ result = RpcResultBuilder.success();
+ } catch (Exception e) {
+ result = RpcResultBuilder.failed();
+ result.withError(ErrorType.APPLICATION, "Exception", e);
+ }
+ return result.buildFuture();
+ }
+
+ @Override
public ListenableFuture<RpcResult<PushAttributeChangeNotificationOutput>> pushAttributeChangeNotification(
PushAttributeChangeNotificationInput input) {
LOG.info("RPC Received change notification {}", input);
diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/PushNotifications.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/PushNotifications.java
index f424878f8..8d32c8cc0 100644
--- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/PushNotifications.java
+++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/PushNotifications.java
@@ -4,6 +4,8 @@
* =================================================================================================
* Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
* =================================================================================================
+ * Update Copyright (C) 2021 Samsung Electronics 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
*
@@ -19,6 +21,7 @@
package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushAttributeChangeNotificationInput;
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushCmNotificationInput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.devicemanager.rev190109.PushFaultNotificationInput;
public interface PushNotifications {
@@ -27,4 +30,6 @@ public interface PushNotifications {
void pushFaultNotification(PushFaultNotificationInput input);
+ void pushCMNotification(PushCmNotificationInput input);
+
}
diff --git a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/FaultEntityManager.java b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/FaultEntityManager.java
index 785f5dbab..7c83a08dc 100644
--- a/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/FaultEntityManager.java
+++ b/sdnr/wt/devicemanager-core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/impl/xml/FaultEntityManager.java
@@ -17,15 +17,13 @@
*/
package org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.xml;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.impl.util.InternalSeverity;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Fault;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.FaultcurrentEntity;
public class FaultEntityManager {
- private static final Pattern pattern = Pattern.compile(".*\\[layerProtocol=(.*)\\]");
+ private static final String FAULT_TAG = "[layerProtocol=";
/**
* The leading indication for notification or events that are not in the currentProblem data of the ONF Coremodel
@@ -34,7 +32,7 @@ public class FaultEntityManager {
/**
* Specific problems are not moving into current problem list
- *
+ *
* @param problemName to be verified
* @return true if problem is current
*/
@@ -48,7 +46,7 @@ public class FaultEntityManager {
/**
* Specific problems are not moving into current problem list
- *
+ *
* @param fault to be verified
* @return true if cleared indication
*/
@@ -59,16 +57,15 @@ public class FaultEntityManager {
/**
* Create a specific ES id for the current log.
- *
+ *
* @return a string with the generated ES Id
*/
public static String genSpecificEsId(String nodeName, String objectId, String problemName) {
String uuId;
- Matcher matcher = pattern.matcher(objectId);
- if (matcher.matches() && matcher.groupCount() == 1) {
- uuId = matcher.group(1);
+ if (objectId.endsWith("]") && objectId.contains(FAULT_TAG)) {
+ uuId = objectId.substring(objectId.indexOf(FAULT_TAG) + FAULT_TAG.length(), objectId.length()-1);
} else {
uuId = objectId;
}
@@ -84,7 +81,7 @@ public class FaultEntityManager {
/**
* Create Es id
- *
+ *
* @param fault used to create uuid for faultcurrent
* @return String with Id
*/
diff --git a/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java b/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java
index 02d381ff2..627192365 100644
--- a/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java
+++ b/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java
@@ -115,7 +115,8 @@ public class TestAai {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
- e.printStackTrace();
+ System.out.println("Break sleep : " + e.getMessage());
+ Thread.currentThread().interrupt();
}
System.out.println("unregistering device");
provider.onDeviceUnregistered(new NodeId(mountPointName));
@@ -132,7 +133,8 @@ public class TestAai {
try {
Thread.sleep(3000);
} catch (InterruptedException e1) {
- e1.printStackTrace();
+ System.out.println("Break sleep : " + e1.getMessage());
+ Thread.currentThread().interrupt();
}
AaiProviderClient provider = new AaiProviderClient(globalCfg, null);
@@ -151,7 +153,8 @@ public class TestAai {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
- e.printStackTrace();
+ System.out.println("Break sleep : " + e.getMessage());
+ Thread.currentThread().interrupt();
}
System.out.println("unregistering device");
provider.onDeviceUnregistered(new NodeId(mountPointName));
diff --git a/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java b/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java
index a403fe4a6..4bad25ce7 100644
--- a/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java
+++ b/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java
@@ -97,12 +97,13 @@ public class TestDcae {
try {
Thread.sleep(5000);
} catch (InterruptedException e) {
- e.printStackTrace();
+ System.out.println("Break sleep : " + e.getMessage());
+ Thread.currentThread().interrupt();
}
try {
provider.close();
} catch (Exception e) {
- e.printStackTrace();
+ System.out.println("Close provider error : " + e.getMessage());
}
}
diff --git a/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevMgrPropertiesFile.java b/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevMgrPropertiesFile.java
index 9b533b554..987424d04 100644
--- a/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevMgrPropertiesFile.java
+++ b/sdnr/wt/devicemanager-core/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevMgrPropertiesFile.java
@@ -124,6 +124,7 @@ public class TestDevMgrPropertiesFile {
try {
Thread.sleep(milliseconds);
} catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
}
}
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/CMBasicHeaderFieldsNotification.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/CMBasicHeaderFieldsNotification.java
new file mode 100644
index 000000000..98f02ec7a
--- /dev/null
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/CMBasicHeaderFieldsNotification.java
@@ -0,0 +1,100 @@
+/*
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt mountpoint-registrar
+ * =================================================================================================
+ * Copyright (C) 2021 Samsung Electronics 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.mountpointregistrar.impl;
+
+public class CMBasicHeaderFieldsNotification {
+ private String cmNodeId;
+ private String cmSequence;
+ private String cmOccurrenceTime;
+ private String sourceId;
+ private String notificationType;
+
+ public static CMBasicHeaderFieldsNotificationBuilder builder() {
+ return new CMBasicHeaderFieldsNotificationBuilder();
+ }
+
+ private CMBasicHeaderFieldsNotification(
+ CMBasicHeaderFieldsNotification.CMBasicHeaderFieldsNotificationBuilder builder) {
+ this.cmNodeId = builder.cmNodeId;
+ this.cmSequence = builder.cmSequence;
+ this.cmOccurrenceTime = builder.cmOccurrenceTime;
+ this.sourceId = builder.sourceId;
+ this.notificationType = builder.notificationType;
+ }
+
+ public static class CMBasicHeaderFieldsNotificationBuilder {
+ private String cmNodeId;
+ private String cmSequence;
+ private String cmOccurrenceTime;
+ private String sourceId;
+ private String notificationType;
+
+ public CMBasicHeaderFieldsNotification build() {
+ return new CMBasicHeaderFieldsNotification(this);
+ }
+
+ public CMBasicHeaderFieldsNotificationBuilder withCMNodeId(String cmNodeId) {
+ this.cmNodeId = cmNodeId;
+ return this;
+ }
+
+ public CMBasicHeaderFieldsNotificationBuilder withCMSequence(
+ String cmSequence) {
+ this.cmSequence = cmSequence;
+ return this;
+ }
+
+ public CMBasicHeaderFieldsNotificationBuilder withCMOccurrenceTime(
+ String cmOccurrenceTime) {
+ this.cmOccurrenceTime = cmOccurrenceTime;
+ return this;
+ }
+
+ public CMBasicHeaderFieldsNotificationBuilder withSourceId(String sourceId) {
+ this.sourceId = sourceId;
+ return this;
+ }
+
+ public CMBasicHeaderFieldsNotificationBuilder withNotificationType(
+ String notificationType) {
+ this.notificationType = notificationType;
+ return this;
+ }
+ }
+
+ public String getCmNodeId() {
+ return cmNodeId;
+ }
+
+ public String getCmSequence() {
+ return cmSequence;
+ }
+
+ public String getCmOccurrenceTime() {
+ return cmOccurrenceTime;
+ }
+
+ public String getNotificationType() {
+ return notificationType;
+ }
+
+ public String getSourceId() {
+ return sourceId;
+ }
+
+}
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/CMNotification.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/CMNotification.java
new file mode 100644
index 000000000..014ff648d
--- /dev/null
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/CMNotification.java
@@ -0,0 +1,113 @@
+/*
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt mountpoint-registrar
+ * =================================================================================================
+ * Copyright (C) 2021 Samsung Electronics 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.mountpointregistrar.impl;
+
+import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.CmOperation;
+
+public class CMNotification {
+ private CMBasicHeaderFieldsNotification basicHeaderFields;
+ private String cmNotificationId;
+ private String cmSourceIndicator;
+ private String cmPath;
+ private String cmOperation;
+ private String cmValue;
+
+ public static CMNotificationBuilder builder() {
+ return new CMNotificationBuilder();
+ }
+
+ private CMNotification(CMNotificationBuilder builder) {
+ this.basicHeaderFields = builder.basicHeaderFields;
+ this.cmNotificationId = builder.cmNotificationId;
+ this.cmSourceIndicator = builder.cmSourceIndicator;
+ this.cmPath = builder.cmPath;
+ this.cmOperation = builder.cmOperation;
+ this.cmValue = builder.cmValue;
+ }
+
+ public static class CMNotificationBuilder {
+ private CMBasicHeaderFieldsNotification basicHeaderFields;
+ private String cmNotificationId;
+ private String cmSourceIndicator;
+ private String cmValue;
+ private String cmPath;
+
+ private String cmOperation = CmOperation.NULL.getName();
+
+
+ public CMNotification build() {
+ return new CMNotification(this);
+ }
+
+ public CMNotificationBuilder withCMBasicHeaderFieldsNotification(
+ CMBasicHeaderFieldsNotification basicHeaderFields) {
+ this.basicHeaderFields = basicHeaderFields;
+ return this;
+ }
+
+ public CMNotificationBuilder withCMNotificationId(
+ String cmNotificationId) {
+ this.cmNotificationId = cmNotificationId;
+ return this;
+ }
+
+ public CMNotificationBuilder withCMSourceIndicator(String cmSourceIndicator) {
+ this.cmSourceIndicator = cmSourceIndicator;
+ return this;
+ }
+
+ public CMNotificationBuilder withCMValue(String cmValue) {
+ this.cmValue = cmValue;
+ return this;
+ }
+
+ public CMNotificationBuilder withCMOperation(String cmOperation) {
+ this.cmOperation = cmOperation;
+ return this;
+ }
+
+ public CMNotificationBuilder withCMPath(String cmPath) {
+ this.cmPath = cmPath;
+ return this;
+ }
+ }
+
+ public CMBasicHeaderFieldsNotification getBasicHeaderFields() {
+ return basicHeaderFields;
+ }
+
+ public String getCmSourceIndicator() {
+ return cmSourceIndicator;
+ }
+
+ public String getCmPath() {
+ return cmPath;
+ }
+
+ public String getCmNotificationId() {
+ return cmNotificationId;
+ }
+
+ public String getCmOperation() {
+ return cmOperation;
+ }
+
+ public String getCmValue() {
+ return cmValue;
+ }
+}
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/CMNotificationClient.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/CMNotificationClient.java
new file mode 100644
index 000000000..b13d4ea38
--- /dev/null
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/CMNotificationClient.java
@@ -0,0 +1,81 @@
+/*
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt mountpoint-registrar
+ * =================================================================================================
+ * Copyright (C) 2021 Samsung Electronics 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.mountpointregistrar.impl;
+
+import static org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.MessageClient.SendMethod.POST;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+public class CMNotificationClient extends MessageClient {
+
+ private static final String CM_NOTIFICATION_URI = "restconf/operations/devicemanager:push-cm-notification";
+ public static final String NODE_ID = "@node-id@", COUNTER = "@counter@", TIMESTAMP = "@timestamp@",
+ OBJECT_ID = "@object-id@", NOTIFICATION_TYPE = "@notification-type@", SOURCE_INDICATOR = "@source-indicator@",
+ NOTIFICATION_ID = "@notification-id@", PATH = "@path@", OPERATION = "@operation@", VALUE = "@value@";
+ public static final List<String> REQUIRED_FIELDS =
+ List.of(NODE_ID, COUNTER, TIMESTAMP, OBJECT_ID, NOTIFICATION_TYPE, NOTIFICATION_ID, SOURCE_INDICATOR, PATH,
+ OPERATION, VALUE);
+
+ private static final String CM_PAYLOAD = "{\n"
+ + " \"devicemanager:input\": {\n"
+ + " \"devicemanager:node-id\": \"" + NODE_ID + "\",\n"
+ + " \"devicemanager:counter\": \"" + COUNTER + "\",\n"
+ + " \"devicemanager:timestamp\": \"" + TIMESTAMP + "\",\n"
+ + " \"devicemanager:object-id\": \"" + OBJECT_ID + "\",\n"
+ + " \"devicemanager:notification-type\": \"" + NOTIFICATION_TYPE + "\",\n"
+ + " \"devicemanager:notification-id\": \"" + NOTIFICATION_ID + "\",\n"
+ + " \"devicemanager:source-indicator\": \"" + SOURCE_INDICATOR + "\",\n"
+ + " \"devicemanager:path\": \"" + PATH + "\",\n"
+ + " \"devicemanager:operation\": \"" + OPERATION + "\",\n"
+ + " \"devicemanager:value\": \"" + VALUE + "\"\n"
+ + " }\n"
+ + "}";
+
+ public CMNotificationClient(String baseUrl) {
+ super(baseUrl, CM_NOTIFICATION_URI);
+ }
+
+ @Override
+ public String prepareMessageFromPayloadMap(Map<String, String> notificationPayloadMap) {
+ return super.prepareMessageFromPayloadMap(notificationPayloadMap, CM_PAYLOAD, REQUIRED_FIELDS);
+ }
+
+ @Override
+ public boolean sendNotification(String message) {
+ return super.sendNotification(message, POST, MessageType.json);
+ }
+
+
+ public static Map<String, String> createCMNotificationPayloadMap(CMNotification cmNotification) {
+ HashMap<String, String> map = new HashMap<>();
+ map.put(NODE_ID, cmNotification.getBasicHeaderFields().getCmNodeId());
+ map.put(COUNTER, cmNotification.getBasicHeaderFields().getCmSequence());
+ map.put(TIMESTAMP, cmNotification.getBasicHeaderFields().getCmOccurrenceTime());
+ map.put(OBJECT_ID, cmNotification.getBasicHeaderFields().getSourceId());
+ map.put(NOTIFICATION_TYPE, cmNotification.getBasicHeaderFields().getNotificationType());
+ map.put(NOTIFICATION_ID, cmNotification.getCmNotificationId());
+ map.put(SOURCE_INDICATOR, cmNotification.getCmSourceIndicator());
+ map.put(PATH, cmNotification.getCmPath());
+ map.put(OPERATION, cmNotification.getCmOperation());
+ map.put(VALUE, cmNotification.getCmValue());
+ return map;
+ }
+}
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPCMVESMsgConsumer.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPCMVESMsgConsumer.java
index 245807ec3..8412e3730 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPCMVESMsgConsumer.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPCMVESMsgConsumer.java
@@ -19,6 +19,10 @@
package org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode;
+import java.time.Instant;
+import java.time.ZoneId;
+import java.util.Iterator;
+import java.util.Map;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -35,19 +39,96 @@ public class DMaaPCMVESMsgConsumer extends DMaaPVESMsgConsumerImpl {
public void processMsg(String msg) throws InvalidMessageException, JsonProcessingException {
LOG.debug("Processing CM message {}", msg);
JsonNode rootNode = convertMessageToJsonNode(msg);
- JsonNode dataNode;
- JsonNode notificationNode;
try {
- dataNode = rootNode.get("event").get("stndDefinedFields").get("data").requireNonNull();
- if(dataNode.get("notificationType").textValue().equalsIgnoreCase("notifyMOIChanges")) {
- notificationNode = dataNode.get("moiChanges");
- LOG.info("Read CM message from DMaaP topic that is moiChanges type with id {}", dataNode.get("notificationId"));
+
+ String cmNodeId = rootNode.at("/event/commonEventHeader/reportingEntityName").textValue();
+ String notificationType = rootNode.at("/event/stndDefinedFields/data/notificationType").textValue();
+
+ if (notificationType.equalsIgnoreCase("notifyMOIChanges")) {
+ LOG.info("Read CM message from DMaaP topic that is moiChanges type with id {}", cmNodeId);
+ processMoiChanges(rootNode);
+ } else if (notificationType.equalsIgnoreCase("notifyMOICreation")) {
+ LOG.info("Read CM message from DMaaP topic that is moiCreation type with id {}", cmNodeId);
+ sendCMNotification(preparePayloadMapFromMoi(rootNode, "/event/stndDefinedFields/data/attributeList"));
+ } else if (notificationType.equalsIgnoreCase("notifyMOIDeletion")) {
+ LOG.info("Read CM message from DMaaP topic that is moiDeletion type with id {}", cmNodeId);
+ sendCMNotification(preparePayloadMapFromMoi(rootNode,"/event/stndDefinedFields/data/attributeList"));
+ } else if (notificationType.equalsIgnoreCase("notifyMOIAttributeValueChanges")) {
+ LOG.info("Read CM message from DMaaP topic that is moiAttributeValueChanges type with id {}", cmNodeId);
+ sendCMNotification(preparePayloadMapFromMoi(rootNode,"/event/stndDefinedFields/data/attributeListValueChanges"));
+ } else {
+ LOG.warn("Message is invalid, sending aborted, wrong CM notification type {}", notificationType);
+ throw new InvalidMessageException();
}
+
} catch (NullPointerException e) {
LOG.warn("Message is invalid, sending aborted, processing stopped because one of fields is missing");
throw new InvalidMessageException("Missing field");
}
- // take required data from notificationNode
}
+ private CMBasicHeaderFieldsNotification prepareCMCommonHeaderFields(JsonNode rootNode) {
+ return CMBasicHeaderFieldsNotification.builder()
+ .withCMNodeId(rootNode.at("/event/commonEventHeader/reportingEntityName").textValue())
+ .withCMSequence(rootNode.at("/event/commonEventHeader/sequence").toString())
+ .withCMOccurrenceTime(Instant
+ .ofEpochMilli(
+ rootNode.at("/event/commonEventHeader/startEpochMicrosec").longValue() / 1000)
+ .atZone(ZoneId.of("Z")).toString())
+ .withSourceId(rootNode.at("/event/commonEventHeader/sourceId").textValue())
+ .withNotificationType(rootNode.at("/event/stndDefinedFields/data/notificationType").textValue())
+ .build();
+ }
+
+ private void processMoiChanges(JsonNode rootNode) {
+ Iterator<JsonNode> nodes = rootNode
+ .at("/event/stndDefinedFields/data/moiChanges")
+ .elements();
+ while (nodes.hasNext()) {
+ sendCMNotification(preparePayloadMapFromMoiChangesArray(rootNode, nodes));
+ }
+ }
+
+ public Map<String, String> preparePayloadMapFromMoiChangesArray(JsonNode rootNode, Iterator<JsonNode> nodes) {
+ JsonNode slaidNode = nodes.next();
+ return CMNotificationClient.createCMNotificationPayloadMap(
+ CMNotification.builder()
+ .withCMBasicHeaderFieldsNotification(
+ prepareCMCommonHeaderFields(rootNode))
+ .withCMNotificationId(slaidNode.get("notificationId").toString())
+ .withCMSourceIndicator(slaidNode.get("sourceIndicator").textValue())
+ .withCMPath(slaidNode.get("path").textValue())
+ .withCMOperation(slaidNode.get("operation").textValue())
+ .withCMValue(slaidNode.get("value").toString()
+ .replace("\"", ""))
+ .build());
+ }
+
+ public Map<String, String> preparePayloadMapFromMoi(JsonNode rootNode, String cmValueKey){
+ return CMNotificationClient.createCMNotificationPayloadMap(
+ CMNotification.builder()
+ .withCMBasicHeaderFieldsNotification(
+ prepareCMCommonHeaderFields(rootNode))
+ .withCMSourceIndicator(rootNode.at("/event/stndDefinedFields/data/sourceIndicator").textValue())
+ .withCMValue(rootNode.at(cmValueKey).toString()
+ .replace("\"", ""))
+ .build());
+ }
+
+ private void sendCMNotification(Map<String, String> payloadMapMessage) {
+ CMNotificationClient cmClient = setRESTConfAuthorization();
+ String message = cmClient.prepareMessageFromPayloadMap(payloadMapMessage);
+ cmClient.sendNotification(message);
+ }
+
+
+ private CMNotificationClient setRESTConfAuthorization() {
+ String sdnrUser = getSDNRUser();
+ String sdnrPasswd = getSDNRPasswd();
+
+ CMNotificationClient cmClient = new CMNotificationClient(getBaseUrl());
+ LOG.debug("Setting RESTConf Authorization values - {} : {}", sdnrUser, sdnrPasswd);
+ cmClient.setAuthorization(sdnrUser, sdnrPasswd);
+ return cmClient;
+ }
}
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java
index fff243893..34b8d4031 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerImpl.java
@@ -80,6 +80,9 @@ public abstract class DMaaPVESMsgConsumerImpl implements DMaaPVESMsgConsumer, DM
}
pauseThread();
}
+ } catch (InterruptedException e) {
+ LOG.warn("Caught exception reading from DMaaP VES Message Topic", e);
+ Thread.currentThread().interrupt();
} catch (JsonProcessingException jsonProcessingException) {
LOG.warn("Failed to convert message to JsonNode: {}", jsonProcessingException.getMessage());
} catch (InvalidMessageException invalidMessageException) {
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerMain.java b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerMain.java
index c694f1d2f..3626f534a 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerMain.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/impl/DMaaPVESMsgConsumerMain.java
@@ -28,189 +28,198 @@ import org.slf4j.LoggerFactory;
public class DMaaPVESMsgConsumerMain implements Runnable {
- private static final Logger LOG = LoggerFactory.getLogger(DMaaPVESMsgConsumerMain.class);
- private static final String _PNFREG_CLASS = "org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPPNFRegVESMsgConsumer";
- private static final String _FAULT_CLASS = "org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPFaultVESMsgConsumer";
- private static final String _CM_CLASS = "org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPCMVESMsgConsumer";
- private static final String _PNFREG_DOMAIN = "pnfRegistration";
- private static final String _FAULT_DOMAIN = "fault";
- private static final String _CM_DOMAIN = "provisioning";
-
- boolean threadsRunning = false;
- List<DMaaPVESMsgConsumer> consumers = new LinkedList<>();
- private PNFRegistrationConfig pnfRegistrationConfig;
- private FaultConfig faultConfig;
- private GeneralConfig generalConfig;
- private ProvisioningConfig provisioningConfig;
-
- public DMaaPVESMsgConsumerMain(Map<String, MessageConfig> configMap, GeneralConfig generalConfig) {
- this.generalConfig = generalConfig;
- configMap.forEach(this::initialize);
- }
-
- public void initialize(String domain, MessageConfig domainConfig) {
- LOG.debug("In initialize method : Domain = {} and domainConfig = {}", domain, domainConfig);
- String consumerClass;
- Properties consumerProperties = new Properties();
- if (domain.equalsIgnoreCase(_PNFREG_DOMAIN)) {
- this.pnfRegistrationConfig = (PNFRegistrationConfig) domainConfig;
- consumerClass = _PNFREG_CLASS;
- LOG.debug("Consumer class = {}", consumerClass);
-
- consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_TRANSPORTTYPE,
- pnfRegistrationConfig.getTransportType());
- consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_HOST_PORT,
- pnfRegistrationConfig.getHostPort());
- consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_CONTENTTYPE,
- pnfRegistrationConfig.getContenttype());
- consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_GROUP,
- pnfRegistrationConfig.getConsumerGroup());
- consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_ID,
- pnfRegistrationConfig.getConsumerId());
- consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_TOPIC, pnfRegistrationConfig.getTopic());
- consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_TIMEOUT,
- pnfRegistrationConfig.getTimeout());
- consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_LIMIT, pnfRegistrationConfig.getLimit());
- consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_FETCHPAUSE,
- pnfRegistrationConfig.getFetchPause());
- consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_PROTOCOL,
- pnfRegistrationConfig.getProtocol());
- consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_USERNAME,
- pnfRegistrationConfig.getUsername());
- consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_PASSWORD,
- pnfRegistrationConfig.getPassword());
- consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_CLIENT_READTIMEOUT,
- pnfRegistrationConfig.getClientReadTimeout());
- consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT,
- pnfRegistrationConfig.getClientConnectTimeout());
- consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_URI,
- pnfRegistrationConfig.getHTTPProxyURI());
- consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_USER,
- pnfRegistrationConfig.getHTTPProxyUsername());
- consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_PASSWORD,
- pnfRegistrationConfig.getHTTPProxyPassword());
-
- threadsRunning = createConsumer(_PNFREG_DOMAIN, consumerProperties);
- } else if (domain.equalsIgnoreCase(_FAULT_DOMAIN)) {
- this.faultConfig = (FaultConfig) domainConfig;
- consumerClass = _FAULT_CLASS;
- LOG.debug("Consumer class = {}", consumerClass);
- consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_TRANSPORTTYPE, faultConfig.getTransportType());
- consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_HOST_PORT, faultConfig.getHostPort());
- consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_CONTENTTYPE, faultConfig.getContenttype());
- consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_GROUP, faultConfig.getConsumerGroup());
- consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_ID, faultConfig.getConsumerId());
- consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_TOPIC, faultConfig.getTopic());
- consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_TIMEOUT, faultConfig.getTimeout());
- consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_LIMIT, faultConfig.getLimit());
- consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_FETCHPAUSE, faultConfig.getFetchPause());
- consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_PROTOCOL, faultConfig.getProtocol());
- consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_USERNAME, faultConfig.getUsername());
- consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_PASSWORD, faultConfig.getPassword());
- consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_CLIENT_READTIMEOUT,
- faultConfig.getClientReadTimeout());
- consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT,
- faultConfig.getClientConnectTimeout());
- consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_URI,
- faultConfig.getHTTPProxyURI());
- consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_USER,
- faultConfig.getHTTPProxyUsername());
- consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_PASSWORD,
- faultConfig.getHTTPProxyPassword());
- threadsRunning = createConsumer(_FAULT_DOMAIN, consumerProperties);
- } else if (domain.equalsIgnoreCase(_CM_DOMAIN)) {
- this.provisioningConfig = (ProvisioningConfig) domainConfig;
- consumerClass = _CM_CLASS;
- LOG.debug("Consumer class = {}", consumerClass);
- consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_TRANSPORTTYPE, provisioningConfig.getTransportType());
- consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_HOST_PORT, provisioningConfig.getHostPort());
- consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_CONTENTTYPE, provisioningConfig.getContenttype());
- consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_GROUP, provisioningConfig.getConsumerGroup());
- consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_ID, provisioningConfig.getConsumerId());
- consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_TOPIC, provisioningConfig.getTopic());
- consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_TIMEOUT, provisioningConfig.getTimeout());
- consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_LIMIT, provisioningConfig.getLimit());
- consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_FETCHPAUSE, provisioningConfig.getFetchPause());
- consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_PROTOCOL, provisioningConfig.getProtocol());
- consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_USERNAME, provisioningConfig.getUsername());
- consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_PASSWORD, provisioningConfig.getPassword());
- consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_CLIENT_READTIMEOUT,
- provisioningConfig.getClientReadTimeout());
- consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT,
- provisioningConfig.getClientConnectTimeout());
- consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_URI,
- provisioningConfig.getHTTPProxyURI());
- consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_USER,
- provisioningConfig.getHTTPProxyUsername());
- consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_PASSWORD,
- provisioningConfig.getHTTPProxyPassword());
- threadsRunning = createConsumer(_CM_DOMAIN, consumerProperties);
- }
- }
-
- private boolean updateThreadState(List<DMaaPVESMsgConsumer> consumers) {
- boolean threadsRunning = false;
- for (DMaaPVESMsgConsumer consumer : consumers) {
- if (consumer.isRunning()) {
- threadsRunning = true;
- }
- }
- return threadsRunning;
- }
-
- public boolean createConsumer(String consumerType, Properties properties) {
- DMaaPVESMsgConsumerImpl consumer = null;
-
- if (consumerType.equalsIgnoreCase(_PNFREG_DOMAIN))
- consumer = new DMaaPPNFRegVESMsgConsumer(generalConfig);
- else if (consumerType.equalsIgnoreCase(_FAULT_DOMAIN))
- consumer = new DMaaPFaultVESMsgConsumer(generalConfig);
- else if (consumerType.equalsIgnoreCase(_CM_DOMAIN))
- consumer = new DMaaPCMVESMsgConsumer(generalConfig);
-
- handleConsumer(consumer, properties, consumers);
- return !consumers.isEmpty();
- }
-
- private boolean handleConsumer(DMaaPVESMsgConsumer consumer, Properties properties,
- List<DMaaPVESMsgConsumer> consumers) {
- if (consumer != null) {
- consumer.init(properties);
-
- if (consumer.isReady()) {
- Thread consumerThread = new Thread(consumer);
- consumerThread.start();
- consumers.add(consumer);
-
- LOG.info("Started consumer thread ({} : {})", consumer.getClass().getSimpleName(), properties);
- return true;
- } else {
- LOG.debug("Consumer {} is not ready", consumer.getClass().getSimpleName());
- }
- }
- return false;
- }
-
- @Override
- public void run() {
- while (threadsRunning) {
- threadsRunning = updateThreadState(consumers);
- if (!threadsRunning) {
- break;
- }
-
- try {
- Thread.sleep(10000);
- } catch (InterruptedException e) {
- LOG.error(e.getLocalizedMessage(), e);
- }
- }
-
- LOG.info("No listener threads running - exiting");
- }
-
- public List<DMaaPVESMsgConsumer> getConsumers() {
- return consumers;
- }
+ private static final Logger LOG = LoggerFactory.getLogger(DMaaPVESMsgConsumerMain.class);
+ private static final String _PNFREG_CLASS =
+ "org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPPNFRegVESMsgConsumer";
+ private static final String _FAULT_CLASS =
+ "org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPFaultVESMsgConsumer";
+ private static final String _CM_CLASS =
+ "org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.DMaaPCMVESMsgConsumer";
+ private static final String _PNFREG_DOMAIN = "pnfRegistration";
+ private static final String _FAULT_DOMAIN = "fault";
+ private static final String _CM_DOMAIN = "provisioning";
+
+ boolean threadsRunning = false;
+ List<DMaaPVESMsgConsumer> consumers = new LinkedList<>();
+ private PNFRegistrationConfig pnfRegistrationConfig;
+ private FaultConfig faultConfig;
+ private GeneralConfig generalConfig;
+ private ProvisioningConfig provisioningConfig;
+
+ public DMaaPVESMsgConsumerMain(Map<String, MessageConfig> configMap, GeneralConfig generalConfig) {
+ this.generalConfig = generalConfig;
+ configMap.forEach(this::initialize);
+ }
+
+ public void initialize(String domain, MessageConfig domainConfig) {
+ LOG.debug("In initialize method : Domain = {} and domainConfig = {}", domain, domainConfig);
+ String consumerClass;
+ Properties consumerProperties = new Properties();
+ if (domain.equalsIgnoreCase(_PNFREG_DOMAIN)) {
+ this.pnfRegistrationConfig = (PNFRegistrationConfig) domainConfig;
+ consumerClass = _PNFREG_CLASS;
+ LOG.debug("Consumer class = {}", consumerClass);
+
+ consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_TRANSPORTTYPE,
+ pnfRegistrationConfig.getTransportType());
+ consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_HOST_PORT,
+ pnfRegistrationConfig.getHostPort());
+ consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_CONTENTTYPE,
+ pnfRegistrationConfig.getContenttype());
+ consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_GROUP,
+ pnfRegistrationConfig.getConsumerGroup());
+ consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_ID,
+ pnfRegistrationConfig.getConsumerId());
+ consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_TOPIC, pnfRegistrationConfig.getTopic());
+ consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_TIMEOUT,
+ pnfRegistrationConfig.getTimeout());
+ consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_LIMIT, pnfRegistrationConfig.getLimit());
+ consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_FETCHPAUSE,
+ pnfRegistrationConfig.getFetchPause());
+ consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_PROTOCOL,
+ pnfRegistrationConfig.getProtocol());
+ consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_USERNAME,
+ pnfRegistrationConfig.getUsername());
+ consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_PASSWORD,
+ pnfRegistrationConfig.getPassword());
+ consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_CLIENT_READTIMEOUT,
+ pnfRegistrationConfig.getClientReadTimeout());
+ consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT,
+ pnfRegistrationConfig.getClientConnectTimeout());
+ consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_URI,
+ pnfRegistrationConfig.getHTTPProxyURI());
+ consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_USER,
+ pnfRegistrationConfig.getHTTPProxyUsername());
+ consumerProperties.put(PNFRegistrationConfig.PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_PASSWORD,
+ pnfRegistrationConfig.getHTTPProxyPassword());
+
+ threadsRunning = createConsumer(_PNFREG_DOMAIN, consumerProperties);
+ } else if (domain.equalsIgnoreCase(_FAULT_DOMAIN)) {
+ this.faultConfig = (FaultConfig) domainConfig;
+ consumerClass = _FAULT_CLASS;
+ LOG.debug("Consumer class = {}", consumerClass);
+ consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_TRANSPORTTYPE, faultConfig.getTransportType());
+ consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_HOST_PORT, faultConfig.getHostPort());
+ consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_CONTENTTYPE, faultConfig.getContenttype());
+ consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_GROUP, faultConfig.getConsumerGroup());
+ consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_ID, faultConfig.getConsumerId());
+ consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_TOPIC, faultConfig.getTopic());
+ consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_TIMEOUT, faultConfig.getTimeout());
+ consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_LIMIT, faultConfig.getLimit());
+ consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_FETCHPAUSE, faultConfig.getFetchPause());
+ consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_PROTOCOL, faultConfig.getProtocol());
+ consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_USERNAME, faultConfig.getUsername());
+ consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_PASSWORD, faultConfig.getPassword());
+ consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_CLIENT_READTIMEOUT,
+ faultConfig.getClientReadTimeout());
+ consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT,
+ faultConfig.getClientConnectTimeout());
+ consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_URI,
+ faultConfig.getHTTPProxyURI());
+ consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_USER,
+ faultConfig.getHTTPProxyUsername());
+ consumerProperties.put(FaultConfig.PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_PASSWORD,
+ faultConfig.getHTTPProxyPassword());
+ threadsRunning = createConsumer(_FAULT_DOMAIN, consumerProperties);
+ } else if (domain.equalsIgnoreCase(_CM_DOMAIN)) {
+ this.provisioningConfig = (ProvisioningConfig) domainConfig;
+ consumerClass = _CM_CLASS;
+ LOG.debug("Consumer class = {}", consumerClass);
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_TRANSPORTTYPE,
+ provisioningConfig.getTransportType());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_HOST_PORT,
+ provisioningConfig.getHostPort());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_CONTENTTYPE,
+ provisioningConfig.getContenttype());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_GROUP,
+ provisioningConfig.getConsumerGroup());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_ID, provisioningConfig.getConsumerId());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_TOPIC, provisioningConfig.getTopic());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_TIMEOUT, provisioningConfig.getTimeout());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_LIMIT, provisioningConfig.getLimit());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_FETCHPAUSE,
+ provisioningConfig.getFetchPause());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_PROTOCOL, provisioningConfig.getProtocol());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_USERNAME, provisioningConfig.getUsername());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_PASSWORD, provisioningConfig.getPassword());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_CLIENT_READTIMEOUT,
+ provisioningConfig.getClientReadTimeout());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_CLIENT_CONNECTTIMEOUT,
+ provisioningConfig.getClientConnectTimeout());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_URI,
+ provisioningConfig.getHTTPProxyURI());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_USER,
+ provisioningConfig.getHTTPProxyUsername());
+ consumerProperties.put(ProvisioningConfig.PROPERTY_KEY_CONSUMER_CLIENT_HTTPPROXY_AUTH_PASSWORD,
+ provisioningConfig.getHTTPProxyPassword());
+ threadsRunning = createConsumer(_CM_DOMAIN, consumerProperties);
+ }
+ }
+
+ private boolean updateThreadState(List<DMaaPVESMsgConsumer> consumers) {
+ boolean threadsRunning = false;
+ for (DMaaPVESMsgConsumer consumer : consumers) {
+ if (consumer.isRunning()) {
+ threadsRunning = true;
+ }
+ }
+ return threadsRunning;
+ }
+
+ public boolean createConsumer(String consumerType, Properties properties) {
+ DMaaPVESMsgConsumerImpl consumer = null;
+
+ if (consumerType.equalsIgnoreCase(_PNFREG_DOMAIN))
+ consumer = new DMaaPPNFRegVESMsgConsumer(generalConfig);
+ else if (consumerType.equalsIgnoreCase(_FAULT_DOMAIN))
+ consumer = new DMaaPFaultVESMsgConsumer(generalConfig);
+ else if (consumerType.equalsIgnoreCase(_CM_DOMAIN))
+ consumer = new DMaaPCMVESMsgConsumer(generalConfig);
+
+ handleConsumer(consumer, properties, consumers);
+ return !consumers.isEmpty();
+ }
+
+ private boolean handleConsumer(DMaaPVESMsgConsumer consumer, Properties properties,
+ List<DMaaPVESMsgConsumer> consumers) {
+ if (consumer != null) {
+ consumer.init(properties);
+
+ if (consumer.isReady()) {
+ Thread consumerThread = new Thread(consumer);
+ consumerThread.start();
+ consumers.add(consumer);
+
+ LOG.info("Started consumer thread ({} : {})", consumer.getClass().getSimpleName(), properties);
+ return true;
+ } else {
+ LOG.debug("Consumer {} is not ready", consumer.getClass().getSimpleName());
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public void run() {
+ while (threadsRunning) {
+ threadsRunning = updateThreadState(consumers);
+ if (!threadsRunning) {
+ break;
+ }
+
+ try {
+ Thread.sleep(10000);
+ } catch (InterruptedException e) {
+ LOG.error(e.getLocalizedMessage(), e);
+ Thread.currentThread().interrupt();
+ }
+ }
+
+ LOG.info("No listener threads running - exiting");
+ }
+
+ public List<DMaaPVESMsgConsumer> getConsumers() {
+ return consumers;
+ }
}
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestCMBasicHeaderFieldsNotification.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestCMBasicHeaderFieldsNotification.java
new file mode 100644
index 000000000..5446da048
--- /dev/null
+++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestCMBasicHeaderFieldsNotification.java
@@ -0,0 +1,45 @@
+/*
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt mountpoint-registrar
+ * =================================================================================================
+ * Copyright (C) 2021 Samsung Electronics 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.mountpointregistrar.test;
+
+import static org.junit.Assert.assertEquals;
+
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.CMBasicHeaderFieldsNotification;
+
+public class TestCMBasicHeaderFieldsNotification {
+
+ private CMBasicHeaderFieldsNotification cmBasicFields;
+
+ @Test
+ public void testCMBasicFieldsBuilder() {
+ cmBasicFields = cmBasicFields.builder()
+ .withCMNodeId("test-node")
+ .withCMSequence("1")
+ .withCMOccurrenceTime("2021-10-18T15:25:19.948Z")
+ .withSourceId("src_device_id_1732")
+ .withNotificationType("notifyMOIChanges")
+ .build();
+
+ assertEquals("test-node", cmBasicFields.getCmNodeId());
+ assertEquals("1", cmBasicFields.getCmSequence());
+ assertEquals("src_device_id_1732", cmBasicFields.getSourceId());
+ assertEquals("2021-10-18T15:25:19.948Z", cmBasicFields.getCmOccurrenceTime());
+ assertEquals("notifyMOIChanges", cmBasicFields.getNotificationType());
+ }
+} \ No newline at end of file
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestCMNotificationBuilder.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestCMNotificationBuilder.java
new file mode 100644
index 000000000..3b74df321
--- /dev/null
+++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestCMNotificationBuilder.java
@@ -0,0 +1,79 @@
+/*
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt mountpoint-registrar
+ * =================================================================================================
+ * Copyright (C) 2021 Samsung Electronics 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.mountpointregistrar.test;
+
+import static org.junit.Assert.*;
+
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.CMBasicHeaderFieldsNotification;
+import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.CMNotification;
+
+public class TestCMNotificationBuilder {
+
+ private CMNotification cmNotification;
+
+ @Test
+ public void testCMNotificationBuilderWithAllDefinedFields() {
+ cmNotification = cmNotification.builder()
+ .withCMBasicHeaderFieldsNotification(CMBasicHeaderFieldsNotification.builder()
+ .withCMNodeId("test-node")
+ .withCMSequence("1")
+ .withCMOccurrenceTime("2021-10-18T15:25:19.948Z")
+ .withSourceId("src_device_id_1732")
+ .withNotificationType("notifyMOIChanges")
+ .build())
+ .withCMNotificationId("123")
+ .withCMSourceIndicator("UNKNOWN")
+ .withCMPath("http://samsung.com/ves=1")
+ .withCMOperation("CREATE")
+ .withCMValue("value")
+ .build();
+
+ assertEquals("test-node", cmNotification.getBasicHeaderFields().getCmNodeId());
+ assertEquals("1", cmNotification.getBasicHeaderFields().getCmSequence());
+ assertEquals("src_device_id_1732", cmNotification.getBasicHeaderFields().getSourceId());
+ assertEquals("2021-10-18T15:25:19.948Z", cmNotification.getBasicHeaderFields().getCmOccurrenceTime());
+ assertEquals("notifyMOIChanges", cmNotification.getBasicHeaderFields().getNotificationType());
+ assertEquals("123", cmNotification.getCmNotificationId());
+ assertEquals("UNKNOWN", cmNotification.getCmSourceIndicator());
+ assertEquals("http://samsung.com/ves=1", cmNotification.getCmPath());
+ assertEquals("CREATE", cmNotification.getCmOperation());
+ assertEquals("value", cmNotification.getCmValue());
+ }
+
+ @Test
+ public void testCMNotificationBuilderWithDefaultCMOperation() {
+ cmNotification = cmNotification.builder()
+ .withCMBasicHeaderFieldsNotification(CMBasicHeaderFieldsNotification.builder()
+ .withCMNodeId("test-node")
+ .withCMSequence("1")
+ .withCMOccurrenceTime("2021-10-18T15:25:19.948Z")
+ .withSourceId("src_device_id_1732")
+ .withNotificationType("notifyMOIChanges")
+ .build())
+ .withCMNotificationId("123")
+ .withCMSourceIndicator("UNKNOWN")
+ .withCMPath("http://samsung.com/ves=1")
+ .build();
+
+ assertEquals("test-node", cmNotification.getBasicHeaderFields().getCmNodeId());
+ assertEquals("NULL", cmNotification.getCmOperation());
+ assertNull(cmNotification.getCmValue());
+ }
+} \ No newline at end of file
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestCMNotificationClient.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestCMNotificationClient.java
new file mode 100644
index 000000000..12ccd4c62
--- /dev/null
+++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestCMNotificationClient.java
@@ -0,0 +1,70 @@
+/*
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt mountpoint-registrar
+ * =================================================================================================
+ * Copyright (C) 2021 Samsung Electronics 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.mountpointregistrar.test;
+
+import static org.junit.Assert.assertTrue;
+
+import java.util.Map;
+import javax.annotation.Nonnull;
+import org.junit.Test;
+import org.onap.ccsdk.features.sdnr.wt.common.http.BaseHTTPResponse;
+import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.CMBasicHeaderFieldsNotification;
+import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.CMNotification;
+import org.onap.ccsdk.features.sdnr.wt.mountpointregistrar.impl.CMNotificationClient;
+
+public class TestCMNotificationClient extends CMNotificationClient {
+ public static String baseUrl = "http://localhost:8181";
+ CMNotificationClient testClient;
+
+ public TestCMNotificationClient() {
+ super(baseUrl);
+ }
+
+ @Test
+ public void testCMNotificationClient() {
+ testClient = new TestCMNotificationClient();
+ testClient.setAuthorization("admin", "admin");
+
+ String msg = testClient.prepareMessageFromPayloadMap(
+ CMNotificationClient.createCMNotificationPayloadMap(
+ CMNotification.builder()
+ .withCMBasicHeaderFieldsNotification(CMBasicHeaderFieldsNotification.builder()
+ .withCMNodeId("test-node")
+ .withCMSequence("1")
+ .withCMOccurrenceTime("2021-10-18T15:25:19.948Z")
+ .withSourceId("src_device_id_1732")
+ .withNotificationType("notifyMOIChanges")
+ .build())
+ .withCMNotificationId("123")
+ .withCMSourceIndicator("UNKNOWN")
+ .withCMPath("http://samsung.com/ves=1")
+ .withCMOperation("CREATE")
+ .withCMValue("value")
+ .build()
+ ));
+ assertTrue(testClient.sendNotification(msg));
+ }
+
+ @Override
+ @Nonnull
+ public BaseHTTPResponse sendRequest(String uri, String method, String body, Map<String, String> headers) {
+ System.out.println("In overridden sendRequest in TestCMNotificationClient");
+ return new BaseHTTPResponse(200, body);
+ }
+} \ No newline at end of file
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPCMVESMsgConsumer.java b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPCMVESMsgConsumer.java
index 0cd7f0228..2c4fb647b 100644
--- a/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPCMVESMsgConsumer.java
+++ b/sdnr/wt/mountpoint-registrar/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/mountpointregistrar/test/TestDMaaPCMVESMsgConsumer.java
@@ -30,7 +30,13 @@ import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Files;
import java.nio.file.Paths;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
import static org.junit.Assert.fail;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNull;
+import java.util.Iterator;
+import java.util.Map;
public class TestDMaaPCMVESMsgConsumer {
@@ -62,6 +68,14 @@ public class TestDMaaPCMVESMsgConsumer {
dMaaPCMVESMsgConsumer.processMsg(cmEvent);
}
+ @Test(expected = InvalidMessageException.class)
+ public void processMsgThatHasInvalidNotificationType()
+ throws URISyntaxException, IOException, InvalidMessageException {
+ File cmFileInvalid = new File(TestDMaaPCMVESMsgConsumer.class.getResource("/msgs/cm_invalid_type.json").toURI());
+ String cmEvent = readFileToString(cmFileInvalid);
+ dMaaPCMVESMsgConsumer.processMsg(cmEvent);
+ }
+
@Test(expected = JsonProcessingException.class)
public void processMsgThatIsNotValidJson() throws URISyntaxException, IOException, InvalidMessageException {
File cmFileInvalid = new File(TestDMaaPCMVESMsgConsumer.class.getResource("/msgs/not_a_json.json").toURI());
@@ -69,12 +83,155 @@ public class TestDMaaPCMVESMsgConsumer {
dMaaPCMVESMsgConsumer.processMsg(cmEvent);
}
+ @Test
+ public void processMsgWithOneElementMoiChangesArray() throws URISyntaxException, IOException {
+ File cmFileValid = new File(TestDMaaPCMVESMsgConsumer.class.getResource("/msgs/cm_valid.json").toURI());
+ String cmEvent = readFileToString(cmFileValid);
+ try {
+ JsonNode rootNode = convertMessageToJsonNode(cmEvent);
+ Iterator<JsonNode> nodes = rootNode
+ .at("/event/stndDefinedFields/data/moiChanges")
+ .elements();
+ Map<String, String> payloadMap =
+ dMaaPCMVESMsgConsumer.preparePayloadMapFromMoiChangesArray(rootNode, nodes);
+
+ assertEquals("samsung-O-DU-1122", payloadMap.get("@node-id@"));
+ assertEquals("0", payloadMap.get("@counter@"));
+ assertEquals("2019-01-09T12:30:07.722Z", payloadMap.get("@timestamp@"));
+ assertEquals("src_device_id_1732f1ad-53fd-4fd1-8b73-a677987d4e8f", payloadMap.get("@object-id@"));
+ assertEquals("notifyMOIChanges", payloadMap.get("@notification-type@"));
+ assertEquals("123", payloadMap.get("@notification-id@"));
+ assertEquals("MANAGEMENT_OPERATION", payloadMap.get("@source-indicator@"));
+ assertEquals("https://samsung.com/3GPP/simulation/network-function/ves=1", payloadMap.get("@path@"));
+ assertEquals("REPLACE", payloadMap.get("@operation@"));
+ assertEquals("{pnf-registration:true,faults-enabled:true}", payloadMap.get("@value@"));
+
+ } catch (Exception e) {
+ fail("Test fail with message: " + e.getMessage());
+ }
+ }
+
+ @Test
+ public void processMsgWithTwoElementMoiChangesArray() throws URISyntaxException, IOException {
+ File cmFileValid =
+ new File(TestDMaaPCMVESMsgConsumer.class.getResource("/msgs/cm_valid_two_element_moi_changes_array.json")
+ .toURI());
+ String cmEvent = readFileToString(cmFileValid);
+ try {
+ JsonNode rootNode = convertMessageToJsonNode(cmEvent);
+ Iterator<JsonNode> nodes = rootNode
+ .at("/event/stndDefinedFields/data/moiChanges")
+ .elements();
+ Map<String, String> payloadMap =
+ dMaaPCMVESMsgConsumer.preparePayloadMapFromMoiChangesArray(rootNode, nodes);
+
+ assertEquals("samsung-O-DU-1122", payloadMap.get("@node-id@"));
+ assertEquals("0", payloadMap.get("@counter@"));
+ assertEquals("2019-01-09T12:30:07.722Z", payloadMap.get("@timestamp@"));
+ assertEquals("src_device_id_1732f1ad-53fd-4fd1-8b73-a677987d4e8f", payloadMap.get("@object-id@"));
+ assertEquals("notifyMOIChanges", payloadMap.get("@notification-type@"));
+ assertEquals("123", payloadMap.get("@notification-id@"));
+ assertEquals("MANAGEMENT_OPERATION", payloadMap.get("@source-indicator@"));
+ assertEquals("https://samsung.com/3GPP/simulation/network-function/ves=1", payloadMap.get("@path@"));
+ assertEquals("REPLACE", payloadMap.get("@operation@"));
+ assertEquals("{pnf-registration:true,faults-enabled:true}", payloadMap.get("@value@"));
+
+ Map<String, String> payloadMap2 = null;
+ while (nodes.hasNext()) {
+ payloadMap2 = dMaaPCMVESMsgConsumer.preparePayloadMapFromMoiChangesArray(rootNode, nodes);
+ }
+ assertEquals("samsung-O-DU-1122", payloadMap2.get("@node-id@"));
+ assertEquals("124", payloadMap2.get("@notification-id@"));
+ assertEquals("RESOURCE_OPERATION", payloadMap2.get("@source-indicator@"));
+ assertEquals("https://samsung.com/3GPP/simulation/network-function/ves=2", payloadMap2.get("@path@"));
+ assertEquals("CREATE", payloadMap2.get("@operation@"));
+ assertEquals("{pnf-registration:false,faults-enabled:false}", payloadMap2.get("@value@"));
+
+ } catch (Exception e) {
+ fail("Test fail with message: " + e.getMessage());
+ }
+ }
+
+ @Test
+ public void processMsgNotifyMoiCreationType() throws URISyntaxException, IOException {
+ File cmFileValid = new File(TestDMaaPCMVESMsgConsumer.class.getResource("/msgs/cm_moi_creation.json").toURI());
+ String cmEvent = readFileToString(cmFileValid);
+ try {
+ JsonNode rootNode = convertMessageToJsonNode(cmEvent);
+ Map<String, String> payloadMap = dMaaPCMVESMsgConsumer.preparePayloadMapFromMoi(rootNode,"/event/stndDefinedFields/data/attributeList");
+ assertEquals("samsung-O-DU-1122", payloadMap.get("@node-id@"));
+ assertEquals("0", payloadMap.get("@counter@"));
+ assertEquals("2019-01-09T12:30:07.722Z", payloadMap.get("@timestamp@"));
+ assertEquals("src_device_id_1732f1ad-53fd-4fd1-8b73-a677987d4e8f", payloadMap.get("@object-id@"));
+ assertEquals("notifyMOICreation", payloadMap.get("@notification-type@"));
+ assertNull(payloadMap.get("@notification-id@"));
+ assertEquals("MANAGEMENT_OPERATION", payloadMap.get("@source-indicator@"));
+ assertNull(payloadMap.get("@path@"));
+ assertEquals("NULL", payloadMap.get("@operation@"));
+ assertEquals("{pnf-registration:true,faults-enabled:true}", payloadMap.get("@value@"));
+
+ } catch (Exception e) {
+ fail("Test fail with message: " + e.getMessage());
+ }
+ }
+
+ @Test
+ public void processMsgNotifyMoiDeletionType() throws URISyntaxException, IOException {
+ File cmFileValid = new File(TestDMaaPCMVESMsgConsumer.class.getResource("/msgs/cm_moi_deletion.json").toURI());
+ String cmEvent = readFileToString(cmFileValid);
+ try {
+ JsonNode rootNode = convertMessageToJsonNode(cmEvent);
+ Map<String, String> payloadMap = dMaaPCMVESMsgConsumer.preparePayloadMapFromMoi(rootNode,"/event/stndDefinedFields/data/attributeList");
+ assertEquals("samsung-O-DU-1122", payloadMap.get("@node-id@"));
+ assertEquals("0", payloadMap.get("@counter@"));
+ assertEquals("2019-01-09T12:30:07.722Z", payloadMap.get("@timestamp@"));
+ assertEquals("src_device_id_1732f1ad-53fd-4fd1-8b73-a677987d4e8f", payloadMap.get("@object-id@"));
+ assertEquals("notifyMOIDeletion", payloadMap.get("@notification-type@"));
+ assertNull(payloadMap.get("@notification-id@"));
+ assertEquals("MANAGEMENT_OPERATION", payloadMap.get("@source-indicator@"));
+ assertNull(payloadMap.get("@path@"));
+ assertEquals("NULL", payloadMap.get("@operation@"));
+ assertEquals("{pnf-registration:true,faults-enabled:true}", payloadMap.get("@value@"));
+
+ } catch (Exception e) {
+ fail("Test fail with message: " + e.getMessage());
+ }
+ }
+
+ @Test
+ public void processMsgNotifyMoiAttributeValueChangesType() throws URISyntaxException, IOException {
+ File cmFileValid =
+ new File(TestDMaaPCMVESMsgConsumer.class.getResource("/msgs/cm_moi_attribute_value_changes.json").toURI());
+ String cmEvent = readFileToString(cmFileValid);
+ try {
+ JsonNode rootNode = convertMessageToJsonNode(cmEvent);
+ Map<String, String> payloadMap = dMaaPCMVESMsgConsumer.preparePayloadMapFromMoi(rootNode,"/event/stndDefinedFields/data/attributeListValueChanges");
+ assertEquals("samsung-O-DU-1122", payloadMap.get("@node-id@"));
+ assertEquals("0", payloadMap.get("@counter@"));
+ assertEquals("2019-01-09T12:30:07.722Z", payloadMap.get("@timestamp@"));
+ assertEquals("src_device_id_1732f1ad-53fd-4fd1-8b73-a677987d4e8f", payloadMap.get("@object-id@"));
+ assertEquals("notifyMOIAttributeValueChanges", payloadMap.get("@notification-type@"));
+ assertNull(payloadMap.get("@notification-id@"));
+ assertEquals("UNKNOWN", payloadMap.get("@source-indicator@"));
+ assertNull(payloadMap.get("@path@"));
+ assertEquals("NULL", payloadMap.get("@operation@"));
+ assertEquals("[{attributeNameValuePairSet:{faults-enabled:true}}]", payloadMap.get("@value@"));
+
+ } catch (Exception e) {
+ fail("Test fail with message: " + e.getMessage());
+ }
+ }
+
private String readFileToString(File file) throws IOException {
StringBuilder fileContent = new StringBuilder();
Files.lines(Paths.get(file.toURI())).forEach(fileContent::append);
return fileContent.toString();
}
+ private JsonNode convertMessageToJsonNode(String message) throws JsonProcessingException {
+ return new ObjectMapper().readTree(message);
+ }
+
@After
public void after() {
generalConfigForTest.close();
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_invalid_type.json b/sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_invalid_type.json
new file mode 100644
index 000000000..ded304032
--- /dev/null
+++ b/sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_invalid_type.json
@@ -0,0 +1,49 @@
+{
+ "event": {
+ "commonEventHeader": {
+ "version": "4.1",
+ "vesEventListenerVersion": "7.2",
+ "domain": "stndDefined",
+ "stndDefinedNamespace": "3GPP-Provisioning",
+ "eventId": "cm0004012",
+ "eventName": "ves_stdnDefined_3GPP-Provisioning",
+ "nfNamingCode": "NFNC",
+ "nfVendorName": "POC",
+ "nfcNamingCode": "NFC",
+ "priority": "Medium",
+ "reportingEntityId": "device_id_1732f1ad-53fd-4fd1-8b73-a677987d4e8f",
+ "reportingEntityName": "samsung-O-DU-1122",
+ "sequence": 0,
+ "sourceId": "src_device_id_1732f1ad-53fd-4fd1-8b73-a677987d4e8f",
+ "sourceName": "samsung-O-DU-1122",
+ "startEpochMicrosec": 1547037007722752,
+ "lastEpochMicrosec": 1547037028498530,
+ "timeZoneOffset": "UTC-05:30"
+ },
+ "stndDefinedFields": {
+ "schemaReference": "https://forge.3gpp.org/rep/sa5/MnS/blob/Rel16/OpenAPI/provMnS.yaml#/components/schemas/NotifyMoiChanges",
+ "data": {
+ "href": "href1",
+ "notificationId": 1,
+ "notificationType": "type",
+ "eventTime": "2021-08-23T11:52:10.6Z",
+ "systemDN": "xyz",
+ "moiChanges": [
+ {
+ "notificationId": 123,
+ "correlatedNotifications": [],
+ "additionalText": "AdditionalTextDetails",
+ "sourceIndicator": "MANAGEMENT_OPERATION",
+ "path":"https://samsung.com/3GPP/simulation/network-function/ves=1",
+ "operation": "REPLACE",
+ "value": {
+ "pnf-registration": "true",
+ "faults-enabled": "true"
+ }
+ }
+ ]
+ },
+ "stndDefinedFieldsVersion": "1.0"
+ }
+ }
+} \ No newline at end of file
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_moi_attribute_value_changes.json b/sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_moi_attribute_value_changes.json
new file mode 100644
index 000000000..088bdd3e5
--- /dev/null
+++ b/sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_moi_attribute_value_changes.json
@@ -0,0 +1,45 @@
+{
+ "event": {
+ "commonEventHeader": {
+ "version": "4.1",
+ "vesEventListenerVersion": "7.2",
+ "domain": "stndDefined",
+ "stndDefinedNamespace": "3GPP-Provisioning",
+ "eventId": "cm0004012",
+ "eventName": "ves_stdnDefined_3GPP-Provisioning",
+ "nfNamingCode": "NFNC",
+ "nfVendorName": "POC",
+ "nfcNamingCode": "NFC",
+ "priority": "Medium",
+ "reportingEntityId": "device_id_1732f1ad-53fd-4fd1-8b73-a677987d4e8f",
+ "reportingEntityName": "samsung-O-DU-1122",
+ "sequence": 0,
+ "sourceId": "src_device_id_1732f1ad-53fd-4fd1-8b73-a677987d4e8f",
+ "sourceName": "samsung-O-DU-1122",
+ "startEpochMicrosec": 1547037007722752,
+ "lastEpochMicrosec": 1547037028498530,
+ "timeZoneOffset": "UTC-05:30"
+ },
+ "stndDefinedFields": {
+ "schemaReference": "https://forge.3gpp.org/rep/sa5/MnS/blob/Rel16/OpenAPI/provMnS.yaml#/components/schemas/NotifyMoiAttributeValueChanges",
+ "data": {
+ "href": "href1",
+ "notificationId": 1,
+ "notificationType": "notifyMOIAttributeValueChanges",
+ "eventTime": "2021-08-23T11:52:10.6Z",
+ "systemDN": "xyz",
+ "correlatedNotifications": [],
+ "additionalText": "AdditionalTextDetails",
+ "sourceIndicator": "UNKNOWN",
+ "attributeListValueChanges": [
+ {
+ "attributeNameValuePairSet": {
+ "faults-enabled": "true"
+ }
+ }
+ ]
+ },
+ "stndDefinedFieldsVersion": "1.0"
+ }
+ }
+} \ No newline at end of file
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_moi_creation.json b/sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_moi_creation.json
new file mode 100644
index 000000000..a43edbb58
--- /dev/null
+++ b/sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_moi_creation.json
@@ -0,0 +1,42 @@
+{
+ "event": {
+ "commonEventHeader": {
+ "version": "4.1",
+ "vesEventListenerVersion": "7.2",
+ "domain": "stndDefined",
+ "stndDefinedNamespace": "3GPP-Provisioning",
+ "eventId": "cm0004012",
+ "eventName": "ves_stdnDefined_3GPP-Provisioning",
+ "nfNamingCode": "NFNC",
+ "nfVendorName": "POC",
+ "nfcNamingCode": "NFC",
+ "priority": "Medium",
+ "reportingEntityId": "device_id_1732f1ad-53fd-4fd1-8b73-a677987d4e8f",
+ "reportingEntityName": "samsung-O-DU-1122",
+ "sequence": 0,
+ "sourceId": "src_device_id_1732f1ad-53fd-4fd1-8b73-a677987d4e8f",
+ "sourceName": "samsung-O-DU-1122",
+ "startEpochMicrosec": 1547037007722752,
+ "lastEpochMicrosec": 1547037028498530,
+ "timeZoneOffset": "UTC-05:30"
+ },
+ "stndDefinedFields": {
+ "schemaReference": "https://forge.3gpp.org/rep/sa5/MnS/blob/Rel16/OpenAPI/provMnS.yaml#/components/schemas/NotifyMoiCreation",
+ "data": {
+ "href": "href1",
+ "notificationId": 1,
+ "notificationType": "notifyMOICreation",
+ "eventTime": "2021-08-23T11:52:10.6Z",
+ "systemDN": "xyz",
+ "correlatedNotifications": [],
+ "additionalText": "AdditionalTextDetails",
+ "sourceIndicator": "MANAGEMENT_OPERATION",
+ "attributeList": {
+ "pnf-registration": "true",
+ "faults-enabled": "true"
+ }
+ },
+ "stndDefinedFieldsVersion": "1.0"
+ }
+ }
+} \ No newline at end of file
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_moi_deletion.json b/sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_moi_deletion.json
new file mode 100644
index 000000000..28c2fefc2
--- /dev/null
+++ b/sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_moi_deletion.json
@@ -0,0 +1,42 @@
+{
+ "event": {
+ "commonEventHeader": {
+ "version": "4.1",
+ "vesEventListenerVersion": "7.2",
+ "domain": "stndDefined",
+ "stndDefinedNamespace": "3GPP-Provisioning",
+ "eventId": "cm0004012",
+ "eventName": "ves_stdnDefined_3GPP-Provisioning",
+ "nfNamingCode": "NFNC",
+ "nfVendorName": "POC",
+ "nfcNamingCode": "NFC",
+ "priority": "Medium",
+ "reportingEntityId": "device_id_1732f1ad-53fd-4fd1-8b73-a677987d4e8f",
+ "reportingEntityName": "samsung-O-DU-1122",
+ "sequence": 0,
+ "sourceId": "src_device_id_1732f1ad-53fd-4fd1-8b73-a677987d4e8f",
+ "sourceName": "samsung-O-DU-1122",
+ "startEpochMicrosec": 1547037007722752,
+ "lastEpochMicrosec": 1547037028498530,
+ "timeZoneOffset": "UTC-05:30"
+ },
+ "stndDefinedFields": {
+ "schemaReference": "https://forge.3gpp.org/rep/sa5/MnS/blob/Rel16/OpenAPI/provMnS.yaml#/components/schemas/NotifyMoiDeletion",
+ "data": {
+ "href": "href1",
+ "notificationId": 1,
+ "notificationType": "notifyMOIDeletion",
+ "eventTime": "2021-08-23T11:52:10.6Z",
+ "systemDN": "xyz",
+ "correlatedNotifications": [],
+ "additionalText": "AdditionalTextDetails",
+ "sourceIndicator": "MANAGEMENT_OPERATION",
+ "attributeList": {
+ "pnf-registration": "true",
+ "faults-enabled": "true"
+ }
+ },
+ "stndDefinedFieldsVersion": "1.0"
+ }
+ }
+} \ No newline at end of file
diff --git a/sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_valid_two_element_moi_changes_array.json b/sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_valid_two_element_moi_changes_array.json
new file mode 100644
index 000000000..44008479d
--- /dev/null
+++ b/sdnr/wt/mountpoint-registrar/provider/src/test/resources/msgs/cm_valid_two_element_moi_changes_array.json
@@ -0,0 +1,61 @@
+{
+ "event": {
+ "commonEventHeader": {
+ "version": "4.1",
+ "vesEventListenerVersion": "7.2",
+ "domain": "stndDefined",
+ "stndDefinedNamespace": "3GPP-Provisioning",
+ "eventId": "cm0004012",
+ "eventName": "ves_stdnDefined_3GPP-Provisioning",
+ "nfNamingCode": "NFNC",
+ "nfVendorName": "POC",
+ "nfcNamingCode": "NFC",
+ "priority": "Medium",
+ "reportingEntityId": "device_id_1732f1ad-53fd-4fd1-8b73-a677987d4e8f",
+ "reportingEntityName": "samsung-O-DU-1122",
+ "sequence": 0,
+ "sourceId": "src_device_id_1732f1ad-53fd-4fd1-8b73-a677987d4e8f",
+ "sourceName": "samsung-O-DU-1122",
+ "startEpochMicrosec": 1547037007722752,
+ "lastEpochMicrosec": 1547037028498530,
+ "timeZoneOffset": "UTC-05:30"
+ },
+ "stndDefinedFields": {
+ "schemaReference": "https://forge.3gpp.org/rep/sa5/MnS/blob/Rel16/OpenAPI/provMnS.yaml#/components/schemas/NotifyMoiChanges",
+ "data": {
+ "href": "href1",
+ "notificationId": 1,
+ "notificationType": "notifyMOIChanges",
+ "eventTime": "2021-08-23T11:52:10.6Z",
+ "systemDN": "xyz",
+ "moiChanges": [
+ {
+ "notificationId": 123,
+ "correlatedNotifications": [],
+ "additionalText": "AdditionalTextDetails",
+ "sourceIndicator": "MANAGEMENT_OPERATION",
+ "path": "https://samsung.com/3GPP/simulation/network-function/ves=1",
+ "operation": "REPLACE",
+ "value": {
+ "pnf-registration": "true",
+ "faults-enabled": "true"
+ }
+ },
+ {
+ "notificationId": 124,
+ "correlatedNotifications": [],
+ "additionalText": "AdditionalTextDetails",
+ "sourceIndicator": "RESOURCE_OPERATION",
+ "path": "https://samsung.com/3GPP/simulation/network-function/ves=2",
+ "operation": "CREATE",
+ "value": {
+ "pnf-registration": "false",
+ "faults-enabled": "false"
+ }
+ }
+ ]
+ },
+ "stndDefinedFieldsVersion": "1.0"
+ }
+ }
+} \ No newline at end of file