aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/data-provider/setup
diff options
context:
space:
mode:
authorhighstreetherbert <herbert.eiselt@highstreet-technologies.com>2020-07-15 15:44:23 +0200
committerhighstreetherbert <herbert.eiselt@highstreet-technologies.com>2020-07-15 19:05:46 +0200
commit25b3759a0907d06e0d8e391f751c6fcf067087f5 (patch)
treef9cd6de6e685216c44f4c44cc7f220f3f23f22c5 /sdnr/wt/data-provider/setup
parent002ad417b90882524276d1b9cfe377c6f6293a4c (diff)
SDN-R data-provider with ES7
Extend to ES 7.x and DB setup Issue-ID: SDNC-1288 Signed-off-by: highstreetherbert <herbert.eiselt@highstreet-technologies.com> Change-Id: Id7778322b793bfa7472a14a90bc0d1fd953c8c73 Signed-off-by: highstreetherbert <herbert.eiselt@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/data-provider/setup')
-rw-r--r--sdnr/wt/data-provider/setup/pom.xml12
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderImpl.java41
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/Program.java114
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java8
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DatabaseInfo.java2
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DatabaseInfo7.java44
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/MavenDatabasePluginInitFile.java1
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java12
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ReleaseGroup.java66
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/SearchHitConverter.java17
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformation.java2
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformationR2.java102
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformation.java11
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformationR2.java81
-rw-r--r--sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestData.java97
-rw-r--r--sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMigrationProvider.java13
-rw-r--r--sdnr/wt/data-provider/setup/tmp.log1
17 files changed, 510 insertions, 114 deletions
diff --git a/sdnr/wt/data-provider/setup/pom.xml b/sdnr/wt/data-provider/setup/pom.xml
index a43ec0c52..cf7929472 100644
--- a/sdnr/wt/data-provider/setup/pom.xml
+++ b/sdnr/wt/data-provider/setup/pom.xml
@@ -60,12 +60,11 @@
<dependency>
<groupId>commons-cli</groupId>
<artifactId>commons-cli</artifactId>
- <version>1.4</version>
</dependency>
<dependency>
- <groupId>org.slf4j</groupId>
- <artifactId>slf4j-log4j12</artifactId>
- </dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ </dependency>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>sdnr-wt-common</artifactId>
@@ -77,7 +76,6 @@
<version>${project.version}</version>
</dependency>
</dependencies>
-
<build>
<plugins>
<plugin>
@@ -89,7 +87,7 @@
<clusterName>testCluster</clusterName>
<transportPort>49504</transportPort>
<httpPort>${databaseport}</httpPort>
- <version>6.5.0</version>
+ <version>7.1.1</version>
</configuration>
<executions>
<execution>
@@ -133,7 +131,7 @@
</executions>
<configuration>
<finalName>sdnr-dmt</finalName>
- <appendAssemblyId>false</appendAssemblyId>
+ <appendAssemblyId>false</appendAssemblyId>
<archive>
<manifest>
<mainClass>org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.Program</mainClass>
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
index dabe0047f..100f52371 100644
--- 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
@@ -33,7 +33,6 @@ 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.Portstatus;
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;
@@ -55,6 +54,7 @@ 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.data.DataMigrationReport;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ReleaseGroup;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.SearchHitConverter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -63,19 +63,13 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService {
private static final Logger LOG = LoggerFactory.getLogger(DataMigrationProviderImpl.class);
+
private final HtDatabaseClient dbClient;
public DataMigrationProviderImpl(HostInfo[] hosts, String username, String password, boolean trustAll,
- long timeoutms) {
+ long timeoutms) throws Exception {
- if (timeoutms > 0) {
- Portstatus.waitSecondsTillAvailable(timeoutms / 1000, hosts);
- }
- try {
- this.dbClient = HtDatabaseClient.getClient(hosts, username, password, trustAll);
- } catch (Exception e) {
- throw new IllegalArgumentException("Can not reach database with parameters.",e);
- }
+ dbClient = HtDatabaseClient.getClient(hosts, username, password, trustAll, timeoutms);
}
@Override
@@ -125,7 +119,7 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService {
for (SearchHit item : data) {
if (!dryrun) {
String id = this.dbClient.doWriteRaw(indexName, dataTypeName, item.getId(),
- item.getSourceAsString());
+ item.getSourceAsString(), true);
if (!item.getId().equals(id)) {
LOG.warn("entry for {} with original id {} was written with another id {}",
component.getValue(), item.getId(), id);
@@ -268,6 +262,7 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService {
return entries;
}
+
@Override
public boolean initDatabase(Release release, int numShards, int numReplicas, String dbPrefix, boolean forceRecreate,
long timeoutms) {
@@ -278,6 +273,16 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService {
if (dbVersion == null) {
return false;
}
+ LOG.info("detected database version {}", dbVersion);
+ if (release == null) {
+ release = ReleaseGroup.CURRENT_RELEASE.getLatestCompatibleRelease(dbVersion);
+ if (release == null) {
+ LOG.warn("unable to autodetect release for this database version for release {}",
+ ReleaseGroup.CURRENT_RELEASE.name());
+ return false;
+ }
+ LOG.info("autodetect release {}", release);
+ }
if (!release.isDbInRange(dbVersion)) {
LOG.warn("db version {} maybe not compatible with release {}", dbVersion, release);
return false;
@@ -342,6 +347,20 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService {
if (entries == null) {
return false;
}
+ if (release == null) {
+ EsVersion dbVersion = this.readActualVersion();
+ if (dbVersion == null) {
+ return false;
+ }
+ LOG.info("detected database version {}", dbVersion);
+ release = ReleaseGroup.CURRENT_RELEASE.getLatestCompatibleRelease(dbVersion);
+ if (release == null) {
+ LOG.warn("unable to autodetect release for this database version for release {}",
+ ReleaseGroup.CURRENT_RELEASE.name());
+ return false;
+ }
+ LOG.info("autodetect release {}", release);
+ }
ReleaseInformation ri = ReleaseInformation.getInstance(release);
AcknowledgedResponse response;
if (entries.size() <= 0) {
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
index c7775a96b..4b201bccc 100644
--- 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
@@ -53,7 +53,9 @@ public class Program {
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_CLEAR_DB_DESCRIPTION = "delete database indices and aliases for current release";
+ private static final String CMD_CLEAR_DB_COMPLETE_DESCRIPTION = "delete all 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";
@@ -61,31 +63,51 @@ public class Program {
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_CLEAR_DB_COMPLETE, CMD_CLEAR_DB_COMPLETE_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 int DEFAULT_DATABASEWAIT_SECONDS = 30;
private static final String DEFAULT_DBURL = "http://sdnrdb:9200";
private static final String DEFAULT_DBPREFIX = "";
+ private static final boolean DEFAULT_TRUSTINSECURESSL = false;
+
private static final String OPTION_FORCE_RECREATE_SHORT = "f";
+ private static final String OPTION_FORCE_RECREATE_LONG = "force-recreate";
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_VERSION_LONG = "version";
private static final String OPTION_SHARDS_SHORT = "s";
+ private static final String OPTION_SHARDS_LONG = "shards";
private static final String OPTION_REPLICAS_SHORT = "r";
+ private static final String OPTION_REPLICAS_LONG = "replicas";
private static final String OPTION_OUTPUTFILE_SHORT = "of";
+ private static final String OPTION_OUTPUTFILE_LONG = "output-file";
private static final String OPTION_INPUTFILE_SHORT = "if";
+ private static final String OPTION_INPUTFILE_LONG = "input-file";
private static final String OPTION_DEBUG_SHORT = "x";
+ private static final String OPTION_DEBUG_LONG = "verbose";
private static final String OPTION_TRUSTINSECURESSL_SHORT = "k";
+ private static final String OPTION_TRUSTINSECURESSL_LONG = "trust-insecure";
private static final String OPTION_DATABASE_SHORT = "db";
+ private static final String OPTION_DATABASE_LONG = "dburl";
private static final String OPTION_COMMAND_SHORT = "c";
+ private static final String OPTION_COMMAND_LONG = "cmd";
private static final String OPTION_DATABASEUSER_SHORT = "dbu";
+ private static final String OPTION_DATABASEUSER_LONG = "db-username";
private static final String OPTION_DATABASEPASSWORD_SHORT = "dbp";
+ private static final String OPTION_DATABASEPASSWORD_LONG = "db-password";
private static final String OPTION_DATABASEPREFIX_SHORT = "p";
+ private static final String OPTION_DATABASEPREFIX_LONG = "prefix";
private static final String OPTION_DATABASEWAIT_SHORT = "w";
+ private static final String OPTION_DATABASEWAIT_LONG = "wait";
private static final String OPTION_HELP_SHORT = "h";
+ private static final String OPTION_HELP_LONG = "help";
// end of constants
// variables
@@ -111,6 +133,9 @@ public class Program {
if (def instanceof Long) {
return cmd.hasOption(option) ? (T) Long.valueOf(cmd.getOptionValue(option)) : def;
}
+ if (def instanceof Release) {
+ return cmd.hasOption(option) ? (T) Release.getValueBySuffix(cmd.getOptionValue(option)) : def;
+ }
if (cmd.hasOption(option) && cmd.getOptionValue(option) != null) {
if (option.equals(OPTION_VERSION_SHORT)) {
String v = cmd.getOptionValue(option);
@@ -215,7 +240,8 @@ public class Program {
if (of == null) {
throw new Exception("please add the parameter output-file");
}
- MavenDatabasePluginInitFile.create(Release.CURRENT_RELEASE, of);
+ MavenDatabasePluginInitFile
+ .create(getOptionOrDefault(cmd, OPTION_VERSION_SHORT, Release.CURRENT_RELEASE), of);
} catch (Exception e) {
return exit(e);
}
@@ -271,11 +297,11 @@ public class Program {
String username = getOptionOrDefault(cmd, OPTION_DATABASEUSER_SHORT, null);
String password = getOptionOrDefault(cmd, OPTION_DATABASEPASSWORD_SHORT, null);
String filename = getOptionOrDefault(cmd, OPTION_OUTPUTFILE_SHORT, null);
- boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, false);
+ boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, DEFAULT_TRUSTINSECURESSL);
if (filename == null) {
throw new Exception("please add output file parameter");
}
- long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30) * 1000;
+ long timeoutms = getTimeoutOptionMillis(cmd);
DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] {HostInfo.parse(dbUrl)},
username, password, trustAll, timeoutms);
DataMigrationReport report = service.importData(filename, false);
@@ -283,6 +309,7 @@ public class Program {
if (!report.completed()) {
throw new Exception("db import seems to be not executed completed");
}
+ LOG.info("database import completed successfully");
}
private static void cmd_dbexport(CommandLine cmd) throws Exception {
@@ -290,11 +317,11 @@ public class Program {
String username = getOptionOrDefault(cmd, OPTION_DATABASEUSER_SHORT, null);
String password = getOptionOrDefault(cmd, OPTION_DATABASEPASSWORD_SHORT, null);
String filename = getOptionOrDefault(cmd, OPTION_OUTPUTFILE_SHORT, null);
- boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, false);
+ boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, DEFAULT_TRUSTINSECURESSL);
if (filename == null) {
throw new Exception("please add output file parameter");
}
- long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30) * 1000;
+ long timeoutms = getTimeoutOptionMillis(cmd);
DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] {HostInfo.parse(dbUrl)},
username, password, trustAll, timeoutms);
DataMigrationReport report = service.exportData(filename);
@@ -302,7 +329,7 @@ public class Program {
if (!report.completed()) {
throw new Exception("db export seems to be not executed completed");
}
-
+ LOG.info("database export completed successfully");
}
private static int exit(Exception e) {
@@ -315,85 +342,96 @@ public class Program {
}
private static void cmd_clear_db(CommandLine cmd) throws Exception {
- Release r = getOptionOrDefault(cmd, OPTION_VERSION_SHORT, Release.CURRENT_RELEASE);
+ Release r = getOptionOrDefault(cmd, OPTION_VERSION_SHORT, (Release) null);
String dbUrl = getOptionOrDefault(cmd, OPTION_DATABASE_SHORT, DEFAULT_DBURL);
String dbPrefix = getOptionOrDefault(cmd, OPTION_DATABASEPREFIX_SHORT, DEFAULT_DBPREFIX);
String username = getOptionOrDefault(cmd, OPTION_DATABASEUSER_SHORT, null);
String password = getOptionOrDefault(cmd, OPTION_DATABASEPASSWORD_SHORT, null);
- boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, false);
- long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30) * 1000;
+ boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, DEFAULT_TRUSTINSECURESSL);
+ long timeoutms = getTimeoutOptionMillis(cmd);
DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] {HostInfo.parse(dbUrl)},
username, password, trustAll, timeoutms);
if (!service.clearDatabase(r, dbPrefix, timeoutms)) {
throw new Exception("failed to init database");
}
+ LOG.info("database clear completed successfully");
}
private static void cmd_clear_db_complete(CommandLine cmd) throws Exception {
String dbUrl = getOptionOrDefault(cmd, OPTION_DATABASE_SHORT, DEFAULT_DBURL);
String username = getOptionOrDefault(cmd, OPTION_DATABASEUSER_SHORT, null);
String password = getOptionOrDefault(cmd, OPTION_DATABASEPASSWORD_SHORT, null);
- boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, false);
- long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30) * 1000;
+ boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, DEFAULT_TRUSTINSECURESSL);
+ long timeoutms = getTimeoutOptionMillis(cmd);
DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] {HostInfo.parse(dbUrl)},
username, password, trustAll, timeoutms);
if (!service.clearCompleteDatabase(timeoutms)) {
throw new Exception("failed to init database");
}
+ LOG.info("database complete clear completed successfully");
}
private static void cmd_init_db(CommandLine cmd) throws Exception {
- Release r = getOptionOrDefault(cmd, OPTION_VERSION_SHORT, Release.CURRENT_RELEASE);
+ Release r = getOptionOrDefault(cmd, OPTION_VERSION_SHORT, (Release) null);
int numShards = getOptionOrDefault(cmd, OPTION_SHARDS_SHORT, DEFAULT_SHARDS);
int numReplicas = getOptionOrDefault(cmd, OPTION_REPLICAS_SHORT, DEFAULT_REPLICAS);
String dbUrl = getOptionOrDefault(cmd, OPTION_DATABASE_SHORT, DEFAULT_DBURL);
String dbPrefix = getOptionOrDefault(cmd, OPTION_DATABASEPREFIX_SHORT, DEFAULT_DBPREFIX);
String username = getOptionOrDefault(cmd, OPTION_DATABASEUSER_SHORT, null);
String password = getOptionOrDefault(cmd, OPTION_DATABASEPASSWORD_SHORT, null);
- boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, false);
- long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30) * 1000;
+ boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, DEFAULT_TRUSTINSECURESSL);
+ long timeoutms = getTimeoutOptionMillis(cmd);
DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] {HostInfo.parse(dbUrl)},
username, password, trustAll, timeoutms);
boolean forceRecreate = cmd.hasOption(OPTION_FORCE_RECREATE_SHORT);
if (!service.initDatabase(r, numShards, numReplicas, dbPrefix, forceRecreate, timeoutms)) {
throw new Exception("failed to init database");
}
+ LOG.info("database init completed successfully");
}
private static Options init() {
Options result = new Options();
- result.addOption(createOption(OPTION_COMMAND_SHORT, "cmd", true, "command to execute", false));
- result.addOption(createOption(OPTION_DATABASE_SHORT, "dburl", true, "database url", false));
- result.addOption(
- createOption(OPTION_DATABASEUSER_SHORT, "db-username", true, "database basic auth username", false));
- result.addOption(createOption(OPTION_DATABASEPASSWORD_SHORT, "db-password", true,
+ result.addOption(createOption(OPTION_COMMAND_SHORT, OPTION_COMMAND_LONG, true, "command to execute", false));
+ result.addOption(createOption(OPTION_DATABASE_SHORT, OPTION_DATABASE_LONG, true, "database url", false));
+ result.addOption(createOption(OPTION_DATABASEUSER_SHORT, OPTION_DATABASEUSER_LONG, true,
+ "database basic auth username", false));
+ result.addOption(createOption(OPTION_DATABASEPASSWORD_SHORT, OPTION_DATABASEPASSWORD_LONG, true,
"database basic auth password", false));
- result.addOption(createOption(OPTION_REPLICAS_SHORT, "replicas", true, "amount of replicas", false));
- result.addOption(createOption(OPTION_SHARDS_SHORT, "shards", true, "amount of shards", false));
- result.addOption(createOption(OPTION_DATABASEPREFIX_SHORT, "prefix", true, "prefix for db indices", false));
- result.addOption(createOption(OPTION_VERSION_SHORT, "version", true, "version", false));
- result.addOption(createOption(OPTION_DEBUG_SHORT, "verbose", false, "verbose mode", false));
- result.addOption(createOption(OPTION_TRUSTINSECURESSL_SHORT, "trust-insecure", false,
+ result.addOption(createOption(OPTION_REPLICAS_SHORT, OPTION_REPLICAS_LONG, true, "amount of replicas", false));
+ result.addOption(createOption(OPTION_SHARDS_SHORT, OPTION_SHARDS_LONG, true, "amount of shards", false));
+ result.addOption(createOption(OPTION_DATABASEPREFIX_SHORT, OPTION_DATABASEPREFIX_LONG, true,
+ "prefix for db indices", false));
+ result.addOption(createOption(OPTION_VERSION_SHORT, OPTION_VERSION_LONG, true, "version", false));
+ result.addOption(createOption(OPTION_DEBUG_SHORT, OPTION_DEBUG_LONG, false, "verbose mode", false));
+ result.addOption(createOption(OPTION_TRUSTINSECURESSL_SHORT, OPTION_TRUSTINSECURESSL_LONG, false,
"trust insecure ssl certs", false));
- result.addOption(createOption(OPTION_DATABASEWAIT_SHORT, "wait", true,
+ result.addOption(createOption(OPTION_DATABASEWAIT_SHORT, OPTION_DATABASEWAIT_LONG, true,
"wait for yellow status with timeout in seconds", false));
- result.addOption(
- createOption(OPTION_FORCE_RECREATE_SHORT, "force-recreate", false, "delete if sth exists", false));
+ result.addOption(createOption(OPTION_FORCE_RECREATE_SHORT, OPTION_FORCE_RECREATE_LONG, false,
+ "delete if sth exists", false));
result.addOption(createOption(OPTION_SILENT_SHORT, OPTION_SILENT, false, "prevent console output", false));
- result.addOption(createOption(OPTION_OUTPUTFILE_SHORT, "output-file", true, "file to write into", false));
- result.addOption(createOption(OPTION_INPUTFILE_SHORT, "input-file", true, "file to read from", false));
- result.addOption(createOption(OPTION_HELP_SHORT, "help", false, "show help", false));
+ result.addOption(
+ createOption(OPTION_OUTPUTFILE_SHORT, OPTION_OUTPUTFILE_LONG, true, "file to write into", false));
+ result.addOption(createOption(OPTION_INPUTFILE_SHORT, OPTION_INPUTFILE_LONG, true, "file to read from", false));
+ result.addOption(createOption(OPTION_HELP_SHORT, OPTION_HELP_LONG, false, "show help", false));
return result;
}
+ private static long getTimeoutOptionMillis(CommandLine cmd) throws ParseException {
+ return getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, DEFAULT_DATABASEWAIT_SECONDS) * 1000;
+ }
+
/**
- * @param opt
- * @param longOpt
- * @param hasArg
- * @param description
- * @param required
- * @return
+ * create option for argparse lib
+ *
+ * @param opt short option string
+ * @param longOpt long option string
+ * @param hasArg flag if has a parameter after option tag
+ * @param description description for help output
+ * @param required flag if is required for program
+ * @return option object for argparse lib
*/
private static Option createOption(String opt, String longOpt, boolean hasArg, String description,
boolean required) {
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 cb20025ff..d772dc296 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
@@ -33,7 +33,9 @@ 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.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 {
@@ -138,8 +140,12 @@ public abstract class ReleaseInformation {
return new ElAltoReleaseInformation();
case FRANKFURT_R1:
return new FrankfurtReleaseInformation();
- case GUILIN:
+ case FRANKFURT_R2:
+ return new FrankfurtReleaseInformationR2();
+ case GUILIN_R1:
return new GuilinReleaseInformation();
+ case GUILIN_R2:
+ return new GuilinReleaseInformationR2();
default:
return null;
}
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
index 4c38b5032..51acd0782 100644
--- 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
@@ -28,7 +28,7 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data;
public class DatabaseInfo {
public final String doctype;
public final String alias;
- private final String mapping;
+ protected final String mapping;
private final String settingsFormat;
private final String index;
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DatabaseInfo7.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DatabaseInfo7.java
new file mode 100644
index 000000000..58b98c2aa
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DatabaseInfo7.java
@@ -0,0 +1,44 @@
+/*
+ * ============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 DatabaseInfo7 extends DatabaseInfo {
+
+ public DatabaseInfo7(String alias, String doctype, String mapping) {
+ super(alias, alias, doctype, mapping);
+ }
+
+ public DatabaseInfo7(String index, String alias, String doctype, String mapping, String settingsformat) {
+ super(index, alias, doctype, mapping, settingsformat);
+ }
+
+ @Override
+ public String getMapping(boolean useStrict) {
+ return this.mapping == null ? null
+ : String.format("{%s\"properties\":%s}", useStrict ? "\"dynamic\": false," : "\"dynamic\": true,",
+ this.mapping);
+ }
+}
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
index 66a5e16d0..3f6334a1e 100644
--- 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
@@ -50,6 +50,7 @@ public class MavenDatabasePluginInitFile {
ReleaseInformation ri = ReleaseInformation.getInstance(release);
Set<ComponentName> comps = ri.getComponents();
List<String> lines = new ArrayList<>();
+ lines.add("PUT:_cluster/settings/:{\"persistent\":{\"action.auto_create_index\":\"true\"}}");
for (ComponentName c : comps) {
lines.add(String.format("PUT:%s/:{" + settings + "," + mappings + "}", ri.getIndex(c), shards, replicas,
ri.getDatabaseMapping(c)));
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 13c604716..b2442df6b 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
@@ -27,11 +27,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", "", new EsVersion(6, 4, 3),
- new EsVersion(6, 8, 6)), FRANKFURT_R3("frankfurt-R3", "", new EsVersion(6, 4, 3),
- new EsVersion(6, 8, 6)),
+ 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)),
- GUILIN("guilin", "", new EsVersion(6, 4, 3), new EsVersion(6, 8, 6));
+ 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;
@@ -67,6 +68,9 @@ public enum Release {
}
public static Release getValueBySuffix(String suffix) {
+ if (!suffix.startsWith("-")) {
+ suffix = "-" + suffix;
+ }
for (Release r : Release.values()) {
if (r.dbSuffix.equals(suffix))
return r;
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
new file mode 100644
index 000000000..c7d26dbed
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ReleaseGroup.java
@@ -0,0 +1,66 @@
+/*
+ * ============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;
+
+import org.onap.ccsdk.features.sdnr.wt.common.database.data.EsVersion;
+
+/**
+ * @author Michael Dürre
+ *
+ */
+public enum ReleaseGroup {
+
+ EL_ALTO(Release.EL_ALTO), FRANKFURT(Release.FRANKFURT_R1, Release.FRANKFURT_R2), GUILIN(Release.GUILIN_R1,
+ Release.GUILIN_R2);
+
+ public static final ReleaseGroup CURRENT_RELEASE = FRANKFURT;
+
+ private final List<Release> releases;
+
+ ReleaseGroup(Release... values) {
+ this.releases = new ArrayList<Release>();
+ if (values != null) {
+ for (Release r : values) {
+ this.releases.add(r);
+ }
+ }
+ }
+
+ /**
+ * @param dbVersion
+ * @return
+ */
+ public Release getLatestCompatibleRelease(EsVersion dbVersion) {
+ Release match = null;
+ for (Release r : this.releases) {
+ if (r.isDbInRange(dbVersion)) {
+ match = r;
+ }
+ }
+ return match;
+ }
+
+
+}
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
index a95a405d6..87c4d6434 100644
--- 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
@@ -22,9 +22,7 @@
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;
+import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation;
public interface SearchHitConverter {
@@ -46,17 +44,8 @@ public interface SearchHitConverter {
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;
-
- }
+ ReleaseInformation ri = ReleaseInformation.getInstance(src);
+ return ri != null ? ri.getConverter(dst, component) : null;
}
}
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
index ad0abee89..7b8c40bca 100644
--- 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
@@ -86,7 +86,7 @@ public class FrankfurtReleaseInformation extends ReleaseInformation {
ClusterSettingsResponse response = null;
try {
- response = dbClient.setupClusterSettings(new ClusterSettingsRequest(false));
+ response = dbClient.setupClusterSettings(new ClusterSettingsRequest(false).maxCompilationsPerMinute(400));
} catch (IOException e) {
LOG.warn("problem setting up cluster: {}", e);
}
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
new file mode 100644
index 000000000..e842b5c7b
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformationR2.java
@@ -0,0 +1,102 @@
+/*
+ * ============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.io.IOException;
+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.DatabaseInfo7;
+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 {
+
+ private final Logger LOG = LoggerFactory.getLogger(FrankfurtReleaseInformationR2.class);
+ private final Map<Release, Map<ComponentName, SearchHitConverter>> converters = new HashMap<>();
+
+ public FrankfurtReleaseInformationR2() {
+ super(Release.FRANKFURT_R2, createDBMap());
+ }
+
+ private static Map<ComponentName, DatabaseInfo> createDBMap() {
+ Map<ComponentName, DatabaseInfo> map = new HashMap<>();
+ map.put(ComponentName.CONNECTIONLOG, new DatabaseInfo7("connectionlog", "connectionlog",
+ "{\"node-id\": {\"type\": \"keyword\"},\"timestamp\": {\"type\": \"date\"},\"status\": {\"type\": \"keyword\"}}"));
+ map.put(ComponentName.EVENTLOG, new DatabaseInfo7("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 DatabaseInfo7("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 DatabaseInfo7("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 DatabaseInfo7("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 DatabaseInfo7("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 DatabaseInfo7("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 DatabaseInfo7("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 DatabaseInfo7("mediator-server", "mediator-server",
+ "{\"url\":{\"type\": \"keyword\"},\"name\":{\"type\": \"keyword\"}}"));
+ map.put(ComponentName.MAINTENANCE, new DatabaseInfo7("maintenancemode", "maintenancemode",
+ "{\"node-id\": {\"type\": \"keyword\"},\"start\": {\"type\": \"date\"},\"end\": {\"type\": \"date\"},\"description\": {\"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;
+ }
+
+ @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;
+ }
+
+}
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 a81a6f0fd..2c2ac25a9 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
@@ -22,16 +22,15 @@
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.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;
-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.DatabaseInfo;
public class GuilinReleaseInformation extends ReleaseInformation {
@@ -40,7 +39,7 @@ public class GuilinReleaseInformation extends ReleaseInformation {
* @param dbMap
*/
public GuilinReleaseInformation() {
- super(Release.GUILIN, createDBMap());
+ super(Release.GUILIN_R1, createDBMap());
}
@@ -63,7 +62,7 @@ public class GuilinReleaseInformation extends ReleaseInformation {
@Override
public SearchHitConverter getConverter(Release dst, ComponentName comp) {
- if (dst == Release.GUILIN) {
+ if (dst == Release.GUILIN_R1) {
return new KeepDataSearchHitConverter(comp);
}
return null;
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
new file mode 100644
index 000000000..29c79f3da
--- /dev/null
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformationR2.java
@@ -0,0 +1,81 @@
+/*
+ * ============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<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_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/TestData.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestData.java
index c7864560b..ab0510c9c 100644
--- a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestData.java
+++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestData.java
@@ -48,32 +48,79 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release;
*
*/
public class TestData {
- private static final JSONObject EVENTLOG_SEARCHHIT = new JSONObject("{\n" + "\"_index\": \"sdnevents_v1\",\n"
- + "\"_type\": \"eventlog\",\n" + "\"_id\": \"AXB7cJHlZ_FApnwi29xq\",\n" + "\"_version\": 1,\n"
- + "\"_score\": 1,\n" + "\"_source\": {\n" + "\"event\": {\n"
- + "\"nodeName\": \"SDN-Controller-465e2ae306ca\",\n" + "\"counter\": \"1\",\n"
- + "\"timeStamp\": \"2020-02-25T08:22:19.8Z\",\n" + "\"objectId\": \"sim2230\",\n"
- + "\"attributeName\": \"ConnectionStatus\",\n" + "\"newValue\": \"connecting\",\n"
- + "\"type\": \"AttributeValueChangedNotificationXml\"\n" + "}\n" + "}\n" + "}");
- private static final JSONObject EVENTLOG_SEARCHHIT2 = new JSONObject("{\n" + "\"_index\": \"sdnevents_v1\",\n"
- + "\"_type\": \"eventlog\",\n" + "\"_id\": \"AXB7cJHlZ_FApnwi29xq\",\n" + "\"_version\": 1,\n"
- + "\"_score\": 1,\n" + "\"_source\": {\n" + "\"event\": {\n"
- + "\"nodeName\": \"SDN-Controller-465e2ae306ca\",\n" + "\"counter\": \"3\",\n"
- + "\"timeStamp\": \"2020-02-22T08:22:19.8Z\",\n" + "\"objectId\": \"sim2230\",\n"
- + "\"attributeName\": \"ConnectionStatus\",\n" + "\"newValue\": \"connected\",\n"
- + "\"type\": \"AttributeValueChangedNotificationXml\"\n" + "}\n" + "}\n" + "}");
- private static final String CONFIG_CONTENT = "[dcae]\n" + "dcaeUserCredentials=admin:admin\n" + "dcaeUrl=off\n"
- + "dcaeHeartbeatPeriodSeconds=120\n" + "dcaeTestCollector=no\n" + "\n" + "[es]\n"
- + "esCluster=sendateodl5\n" + "#time limit to keep increasing data in database [in seconds]\n"
- + "#60*60*24*30 (30days)\n" + "esArchiveLimit=2592000\n" + "#folder where removed data will be stored\n"
- + "esArchiveFolder=./backup\n" + "#interval to archive database [in seconds]\n" + "#60*60*24 (1day)\n"
- + "esArchiveInterval=86400\n" + "\n" + "[aai]\n" + "#keep comment\n"
- + "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + "aaiUrl=http://localhost:81\n"
- + "aaiUserCredentials=AAI:AAI\n" + "aaiDeleteOnMountpointRemove=false\n" + "aaiTrustAllCerts=false\n"
- + "aaiApiVersion=aai/v13\n" + "aaiPropertiesFile=aaiclient.properties\n" + "aaiApplicationId=SDNR\n"
+ // @formatter:off
+ private static final JSONObject EVENTLOG_SEARCHHIT = new JSONObject("{\n"
+ + "\"_index\": \"sdnevents_v1\",\n"
+ + "\"_type\": \"eventlog\",\n"
+ + "\"_id\": \"AXB7cJHlZ_FApnwi29xq\",\n"
+ + "\"_version\": 1,\n"
+ + "\"_score\": 1,\n"
+ + "\"_source\": {\n"
+ + "\"event\": {\n"
+ + "\"nodeName\": \"SDN-Controller-465e2ae306ca\",\n"
+ + "\"counter\": \"1\",\n"
+ + "\"timeStamp\": \"2020-02-25T08:22:19.8Z\",\n"
+ + "\"objectId\": \"sim2230\",\n"
+ + "\"attributeName\": \"ConnectionStatus\",\n"
+ + "\"newValue\": \"connecting\",\n"
+ + "\"type\": \"AttributeValueChangedNotificationXml\"\n"
+ + "}\n"
+ + "}\n"
+ + "}");
+ private static final JSONObject EVENTLOG_SEARCHHIT2 = new JSONObject("{\n"
+ + "\"_index\": \"sdnevents_v1\",\n"
+ + "\"_type\": \"eventlog\",\n"
+ + "\"_id\": \"AXB7cJHlZ_FApnwi29xq\",\n"
+ + "\"_version\": 1,\n"
+ + "\"_score\": 1,\n"
+ + "\"_source\": {\n"
+ + "\"event\": {\n"
+ + "\"nodeName\": \"SDN-Controller-465e2ae306ca\",\n"
+ + "\"counter\": \"3\",\n"
+ + "\"timeStamp\": \"2020-02-22T08:22:19.8Z\",\n"
+ + "\"objectId\": \"sim2230\",\n"
+ + "\"attributeName\": \"ConnectionStatus\",\n"
+ + "\"newValue\": \"connected\",\n"
+ + "\"type\": \"AttributeValueChangedNotificationXml\"\n"
+ + "}\n"
+ + "}\n"
+ + "}");
+ private static final String CONFIG_CONTENT = "[dcae]\n"
+ + "dcaeUserCredentials=admin:admin\n"
+ + "dcaeUrl=off\n"
+ + "dcaeHeartbeatPeriodSeconds=120\n"
+ + "dcaeTestCollector=no\n"
+ + "\n"
+ + "[es]\n"
+ + "esCluster=sendateodl5\n"
+ + "#time limit to keep increasing data in database [in seconds]\n"
+ + "#60*60*24*30 (30days)\n"
+ + "esArchiveLimit=2592000\n"
+ + "#folder where removed data will be stored\n"
+ + "esArchiveFolder=./backup\n"
+ + "#interval to archive database [in seconds]\n"
+ + "#60*60*24 (1day)\n"
+ + "esArchiveInterval=86400\n"
+ + "\n"
+ + "[aai]\n"
+ + "#keep comment\n"
+ + "aaiHeaders=[\"X-TransactionId: 9999\"]\n"
+ + "aaiUrl=http://localhost:81\n"
+ + "aaiUserCredentials=AAI:AAI\n"
+ + "aaiDeleteOnMountpointRemove=false\n"
+ + "aaiTrustAllCerts=false\n"
+ + "aaiApiVersion=aai/v13\n"
+ + "aaiPropertiesFile=aaiclient.properties\n"
+ + "aaiApplicationId=SDNR\n"
+ "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n"
- + "aaiPcks12ClientCertPassphrase=adminadmin\n" + "aaiClientConnectionTimeout=30000\n" + "\n" + "[pm]\n"
- + "pmCluster=sendateodl5\n" + "pmEnabled=true\n" + "";
+ + "aaiPcks12ClientCertPassphrase=adminadmin\n"
+ + "aaiClientConnectionTimeout=30000\n"
+ + "\n"
+ + "[pm]\n"
+ + "pmCluster=sendateodl5\n"
+ + "pmEnabled=true\n"
+ + "";
+ // @formatter:on
@Test
public void testComponentData() {
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 02877f0c8..32438410f 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
@@ -27,7 +27,6 @@ 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.DataMigrationProviderImpl;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DataMigrationReport;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release;
@@ -42,16 +41,20 @@ public class TestMigrationProvider {
.valueOf(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200"))};
@Test
- public void testCreateImport() {
+ public void testCreateImport() throws Exception {
DataMigrationProviderImpl provider = new DataMigrationProviderImpl(hosts, null, null, true, 5000);
try {
+
+
//create el alto db infrastructure
- provider.initDatabase(Release.FRANKFURT_R1, 5, 1, "", true, 10000);
+ if (!provider.initDatabase(null, 5, 1, "", true, 10000)) {
+ fail("unable to init database");
+ }
//import data into database
- DataMigrationReport report = provider.importData(FRANKFURT_BACKUP_FILE, false, Release.FRANKFURT_R1);
+ DataMigrationReport report = provider.importData(FRANKFURT_BACKUP_FILE, false, Release.FRANKFURT_R2);
assertTrue(report.completed());
- assertEquals(Release.FRANKFURT_R1, provider.autoDetectRelease());
+ assertEquals(Release.FRANKFURT_R2, provider.autoDetectRelease());
} catch (Exception e) {
fail(e.getMessage());
}
diff --git a/sdnr/wt/data-provider/setup/tmp.log b/sdnr/wt/data-provider/setup/tmp.log
deleted file mode 100644
index d2c5a8726..000000000
--- a/sdnr/wt/data-provider/setup/tmp.log
+++ /dev/null
@@ -1 +0,0 @@
-{"configs":{},"components":{},"release":"frankfurt-R1","created":"2020-02-25T05:29:35.3Z"}