From f88794b887842911b30a75afc53f87f660d1c1e7 Mon Sep 17 00:00:00 2001 From: Michael DÜrre Date: Thu, 19 Nov 2020 15:40:16 +0100 Subject: adapt ES version to 7.9.x MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit add new ES mapping for honolulu Issue-ID: SDNC-1411 Signed-off-by: Michael DÜrre Change-Id: I477f87cd5b6da564663b6677e3cd94afef4dd1a6 --- sdnr/wt/common/pom.xml | 2 +- .../sdnr/wt/common/database/data/DbFilter.java | 20 ++++-- .../sdnr/wt/common/database/data/EsVersion.java | 8 ++- ...ServletInputStreamFromByteArrayInputStream.java | 45 ++++++++++++ ...ServletOutputStreamToByteArrayOutputStream.java | 43 ++++++++++++ .../test/ServletOutputStreamToStringWriter.java | 43 ++++++++++++ .../wt/common/test/helper/HelpServletBase.java | 37 +++------- sdnr/wt/data-provider/provider/pom.xml | 4 +- sdnr/wt/data-provider/setup/pom.xml | 2 +- .../wt/dataprovider/setup/ReleaseInformation.java | 3 + .../wt/dataprovider/setup/data/ComponentName.java | 7 +- .../sdnr/wt/dataprovider/setup/data/Release.java | 29 ++++---- .../wt/dataprovider/setup/data/ReleaseGroup.java | 4 +- .../setup/honolulu/HonoluluReleaseInformation.java | 79 ++++++++++++++++++++++ 14 files changed, 268 insertions(+), 58 deletions(-) create mode 100644 sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletInputStreamFromByteArrayInputStream.java create mode 100644 sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToByteArrayOutputStream.java create mode 100644 sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToStringWriter.java create mode 100644 sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/honolulu/HonoluluReleaseInformation.java (limited to 'sdnr') diff --git a/sdnr/wt/common/pom.xml b/sdnr/wt/common/pom.xml index 2698c3a2a..a1b54af6e 100644 --- a/sdnr/wt/common/pom.xml +++ b/sdnr/wt/common/pom.xml @@ -120,7 +120,7 @@ testCluster 9500 ${databaseport} - 7.1.1 + 7.9.3 120 diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/DbFilter.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/DbFilter.java index 2a8f04df3..82c036406 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/DbFilter.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/DbFilter.java @@ -21,10 +21,14 @@ */ package org.onap.ccsdk.features.sdnr.wt.common.database.data; +import java.util.Arrays; +import java.util.List; import org.onap.ccsdk.features.sdnr.wt.common.database.queries.RangeQueryBuilder; public class DbFilter { + private static final List timestampValueNames = Arrays.asList("timestamp", "start", "end", "date"); + public static String createDatabaseRegex(String restFilterValue) { return restFilterValue == null ? null : restFilterValue.replace("?", ".{1,1}").replace("*", ".*"); } @@ -36,18 +40,21 @@ public class DbFilter { public static boolean isComparisonValid(String restFilterValue) { return restFilterValue == null ? false : restFilterValue.contains(">") || restFilterValue.contains("<"); } + public static boolean isDatetimeKeyValue(String key, String value) { + return timestampValueNames.contains(key.toLowerCase()); + } public static RangeQueryBuilder getRangeQuery(String key, String restFilterValue) { RangeQueryBuilder query = new RangeQueryBuilder(key); restFilterValue = restFilterValue.trim(); if (restFilterValue.startsWith(">=")) { - query.gte(getObjectFromString(restFilterValue.substring(2).trim())); + query.gte(getObjectFromString(key,restFilterValue.substring(2).trim())); } else if (restFilterValue.startsWith(">")) { - query.gt(getObjectFromString(restFilterValue.substring(1).trim())); + query.gt(getObjectFromString(key,restFilterValue.substring(1).trim())); } else if (restFilterValue.startsWith("<=")) { - query.lte(getObjectFromString(restFilterValue.substring(2).trim())); + query.lte(getObjectFromString(key,restFilterValue.substring(2).trim())); } else if (restFilterValue.startsWith("<")) { - query.lt(getObjectFromString(restFilterValue.substring(1).trim())); + query.lt(getObjectFromString(key,restFilterValue.substring(1).trim())); } else { return null; } @@ -55,7 +62,10 @@ public class DbFilter { return query; } - private static Object getObjectFromString(String str) { + private static Object getObjectFromString(String key, String str) { + if(isDatetimeKeyValue(key, str)) { + return str; + } try { return Double.parseDouble(str); } catch (NumberFormatException | NullPointerException nfe) { diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/EsVersion.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/EsVersion.java index 1dd1c3d53..e1fd02de0 100644 --- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/EsVersion.java +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/EsVersion.java @@ -22,7 +22,6 @@ package org.onap.ccsdk.features.sdnr.wt.common.database.data; import java.text.ParseException; - import org.eclipse.jdt.annotation.NonNull; @@ -104,6 +103,9 @@ public class EsVersion { if (this.equals(v)) { return true; } + return this.isNewerThan(v); + } + public boolean isNewerThan(EsVersion v) { if (this.major > v.major) { return true; } else if (this.major < v.major) { @@ -124,6 +126,10 @@ public class EsVersion { if (this.equals(v)) { return true; } + return this.isOlderThan(v); + } + + public boolean isOlderThan(EsVersion v) { if (this.major < v.major) { return true; } else if (this.major > v.major) { diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletInputStreamFromByteArrayInputStream.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletInputStreamFromByteArrayInputStream.java new file mode 100644 index 000000000..b926ff65c --- /dev/null +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletInputStreamFromByteArrayInputStream.java @@ -0,0 +1,45 @@ +/* + * ============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.common.test; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import javax.servlet.ServletInputStream; + +public class ServletInputStreamFromByteArrayInputStream extends ServletInputStream { + + // variables + private ByteArrayInputStream bis; + // end of variables + + // constructors + public ServletInputStreamFromByteArrayInputStream(byte[] data) { + bis = new ByteArrayInputStream(data); + } + // end of constructors + + @Override + public int read() throws IOException { + return bis.read(); + } + +} diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToByteArrayOutputStream.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToByteArrayOutputStream.java new file mode 100644 index 000000000..1914d9b67 --- /dev/null +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToByteArrayOutputStream.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.common.test; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import javax.servlet.ServletOutputStream; + +public class ServletOutputStreamToByteArrayOutputStream extends ServletOutputStream { + + // variables + ByteArrayOutputStream out = new ByteArrayOutputStream(); + + // end of variables + + @Override + public void write(int arg0) throws IOException { + out.write(arg0); + } + + public ByteArrayOutputStream getByteArrayOutputStream() { + return out; + } +} diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToStringWriter.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToStringWriter.java new file mode 100644 index 000000000..57ed596ae --- /dev/null +++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/ServletOutputStreamToStringWriter.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.common.test; + +import java.io.IOException; +import java.io.StringWriter; +import javax.servlet.ServletOutputStream; + +public class ServletOutputStreamToStringWriter extends ServletOutputStream { + + // variables + private StringWriter out = new StringWriter(); + // end of variables + + @Override + public void write(int arg0) throws IOException { + out.write(arg0); + } + + public StringWriter getStringWriter() { + return out; + } + +} diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServletBase.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServletBase.java index dbdaace34..a3d2c9be9 100644 --- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServletBase.java +++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServletBase.java @@ -27,29 +27,23 @@ import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; - -import java.io.ByteArrayInputStream; +import com.sun.net.httpserver.HttpExchange; +import com.sun.net.httpserver.HttpHandler; +import com.sun.net.httpserver.HttpServer; import java.io.IOException; import java.io.OutputStream; -import java.io.StringWriter; import java.net.InetSocketAddress; import java.util.Enumeration; import java.util.Map; import java.util.Vector; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; - -import javax.servlet.ServletInputStream; -import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; - import org.junit.After; import org.junit.Before; - -import com.sun.net.httpserver.HttpExchange; -import com.sun.net.httpserver.HttpHandler; -import com.sun.net.httpserver.HttpServer; +import org.onap.ccsdk.features.sdnr.wt.common.test.ServletInputStreamFromByteArrayInputStream; +import org.onap.ccsdk.features.sdnr.wt.common.test.ServletOutputStreamToStringWriter; @SuppressWarnings("restriction") public class HelpServletBase { @@ -97,21 +91,8 @@ public class HelpServletBase { HttpServletRequest mockRequest = mock(HttpServletRequest.class); HttpServletResponse mockResponse = mock(HttpServletResponse.class); - StringWriter out = new StringWriter(); - ServletOutputStream printOut = new ServletOutputStream() { - - @Override - public void write(int arg0) throws IOException { - out.write(arg0); - } - }; - ByteArrayInputStream bis = new ByteArrayInputStream(data.getBytes()); - ServletInputStream inputStream = new ServletInputStream() { - @Override - public int read() throws IOException { - return bis.read(); - } - }; + ServletOutputStreamToStringWriter printOut = new ServletOutputStreamToStringWriter(); + ServletInputStreamFromByteArrayInputStream inputStream = new ServletInputStreamFromByteArrayInputStream(data.getBytes()); Vector headers = new Vector(); headers.addElement("Accept"); headers.add("User-Agent"); @@ -142,9 +123,9 @@ public class HelpServletBase { verify(mockResponse).setStatus(200); if (exact) - assertEquals(expectedResponse, out.toString()); + assertEquals(expectedResponse, printOut.getStringWriter().toString()); else - assertTrue("response not for method " + method + "correct", out.toString().contains(expectedResponse)); + assertTrue("response not for method " + method + "correct", printOut.getStringWriter().toString().contains(expectedResponse)); // currently unable to check extra headers if (headersToCheck != null) { diff --git a/sdnr/wt/data-provider/provider/pom.xml b/sdnr/wt/data-provider/provider/pom.xml index 97c04d564..da9d69532 100644 --- a/sdnr/wt/data-provider/provider/pom.xml +++ b/sdnr/wt/data-provider/provider/pom.xml @@ -155,8 +155,6 @@ ${basedir}/../../data-provider/setup/target/sdnr-dmt.jar -c pluginfile - -v - v3 -of ${project.build.directory}/EsInit.script @@ -172,7 +170,7 @@ testCluster 9500 ${databaseport} - 7.6.1 + 7.9.3 120 ${project.build.directory}/EsInit.script diff --git a/sdnr/wt/data-provider/setup/pom.xml b/sdnr/wt/data-provider/setup/pom.xml index 3a1b597db..865d5570e 100644 --- a/sdnr/wt/data-provider/setup/pom.xml +++ b/sdnr/wt/data-provider/setup/pom.xml @@ -87,7 +87,7 @@ testCluster 49504 ${databaseport} - 7.6.1 + 7.9.3 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 9b7a49346..913313b86 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 @@ -34,6 +34,7 @@ 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.honolulu.HonoluluReleaseInformation; public abstract class ReleaseInformation { @@ -142,6 +143,8 @@ public abstract class ReleaseInformation { return new FrankfurtReleaseInformationR2(); case GUILIN_R1: return new GuilinReleaseInformation(); + case HONOLULU_R1: + return new HonoluluReleaseInformation(); default: return null; } diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentName.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentName.java index ab3f311a1..c3974b98a 100644 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentName.java +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentName.java @@ -25,9 +25,10 @@ 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"); + "historicalperformance24h"), INVENTORY( + "inventory"), INVENTORYTOPLEVEL("inventorytoplevel"), MAINTENANCE( + "maintenance"), MEDIATOR_SERVER("mediator-server"), REQUIRED_NETWORKELEMENT( + "required-networkelement"), GUICUTTHROUGH("guicutthrough"); private final String value; 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 4f55f4cd7..9b67bd46b 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 @@ -29,20 +29,26 @@ 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)), - GUILIN_R1("guilin-R1", "-v4", new EsVersion(7,1,1), new EsVersion(7,6,1)); + GUILIN_R1("guilin-R1", "-v4", new EsVersion(7,1,1), new EsVersion(7,6,1)), + HONOLULU_R1("honolulu-R1", "-v5", new EsVersion(7,1,1), new EsVersion(8,0,0), false); - public static final Release CURRENT_RELEASE = Release.GUILIN_R1; + public static final Release CURRENT_RELEASE = Release.HONOLULU_R1; private final String value; private final String dbSuffix; private final EsVersion minDbVersion; private final EsVersion maxDbVersion; + private final boolean includeEndVersion; - private Release(String s, String dbsuffix, EsVersion minDbVersion, EsVersion maxDbVersion) { + private Release(String s, String dbsuffix, EsVersion minDbVersion, EsVersion maxDbVersion) { + this(s, dbsuffix, minDbVersion, maxDbVersion, true); + } + private Release(String s, String dbsuffix, EsVersion minDbVersion, EsVersion maxDbVersion, boolean includeEnd) { this.value = s; this.dbSuffix = dbsuffix; this.minDbVersion = minDbVersion; this.maxDbVersion = maxDbVersion; + this.includeEndVersion = includeEnd; } @Override @@ -83,25 +89,20 @@ public enum Release { 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); + if(this.includeEndVersion) { + return dbVersion.isNewerOrEqualThan(minDbVersion) && dbVersion.isOlderOrEqualThan(maxDbVersion); + } + else { + return dbVersion.isNewerOrEqualThan(minDbVersion) && dbVersion.isOlderThan(maxDbVersion); + } } } 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 993d0261f..6d2da9035 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 @@ -31,9 +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); + EL_ALTO(Release.EL_ALTO), FRANKFURT(Release.FRANKFURT_R1, Release.FRANKFURT_R2), GUILIN(Release.GUILIN_R1), HONOLULU(Release.HONOLULU_R1); - public static final ReleaseGroup CURRENT_RELEASE = GUILIN; + public static final ReleaseGroup CURRENT_RELEASE = HONOLULU; private final List releases; diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/honolulu/HonoluluReleaseInformation.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/honolulu/HonoluluReleaseInformation.java new file mode 100644 index 000000000..255a031e7 --- /dev/null +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/honolulu/HonoluluReleaseInformation.java @@ -0,0 +1,79 @@ +/* + * ============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.honolulu; + +import java.io.IOException; +import java.util.Map; +import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient; +import org.onap.ccsdk.features.sdnr.wt.common.database.requests.ClusterSettingsRequest; +import org.onap.ccsdk.features.sdnr.wt.common.database.responses.ClusterSettingsResponse; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DatabaseInfo; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DatabaseInfo7; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.KeepDataSearchHitConverter; +import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.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 HonoluluReleaseInformation extends ReleaseInformation { + + private final Logger LOG = LoggerFactory.getLogger(HonoluluReleaseInformation.class); + public HonoluluReleaseInformation() { + super(Release.HONOLULU_R1,createDBMap()); + + } + + private static Map createDBMap() { + Map map= FrankfurtReleaseInformationR2.createDBMap(); + map.put(ComponentName.GUICUTTHROUGH, new DatabaseInfo7("guicutthrough", "guicutthrough", + "{\"name\": {\"type\": \"keyword\"},\"weburi\": {\"type\": \"keyword\"}}")); + return map; + } + + @Override + public SearchHitConverter getConverter(Release dst, ComponentName comp) { + if (dst == Release.HONOLULU_R1) { + return new KeepDataSearchHitConverter(comp); + } + return null; + } + + @Override + protected boolean runPreInitCommands(HtDatabaseClient dbClient) { + ClusterSettingsResponse response = null; + try { + response = dbClient.setupClusterSettings(new ClusterSettingsRequest(false).maxCompilationsPerMinute(400)); + } catch (IOException e) { + LOG.warn("problem setting up cluster: {}", e); + } + return response == null ? false : response.isAcknowledged(); + } + + @Override + protected boolean runPostInitCommands(HtDatabaseClient dbClient) { + return true; + } + +} -- cgit 1.2.3-korg