From a2eeabae39d005aee24425315b32ddb07af0570c Mon Sep 17 00:00:00 2001 From: Michael Dürre Date: Thu, 3 Sep 2020 12:58:43 +0200 Subject: update data migration tool MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix guilin database schema and init Issue-ID: CCSDK-2727 Signed-off-by: Michael Dürre Change-Id: Ic688a835b90a3e64ef01a010f601b9a7b953d320 --- .../wt/dataprovider/setup/ReleaseInformation.java | 20 +++--- .../sdnr/wt/dataprovider/setup/data/Release.java | 13 ++-- .../wt/dataprovider/setup/data/ReleaseGroup.java | 6 +- .../frankfurt/FrankfurtReleaseInformationR2.java | 10 +-- .../setup/guilin/GuilinReleaseInformation.java | 42 ++++------- .../setup/guilin/GuilinReleaseInformationR2.java | 81 ---------------------- .../dataprovider/setup/TestMigrationProvider.java | 3 +- 7 files changed, 36 insertions(+), 139 deletions(-) delete mode 100644 sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformationR2.java (limited to 'sdnr/wt/data-provider') diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java index d772dc296..9b7a49346 100644 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java @@ -23,7 +23,6 @@ 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.HtDatabaseClient; import org.onap.ccsdk.features.sdnr.wt.common.database.data.IndicesEntryList; import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName; @@ -35,7 +34,6 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.elalto.ElAltoReleaseIn import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.frankfurt.FrankfurtReleaseInformation; import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.frankfurt.FrankfurtReleaseInformationR2; import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.guilin.GuilinReleaseInformation; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.guilin.GuilinReleaseInformationR2; public abstract class ReleaseInformation { @@ -53,7 +51,7 @@ public abstract class ReleaseInformation { /** * get database alias for component - * + * * @param name * @return alias or null if not exists */ @@ -67,7 +65,7 @@ public abstract class ReleaseInformation { /** * get index name for component - * + * * @param comp * @return null if component does not exists in this release, otherwise index name */ @@ -77,7 +75,7 @@ public abstract class ReleaseInformation { /** * get index name for component with prefix - * + * * @param comp * @param prefix * @return null if component does not exists in this release, otherwise index name @@ -88,7 +86,7 @@ public abstract class ReleaseInformation { /** * get database datatype (doctype) for component - * + * * @param name * @return datatype or null if not exists */ @@ -102,7 +100,7 @@ public abstract class ReleaseInformation { /** * get database doctype definition for component - * + * * @param name * @return mappings or null if not exists */ @@ -112,7 +110,7 @@ public abstract class ReleaseInformation { /** * get database settings definition for component - * + * * @param name * @return settings or null if not exists */ @@ -122,7 +120,7 @@ public abstract class ReleaseInformation { /** * get converter for component data - * + * * @param dst destination release * @param comp component to convert * @return @@ -144,8 +142,6 @@ public abstract class ReleaseInformation { return new FrankfurtReleaseInformationR2(); case GUILIN_R1: return new GuilinReleaseInformation(); - case GUILIN_R2: - return new GuilinReleaseInformationR2(); default: return null; } @@ -192,7 +188,7 @@ public abstract class ReleaseInformation { protected abstract boolean runPreInitCommands(HtDatabaseClient dbClient); /** - * + * * @param dbClient * @return if succeeded or not */ diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java index b2442df6b..4f55f4cd7 100644 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java @@ -26,15 +26,12 @@ 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", "-v3", new EsVersion(7, 0, 1), - new EsVersion(7, 6, 1)), - //FRANKFURT_R3("frankfurt-R3","",new EsVersion(6,4,3),new EsVersion(6,8,6)), + 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", "-v3", new EsVersion(7, 0, 1), new EsVersion(7, 6, 1)), + GUILIN_R1("guilin-R1", "-v4", new EsVersion(7,1,1), new EsVersion(7,6,1)); - GUILIN_R1("guilin-R1", "-v4", new EsVersion(6, 4, 3), new EsVersion(6, 8, 6)), GUILIN_R2("guilin-R2", "-v5", - new EsVersion(7, 0, 1), new EsVersion(7, 6, 1)); - - public static final Release CURRENT_RELEASE = Release.FRANKFURT_R1; + public static final Release CURRENT_RELEASE = Release.GUILIN_R1; private final String value; private final String dbSuffix; diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ReleaseGroup.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ReleaseGroup.java index c7d26dbed..993d0261f 100644 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ReleaseGroup.java +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ReleaseGroup.java @@ -23,7 +23,6 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data; import java.util.ArrayList; import java.util.List; - import org.onap.ccsdk.features.sdnr.wt.common.database.data.EsVersion; /** @@ -32,10 +31,9 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.data.EsVersion; */ public enum ReleaseGroup { - EL_ALTO(Release.EL_ALTO), FRANKFURT(Release.FRANKFURT_R1, Release.FRANKFURT_R2), GUILIN(Release.GUILIN_R1, - Release.GUILIN_R2); + EL_ALTO(Release.EL_ALTO), FRANKFURT(Release.FRANKFURT_R1, Release.FRANKFURT_R2), GUILIN(Release.GUILIN_R1); - public static final ReleaseGroup CURRENT_RELEASE = FRANKFURT; + public static final ReleaseGroup CURRENT_RELEASE = GUILIN; private final List releases; diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformationR2.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformationR2.java index e842b5c7b..f972777b9 100644 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformationR2.java +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformationR2.java @@ -24,6 +24,10 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.frankfurt; import java.io.IOException; import java.util.HashMap; import java.util.Map; +import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; +import org.onap.ccsdk.features.sdnr.wt.common.database.requests.ClusterSettingsRequest; +import org.onap.ccsdk.features.sdnr.wt.common.database.responses.ClusterSettingsResponse; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation; import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName; import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DatabaseInfo; import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DatabaseInfo7; @@ -31,10 +35,6 @@ 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; -import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; -import org.onap.ccsdk.features.sdnr.wt.common.database.requests.ClusterSettingsRequest; -import org.onap.ccsdk.features.sdnr.wt.common.database.responses.ClusterSettingsResponse; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation; public class FrankfurtReleaseInformationR2 extends ReleaseInformation { @@ -45,7 +45,7 @@ public class FrankfurtReleaseInformationR2 extends ReleaseInformation { super(Release.FRANKFURT_R2, createDBMap()); } - private static Map createDBMap() { + public static Map createDBMap() { Map map = new HashMap<>(); map.put(ComponentName.CONNECTIONLOG, new DatabaseInfo7("connectionlog", "connectionlog", "{\"node-id\": {\"type\": \"keyword\"},\"timestamp\": {\"type\": \"date\"},\"status\": {\"type\": \"keyword\"}}")); 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 index 2c2ac25a9..e057d82f2 100644 --- 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 @@ -21,43 +21,25 @@ */ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.guilin; -import java.util.HashMap; -import java.util.Map; - +import java.io.IOException; import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; +import org.onap.ccsdk.features.sdnr.wt.common.database.requests.ClusterSettingsRequest; +import org.onap.ccsdk.features.sdnr.wt.common.database.responses.ClusterSettingsResponse; import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation; import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DatabaseInfo; import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.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.frankfurt.FrankfurtReleaseInformationR2; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class GuilinReleaseInformation extends ReleaseInformation { - /** - * @param r - * @param dbMap - */ + private final Logger LOG = LoggerFactory.getLogger(GuilinReleaseInformation.class); public GuilinReleaseInformation() { - super(Release.GUILIN_R1, createDBMap()); - - } + super(Release.GUILIN_R1, FrankfurtReleaseInformationR2.createDBMap()); - private static Map createDBMap() { - Map 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 @@ -70,7 +52,13 @@ public class GuilinReleaseInformation extends ReleaseInformation { @Override protected boolean runPreInitCommands(HtDatabaseClient dbClient) { - return true; + ClusterSettingsResponse response = null; + try { + response = dbClient.setupClusterSettings(new ClusterSettingsRequest(false).maxCompilationsPerMinute(400)); + } catch (IOException e) { + LOG.warn("problem setting up cluster: {}", e); + } + return response == null ? false : response.isAcknowledged(); } @Override diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformationR2.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformationR2.java deleted file mode 100644 index 29c79f3da..000000000 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformationR2.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * ============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.Map; - -import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DatabaseInfo; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.KeepDataSearchHitConverter; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release; -import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.SearchHitConverter; - -public class GuilinReleaseInformationR2 extends ReleaseInformation { - - /** - * @param r - * @param dbMap - */ - public GuilinReleaseInformationR2() { - super(Release.GUILIN_R2, createDBMap()); - - } - - private static Map createDBMap() { - Map 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_R2) { - return new KeepDataSearchHitConverter(comp); - } - return null; - } - - @Override - protected boolean runPreInitCommands(HtDatabaseClient dbClient) { - return true; - } - - @Override - protected boolean runPostInitCommands(HtDatabaseClient dbClient) { - return true; - } - -} diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMigrationProvider.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMigrationProvider.java index 32438410f..aaa33839f 100644 --- a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMigrationProvider.java +++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMigrationProvider.java @@ -24,7 +24,6 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; - import org.junit.Test; import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo; import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DataMigrationReport; @@ -54,7 +53,7 @@ public class TestMigrationProvider { //import data into database DataMigrationReport report = provider.importData(FRANKFURT_BACKUP_FILE, false, Release.FRANKFURT_R2); assertTrue(report.completed()); - assertEquals(Release.FRANKFURT_R2, provider.autoDetectRelease()); + assertEquals(Release.CURRENT_RELEASE, provider.autoDetectRelease()); } catch (Exception e) { fail(e.getMessage()); } -- cgit 1.2.3-korg