aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/data-provider
diff options
context:
space:
mode:
authorMichael Dürre <michael.duerre@highstreet-technologies.com>2020-03-04 07:43:07 +0100
committerMichael Dürre <michael.duerre@highstreet-technologies.com>2020-03-04 07:43:22 +0100
commit298e36213bae8e9c972928d09f7cf58d23bba991 (patch)
tree8ebc0398a88f876b3bfcdc097f1cc3bb58689365 /sdnr/wt/data-provider
parenta88eb4a899fee09bc3c067a2764bb182d485d119 (diff)
fixed db init
fixed db initialziation for maintenance Issue-ID: SDNC-1108 Signed-off-by: Michael Dürre <michael.duerre@highstreet-technologies.com> Change-Id: Ifcfdf80f31cb7691716e8f4cec6ba1ba52644709
Diffstat (limited to 'sdnr/wt/data-provider')
-rw-r--r--sdnr/wt/data-provider/setup/pom.xml23
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderImpl.java12
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderService.java7
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/Program.java579
-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/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMigrationProvider.java2
6 files changed, 292 insertions, 333 deletions
diff --git a/sdnr/wt/data-provider/setup/pom.xml b/sdnr/wt/data-provider/setup/pom.xml
index 74391a86d..e9618b1f7 100644
--- a/sdnr/wt/data-provider/setup/pom.xml
+++ b/sdnr/wt/data-provider/setup/pom.xml
@@ -80,29 +80,6 @@
<build>
<plugins>
<plugin>
- <groupId>org.codehaus.mojo</groupId>
- <artifactId>exec-maven-plugin</artifactId>
- <executions>
- <execution>
- <id>generateDTOs</id>
- <phase>generate-sources</phase>
- <goals>
- <goal>exec</goal>
- </goals>
- <configuration>
- <skip>${skipTests}</skip>
- <executable>bash</executable>
- <arguments>
- <argument>${basedir}/../provider/src/main/resources/es-init.sh</argument>
- <argument>initfile</argument>
- <argument>-f</argument>
- <argument>${project.build.directory}/EsInit.script</argument>
- </arguments>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
<groupId>com.github.alexcojocaru</groupId>
<artifactId>elasticsearch-maven-plugin</artifactId>
<version>6.16</version>
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 c20a1ad06..10fc5866b 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
@@ -260,7 +260,10 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService {
@Override
public boolean initDatabase(Release release, int numShards, int numReplicas, String dbPrefix,
- boolean forceRecreate) {
+ boolean forceRecreate,long timeoutms) {
+ if(timeoutms>0) {
+ this.dbClient.waitForYellowStatus(timeoutms);
+ }
EsVersion dbVersion = this.readActualVersion();
if (dbVersion == null) {
return false;
@@ -270,7 +273,7 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService {
return false;
}
if (forceRecreate) {
- this.clearDatabase(release, dbPrefix);
+ this.clearDatabase(release, dbPrefix,0);
}
ReleaseInformation ri = ReleaseInformation.getInstance(release);
AliasesEntryList aliases = this.readAliases();
@@ -319,8 +322,11 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService {
}
@Override
- public boolean clearDatabase(Release release, String dbPrefix) {
+ public boolean clearDatabase(Release release, String dbPrefix, long timeoutms) {
+ if(timeoutms>0) {
+ this.dbClient.waitForYellowStatus(timeoutms);
+ }
//check aliases
AliasesEntryList entries = this.readAliases();
if (entries == null) {
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderService.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderService.java
index d908d6931..5a0ec3b6a 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderService.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderService.java
@@ -56,15 +56,16 @@ public interface DataMigrationProviderService {
* @param numReplicas
* @param dbPrefix
* @param forceRecreate
+ * @param timeoutms
* @return
*/
- boolean initDatabase(Release release, int numShards, int numReplicas, String dbPrefix, boolean forceRecreate);
-
+ boolean initDatabase(Release release, int numShards, int numReplicas, String dbPrefix, boolean forceRecreate,
+ long timeoutms);
/**
* clean up the database
* all data will be removed
* complete structure will be destroyed
* @return
*/
- boolean clearDatabase(Release release, String dbPrefix);
+ boolean clearDatabase(Release release, String dbPrefix, long timeoutms);
}
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 23a64f252..a1b92e9b3 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
@@ -43,328 +43,303 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release;
*/
public class Program {
- private static final String CMD_INITDB = "init";
- private static final String CMD_CLEAR_DB = "delete";
- private static final String CMD_CREATE_PLUGIN_INIT_FILE = "pluginfile";
- private static final String CMD_IMPORT = "import";
- private static final String CMD_EXPORT = "export";
- private static final String CMD_LIST_VERSION = "list";
- private static final String CMD_INITDB_DESCRIPTION = "initialize databse indices and aliases";
- private static final String CMD_CLEAR_DB_DESCRIPTION = "clear database indices and aliases";
- private static final String CMD_CREATE_PLUGIN_INIT_FILE_DESCRIPTION = "create maven plugin file";
- private static final String CMD_IMPORT_DESCRIPTION = "import data into database";
- private static final String CMD_EXPORT_DESCRIPTION = "export data from database";
- private static final String CMD_LIST_VERSION_DESCRIPTION = "list release versions";
+ private static final String CMD_INITDB = "init";
+ private static final String CMD_CLEAR_DB = "delete";
+ private static final String CMD_CREATE_PLUGIN_INIT_FILE = "pluginfile";
+ private static final String CMD_IMPORT = "import";
+ private static final String CMD_EXPORT = "export";
+ private static final String CMD_LIST_VERSION = "list";
+ private static final String CMD_INITDB_DESCRIPTION = "initialize databse indices and aliases";
+ private static final String CMD_CLEAR_DB_DESCRIPTION = "clear database indices and aliases";
+ private static final String CMD_CREATE_PLUGIN_INIT_FILE_DESCRIPTION = "create maven plugin file";
+ private static final String CMD_IMPORT_DESCRIPTION = "import data into database";
+ private static final String CMD_EXPORT_DESCRIPTION = "export data from database";
+ private static final String CMD_LIST_VERSION_DESCRIPTION = "list release versions";
- private static final List<String[]> commands = Arrays.asList(new String[] { CMD_INITDB, CMD_INITDB_DESCRIPTION },
- new String[] { CMD_CLEAR_DB, CMD_CLEAR_DB_DESCRIPTION },
- new String[] { CMD_CREATE_PLUGIN_INIT_FILE, CMD_CREATE_PLUGIN_INIT_FILE_DESCRIPTION },
- new String[] { CMD_IMPORT, CMD_IMPORT_DESCRIPTION }, new String[] { CMD_EXPORT, CMD_EXPORT_DESCRIPTION },
- new String[] { CMD_LIST_VERSION, CMD_LIST_VERSION_DESCRIPTION });
- private static final String APPLICATION_NAME = "SDNR DataMigrationTool";
- private static final int DEFAULT_SHARDS = 5;
- private static final int DEFAULT_REPLICAS = 1;
- private static final String DEFAULT_DBURL = "http://sdnrdb:9200";
- private static final String DEFAULT_DBPREFIX = "";
- private static final String OPTION_FORCE_RECREATE_SHORT = "f";
- private static final String OPTION_SILENT_SHORT = "n";
- private static final String OPTION_SILENT = "silent";
- private static final String OPTION_VERSION_SHORT = "v";
- private static final String OPTION_SHARDS_SHORT = "s";
- private static final String OPTION_REPLICAS_SHORT = "r";
- private static final String OPTION_OUTPUTFILE_SHORT = "of";
- private static final String OPTION_INPUTFILE_SHORT = "if";
- private static final String OPTION_DEBUG_SHORT = "x";
- private static final String OPTION_TRUSTINSECURESSL_SHORT = "k";
+ private static final List<String[]> commands = Arrays.asList(new String[] { CMD_INITDB, CMD_INITDB_DESCRIPTION },
+ new String[] { CMD_CLEAR_DB, CMD_CLEAR_DB_DESCRIPTION },
+ new String[] { CMD_CREATE_PLUGIN_INIT_FILE, CMD_CREATE_PLUGIN_INIT_FILE_DESCRIPTION },
+ new String[] { CMD_IMPORT, CMD_IMPORT_DESCRIPTION }, new String[] { CMD_EXPORT, CMD_EXPORT_DESCRIPTION },
+ new String[] { CMD_LIST_VERSION, CMD_LIST_VERSION_DESCRIPTION });
+ private static final String APPLICATION_NAME = "SDNR DataMigrationTool";
+ private static final int DEFAULT_SHARDS = 5;
+ private static final int DEFAULT_REPLICAS = 1;
+ private static final String DEFAULT_DBURL = "http://sdnrdb:9200";
+ private static final String DEFAULT_DBPREFIX = "";
+ private static final String OPTION_FORCE_RECREATE_SHORT = "f";
+ private static final String OPTION_SILENT_SHORT = "n";
+ private static final String OPTION_SILENT = "silent";
+ private static final String OPTION_VERSION_SHORT = "v";
+ private static final String OPTION_SHARDS_SHORT = "s";
+ private static final String OPTION_REPLICAS_SHORT = "r";
+ private static final String OPTION_OUTPUTFILE_SHORT = "of";
+ private static final String OPTION_INPUTFILE_SHORT = "if";
+ private static final String OPTION_DEBUG_SHORT = "x";
+ private static final String OPTION_TRUSTINSECURESSL_SHORT = "k";
+ private static final String OPTION_DATABSE_SHORT = "db";
- private static Options options = init();
+ private static Options options = init();
- private static Log LOG = null;
+ private static Log LOG = null;
- @SuppressWarnings("unchecked")
- private static <T> T getOptionOrDefault(CommandLine cmd, String option, T def) throws ParseException {
- if (def instanceof Boolean) {
- return cmd.hasOption(option) ? (T) Boolean.TRUE : def;
- }
- if (cmd.hasOption(option) && cmd.getOptionValue(option) != null) {
- if (option.equals(OPTION_VERSION_SHORT)) {
- String v = cmd.getOptionValue(option);
- return (T) Release.getValueBySuffix(v.startsWith("-") ? v : ("-" + v));
- } else {
- return (T) cmd.getParsedOptionValue(option);
- }
- }
- return def;
- }
+ @SuppressWarnings("unchecked")
+ private static <T> T getOptionOrDefault(CommandLine cmd, String option, T def) throws ParseException {
+ if (def instanceof Boolean) {
+ return cmd.hasOption(option) ? (T) Boolean.TRUE : def;
+ }
+ if (def instanceof Integer) {
+ return cmd.hasOption(option) ? (T) Integer.valueOf(cmd.getOptionValue(option)) : def;
+ }
+ if (def instanceof Long) {
+ return cmd.hasOption(option) ? (T) Long.valueOf(cmd.getOptionValue(option)) : def;
+ }
+ if (cmd.hasOption(option) && cmd.getOptionValue(option) != null) {
+ if (option.equals(OPTION_VERSION_SHORT)) {
+ String v = cmd.getOptionValue(option);
+ return (T) Release.getValueBySuffix(v.startsWith("-") ? v : "-" + v);
+ } else {
+ return (T) cmd.getParsedOptionValue(option);
+ }
+ }
+ return def;
+ }
- private static void initLog(boolean silent, String logfile) {
- initLog(silent, logfile, Level.INFO);
- }
+ private static void initLog(boolean silent, String logfile, Level loglvl) {
+ Logger.getRootLogger().getLoggerRepository().resetConfiguration();
+ LOG = LogFactory.getLog(Program.class);
+ if (!silent) {
+ ConsoleAppender console = new ConsoleAppender(); // create appender
+ // configure the appender
+ String PATTERN = "%d [%p|%C{1}] %m%n";
+ console.setLayout(new PatternLayout(PATTERN));
+ console.setThreshold(loglvl);
+ console.activateOptions();
+ // add appender to any Logger (here is root)
+ Logger.getRootLogger().addAppender(console);
+ }
+ if (logfile != null) {
+ RollingFileAppender fa = new RollingFileAppender();
+ fa.setName("FileLogger");
+ fa.setFile(logfile);
+ fa.setLayout(new PatternLayout("%d %-5p [%c] %m%n"));
+ fa.setThreshold(loglvl);
+ fa.setMaximumFileSize(10000000);
+ fa.setAppend(true);
+ fa.setMaxBackupIndex(5);
+ fa.activateOptions();
+ // add appender to any Logger (here is root)
+ Logger.getRootLogger().addAppender(fa);
+ }
+ // repeat with all other desired appenders
+ }
- private static void initLog(boolean silent, String logfile, Level loglvl) {
- Logger.getRootLogger().getLoggerRepository().resetConfiguration();
- LOG = LogFactory.getLog(Program.class);
- if (!silent) {
- ConsoleAppender console = new ConsoleAppender(); // create appender
- // configure the appender
- String PATTERN = "%d [%p|%C{1}] %m%n";
- console.setLayout(new PatternLayout(PATTERN));
- console.setThreshold(loglvl);
- console.activateOptions();
- // add appender to any Logger (here is root)
- Logger.getRootLogger().addAppender(console);
- }
- if (logfile != null) {
- RollingFileAppender fa = new RollingFileAppender();
- fa.setName("FileLogger");
- fa.setFile(logfile);
- fa.setLayout(new PatternLayout("%d %-5p [%c] %m%n"));
- fa.setThreshold(loglvl);
- fa.setMaximumFileSize(10000000);
- fa.setAppend(true);
- fa.setMaxBackupIndex(5);
- fa.activateOptions();
- // add appender to any Logger (here is root)
- Logger.getRootLogger().addAppender(fa);
- }
- // repeat with all other desired appenders
- }
+ public static void main(String[] args) {
+ CommandLineParser parser = new DefaultParser();
+ HelpFormatter formatter = new HelpFormatter();
+ CommandLine cmd = null;
+ try {
+ cmd = parser.parse(options, args);
+ } catch (ParseException e) {
+ System.out.println(e.getMessage());
+ printHelp(formatter);
+ System.exit(1);
+ }
+ if (cmd == null) {
+ printHelp(formatter);
+ System.exit(1);
+ }
+ try {
+ initLog(getOptionOrDefault(cmd, OPTION_SILENT_SHORT, false), null,
+ getOptionOrDefault(cmd, OPTION_DEBUG_SHORT, false) ? Level.DEBUG : Level.INFO);
+ } catch (ParseException e2) {
- public static void main(String[] args) {
- CommandLineParser parser = new DefaultParser();
- HelpFormatter formatter = new HelpFormatter();
- CommandLine cmd = null;
- try {
- cmd = parser.parse(options, args);
- } catch (ParseException e) {
- System.out.println(e.getMessage());
- printHelp(formatter);
- System.exit(1);
- }
- if (cmd == null) {
- printHelp(formatter);
- System.exit(1);
- }
- try {
- initLog(getOptionOrDefault(cmd, OPTION_SILENT_SHORT, false), null,
- getOptionOrDefault(cmd, OPTION_DEBUG_SHORT, false) ? Level.DEBUG : Level.INFO);
- } catch (ParseException e2) {
+ }
+ switch (cmd.getOptionValue("c")) {
+ case CMD_INITDB:
+ try {
+ cmd_init_db(cmd);
+ } catch (Exception e1) {
+ exit(e1);
+ }
+ break;
+ case CMD_CLEAR_DB:
+ try {
+ cmd_clear_db(cmd);
+ } catch (Exception e1) {
+ exit(e1);
+ }
+ break;
+ case CMD_CREATE_PLUGIN_INIT_FILE:
+ try {
+ String of = getOptionOrDefault(cmd, "of", null);
+ if (of == null) {
+ throw new Exception("please add the parameter output-file");
+ }
+ MavenDatabasePluginInitFile.create(Release.CURRENT_RELEASE, of);
+ } catch (Exception e) {
+ exit(e);
+ }
+ break;
+ case CMD_IMPORT:
+ try {
+ cmd_dbimport(cmd);
+ } catch (Exception e1) {
+ exit(e1);
+ }
+ break;
+ case CMD_EXPORT:
+ try {
+ cmd_dbexport(cmd);
+ } catch (Exception e) {
+ exit(e);
+ }
+ break;
+ case CMD_LIST_VERSION:
+ cmd_listversion();
+ break;
+ default:
+ printHelp(formatter);
+ break;
+ }
+ System.exit(0);
+ }
- }
- switch (cmd.getOptionValue("c")) {
- case CMD_INITDB:
- try {
- cmd_init_db(cmd);
- } catch (Exception e1) {
- exit(e1);
- }
- break;
- case CMD_CLEAR_DB:
- try {
- cmd_clear_db(cmd);
- } catch (Exception e1) {
- exit(e1);
- }
- break;
- case CMD_CREATE_PLUGIN_INIT_FILE:
- try {
- String of = getOptionOrDefault(cmd, "of", null);
- if (of == null) {
- throw new Exception("please add the parameter output-file");
- }
- MavenDatabasePluginInitFile.create(Release.CURRENT_RELEASE, of);
- } catch (Exception e) {
- exit(e);
- }
- break;
- case CMD_IMPORT:
- try {
- cmd_dbimport(cmd);
- } catch (Exception e1) {
- exit(e1);
- }
- break;
- case CMD_EXPORT:
- try {
- cmd_dbexport(cmd);
- } catch (Exception e) {
- exit(e);
- }
- break;
- case CMD_LIST_VERSION:
- cmd_listversion();
- break;
- default:
- printHelp(formatter);
- break;
- }
- System.exit(0);
- }
+ private static void printHelp(HelpFormatter formatter) {
+ formatter.printHelp(APPLICATION_NAME, options);
+ System.out.println("\nCommands:");
+ for (String[] c : commands) {
+ System.out.println(String.format("%10s\t%s", c[0], c[1]));
+ }
+ }
- /**
- * @param formatter
- */
- private static void printHelp(HelpFormatter formatter) {
- formatter.printHelp(APPLICATION_NAME, options);
- System.out.println("\nCommands:");
- for (String[] c : commands) {
- System.out.println(String.format("%10s\t%s", c[0], c[1]));
- }
- }
+ private static void cmd_listversion() {
- /**
- *
- */
- private static void cmd_listversion() {
+ System.out.println("Database Releases:");
+ final String format = "%15s\t%8s";
+ System.out.println(String.format(format, "Name", "Version"));
+ for (Release r : Release.values()) {
- System.out.println("Database Releases:");
- final String format = "%15s\t%8s";
- System.out.println(String.format(format, "Name", "Version"));
- for (Release r : Release.values()) {
+ System.out.println(String.format(format, r.getValue(),
+ r.getDBSuffix() != null && r.getDBSuffix().length() > 1 ? r.getDBSuffix().substring(1) : ""));
+ }
- System.out.println(String.format(format, r.getValue(),
- r.getDBSuffix() != null && r.getDBSuffix().length() > 1 ? r.getDBSuffix().substring(1) : ""));
- }
+ }
- }
+ private static void cmd_dbimport(CommandLine cmd) throws Exception {
+ String dbUrl = getOptionOrDefault(cmd, OPTION_DATABSE_SHORT, DEFAULT_DBURL);
+ String username = getOptionOrDefault(cmd, "dbu", null);
+ String password = getOptionOrDefault(cmd, "dbp", null);
+ String filename = getOptionOrDefault(cmd, OPTION_OUTPUTFILE_SHORT, null);
+ boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, false);
+ if (filename == null) {
+ throw new Exception("please add output file parameter");
+ }
+ DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) },
+ username, password, trustAll);
+ DataMigrationReport report = service.importData(filename, false);
+ LOG.info(report);
+ if(!report.completed()) {
+ throw new Exception("db import seems to be not executed completed");
+ }
+ }
- /**
- * @throws Exception
- *
- */
- private static void cmd_dbimport(CommandLine cmd) throws Exception {
- String dbUrl = getOptionOrDefault(cmd, "db", DEFAULT_DBURL);
- String username = getOptionOrDefault(cmd, "dbu", null);
- String password = getOptionOrDefault(cmd, "dbp", null);
- String filename = getOptionOrDefault(cmd, OPTION_OUTPUTFILE_SHORT, null);
- boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, false);
- if (filename == null) {
- throw new Exception("please add output file parameter");
- }
- DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) },
- username, password, trustAll);
- DataMigrationReport report = service.importData(filename, false);
- LOG.info(report);
- if(!report.completed()) {
- throw new Exception("db import seems to be not executed completed");
- }
- }
+ private static void cmd_dbexport(CommandLine cmd) throws Exception {
+ String dbUrl = getOptionOrDefault(cmd, "db", DEFAULT_DBURL);
+ String username = getOptionOrDefault(cmd, "dbu", null);
+ String password = getOptionOrDefault(cmd, "dbp", null);
+ String filename = getOptionOrDefault(cmd, OPTION_OUTPUTFILE_SHORT, null);
+ boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, false);
+ if (filename == null) {
+ throw new Exception("please add output file parameter");
+ }
+ DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) },
+ username, password, trustAll);
+ DataMigrationReport report = service.exportData(filename);
+ LOG.info(report);
+ if(!report.completed()) {
+ throw new Exception("db export seems to be not executed completed");
+ }
- /**
- * @throws Exception
- *
- */
- private static void cmd_dbexport(CommandLine cmd) throws Exception {
- String dbUrl = getOptionOrDefault(cmd, "db", DEFAULT_DBURL);
- String username = getOptionOrDefault(cmd, "dbu", null);
- String password = getOptionOrDefault(cmd, "dbp", null);
- String filename = getOptionOrDefault(cmd, OPTION_OUTPUTFILE_SHORT, null);
- boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, false);
- if (filename == null) {
- throw new Exception("please add output file parameter");
- }
- DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) },
- username, password, trustAll);
- DataMigrationReport report = service.exportData(filename);
- LOG.info(report);
- if(!report.completed()) {
- throw new Exception("db export seems to be not executed completed");
- }
+ }
- }
+ private static void exit(Exception e) {
+ if (LOG != null) {
+ LOG.error("Error during execution: {}", e);
+ } else {
+ System.err.println(e);
+ }
+ System.exit(1);
+ }
- /**
- * @param e
- */
- private static void exit(Exception e) {
- if (LOG != null) {
- LOG.error("Error during execution: {}", e);
- } else {
- System.err.println(e);
- }
- System.exit(1);
- }
+ private static void cmd_clear_db(CommandLine cmd) throws Exception {
+ Release r = getOptionOrDefault(cmd, OPTION_VERSION_SHORT, Release.CURRENT_RELEASE);
+ String dbUrl = getOptionOrDefault(cmd, OPTION_DATABSE_SHORT, DEFAULT_DBURL);
+ String dbPrefix = getOptionOrDefault(cmd, "p", DEFAULT_DBPREFIX);
+ String username = getOptionOrDefault(cmd, "dbu", null);
+ String password = getOptionOrDefault(cmd, "dbp", null);
+ boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, false);
+ DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) },
+ username, password, trustAll);
+ long timeoutms = getOptionOrDefault(cmd, "w", 30)*1000;
+ if (!service.clearDatabase(r, dbPrefix,timeoutms)) {
+ throw new Exception("failed to init database");
+ }
+ }
- /**
- * @param cmd
- * @throws java.text.ParseException
- * @throws Exception
- */
- private static void cmd_clear_db(CommandLine cmd) throws Exception {
- Release r = getOptionOrDefault(cmd, OPTION_VERSION_SHORT, Release.CURRENT_RELEASE);
- String dbUrl = getOptionOrDefault(cmd, "db", DEFAULT_DBURL);
- String dbPrefix = getOptionOrDefault(cmd, "p", DEFAULT_DBPREFIX);
- String username = getOptionOrDefault(cmd, "dbu", null);
- String password = getOptionOrDefault(cmd, "dbp", null);
- boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, false);
- DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) },
- username, password, trustAll);
- if (!service.clearDatabase(r, dbPrefix)) {
- throw new Exception("failed to init database");
- }
- }
+ private static void cmd_init_db(CommandLine cmd) throws Exception {
+ Release r = getOptionOrDefault(cmd, OPTION_VERSION_SHORT, Release.CURRENT_RELEASE);
+ int numShards = getOptionOrDefault(cmd, OPTION_SHARDS_SHORT, DEFAULT_SHARDS);
+ int numReplicas = getOptionOrDefault(cmd, OPTION_REPLICAS_SHORT, DEFAULT_REPLICAS);
+ String dbUrl = getOptionOrDefault(cmd, "db", DEFAULT_DBURL);
+ String dbPrefix = getOptionOrDefault(cmd, "p", DEFAULT_DBPREFIX);
+ String username = getOptionOrDefault(cmd, "dbu", null);
+ String password = getOptionOrDefault(cmd, "dbp", null);
+ boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, false);
+ DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) },
+ username, password, trustAll);
+ long timeoutms = getOptionOrDefault(cmd, "w", 30)*1000;
+ boolean forceRecreate = cmd.hasOption(OPTION_FORCE_RECREATE_SHORT);
+ if (!service.initDatabase(r, numShards, numReplicas, dbPrefix, forceRecreate,timeoutms)) {
+ throw new Exception("failed to init database");
+ }
- /**
- * @param cmd
- * @throws java.text.ParseException
- * @throws Exception
- */
- private static void cmd_init_db(CommandLine cmd) throws Exception {
- Release r = getOptionOrDefault(cmd, OPTION_VERSION_SHORT, Release.CURRENT_RELEASE);
- int numShards = getOptionOrDefault(cmd, OPTION_SHARDS_SHORT, DEFAULT_SHARDS);
- int numReplicas = getOptionOrDefault(cmd, OPTION_REPLICAS_SHORT, DEFAULT_REPLICAS);
- String dbUrl = getOptionOrDefault(cmd, "db", DEFAULT_DBURL);
- String dbPrefix = getOptionOrDefault(cmd, "p", DEFAULT_DBPREFIX);
- String username = getOptionOrDefault(cmd, "dbu", null);
- String password = getOptionOrDefault(cmd, "dbp", null);
- boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, false);
- DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) },
- username, password, trustAll);
- boolean forceRecreate = cmd.hasOption(OPTION_FORCE_RECREATE_SHORT);
- if (!service.initDatabase(r, numShards, numReplicas, dbPrefix, forceRecreate)) {
- throw new Exception("failed to init database");
- }
+ }
- }
+ private static Options init() {
+ Options result = new Options();
+ result.addOption(createOption("c", "cmd", true, "command to execute", true));
+ result.addOption(createOption(OPTION_DATABSE_SHORT, "dburl", true, "database url", false));
+ result.addOption(createOption("dbu", "db-username", true, "database basic auth username", false));
+ result.addOption(createOption("dbp", "db-password", 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("p", "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,
+ "trust insecure ssl certs", false));
+ result.addOption(createOption("w", "wait", 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_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));
- /**
- * @return
- */
- private static Options init() {
- Options options = new Options();
- options.addOption(createOption("c", "cmd", true, "command to execute", true));
- options.addOption(createOption("db", "dburl", true, "database url", false));
- options.addOption(createOption("dbu", "db-username", true, "database basic auth username", false));
- options.addOption(createOption("dbp", "db-password", true, "database basic auth password", false));
- options.addOption(createOption(OPTION_REPLICAS_SHORT, "replicas", true, "amount of replicas", false));
- options.addOption(createOption(OPTION_SHARDS_SHORT, "shards", true, "amount of shards", false));
- options.addOption(createOption("p", "prefix", true, "prefix for db indices", false));
- options.addOption(createOption(OPTION_VERSION_SHORT, "version", true, "version", false));
- options.addOption(createOption(OPTION_DEBUG_SHORT, "verbose", false, "verbose mode", false));
- options.addOption(createOption(OPTION_TRUSTINSECURESSL_SHORT, "trust-insecure", false,
- "trust insecure ssl certs", false));
- options.addOption(createOption("w", "wait", true, "wait delay for yellow status", false));
- options.addOption(
- createOption(OPTION_FORCE_RECREATE_SHORT, "force-recreate", false, "delete if sth exists", false));
- options.addOption(createOption(OPTION_SILENT_SHORT, OPTION_SILENT, false, "prevent console output", false));
- options.addOption(createOption(OPTION_OUTPUTFILE_SHORT, "output-file", true, "file to write into", false));
- options.addOption(createOption(OPTION_INPUTFILE_SHORT, "input-file", true, "file to read from", false));
+ return result;
+ }
- return options;
- }
-
- /**
- * @param opt
- * @param longOpt
- * @param hasArg
- * @param description
- * @param required
- * @return
- */
- private static Option createOption(String opt, String longOpt, boolean hasArg, String description,
- boolean required) {
- Option o = new Option(opt, longOpt, hasArg, description);
- o.setRequired(required);
- return o;
- }
+ /**
+ * @param opt
+ * @param longOpt
+ * @param hasArg
+ * @param description
+ * @param required
+ * @return
+ */
+ private static Option createOption(String opt, String longOpt, boolean hasArg, String description,
+ boolean required) {
+ Option o = new Option(opt, longOpt, hasArg, description);
+ o.setRequired(required);
+ return o;
+ }
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformation.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformation.java
index 4fab820b7..bbbde1f22 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
@@ -68,7 +68,7 @@ public class FrankfurtReleaseInformation extends ReleaseInformation {
map.put(ComponentName.MEDIATOR_SERVER, new DatabaseInfo("mediator-server", "mediator-server",
"{\"url\":{\"type\": \"keyword\"},\"name\":{\"type\": \"keyword\"}}"));
map.put(ComponentName.MAINTENANCE, new DatabaseInfo("maintenancemode", "maintenancemode",
- "{\"node-id\": {\"type\": \"keyword\"},\"active\": {\"type\": \"boolean\"}},\"date_detection\":false}}"));
+ "{\"node-id\": {\"type\": \"keyword\"},\"start\": {\"type\": \"date\"},\"end\": {\"type\": \"date\"},\"description\": {\"type\": \"keyword\"},\"active\": {\"type\": \"boolean\"}},\"date_detection\":false}}"));
return map;
}
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 7949f0439..483ca0bc4 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
@@ -47,7 +47,7 @@ public class TestMigrationProvider {
try {
//create el alto db infrastructure
- provider.initDatabase(Release.FRANKFURT_R1, 5, 1, "", true);
+ provider.initDatabase(Release.FRANKFURT_R1, 5, 1, "", true,10000);
//import data into database
DataMigrationReport report = provider.importData(FRANKFURT_BACKUP_FILE, false, Release.FRANKFURT_R1);
assertTrue(report.completed());