summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/data-provider/setup/src/main
diff options
context:
space:
mode:
authorMichael Dürre <michael.duerre@highstreet-technologies.com>2020-02-26 06:41:50 +0100
committerKAPIL SINGAL <ks220y@att.com>2020-02-27 14:52:20 +0000
commitee75b19ee79f49b28a3137b6dcfdf02d6120f3de (patch)
tree49a6a7b10578ee5f9780ea38f8a9408cf4cf14c7 /sdnr/wt/data-provider/setup/src/main
parent8f762f215f49fd4b1d498adc2cc4f98093f0ddf3 (diff)
add data migration tool
add tool for data migration and initialization Issue-ID: SDNC-1085 Signed-off-by: Michael Dürre <michael.duerre@highstreet-technologies.com> Change-Id: Ibd1ffeffa95d2897ae65f7d964e98941d810ffcb Signed-off-by: Michael Dürre <michael.duerre@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/data-provider/setup/src/main')
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderImpl.java370
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderService.java70
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/Program.java357
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java157
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/BaseSearchHitConverter.java51
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentData.java62
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentName.java59
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigData.java35
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigName.java52
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataContainer.java141
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataMigrationReport.java54
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DatabaseInfo.java63
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/KeepDataSearchHitConverter.java43
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/MavenDatabasePluginInitFile.java58
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java98
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/SearchHitConverter.java64
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/ElAltoReleaseInformation.java92
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtConnectionlogConverter.java120
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtEventlogConverter.java55
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultcurrentConverter.java80
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultlogConverter.java78
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtMaintenanceConverter.java86
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtRequiredNetworkElementConverter.java78
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformation.java77
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/data/ConnectionLogStatus.java38
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformation.java71
26 files changed, 2509 insertions, 0 deletions
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderImpl.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderImpl.java
new file mode 100644
index 000000000..ff5406a99
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderImpl.java
@@ -0,0 +1,370 @@
+/*
+ * ============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 java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Set;
+
+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.config.HostInfo;
+import org.onap.ccsdk.features.sdnr.wt.common.database.data.AliasesEntry;
+import org.onap.ccsdk.features.sdnr.wt.common.database.data.AliasesEntryList;
+import org.onap.ccsdk.features.sdnr.wt.common.database.data.EsVersion;
+import org.onap.ccsdk.features.sdnr.wt.common.database.data.IndicesEntry;
+import org.onap.ccsdk.features.sdnr.wt.common.database.data.IndicesEntryList;
+import org.onap.ccsdk.features.sdnr.wt.common.database.requests.CreateAliasRequest;
+import org.onap.ccsdk.features.sdnr.wt.common.database.requests.CreateIndexRequest;
+import org.onap.ccsdk.features.sdnr.wt.common.database.requests.DeleteAliasRequest;
+import org.onap.ccsdk.features.sdnr.wt.common.database.requests.DeleteIndexRequest;
+import org.onap.ccsdk.features.sdnr.wt.common.database.responses.AcknowledgedResponse;
+import org.onap.ccsdk.features.sdnr.wt.common.database.responses.GetInfoResponse;
+import org.onap.ccsdk.features.sdnr.wt.common.database.responses.ListAliasesResponse;
+import org.onap.ccsdk.features.sdnr.wt.common.database.responses.ListIndicesResponse;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentData;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DataMigrationReport;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DataContainer;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.SearchHitConverter;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+public class DataMigrationProviderImpl implements DataMigrationProviderService {
+
+ private final Logger LOG = LoggerFactory.getLogger(DataMigrationProviderImpl.class);
+
+ private final HtDatabaseClient dbClient;
+
+ public DataMigrationProviderImpl(HostInfo[] hosts, String username, String password, boolean trustAll) {
+ this.dbClient = new HtDatabaseClient(hosts, username, password, trustAll);
+ }
+
+ @Override
+ public DataMigrationReport importData(String filename, boolean dryrun) throws Exception {
+ return this.importData(filename, dryrun, Release.CURRENT_RELEASE);
+ }
+
+ public DataMigrationReport importData(String filename, boolean dryrun, Release forRelease) throws Exception {
+ DataMigrationReport report = new DataMigrationReport();
+ File file = new File(filename);
+ if (!file.exists()) {
+ if (dryrun) {
+ report.error("file %s not found", filename);
+ return report;
+ }
+ throw new FileNotFoundException(filename);
+ }
+ DataContainer container = null;
+ try {
+ container = DataContainer.load(file);
+ } catch (Exception e) {
+ if (dryrun) {
+ report.error("problem loading file %s: %s", filename, e.getMessage());
+ return report;
+ }
+ throw new Exception("problem loading file " + filename, e);
+ }
+ ReleaseInformation ri = ReleaseInformation.getInstance(forRelease);
+ SearchHitConverter converter;
+ Set<ComponentName> components = ri.getComponents();
+ //for all db components of dest architecture
+ for (ComponentName component : components) {
+ //convert to ComponentData for current release with existing ComponentData of the container
+ converter = SearchHitConverter.Factory.getInstance(container.getRelease(), forRelease, component);
+ if (converter == null) {
+ continue;
+ }
+ ComponentData data = converter.convert(container);
+ if (data != null) {
+ String indexName = ri.getAlias(component);
+ String dataTypeName = ri.getDataType(component);
+ if (dryrun) {
+ report.log("write %d entries into %s/%s", data.size(), indexName, dataTypeName);
+ } else {
+ LOG.debug("write {} entries into {}/{}", data.size(), indexName, dataTypeName);
+ }
+ for (SearchHit item : data) {
+ if (!dryrun) {
+ String id = this.dbClient.doWriteRaw(indexName, dataTypeName, item.getId(),
+ item.getSourceAsString());
+ if (!item.getId().equals(id)) {
+ LOG.warn("entry for {} with original id {} was written with another id {}",
+ component.getValue(), item.getId(), id);
+ }
+ }
+ }
+ } else {
+ if (dryrun) {
+ report.error("unable to convert data for " + component.getValue() + " from version "
+ + container.getRelease().getValue() + " to " + forRelease.getValue() + "\n");
+ } else {
+ LOG.warn("unable to convert data for {} from version {} to {}", component.getValue(),
+ container.getRelease().getValue(), forRelease.getValue());
+ }
+ }
+ }
+ LOG.info("import of {} completed", filename);
+ if (dryrun) {
+ report.log("import of %s completed", filename);
+ }
+ report.setCompleted(true);
+ return report;
+ }
+
+
+ /**
+ * export data
+ * if file exists .1 (.n) will be created
+ *
+ */
+ @Override
+ public DataMigrationReport exportData(String filename) {
+ DataMigrationReport report = new DataMigrationReport();
+
+ DataContainer container = new DataContainer();
+
+ filename = this.checkFilenameForWrite(filename);
+ LOG.info("output will be written to {}", filename);
+ //autodetect version
+ Release dbRelease = this.autoDetectRelease();
+ if(dbRelease==null) {
+ report.error("unbable to detect db release. is database initialized?");
+ return report;
+ }
+ ReleaseInformation ri = ReleaseInformation.getInstance(dbRelease);
+ boolean componentsSucceeded = true;
+ for(ComponentName c: ri.getComponents()) {
+ ComponentData data = new ComponentData(c);
+ SearchResult<SearchHit> result = this.dbClient.doReadAllJsonData(ri.getAlias(c),ri.getDataType(c),false);
+ data.addAll(result.getHits());
+ container.addComponent(c, data );
+ }
+ try {
+ Files.write(new File(filename).toPath(), Arrays.asList(container.toJSON()), StandardCharsets.UTF_8);
+ report.setCompleted(componentsSucceeded);
+ } catch (IOException e) {
+ LOG.warn("problem writing data to {}: {}", filename, e);
+ }
+ return report;
+ }
+
+ private String checkFilenameForWrite(String filename) {
+ File f = new File(filename);
+ if (!f.exists()) {
+ return filename;
+ }
+ return this.checkFilenameForWrite(filename, 0);
+ }
+
+ private String checkFilenameForWrite(String filename, int apdx) {
+ File f = new File(String.format("$s.$d",filename,apdx));
+ if (!f.exists()) {
+ return filename;
+ }
+ return this.checkFilenameForWrite(filename, apdx + 1);
+ }
+
+ @Override
+ public Release getCurrentVersion() {
+ return Release.CURRENT_RELEASE;
+ }
+
+
+ public Release autoDetectRelease() {
+ EsVersion dbVersion = this.readActualVersion();
+ AliasesEntryList aliases = this.readAliases();
+ IndicesEntryList indices = this.readIndices();
+ if(indices==null) {
+ return null;
+ }
+ List<Release> foundReleases = new ArrayList<Release>();
+ //if there are active aliases reduce indices to the active ones
+ if(aliases!=null && aliases.size()>0) {
+ indices = indices.subList(aliases.getLinkedIndices());
+ }
+ for(Release r:Release.values()) {
+ if(r.isDbInRange(dbVersion)) {
+ ReleaseInformation ri = ReleaseInformation.getInstance(r);
+ if(ri!=null && ri.containsIndices(indices)) {
+ foundReleases.add(r);
+ }
+ }
+ }
+ if (foundReleases.size() == 1) {
+ return foundReleases.get(0);
+ }
+ LOG.error("detect {} releases: {}. unable to detect for which one to do sth.",foundReleases.size(), foundReleases);
+ return null;
+ }
+ private EsVersion readActualVersion() {
+ try {
+ GetInfoResponse response = this.dbClient.getInfo();
+ return response.getVersion();
+ } catch (Exception e) {
+ LOG.warn(e.getMessage());
+ }
+ return null;
+ }
+
+ private AliasesEntryList readAliases() {
+ AliasesEntryList entries = null;
+ try {
+ ListAliasesResponse response = this.dbClient.getAliases();
+ entries = response.getEntries();
+ } catch (ParseException | IOException e) {
+ LOG.error(e.getMessage());
+ }
+ return entries;
+ }
+
+ private IndicesEntryList readIndices() {
+ IndicesEntryList entries = null;
+ try {
+ ListIndicesResponse response = this.dbClient.getIndices();
+ entries = response.getEntries();
+ } catch (ParseException | IOException e) {
+ LOG.error(e.getMessage());
+ }
+ return entries;
+ }
+
+ @Override
+ public boolean initDatabase(Release release, int numShards, int numReplicas, String dbPrefix,
+ boolean forceRecreate) {
+ EsVersion dbVersion = this.readActualVersion();
+ if (dbVersion == null) {
+ return false;
+ }
+ if (!release.isDbInRange(dbVersion)) {
+ LOG.warn("db version {} maybe not compatible with release {}", dbVersion, release);
+ return false;
+ }
+ if (forceRecreate) {
+ this.clearDatabase(release, dbPrefix);
+ }
+ ReleaseInformation ri = ReleaseInformation.getInstance(release);
+ AliasesEntryList aliases = this.readAliases();
+ IndicesEntryList indices = this.readIndices();
+ if (aliases == null || indices == null) {
+ return false;
+ }
+ AcknowledgedResponse response = null;
+ for (ComponentName component : ri.getComponents()) {
+ try {
+ if (ri.hasOwnDbIndex(component)) {
+ //check if index already exists
+ String indexName = ri.getIndex(component, dbPrefix);
+ String aliasName = ri.getAlias(component, dbPrefix);
+ if (indices.findByIndex(indexName) == null) {
+ LOG.info("creating index for {}", component);
+ CreateIndexRequest request = new CreateIndexRequest(ri.getIndex(component, dbPrefix));
+ request.mappings(new JSONObject(ri.getDatabaseMapping(component)));
+ request.settings(new JSONObject(ri.getDatabaseSettings(component, numShards, numReplicas)));
+ response = this.dbClient.createIndex(request);
+ LOG.info(response.isAcknowledged() ? "succeeded" : "failed");
+ } else {
+ LOG.info("index {} for {} already exists", indexName, component);
+ }
+ //check if alias already exists
+ if (aliases.findByAlias(aliasName) == null) {
+ LOG.info("creating alias for {}", component);
+ response = this.dbClient.createAlias(new CreateAliasRequest(indexName, aliasName));
+ LOG.info(response.isAcknowledged() ? "succeeded" : "failed");
+ } else {
+ LOG.info("alias {} for index {} for {} already exists", aliasName, indexName, component);
+ }
+ }
+ } catch (IOException e) {
+ LOG.error(e.getMessage());
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public boolean clearDatabase(Release release, String dbPrefix) {
+
+ //check aliases
+ AliasesEntryList entries = this.readAliases();
+ if (entries == null) {
+ return false;
+ }
+ ReleaseInformation ri = ReleaseInformation.getInstance(release);
+ AcknowledgedResponse response;
+ if (entries.size() <= 0) {
+ LOG.info("no aliases to clear");
+ } else {
+ for (ComponentName component : ri.getComponents()) {
+ String aliasToDelete = ri.getAlias(component, dbPrefix);
+ AliasesEntry entryToDelete = entries.findByAlias(aliasToDelete);
+ if (entryToDelete != null) {
+ try {
+ LOG.info("deleting alias {} for index {}", entryToDelete.getAlias(), entryToDelete.getIndex());
+ response=this.dbClient.deleteAlias(
+ new DeleteAliasRequest(entryToDelete.getIndex(), entryToDelete.getAlias()));
+ LOG.info(response.isResponseSucceeded()?"succeeded":"failed");
+ } catch (IOException e) {
+ LOG.error(e.getMessage());
+ return false;
+ }
+ }
+ }
+ }
+ IndicesEntryList entries2 = this.readIndices();
+ if (entries2 == null) {
+ return false;
+ }
+ if (entries2.size() <= 0) {
+ LOG.info("no indices to clear");
+ } else {
+ for (ComponentName component : ri.getComponents()) {
+ String indexToDelete = ri.getIndex(component, dbPrefix);
+ IndicesEntry entryToDelete = entries2.findByIndex(indexToDelete);
+ if (entryToDelete != null) {
+ try {
+ LOG.info("deleting index {}", entryToDelete.getName());
+ response=this.dbClient.deleteIndex(new DeleteIndexRequest(entryToDelete.getName()));
+ LOG.info(response.isResponseSucceeded()?"succeeded":"failed");
+ } catch (IOException e) {
+ LOG.error(e.getMessage());
+ return false;
+ }
+ }
+ }
+ }
+
+ return true;
+ }
+
+}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderService.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderService.java
new file mode 100644
index 000000000..d908d6931
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderService.java
@@ -0,0 +1,70 @@
+/*
+ * ============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 java.io.FileNotFoundException;
+
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DataMigrationReport;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release;
+
+
+public interface DataMigrationProviderService {
+
+ /**
+ * import data from file and write these to database
+ * @param filename source
+ * @param dryrun only loading file and check consistency, not pushing into database
+ * @return report
+ * @throws FileNotFoundException
+ * @throws Exception
+ */
+ DataMigrationReport importData(String filename,boolean dryrun) throws FileNotFoundException, Exception;
+ /**
+ * export current data to file
+ * @param filename
+ */
+ DataMigrationReport exportData(String filename);
+
+ /**
+ *
+ * @return
+ */
+ Release getCurrentVersion();
+
+ /**
+ * @param release
+ * @param numShards
+ * @param numReplicas
+ * @param dbPrefix
+ * @param forceRecreate
+ * @return
+ */
+ boolean initDatabase(Release release, int numShards, int numReplicas, String dbPrefix, boolean forceRecreate);
+
+ /**
+ * clean up the database
+ * all data will be removed
+ * complete structure will be destroyed
+ * @return
+ */
+ boolean clearDatabase(Release release, String dbPrefix);
+}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/Program.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/Program.java
new file mode 100644
index 000000000..abb372920
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/Program.java
@@ -0,0 +1,357 @@
+/*
+ * ============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 java.util.Arrays;
+import java.util.List;
+
+import org.apache.commons.cli.*;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.log4j.ConsoleAppender;
+import org.apache.log4j.Level;
+import org.apache.log4j.Logger;
+import org.apache.log4j.PatternLayout;
+import org.apache.log4j.RollingFileAppender;
+import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DataMigrationReport;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.MavenDatabasePluginInitFile;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release;
+
+/**
+ * @author Michael Dürre
+ *
+ */
+public class Program {
+
+ private static final String CMD_INITDB = "init";
+ private static final String CMD_CLEAR_DB = "delete";
+ private static final String CMD_CREATE_PLUGIN_INIT_FILE = "pluginfile";
+ private static final String CMD_IMPORT = "import";
+ private static final String CMD_EXPORT = "export";
+ private static final String CMD_LIST_VERSION = "list";
+ private static final String CMD_INITDB_DESCRIPTION = "initialize databse indices and aliases";
+ private static final String CMD_CLEAR_DB_DESCRIPTION = "clear database indices and aliases";
+ private static final String CMD_CREATE_PLUGIN_INIT_FILE_DESCRIPTION = "create maven plugin file";
+ private static final String CMD_IMPORT_DESCRIPTION = "import data into database";
+ private static final String CMD_EXPORT_DESCRIPTION = "export data from database";
+ private static final String CMD_LIST_VERSION_DESCRIPTION = "list release versions";
+
+ private static final List<String[]> commands = Arrays.asList(new String[] { CMD_INITDB, CMD_INITDB_DESCRIPTION },
+ new String[] { CMD_CLEAR_DB, CMD_CLEAR_DB_DESCRIPTION },
+ new String[] { CMD_CREATE_PLUGIN_INIT_FILE, CMD_CREATE_PLUGIN_INIT_FILE_DESCRIPTION },
+ new String[] { CMD_IMPORT, CMD_IMPORT_DESCRIPTION }, new String[] { CMD_EXPORT, CMD_EXPORT_DESCRIPTION },
+ new String[] { CMD_LIST_VERSION, CMD_LIST_VERSION_DESCRIPTION });
+ private static final String APPLICATION_NAME = "SDNR DataMigrationTool";
+ private static final int DEFAULT_SHARDS = 5;
+ private static final int DEFAULT_REPLICAS = 1;
+ private static final String DEFAULT_DBURL = "http://sdnrdb:9200";
+ private static final String DEFAULT_DBPREFIX = "";
+ private static final String OPTION_FORCE_RECREATE_SHORT = "f";
+ private static final String OPTION_SILENT_SHORT = "n";
+ private static final String OPTION_SILENT = "silent";
+ private static final String OPTION_VERSION_SHORT = "v";
+ private static final String OPTION_SHARDS_SHORT = "s";
+ private static final String OPTION_REPLICAS_SHORT = "r";
+ private static final String OPTION_OUTPUTFILE_SHORT = "of";
+ private static final String OPTION_INPUTFILE_SHORT = "if";
+ private static final String OPTION_DEBUG_SHORT = "x";
+ private static final String OPTION_TRUSTINSECURESSL_SHORT = "k";
+
+ private static Options options = init();
+
+ private static Log LOG = null;
+
+ @SuppressWarnings("unchecked")
+ private static <T> T getOptionOrDefault(CommandLine cmd, String option, T def) throws ParseException {
+ if (def instanceof Boolean) {
+ return cmd.hasOption(option) ? (T) Boolean.TRUE : def;
+ }
+ if (cmd.hasOption(option) && cmd.getOptionValue(option) != null) {
+ if (option.equals(OPTION_VERSION_SHORT)) {
+ String v = cmd.getOptionValue(option);
+ return (T) Release.getValueBySuffix(v.startsWith("-") ? v : ("-" + v));
+ } else {
+ return (T) cmd.getParsedOptionValue(option);
+ }
+ }
+ return def;
+ }
+
+ private static void initLog(boolean silent, String logfile) {
+ initLog(silent, logfile, Level.INFO);
+ }
+
+ private static void initLog(boolean silent, String logfile, Level loglvl) {
+ Logger.getRootLogger().getLoggerRepository().resetConfiguration();
+ LOG = LogFactory.getLog(Program.class);
+ if (!silent) {
+ ConsoleAppender console = new ConsoleAppender(); // create appender
+ // configure the appender
+ String PATTERN = "%d [%p|%C{1}] %m%n";
+ console.setLayout(new PatternLayout(PATTERN));
+ console.setThreshold(loglvl);
+ console.activateOptions();
+ // add appender to any Logger (here is root)
+ Logger.getRootLogger().addAppender(console);
+ }
+ if (logfile != null) {
+ RollingFileAppender fa = new RollingFileAppender();
+ fa.setName("FileLogger");
+ fa.setFile(logfile);
+ fa.setLayout(new PatternLayout("%d %-5p [%c] %m%n"));
+ fa.setThreshold(loglvl);
+ fa.setMaximumFileSize(10000000);
+ fa.setAppend(true);
+ fa.setMaxBackupIndex(5);
+ fa.activateOptions();
+ // add appender to any Logger (here is root)
+ Logger.getRootLogger().addAppender(fa);
+ }
+ // repeat with all other desired appenders
+ }
+
+ public static void main(String[] args) {
+ CommandLineParser parser = new DefaultParser();
+ HelpFormatter formatter = new HelpFormatter();
+ CommandLine cmd = null;
+ try {
+ cmd = parser.parse(options, args);
+ } catch (ParseException e) {
+ System.out.println(e.getMessage());
+ printHelp(formatter);
+ System.exit(1);
+ }
+ if (cmd == null) {
+ printHelp(formatter);
+ System.exit(1);
+ }
+ try {
+ initLog(getOptionOrDefault(cmd, OPTION_SILENT_SHORT, false), null,getOptionOrDefault(cmd, OPTION_DEBUG_SHORT, false)?Level.DEBUG:Level.INFO);
+ } catch (ParseException e2) {
+
+ }
+ switch (cmd.getOptionValue("c")) {
+ case CMD_INITDB:
+ try {
+ cmd_init_db(cmd);
+ } catch (Exception e1) {
+ exit(e1);
+ }
+ break;
+ case CMD_CLEAR_DB:
+ try {
+ cmd_clear_db(cmd);
+ } catch (Exception e1) {
+ exit(e1);
+ }
+ break;
+ case CMD_CREATE_PLUGIN_INIT_FILE:
+ try {
+ String of = getOptionOrDefault(cmd, "of", null);
+ if (of == null) {
+ throw new Exception("please add the parameter output-file");
+ }
+ MavenDatabasePluginInitFile.create(Release.CURRENT_RELEASE, of);
+ } catch (Exception e) {
+ exit(e);
+ }
+ break;
+ case CMD_IMPORT:
+ try {
+ cmd_dbimport(cmd);
+ } catch (Exception e1) {
+ exit(e1);
+ }
+ break;
+ case CMD_EXPORT:
+ try {
+ cmd_dbexport(cmd);
+ } catch (Exception e) {
+ exit(e);
+ }
+ break;
+ case CMD_LIST_VERSION:
+ cmd_listversion();
+ break;
+ default:
+ printHelp(formatter);
+ break;
+ }
+ System.exit(0);
+ }
+
+ /**
+ * @param formatter
+ */
+ private static void printHelp(HelpFormatter formatter) {
+ formatter.printHelp(APPLICATION_NAME, options);
+ System.out.println("\nCommands:");
+ for (String[] c : commands) {
+ System.out.println(String.format("%10s\t%s", c[0], c[1]));
+ }
+ }
+
+ /**
+ *
+ */
+ private static void cmd_listversion() {
+
+ System.out.println("Database Releases:");
+ final String format = "%15s\t%8s";
+ System.out.println(String.format(format, "Name", "Version"));
+ for (Release r : Release.values()) {
+
+ System.out.println(String.format(format, r.getValue(),
+ r.getDBSuffix() != null && r.getDBSuffix().length() > 1 ? r.getDBSuffix().substring(1) : ""));
+ }
+
+ }
+
+ /**
+ * @throws Exception
+ *
+ */
+ private static void cmd_dbimport(CommandLine cmd) throws Exception {
+ String dbUrl = getOptionOrDefault(cmd, "db", DEFAULT_DBURL);
+ String username = getOptionOrDefault(cmd, "dbu", null);
+ String password = getOptionOrDefault(cmd, "dbp", null);
+ String filename = getOptionOrDefault(cmd, OPTION_OUTPUTFILE_SHORT, null);
+ boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, false);
+ if (filename == null) {
+ throw new Exception("please add output file parameter");
+ }
+ DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) },
+ username, password,trustAll);
+ DataMigrationReport report = service.importData(filename,false);
+ LOG.info(report);
+ }
+
+ /**
+ * @throws Exception
+ *
+ */
+ private static void cmd_dbexport(CommandLine cmd) throws Exception {
+ String dbUrl = getOptionOrDefault(cmd, "db", DEFAULT_DBURL);
+ String username = getOptionOrDefault(cmd, "dbu", null);
+ String password = getOptionOrDefault(cmd, "dbp", null);
+ String filename = getOptionOrDefault(cmd, OPTION_OUTPUTFILE_SHORT, null);
+ boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, false);
+ if (filename == null) {
+ throw new Exception("please add output file parameter");
+ }
+ DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) },
+ username, password,trustAll);
+ DataMigrationReport report = service.exportData(filename);
+ LOG.info(report);
+ }
+
+ /**
+ * @param e
+ */
+ private static void exit(Exception e) {
+ if (LOG != null) {
+ LOG.error("Error during execution: {}", e);
+ } else {
+ System.err.println(e);
+ }
+ System.exit(1);
+ }
+
+ /**
+ * @param cmd
+ * @throws ParseException
+ * @throws java.text.ParseException
+ */
+ private static void cmd_clear_db(CommandLine cmd) throws ParseException, java.text.ParseException {
+ Release r = getOptionOrDefault(cmd, OPTION_VERSION_SHORT, Release.CURRENT_RELEASE);
+ String dbUrl = getOptionOrDefault(cmd, "db", DEFAULT_DBURL);
+ String dbPrefix = getOptionOrDefault(cmd, "p", DEFAULT_DBPREFIX);
+ String username = getOptionOrDefault(cmd, "dbu", null);
+ String password = getOptionOrDefault(cmd, "dbp", null);
+ boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, false);
+ DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) },
+ username, password,trustAll);
+ service.clearDatabase(r, dbPrefix);
+ }
+
+ /**
+ * @param cmd
+ * @throws ParseException
+ * @throws java.text.ParseException
+ */
+ private static void cmd_init_db(CommandLine cmd) throws ParseException, java.text.ParseException {
+ Release r = getOptionOrDefault(cmd, OPTION_VERSION_SHORT, Release.CURRENT_RELEASE);
+ int numShards = getOptionOrDefault(cmd, OPTION_SHARDS_SHORT, DEFAULT_SHARDS);
+ int numReplicas = getOptionOrDefault(cmd, OPTION_REPLICAS_SHORT, DEFAULT_REPLICAS);
+ String dbUrl = getOptionOrDefault(cmd, "db", DEFAULT_DBURL);
+ String dbPrefix = getOptionOrDefault(cmd, "p", DEFAULT_DBPREFIX);
+ String username = getOptionOrDefault(cmd, "dbu", null);
+ String password = getOptionOrDefault(cmd, "dbp", null);
+ boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, false);
+ DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) },
+ username, password,trustAll);
+ boolean forceRecreate = cmd.hasOption(OPTION_FORCE_RECREATE_SHORT);
+ service.initDatabase(r, numShards, numReplicas, dbPrefix, forceRecreate);
+
+ }
+
+ /**
+ * @return
+ */
+ private static Options init() {
+ Options options = new Options();
+ options.addOption(createOption("c", "cmd", true, "command to execute", true));
+ options.addOption(createOption("db", "dburl", true, "database url", false));
+ options.addOption(createOption("dbu", "db-username", true, "database basic auth username", false));
+ options.addOption(createOption("dbp", "db-password", true, "database basic auth password", false));
+ options.addOption(createOption(OPTION_REPLICAS_SHORT, "replicas", true, "amount of replicas", false));
+ options.addOption(createOption(OPTION_SHARDS_SHORT, "shards", true, "amount of shards", false));
+ options.addOption(createOption("p", "prefix", true, "prefix for db indices", false));
+ options.addOption(createOption(OPTION_VERSION_SHORT, "version", true, "version", false));
+ options.addOption(createOption(OPTION_DEBUG_SHORT, "verbose", false, "verbose mode", false));
+ options.addOption(createOption(OPTION_TRUSTINSECURESSL_SHORT, "trust-insecure", false, "trust insecure ssl certs", false));
+ options.addOption(createOption("w", "wait", true, "wait delay for yellow status", false));
+ options.addOption(
+ createOption(OPTION_FORCE_RECREATE_SHORT, "force-recreate", false, "delete if sth exists", false));
+ options.addOption(createOption(OPTION_SILENT_SHORT, OPTION_SILENT, false, "prevent console output", false));
+ options.addOption(createOption(OPTION_OUTPUTFILE_SHORT, "output-file", true, "file to write into", false));
+ options.addOption(createOption(OPTION_INPUTFILE_SHORT, "input-file", true, "file to read from", false));
+
+ return options;
+ }
+
+ /**
+ * @param opt
+ * @param longOpt
+ * @param hasArg
+ * @param description
+ * @param required
+ * @return
+ */
+ private static Option createOption(String opt, String longOpt, boolean hasArg, String description,
+ boolean required) {
+ Option o = new Option(opt, longOpt, hasArg, description);
+ o.setRequired(required);
+ return o;
+ }
+}
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
new file mode 100644
index 000000000..5c5aa2a8b
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java
@@ -0,0 +1,157 @@
+/*
+ * ============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 java.util.Map;
+import java.util.Set;
+
+import org.onap.ccsdk.features.sdnr.wt.common.database.data.IndicesEntryList;
+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.KeepDataSearchHitConverter;
+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.elalto.ElAltoReleaseInformation;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.frankfurt.FrankfurtReleaseInformation;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.guilin.GuilinReleaseInformation;
+
+public abstract class ReleaseInformation {
+
+ private final Release release;
+ private final Map<ComponentName, DatabaseInfo> dbMap;
+
+ public ReleaseInformation(Release r, Map<ComponentName, DatabaseInfo> dbMap) {
+ this.release = r;
+ this.dbMap = dbMap;
+ }
+
+ /**
+ * get database alias for component
+ * @param name
+ * @return alias or null if not exists
+ */
+ public String getAlias(ComponentName name) {
+ return this.getAlias(name,"");
+ }
+ public String getAlias(ComponentName name,String prefix) {
+ return dbMap.get(name) == null ? null : prefix+dbMap.get(name).alias;
+ }
+
+ /**
+ * @param c
+ * @return
+ */
+ public String getIndex(ComponentName name) {
+ return this.getIndex(name,"");
+ }
+ public String getIndex(ComponentName name,String prefix) {
+ return dbMap.get(name) == null ? null : (prefix+dbMap.get(name).getIndex(this.release.getDBSuffix()));
+ }
+
+ /**
+ * get database datatype (doctype) for component
+ * @param name
+ * @return datatype or null if not exists
+ */
+ public String getDataType(ComponentName name) {
+ return dbMap.get(name) == null ? null : dbMap.get(name).doctype;
+ }
+
+ /**
+ * get database doctype definition for component
+ * @param name
+ * @return mappings or null if not exists
+ */
+ public String getDatabaseMapping(ComponentName name) {
+ return dbMap.get(name) == null ? null : dbMap.get(name).getMapping();
+ }
+ /**
+ * get database settings definition for component
+ * @param name
+ * @return settings or null if not exists
+ */
+ public String getDatabaseSettings(ComponentName name,int shards,int replicas) {
+ return dbMap.get(name) == null ? null : dbMap.get(name).getSettings(shards, replicas);
+ }
+
+ /**
+ * get converter for component data
+ * @param dst destination release
+ * @param comp component to convert
+ * @return
+ */
+ public SearchHitConverter getConverter(Release dst, ComponentName comp) {
+ if(dst==this.release && this.getComponents().contains(comp)) {
+ return new KeepDataSearchHitConverter(comp);
+ }
+ return null;
+ }
+
+ public static ReleaseInformation getInstance(Release r) {
+ switch (r) {
+ case EL_ALTO:
+ return new ElAltoReleaseInformation();
+ case FRANKFURT_R1:
+ return new FrankfurtReleaseInformation();
+ case GUILIN:
+ return new GuilinReleaseInformation();
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * @return
+ */
+ public Set<ComponentName> getComponents() {
+ return dbMap.keySet();
+ }
+
+ /**
+ * @param component
+ * @return
+ */
+ public boolean hasOwnDbIndex(ComponentName component) {
+ return this.getDatabaseMapping(component)!=null;
+ }
+
+ /**
+ * @param indices
+ * @return true if components of this release are covered by the given indices
+ */
+ protected boolean containsIndices(IndicesEntryList indices) {
+
+ if(this.dbMap.size()<=0) {
+ return false;
+ }
+ for(DatabaseInfo entry:this.dbMap.values()) {
+ String dbIndexName = entry.getIndex(this.release.getDBSuffix());
+ if(indices.findByIndex(dbIndexName)==null) {
+ return false;
+ }
+ }
+ return true;
+
+ }
+
+
+}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/BaseSearchHitConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/BaseSearchHitConverter.java
new file mode 100644
index 000000000..2f4f067bd
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/BaseSearchHitConverter.java
@@ -0,0 +1,51 @@
+/*
+ * ============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.data;
+
+import org.json.JSONObject;
+import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
+
+public abstract class BaseSearchHitConverter implements SearchHitConverter {
+
+ private ComponentName name;
+ public BaseSearchHitConverter(ComponentName name) {
+ this.name = name;
+ }
+
+ protected SearchHit getSearchHit(String index, String type, String id, JSONObject data) {
+ JSONObject o = new JSONObject();
+ o.put("_index", index);
+ o.put("_type", type);
+ o.put("_id", id);
+ o.put("_source", data);
+ return new SearchHit(o);
+ }
+ @Override
+ public ComponentData convert(DataContainer container) {
+ ComponentData srcData = container.getComponents().get(this.name);
+ ComponentData dstData = new ComponentData(srcData.getName());
+ for(SearchHit sh:srcData) {
+ dstData.add(this.convert(sh));
+ }
+ return dstData;
+ }
+}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentData.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentData.java
new file mode 100644
index 000000000..fd361843c
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentData.java
@@ -0,0 +1,62 @@
+/*
+ * ============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.data;
+
+import java.util.ArrayList;
+import org.json.JSONArray;
+import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
+
+public class ComponentData extends ArrayList<SearchHit>{
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private final ComponentName name;
+
+ public ComponentData(ComponentName name) {
+ this(name,null);
+ }
+
+ public ComponentData(ComponentName name,JSONArray a) {
+ this.name = name;
+ if(a!=null) {
+ for(int i=0;i<a.length();i++) {
+ this.add(new SearchHit(a.getJSONObject(i)));
+ }
+ }
+
+ }
+
+ public ComponentName getName() {
+ return this.name;
+ }
+
+ public JSONArray toJsonArray() {
+ JSONArray a = new JSONArray();
+ for(SearchHit h:this) {
+ a.put(h.getRaw());
+ }
+ return a;
+ }
+
+}
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
new file mode 100644
index 000000000..9c5ef5c53
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentName.java
@@ -0,0 +1,59 @@
+/*
+ * ============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.data;
+
+public enum ComponentName {
+
+ CONNECTIONLOG("connectionlog"),
+ EVENTLOG("eventlog"),
+ FAULTLOG("faultlog"),
+ FAULTCURRENT("faultcurrent"),
+ HISTORICAL_PERFORMANCE_15M("historicalperformance15m"),
+ HISTORICAL_PERFORMANCE_24H("historicalperformance24h"),
+ INVENTORY("inventory"),
+ INVENTORYTOPLEVEL("inventorytoplevel"),
+ MAINTENANCE("maintenance"),
+ MEDIATOR_SERVER("mediator-server"),
+ REQUIRED_NETWORKELEMENT("required-networkelement");
+
+ private final String value;
+
+ private ComponentName(String s) {
+ this.value = s;
+ }
+ @Override
+ public String toString() {
+ return this.value;
+ }
+ public String getValue() {
+ return value;
+ }
+ public static ComponentName getValueOf(String s) throws Exception {
+ s = s.toLowerCase();
+ for(ComponentName p:ComponentName.values()) {
+ if(p.value.equals(s)) {
+ return p;
+ }
+ }
+ throw new Exception("value not found for "+s);
+ }
+} \ No newline at end of file
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigData.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigData.java
new file mode 100644
index 000000000..95c483736
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigData.java
@@ -0,0 +1,35 @@
+/*
+ * ============LICENSE_START=======================================================
+ * ONAP : ccsdk features
+ * ================================================================================
+ * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property.
+ * All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ *
+ */
+package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data;
+
+public class ConfigData {
+
+ private final String[] lines;
+
+ public String[] getLines() {
+ return this.lines;
+ }
+ public ConfigData(String content) {
+ this.lines = content.split("\n");
+ }
+
+}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigName.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigName.java
new file mode 100644
index 000000000..181fe2006
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigName.java
@@ -0,0 +1,52 @@
+/*
+ * ============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.data;
+
+public enum ConfigName {
+
+ APIGATEWAY("apigateway"),
+ DEVICEMANAGER("devicemanager"),
+ DATAPROVIDER("dataprovider");
+
+
+ private final String value;
+
+ private ConfigName(String s) {
+ this.value = s;
+ }
+ @Override
+ public String toString() {
+ return this.value;
+ }
+ public String getValue() {
+ return value;
+ }
+ public static ConfigName getValueOf(String s) throws Exception {
+ s = s.toLowerCase();
+ for(ConfigName p:ConfigName.values()) {
+ if(p.value.equals(s)) {
+ return p;
+ }
+ }
+ throw new Exception("value not found");
+ }
+} \ No newline at end of file
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataContainer.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataContainer.java
new file mode 100644
index 000000000..f50969ed6
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataContainer.java
@@ -0,0 +1,141 @@
+/*
+ * ============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.data;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.nio.file.Files;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.json.JSONArray;
+import org.json.JSONObject;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStampImpl;
+
+/**
+ *
+ * @author Michael Dürre
+ *
+ */
+public class DataContainer {
+
+ private final Release release;
+ private final Date created;
+ private final Map<ComponentName, ComponentData> components;
+ private final Map<ConfigName, ConfigData> configs;
+
+ public Release getRelease() {
+ return this.release;
+ }
+
+ public boolean isCurrentRelease() {
+ return this.release.equals(Release.CURRENT_RELEASE);
+ }
+
+ public Date getCreated() {
+ return this.created;
+ }
+
+ public Map<ComponentName, ComponentData> getComponents() {
+ return this.components;
+ }
+
+ public Map<ConfigName, ConfigData> getConfigs() {
+ return this.configs;
+ }
+
+ public DataContainer() {
+ this(Release.CURRENT_RELEASE);
+ }
+
+ public DataContainer(Release release) {
+ this(release, new Date());
+ }
+
+ public DataContainer(Release release, Date dt) {
+ this.release = release;
+ this.created = dt;
+ this.components = new HashMap<>();
+ this.configs = new HashMap<>();
+ }
+
+ public void addComponent(ComponentName name, ComponentData data) {
+ this.components.put(name, data);
+ }
+
+ public void addConfig(ConfigName name, ConfigData data) {
+ this.configs.put(name, data);
+ }
+
+ public static DataContainer load(File file) throws Exception {
+ if(!file.exists()) {
+ throw new FileNotFoundException();
+ }
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'");
+ JSONObject o = new JSONObject(new String(Files.readAllBytes(file.toPath())));
+ DataContainer c = new DataContainer(Release.getValueOf(o.getString("release")),
+ format.parse(o.getString("created")));
+ JSONObject comps = o.getJSONObject("components");
+
+ String k;
+ ComponentName compKey;
+ JSONArray compData;
+ for (Object key : comps.keySet()) {
+ k = String.valueOf(key);
+ // check component if exists
+ compKey = ComponentName.getValueOf(k);
+ compData = comps.getJSONArray(k);
+ c.addComponent(compKey, new ComponentData(compKey, compData));
+ }
+ ConfigName confKey;
+ ConfigData confData;
+ JSONObject confs = o.getJSONObject("configs");
+ for (Object key : confs.keySet()) {
+ k = String.valueOf(key);
+ confKey = ConfigName.getValueOf(k);
+ confData = new ConfigData(confs.getString(k));
+ c.addConfig(confKey, confData);
+ }
+ return c;
+ }
+
+ public String toJSON() {
+ JSONObject o = new JSONObject();
+ o.put("release", this.release.getValue());
+ o.put("created", NetconfTimeStampImpl.getConverter().getTimeStampAsNetconfString(this.created));
+ JSONObject compsJson = new JSONObject();
+ JSONObject confsJson = new JSONObject();
+ for (Entry<ComponentName, ComponentData> entry : this.components.entrySet()) {
+ compsJson.put(entry.getKey().getValue(), entry.getValue().toJsonArray());
+ }
+ for (Entry<ConfigName, ConfigData> entry : this.configs.entrySet()) {
+ confsJson.put(entry.getKey().getValue(), entry.getValue().toString());
+ }
+ o.put("components", compsJson);
+ o.put("configs", confsJson);
+ return o.toString();
+ }
+
+} \ No newline at end of file
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataMigrationReport.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataMigrationReport.java
new file mode 100644
index 000000000..c8270bad6
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataMigrationReport.java
@@ -0,0 +1,54 @@
+/*
+ * ============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.data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class DataMigrationReport {
+
+ private boolean completed;
+ private final List<String> logs;
+ private final List<String> errors;
+ public void setCompleted(boolean s) {
+ this.completed = s;
+ }
+ public boolean completed() {
+ return this.completed;
+ }
+ public void log(String format,Object ...params) {
+ this.logs.add(String.format(format, params));
+ }
+ public void error(String format,Object ...params) {
+ this.errors.add(String.format(format, params));
+ }
+ public DataMigrationReport() {
+ this.completed = false;
+ this.logs = new ArrayList<>();
+ this.errors = new ArrayList<>();
+ }
+ @Override
+ public String toString() {
+ return "DataMigrationReport [completed=" + completed + ", logs=" + logs + ", errors=" + errors + "]";
+ }
+
+}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DatabaseInfo.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DatabaseInfo.java
new file mode 100644
index 000000000..a6e81343a
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DatabaseInfo.java
@@ -0,0 +1,63 @@
+/*
+ * ============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.data;
+
+/**
+ * @author Michael Dürre
+ *
+ */
+public class DatabaseInfo {
+ public final String doctype;
+ public final String alias;
+ private final String mapping;
+ private final String settingsFormat;
+ private final String index;
+ public String getIndex(String version) {
+ return this.index + version;
+ }
+
+ public DatabaseInfo(String alias, String doctype, String mapping) {
+ this(alias,alias,doctype,mapping);
+ }
+
+ public DatabaseInfo(String index,String alias, String doctype, String mapping) {
+ this(index,alias,doctype, mapping,
+ "{\"index\":{\"number_of_shards\":%d,\"number_of_replicas\":%d},\"analysis\":{\"analyzer\":{\"content\":"
+ + "{\"type\":\"custom\",\"tokenizer\":\"whitespace\"}}}}");
+ }
+
+ public DatabaseInfo(String index,String alias,String doctype, String mapping, String settingsformat) {
+ this.index = index;
+ this.alias = alias;
+ this.doctype = doctype;
+ this.mapping = mapping;
+ this.settingsFormat = settingsformat;
+ }
+
+
+ public String getMapping() {
+ return this.mapping==null?null:String.format("{\"%s\":{\"properties\":%s}}",this.doctype, this.mapping);
+ }
+ public String getSettings(int shards, int replicas) {
+ return String.format(this.settingsFormat, shards, replicas);
+ }
+} \ No newline at end of file
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/KeepDataSearchHitConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/KeepDataSearchHitConverter.java
new file mode 100644
index 000000000..fa86c90e2
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/KeepDataSearchHitConverter.java
@@ -0,0 +1,43 @@
+/*
+ * ============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.data;
+
+import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
+
+public class KeepDataSearchHitConverter implements SearchHitConverter {
+
+
+ private final ComponentName name;
+
+ public KeepDataSearchHitConverter(ComponentName name) {
+ this.name = name;
+ }
+ @Override
+ public SearchHit convert(SearchHit source) {
+ return source;
+ }
+
+ @Override
+ public ComponentData convert(DataContainer container) {
+ return container.getComponents().get(this.name);
+ }
+}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/MavenDatabasePluginInitFile.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/MavenDatabasePluginInitFile.java
new file mode 100644
index 000000000..a63f8d4c1
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/MavenDatabasePluginInitFile.java
@@ -0,0 +1,58 @@
+/*
+ * ============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.data;
+
+import java.io.File;
+import java.io.IOException;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation;
+
+
+/**
+ * @author Michael Dürre
+ *
+ */
+public class MavenDatabasePluginInitFile {
+ private static final int replicas=1;
+ private static final int shards=5;
+ private static final String mappings="\"mappings\":%s";
+ private static final String settings="\"settings\":{\"index\":{\"number_of_shards\":%d,\"number_of_replicas\":%d},\"analysis\":{\"analyzer\":{\"content\":"+
+ "{\"type\":\"custom\",\"tokenizer\":\"whitespace\"}}}}";
+
+ public static void create(Release release, String filename) throws IOException {
+
+ ReleaseInformation ri = ReleaseInformation.getInstance(release);
+ Set<ComponentName> comps=ri.getComponents();
+ List<String> lines = new ArrayList<String>();
+ for(ComponentName c:comps) {
+ lines.add(String.format("PUT:%s/:{"+settings+","+mappings+"}",ri.getIndex(c),shards,replicas,ri.getDatabaseMapping(c)));
+ lines.add(String.format("PUT:%s/_alias/%s/:{}", ri.getIndex(c),ri.getAlias(c)));
+ }
+ Files.write(new File(filename).toPath(),lines,StandardCharsets.UTF_8);
+
+ }
+}
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
new file mode 100644
index 000000000..ae4522dc5
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java
@@ -0,0 +1,98 @@
+/*
+ * ============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.data;
+
+import org.onap.ccsdk.features.sdnr.wt.common.database.data.AliasesEntry;
+import org.onap.ccsdk.features.sdnr.wt.common.database.data.EsVersion;
+
+public enum Release {
+
+ EL_ALTO("el alto","_v1",new EsVersion(2,2,0),new EsVersion(2,2,0)),
+ FRANKFURT_R1("frankfurt-R1","-v2",new EsVersion(6,4,3),new EsVersion(6,8,6)),
+ FRANKFURT_R2("frankfurt-R2","",new EsVersion(6,4,3),new EsVersion(6,8,6)),
+ FRANKFURT_R3("frankfurt-R3","",new EsVersion(6,4,3),new EsVersion(6,8,6)),
+
+ GUILIN("guilin","",new EsVersion(6,4,3),new EsVersion(6,8,6));
+
+ public static final Release CURRENT_RELEASE = Release.FRANKFURT_R1;
+
+ private final String value;
+ private final String dbSuffix;
+ private final EsVersion minDbVersion;
+ private final EsVersion maxDbVersion;
+
+ private Release(String s,String dbsuffix,EsVersion minDbVersion,EsVersion maxDbVersion) {
+ this.value = s;
+ this.dbSuffix=dbsuffix;
+ this.minDbVersion = minDbVersion;
+ this.maxDbVersion = maxDbVersion;
+ }
+ @Override
+ public String toString() {
+ return this.value;
+ }
+ public String getValue() {
+ return value;
+ }
+ public static Release getValueOf(String s) throws Exception {
+ //s = s.toLowerCase();
+ for(Release p:Release.values()) {
+ if(p.value.equals(s)) {
+ return p;
+ }
+ }
+ throw new Exception("value not found");
+ }
+ public static Release getValueBySuffix(String suffix) {
+ for(Release r:Release.values()) {
+ if(r.dbSuffix.equals(suffix))
+ return r;
+ }
+ return null;
+ }
+ public static String getDbSuffix(AliasesEntry entry) throws Exception {
+ ComponentName comp = ComponentName.getValueOf(entry.getAlias());
+ if(comp!=null) {
+ return entry.getIndex().substring(entry.getAlias().length());
+ }
+ return null;
+ }
+ /**
+ * @return
+ */
+ public String getDBSuffix() {
+ return this.dbSuffix;
+ }
+ /**
+ * @return
+ */
+ public EsVersion getDBVersion() {
+ return this.minDbVersion;
+ }
+ /**
+ * @param dbVersion2
+ * @return
+ */
+ public boolean isDbInRange(EsVersion dbVersion) {
+ return dbVersion.isNewerOrEqualThan(minDbVersion) && dbVersion.isOlderOrEqualThan(maxDbVersion);
+ }
+}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/SearchHitConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/SearchHitConverter.java
new file mode 100644
index 000000000..7a549ca86
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/SearchHitConverter.java
@@ -0,0 +1,64 @@
+/*
+ * ============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.data;
+
+import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.elalto.ElAltoReleaseInformation;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.frankfurt.FrankfurtReleaseInformation;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.guilin.GuilinReleaseInformation;
+
+public interface SearchHitConverter {
+
+ /**
+ * convert single entry of database
+ * @param source
+ * @return
+ */
+ public SearchHit convert(SearchHit source);
+
+ /**
+ * @param component destination component
+ * @param container source data
+ * @return data for destination component
+ */
+ public ComponentData convert(DataContainer container);
+
+
+ public static class Factory{
+ public static SearchHitConverter getInstance(Release src,Release dst, ComponentName component) {
+ switch(src) {
+ case EL_ALTO:
+ return new ElAltoReleaseInformation().getConverter(dst, component);
+ case FRANKFURT_R1:
+ return new FrankfurtReleaseInformation().getConverter(dst, component);
+ case GUILIN:
+ return new GuilinReleaseInformation().getConverter(dst, component);
+ default:
+ return null;
+
+ }
+ }
+ }
+
+
+
+}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/ElAltoReleaseInformation.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/ElAltoReleaseInformation.java
new file mode 100644
index 000000000..559468f79
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/ElAltoReleaseInformation.java
@@ -0,0 +1,92 @@
+/*
+ * ============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.elalto;
+
+import java.util.HashMap;
+import java.util.Map;
+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.KeepDataSearchHitConverter;
+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.ReleaseInformation;
+
+public class ElAltoReleaseInformation extends ReleaseInformation {
+
+
+ private Map<Release, Map<ComponentName, SearchHitConverter>> converters;
+
+ public ElAltoReleaseInformation() {
+ super(Release.EL_ALTO, createDbInfos());
+ this.converters = generateConverters();
+ }
+
+ private static Map<ComponentName, DatabaseInfo> createDbInfos() {
+ Map<ComponentName,DatabaseInfo> map = new HashMap<>();
+ map.put(ComponentName.EVENTLOG, new DatabaseInfo("sdnevents","eventlog",""));
+ map.put(ComponentName.FAULTCURRENT, new DatabaseInfo("sdnevents","faultcurrent",""));
+ map.put(ComponentName.FAULTLOG, new DatabaseInfo("sdnevents","faultlog",""));
+ map.put(ComponentName.INVENTORY, new DatabaseInfo("sdnevents","inventoryequipment",""));
+ map.put(ComponentName.INVENTORYTOPLEVEL, new DatabaseInfo("sdnevents","inventorytoplevel",""));
+ map.put(ComponentName.HISTORICAL_PERFORMANCE_15M, new DatabaseInfo("sdnperformance","historicalperformance15min",""));
+ map.put(ComponentName.HISTORICAL_PERFORMANCE_24H, new DatabaseInfo("sdnperformance","historicalperformance24h",""));
+ map.put(ComponentName.REQUIRED_NETWORKELEMENT, new DatabaseInfo("mwtn","required-networkelement","{\"required-networkelement\": {\"date_detection\": false }}"));
+ map.put(ComponentName.MEDIATOR_SERVER, new DatabaseInfo("mwtn","mediator-server",""));
+ map.put(ComponentName.MAINTENANCE, new DatabaseInfo("mwtn","maintenancemode",""));
+ return map;
+ }
+
+ /**
+ * @return components used in el alto
+ */
+
+
+ private static Map<Release, Map<ComponentName, SearchHitConverter>> generateConverters() {
+ Map<Release, Map<ComponentName, SearchHitConverter>> c = new HashMap<>();
+ Map<ComponentName, SearchHitConverter> frankfurtConverters = new HashMap<>();
+ frankfurtConverters.put(ComponentName.EVENTLOG, new FrankfurtEventlogConverter());
+ frankfurtConverters.put(ComponentName.FAULTCURRENT, new FrankfurtFaultcurrentConverter());
+ frankfurtConverters.put(ComponentName.FAULTLOG, new FrankfurtFaultlogConverter());
+ frankfurtConverters.put(ComponentName.INVENTORY, new KeepDataSearchHitConverter(ComponentName.INVENTORY));
+ //obsolete in frankfurt
+ //frankfurtConverters.put(ComponentName.INVENTORYTOPLEVEL, new KeepDataSearchHitConverter(ComponentName.INVENTORYTOPLEVEL));
+ frankfurtConverters.put(ComponentName.HISTORICAL_PERFORMANCE_15M, new KeepDataSearchHitConverter(ComponentName.HISTORICAL_PERFORMANCE_15M));
+ frankfurtConverters.put(ComponentName.HISTORICAL_PERFORMANCE_24H, new KeepDataSearchHitConverter(ComponentName.HISTORICAL_PERFORMANCE_24H));
+ frankfurtConverters.put(ComponentName.MAINTENANCE, new FrankfurtMaintenanceConverter());
+ frankfurtConverters.put(ComponentName.MEDIATOR_SERVER, new KeepDataSearchHitConverter(ComponentName.MEDIATOR_SERVER));
+ frankfurtConverters.put(ComponentName.REQUIRED_NETWORKELEMENT, new FrankfurtRequiredNetworkElementConverter());
+ frankfurtConverters.put(ComponentName.CONNECTIONLOG,new FrankfurtConnectionlogConverter());
+ c.put(Release.FRANKFURT_R1,frankfurtConverters);
+ return c;
+ }
+
+ @Override
+ public SearchHitConverter getConverter(Release dst, ComponentName comp) {
+ SearchHitConverter c=this.converters.containsKey(dst)?this.converters.get(dst).get(comp):null;
+ if(c==null) {
+ c=super.getConverter(dst, comp);
+ }
+ return c;
+ }
+
+
+}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtConnectionlogConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtConnectionlogConverter.java
new file mode 100644
index 000000000..d68373199
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtConnectionlogConverter.java
@@ -0,0 +1,120 @@
+/*
+ * ============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.elalto;
+
+import java.util.Map;
+
+import org.json.JSONObject;
+import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.BaseSearchHitConverter;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentData;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DataContainer;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.frankfurt.data.ConnectionLogStatus;
+
+/**
+ *
+ * @author Michael Dürre
+ *
+ * Convert data from el alto to frankfurt
+ *
+ * src: eventlog
+ * dst: connectionlog
+ *
+ *
+ * {
+ * "event": {
+ * "nodeName": "SDN-Controller-5a150173d678",
+ * "counter": "48",
+ * "timeStamp": "2019-10-07T09:57:08.2Z",
+ * "objectId": "Sim2230",
+ * "attributeName": "ConnectionStatus",
+ * "newValue": "connecting",
+ * "type": "AttributeValueChangedNotificationXml"
+ * }
+ * }
+ *
+ * =>
+ *
+ * {
+ * "timestamp": "2020-01-28T12:00:10.2Z",
+ * "status": "Connected",
+ * "node-id": "sim1"
+ * }
+ *
+ */
+public class FrankfurtConnectionlogConverter extends BaseSearchHitConverter {
+
+ public FrankfurtConnectionlogConverter() {
+ super(ComponentName.CONNECTIONLOG);
+ }
+
+ /**
+ * @source eventlog searchhit converted to connectionlog entry
+ */
+ @Override
+ public SearchHit convert(SearchHit source) {
+
+ JSONObject data = new JSONObject();
+ JSONObject inner = source.getSource().getJSONObject("event");
+ String eventType = inner.getString("type");
+ String eventSource = inner.getString("nodeName");
+ if (!eventSource.startsWith("SDN-Controller")) {
+ return null;
+ }
+ data.put("node-id", inner.getString("objectId"));
+ data.put("timestamp", inner.getString("timeStamp"));
+ if (eventType.equals("AttributeValueChangedNotificationXml")) {
+ String event = inner.getString("newValue").toLowerCase();
+ if (event.equals("connected")) {
+ data.put("status", ConnectionLogStatus.Connected.getName());
+ } else if (event.equals("connecting")) {
+ data.put("status", ConnectionLogStatus.Connecting.getName());
+ } else {
+ data.put("status", ConnectionLogStatus.UnableToConnect.getName());
+ }
+
+ } else if (eventType.equals("ObjectCreationNotificationXml")) {
+ data.put("status", ConnectionLogStatus.Mounted.getName());
+
+ } else if (eventType.equals("ObjectDeletionNotificationXml")) {
+ data.put("status", ConnectionLogStatus.Unmounted.getName());
+ }
+
+ return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data);
+ }
+
+ @Override
+ public ComponentData convert(DataContainer container) {
+ Map<ComponentName, ComponentData> src = container.getComponents();
+ if (!src.containsKey(ComponentName.EVENTLOG)) {
+ return null;
+ }
+ ComponentData eventData = src.get(ComponentName.EVENTLOG);
+ ComponentData dstData = new ComponentData(ComponentName.CONNECTIONLOG);
+ for (SearchHit sh : eventData) {
+ dstData.add(this.convert(sh));
+ }
+ return dstData;
+ }
+
+}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtEventlogConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtEventlogConverter.java
new file mode 100644
index 000000000..e04378bbe
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtEventlogConverter.java
@@ -0,0 +1,55 @@
+/*
+ * ============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.elalto;
+
+import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.BaseSearchHitConverter;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentData;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DataContainer;
+
+/**
+ *
+ * @author Michael Dürre
+ *
+ *
+ * Cannot be converted from el alto to frankfurt
+ * most of the entries are in connectionlog
+ *
+ */
+public class FrankfurtEventlogConverter extends BaseSearchHitConverter{
+
+ public FrankfurtEventlogConverter() {
+ super(ComponentName.EVENTLOG);
+ }
+
+ @Override
+ public SearchHit convert(SearchHit source) {
+ return null;
+ }
+
+ @Override
+ public ComponentData convert(DataContainer container) {
+ return null;
+ }
+
+}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultcurrentConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultcurrentConverter.java
new file mode 100644
index 000000000..060434fe9
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultcurrentConverter.java
@@ -0,0 +1,80 @@
+/*
+ * ============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.elalto;
+
+import org.json.JSONObject;
+import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.BaseSearchHitConverter;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName;
+
+/**
+ *
+ * @author Michael Dürre
+ *
+ * {
+ * "faultCurrent": {
+ * "nodeName": "sim9090",
+ * "counter": "50443",
+ * "timeStamp": "2017-07-27T13:33:49.0Z",
+ * "objectId": "a2.module-1.1.5.6",
+ * "problem": "Ais",
+ * "severity": "Major",
+ * "type": "ProblemNotificationXml"
+ * }
+ * }
+ *
+ * =>
+ *
+ * {
+ * "timestamp": "2017-01-01T00:00:00.0Z",
+ * "object-id": "LP-MWS-TTP-01",
+ * "severity": "Warning",
+ * "counter": 2,
+ * "node-id": "sim1",
+ * "problem": "unknownProblem2"
+ * }
+ */
+public class FrankfurtFaultcurrentConverter extends BaseSearchHitConverter {
+
+ /**
+ * @param name
+ */
+ public FrankfurtFaultcurrentConverter() {
+ super(ComponentName.FAULTCURRENT);
+ }
+
+ @Override
+ public SearchHit convert(SearchHit source) {
+
+ JSONObject data = new JSONObject();
+ JSONObject src = source.getSource();
+ JSONObject srcInner = src.getJSONObject("faultCurrent");
+ data.put("node-id", srcInner.getString("nodeName"));
+ data.put("severity", srcInner.getString("severity"));
+ data.put("counter", Long.parseLong(srcInner.getString("counter")));
+ data.put("timestamp", srcInner.getString("timeStamp"));
+ data.put("object-id",srcInner.getString("objectId"));
+ data.put("problem", srcInner.getString("problem"));
+
+ return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data );
+ }
+}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultlogConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultlogConverter.java
new file mode 100644
index 000000000..87e71c612
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultlogConverter.java
@@ -0,0 +1,78 @@
+/*
+ * ============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.elalto;
+
+import org.json.JSONObject;
+import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.BaseSearchHitConverter;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName;
+
+/**
+ *
+ * @author Michael Dürre
+ *{
+ * "fault": {
+ * "nodeName": "SDN-Controller-5a150173d678",
+ * "counter": "380",
+ * "timeStamp": "2019-10-18T18:40:25.0Z",
+ * "objectId": "ADVA-DTAG-Nuernberg-3",
+ * "problem": "connectionLossOAM",
+ * "severity": "Major",
+ * "type": "ProblemNotificationXml"
+ * }
+ *}
+ *
+ * =>
+ *{
+ * "timestamp": "2017-01-01T00:00:00.0Z",
+ * "object-id": "LP-MWPS-RADIO",
+ * "severity": "Critical",
+ * "counter": -1,
+ * "node-id": "sim1",
+ * "source-type": "Netconf",
+ * "problem": "signalIsLost"
+ *}
+ *
+ */
+public class FrankfurtFaultlogConverter extends BaseSearchHitConverter{
+
+ public FrankfurtFaultlogConverter() {
+ super(ComponentName.FAULTLOG);
+ }
+
+ @Override
+ public SearchHit convert(SearchHit source) {
+
+ JSONObject data = new JSONObject();
+ JSONObject src = source.getSource();
+ JSONObject srcInner = src.getJSONObject("fault");
+ data.put("node-id", srcInner.getString("nodeName"));
+ data.put("severity", srcInner.getString("severity"));
+ data.put("counter", Long.parseLong(srcInner.getString("counter")));
+ data.put("timestamp", srcInner.getString("timeStamp"));
+ data.put("object-id",srcInner.getString("objectId"));
+ data.put("problem", srcInner.getString("problem"));
+ data.put("type", "Netconf");
+ return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data );
+ }
+
+}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtMaintenanceConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtMaintenanceConverter.java
new file mode 100644
index 000000000..16be5d97b
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtMaintenanceConverter.java
@@ -0,0 +1,86 @@
+/*
+ * ============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.elalto;
+
+import org.json.JSONObject;
+import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.BaseSearchHitConverter;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName;
+
+/**
+ * convert maintenance object from el alto version to frankfurt
+ *
+ * @author jack
+ *
+ *{
+ * "node": "ddd",
+ * "filter": [
+ * {
+ * "definition": {
+ * "object-id-ref": "",
+ * "problem": ""
+ * },
+ * "description": "",
+ * "start": "2019-11-26T15:37+00:00",
+ * "end": "2019-11-26T23:37+00:00"
+ * }],
+ * "active": false
+ *}
+ * =>
+ *{
+ * "id": "sim1"
+ * "node-id": "sim1",
+ * "description": "",
+ * "start": "2020-01-28T12:00:17.6Z",
+ * "end": "2020-01-28T12:00:17.6Z",
+ * "active": false,
+ * "object-id-ref": "",
+ * "problem": ""
+ *
+ */
+public class FrankfurtMaintenanceConverter extends BaseSearchHitConverter {
+
+ public FrankfurtMaintenanceConverter() {
+ super(ComponentName.MAINTENANCE);
+ }
+
+ @Override
+ public SearchHit convert(SearchHit source) {
+
+ JSONObject src = source.getSource();
+ JSONObject data = new JSONObject();
+ data.put("id", src.getString("node"));
+ data.put("node-id", src.getString("node"));
+ data.put("active", src.getBoolean("active"));
+ JSONObject filter = null;
+ if (src.has("filter")) {
+ filter = src.getJSONArray("filter").length() > 0 ? src.getJSONArray("filter").getJSONObject(0) : null;
+ }
+ data.put("start", filter != null ? filter.getString("start") : "");
+ data.put("end", filter != null ? filter.getString("end") : "");
+ data.put("description", filter != null ? filter.getString("description") : "");
+ JSONObject definition = filter!=null?filter.has("definition")?filter.getJSONObject("definition"):null:null;
+ data.put("problem", definition!=null?definition.getString("problem"):"");
+ data.put("object-id-ref", definition!=null?definition.getString("object-id-ref"):"");
+ return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data);
+ }
+}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtRequiredNetworkElementConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtRequiredNetworkElementConverter.java
new file mode 100644
index 000000000..ef6de907e
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtRequiredNetworkElementConverter.java
@@ -0,0 +1,78 @@
+/*
+ * ============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.elalto;
+
+import org.json.JSONObject;
+import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.BaseSearchHitConverter;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.frankfurt.data.ConnectionLogStatus;
+
+/**
+ *
+ * @author Michael Dürre
+ *
+ * {
+ * "mountId":"nts-manager-dev-micha",
+ * "host":"10.20.5.2",
+ * "port":8300,
+ * "username":"netconf",
+ * "password":"netconf"
+ * }
+ *
+ * =>
+ *
+ * {
+ * "node-id": "sim1",
+ * "is-required": true,
+ * "password": "ads",
+ * "port": 12600,
+ * "host": "10.20.5.2",
+ * "id": "sim1",
+ * "username": "ad",
+ * "status": "Connected"
+ * }
+ *
+ */
+public class FrankfurtRequiredNetworkElementConverter extends BaseSearchHitConverter{
+
+ public FrankfurtRequiredNetworkElementConverter() {
+ super(ComponentName.REQUIRED_NETWORKELEMENT);
+ }
+
+ @Override
+ public SearchHit convert(SearchHit source) {
+
+ JSONObject data = new JSONObject();
+ JSONObject src = source.getSource();
+ data.put("id", src.getString("mountId"));
+ data.put("node-id", src.getString("mountId"));
+ data.put("username", src.getString("username"));
+ data.put("password", src.getString("password"));
+ data.put("host", src.getString("host"));
+ data.put("port", src.getInt("port"));
+ data.put("status", ConnectionLogStatus.Undefined.getName());
+ data.put("is-required", true);
+ return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data );
+ }
+
+}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformation.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformation.java
new file mode 100644
index 000000000..f83263b62
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformation.java
@@ -0,0 +1,77 @@
+/*
+ * ============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.frankfurt;
+
+import java.util.HashMap;
+import java.util.Map;
+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.Release;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.SearchHitConverter;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation;
+
+public class FrankfurtReleaseInformation extends ReleaseInformation {
+
+ private final Map<Release, Map<ComponentName, SearchHitConverter>> converters = new HashMap<>();
+
+ public FrankfurtReleaseInformation() {
+ super(Release.FRANKFURT_R1, createDBMap());
+ }
+
+ private static Map<ComponentName, DatabaseInfo> createDBMap() {
+ Map<ComponentName, DatabaseInfo> map = new HashMap<>();
+ map.put(ComponentName.CONNECTIONLOG, new DatabaseInfo("connectionlog", "connectionlog",
+ "{\"node-id\": {\"type\": \"keyword\"},\"timestamp\": {\"type\": \"date\"},\"status\": {\"type\": \"keyword\"}}"));
+ map.put(ComponentName.EVENTLOG, new DatabaseInfo("eventlog", "eventlog",
+ "{\"node-id\": {\"type\": \"keyword\"},\"source-type\": {\"type\": \"keyword\"},\"timestamp\": {\"type\": \"date\"},\"new-value\": {\"type\": \"keyword\"},\"attribute-name\": {\"type\": \"keyword\"},\"counter\": {\"type\": \"long\"},\"object-id\": {\"type\": \"keyword\"}}"));
+ map.put(ComponentName.FAULTCURRENT, new DatabaseInfo("faultcurrent", "faultcurrent",
+ "{\"node-id\": {\"type\": \"keyword\"},\"severity\": {\"type\": \"keyword\"},\"timestamp\": {\"type\": \"date\"},\"problem\": {\"type\": \"keyword\"},\"counter\": {\"type\": \"long\"},\"object-id\":{\"type\": \"keyword\"}}"));
+ map.put(ComponentName.FAULTLOG, new DatabaseInfo("faultlog", "faultlog",
+ "{\"node-id\": {\"type\": \"keyword\"},\"severity\": {\"type\": \"keyword\"},\"timestamp\": {\"type\": \"date\"},\"problem\": {\"type\": \"keyword\"},\"counter\": {\"type\": \"long\"},\"object-id\":{\"type\": \"keyword\"},\"source-type\":{\"type\": \"keyword\"}}"));
+ map.put(ComponentName.INVENTORY, new DatabaseInfo("inventoryequipment", "inventoryequipment",
+ "{\"date\": {\"type\": \"keyword\"},\"model-identifier\": {\"type\": \"keyword\"},\"manufacturer-identifier\": {\"type\": \"keyword\"},\"type-name\": {\"type\": \"keyword\"},\"description\": {\"type\": \"keyword\"},\"uuid\": {\"type\": \"keyword\"},\"version\": {\"type\": \"keyword\"},\"parent-uuid\": {\"type\": \"keyword\"},\"contained-holder\": {\"type\": \"keyword\"},\"node-id\": {\"type\": \"keyword\"},\"tree-level\": {\"type\": \"long\"},\"part-type-id\": {\"type\": \"keyword\"},\"serial\": {\"type\": \"keyword\"}}"));
+ map.put(ComponentName.HISTORICAL_PERFORMANCE_15M, new DatabaseInfo("historicalperformance15min",
+ "historicalperformance15min",
+ "{\"node-name\":{\"type\": \"keyword\"},\"timestamp\":{\"type\": \"date\"},\"suspect-interval-flag\":{\"type\":\"boolean\"},\"scanner-id\":{\"type\": \"keyword\"},\"uuid-interface\":{\"type\": \"keyword\"},\"layer-protocol-name\":{\"type\": \"keyword\"},\"granularity-period\":{\"type\": \"keyword\"},\"radio-signal-id\":{\"type\": \"keyword\"}}"));
+ map.put(ComponentName.HISTORICAL_PERFORMANCE_24H, new DatabaseInfo("historicalperformance24h",
+ "historicalperformance24h",
+ "{\"node-name\":{\"type\": \"keyword\"},\"timestamp\":{\"type\": \"date\"},\"suspect-interval-flag\":{\"type\":\"boolean\"},\"scanner-id\":{\"type\": \"keyword\"},\"uuid-interface\":{\"type\": \"keyword\"},\"layer-protocol-name\":{\"type\": \"keyword\"},\"granularity-period\":{\"type\": \"keyword\"},\"radio-signal-id\":{\"type\": \"keyword\"}}"));
+ map.put(ComponentName.REQUIRED_NETWORKELEMENT, new DatabaseInfo("networkelement-connection",
+ "networkelement-connection",
+ "{\"node-id\": {\"type\": \"keyword\"},\"host\": {\"type\": \"keyword\"},\"port\": {\"type\": \"long\"},\"username\": {\"type\": \"keyword\"},\"password\": {\"type\": \"keyword\"},\"core-model-capability\": {\"type\": \"keyword\"},\"device-type\": {\"type\": \"keyword\"},\"is-required\": {\"type\": \"boolean\"},\"status\": {\"type\": \"keyword\"}}"));
+ map.put(ComponentName.MEDIATOR_SERVER, new DatabaseInfo("mediator-server", "mediator-server",
+ "{\"url\":{\"type\": \"keyword\"},\"name\":{\"type\": \"keyword\"}}"));
+ map.put(ComponentName.MAINTENANCE, new DatabaseInfo("maintenancemode", "maintenancemode",
+ "{\"node-id\": {\"type\": \"keyword\"},\"active\": {\"type\": \"boolean\"}},\"date_detection\":false}}"));
+ return map;
+ }
+
+ @Override
+ public SearchHitConverter getConverter(Release dst, ComponentName comp) {
+ SearchHitConverter c=this.converters.containsKey(dst)?this.converters.get(dst).get(comp):null;
+ if(c==null) {
+ c=super.getConverter(dst, comp);
+ }
+ return c;
+ }
+
+}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/data/ConnectionLogStatus.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/data/ConnectionLogStatus.java
new file mode 100644
index 000000000..7615c4452
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/data/ConnectionLogStatus.java
@@ -0,0 +1,38 @@
+/*
+ * ============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.frankfurt.data;
+
+/**
+ * @author Michael Dürre
+ *
+ */
+public enum ConnectionLogStatus {
+ Connected, Connecting, UnableToConnect, Mounted, Unmounted, Undefined;
+
+ /**
+ * @return
+ */
+ public String getName() {
+ return this.name();
+ }
+
+}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformation.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformation.java
new file mode 100644
index 000000000..4912e4bc4
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformation.java
@@ -0,0 +1,71 @@
+/*
+ * ============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.guilin;
+
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.KeepDataSearchHitConverter;
+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.ReleaseInformation;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DatabaseInfo;
+
+public class GuilinReleaseInformation extends ReleaseInformation {
+
+ /**
+ * @param r
+ * @param dbMap
+ */
+ public GuilinReleaseInformation() {
+ super(Release.GUILIN, createDBMap());
+
+ }
+
+ private static Map<ComponentName, DatabaseInfo> createDBMap() {
+ Map<ComponentName, DatabaseInfo> map = new HashMap<>();
+ map.put(ComponentName.EVENTLOG, new DatabaseInfo("eventlog", "eventlog", ""));
+ map.put(ComponentName.FAULTCURRENT, new DatabaseInfo("faultcurrent", "faultcurrent", ""));
+ map.put(ComponentName.FAULTLOG, new DatabaseInfo("faultlog", "faultlog", ""));
+ map.put(ComponentName.INVENTORY, new DatabaseInfo("inventoryequipment", "inventoryequipment", ""));
+ map.put(ComponentName.HISTORICAL_PERFORMANCE_15M,
+ new DatabaseInfo("historicalperformance15min", "historicalperformance15min", ""));
+ map.put(ComponentName.HISTORICAL_PERFORMANCE_24H,
+ new DatabaseInfo("historicalperformance24h", "historicalperformance24h", ""));
+ map.put(ComponentName.REQUIRED_NETWORKELEMENT,
+ new DatabaseInfo("networkelement-connection", "networkelement-connection", ""));
+ map.put(ComponentName.MEDIATOR_SERVER, new DatabaseInfo("mediator-server", "mediator-server", ""));
+ map.put(ComponentName.MAINTENANCE, new DatabaseInfo("maintenancemode", "maintenancemode", ""));
+ return map;
+ }
+
+ @Override
+ public SearchHitConverter getConverter(Release dst, ComponentName comp) {
+ if (dst == Release.GUILIN) {
+ return new KeepDataSearchHitConverter(comp);
+ }
+ return null;
+ }
+
+}