2 * ============LICENSE_START=======================================================
3 * ONAP : ccsdk features
4 * ================================================================================
5 * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
7 * ================================================================================
8 * Update Copyright (C) 2021 Samsung Electronics Intellectual Property. All rights reserved.
9 * =================================================================================================
10 c * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 * ============LICENSE_END=========================================================
24 package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.jakarta;
26 import java.io.IOException;
28 import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
29 import org.onap.ccsdk.features.sdnr.wt.common.database.requests.ClusterSettingsRequest;
30 import org.onap.ccsdk.features.sdnr.wt.common.database.responses.ClusterSettingsResponse;
31 import org.onap.ccsdk.features.sdnr.wt.dataprovider.database.sqldb.SqlDBClient;
32 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation;
33 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName;
34 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DatabaseInfo;
35 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DatabaseInfo7;
36 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.KeepDataSearchHitConverter;
37 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.MariaDBTableInfo;
38 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release;
39 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.SearchHitConverter;
40 import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.istanbul.IstanbulReleaseInformation;
41 import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev201110.Entity;
42 import org.slf4j.Logger;
43 import org.slf4j.LoggerFactory;
45 public class JakartaReleaseInformation extends ReleaseInformation {
47 private static final String TABLENAME_CONTROLLER_FORMAT = IstanbulReleaseInformation.TABLENAME_CONTROLLER_FORMAT;
48 private static final String TABLEMAPPING_CONTROLLER = IstanbulReleaseInformation.TABLEMAPPING_CONTROLLER;
49 private static final String TIMEZONE_TYPE_FORMAT = IstanbulReleaseInformation.TIMEZONE_TYPE_FORMAT;
50 private final Logger LOG = LoggerFactory.getLogger(JakartaReleaseInformation.class);
52 private static final String TABLEMAPPING_CMLOG_FORMAT = "`id` int(11) NOT NULL AUTO_INCREMENT,\n"
53 + "`controller-id` VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_bin NOT NULL,\n"
54 + "`source-type` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
55 + "`object-id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`timestamp` DATETIME(3) ,\n" + "`timestamp-tz` "
56 + String.format(TIMEZONE_TYPE_FORMAT, "timestamp-tz") + " ,\n"
57 + "`node-id` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`counter` INTEGER ,\n"
58 + "`notification-type` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
59 + "`notification-id` VARCHAR(40) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
60 + "`source-indicator` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
61 + "`path` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "`operation` VARCHAR(100) CHARACTER SET utf8 COLLATE utf8_bin ,\n"
62 + "`value` VARCHAR(255) CHARACTER SET utf8 COLLATE utf8_bin ,\n" + "primary key(id),foreign key(`controller-id`) "
63 + "references `controller%s`(id) ";
65 public JakartaReleaseInformation() {
66 super(Release.JAKARTA_R1, createDBMap(), createMariaDBMap());
69 private static Map<ComponentName, DatabaseInfo> createDBMap() {
70 Map<ComponentName, DatabaseInfo> map = IstanbulReleaseInformation.createDBMap();
71 map.put(ComponentName.CMLOG, new DatabaseInfo7("cmlog", "cmlog",
72 "{\"node-id\": {\"type\": \"keyword\"},\"counter\": {\"type\": \"long\"},"
73 + "\"notification-id\": {\"type\": \"date\"},\"notification-type\": {\"type\": \"keyword\"},"
74 + "\"object-id\": {\"type\": \"long\"},\"operation\":{\"type\": \"keyword\"},"
75 + "\"path\": {\"type\": \"long\"},\"source-indicator\":{\"type\": \"keyword\"},"
76 + "\"source-type\": {\"type\": \"long\"},\"timestamp\":{\"type\": \"keyword\"},"
77 + "\"value\":{\"type\": \"keyword\"}}"));
81 private static Map<ComponentName, MariaDBTableInfo> createMariaDBMap() {
82 Map<ComponentName, MariaDBTableInfo> map =
83 IstanbulReleaseInformation.createMariaDBMap(Release.JAKARTA_R1.getDBSuffix());
84 map.put(ComponentName.CMLOG, new MariaDBTableInfo(Entity.Cmlog.getName(), TABLEMAPPING_CMLOG_FORMAT));
89 public SearchHitConverter getConverter(Release dst, ComponentName comp) {
90 if (dst == Release.JAKARTA_R1) {
91 return new KeepDataSearchHitConverter(comp);
97 public boolean runPreInitCommands(HtDatabaseClient dbClient) {
98 ClusterSettingsResponse response = null;
100 response = dbClient.setupClusterSettings(new ClusterSettingsRequest(false).maxCompilationsPerMinute(400));
101 } catch (IOException e) {
102 LOG.warn("problem setting up cluster: {}", e);
104 return response == null ? false : response.isAcknowledged();
108 public boolean runPostInitCommands(HtDatabaseClient dbClient) {
113 public boolean runPreInitCommands(SqlDBClient dbClient) {
114 boolean success = dbClient.createTable(
115 String.format(TABLENAME_CONTROLLER_FORMAT, this.getReleas().getDBSuffix()), TABLEMAPPING_CONTROLLER);
120 public boolean runPostInitCommands(SqlDBClient dbClient) {