diff options
author | highstreetherbert <herbert.eiselt@highstreet-technologies.com> | 2020-07-10 17:18:59 +0200 |
---|---|---|
committer | highstreetherbert <herbert.eiselt@highstreet-technologies.com> | 2020-07-10 17:19:12 +0200 |
commit | 52d1616151680d46cceb62cba752465ffd75a298 (patch) | |
tree | 23e2681573d77ba906fd3cd1d0bbc249ec1fafef /sdnr/wt/data-provider/setup/src | |
parent | 23c27ddcd79913d11eac16eb42c5a43899de97a1 (diff) |
Reformat sdnr data-provider to ONAP code style
Reformat to ONAP code style
Issue-ID: SDNC-1275
Signed-off-by: highstreetherbert <herbert.eiselt@highstreet-technologies.com>
Change-Id: I16230015ab8af278ec9f865690b9308d8fa2c78a
Signed-off-by: highstreetherbert <herbert.eiselt@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/data-provider/setup/src')
31 files changed, 1316 insertions, 1383 deletions
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderImpl.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderImpl.java index a336c0f6f..821e3ec1e 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 @@ -62,14 +62,15 @@ import org.slf4j.LoggerFactory; 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) { + public DataMigrationProviderImpl(HostInfo[] hosts, String username, String password, boolean trustAll, + long timeoutms) { - if(timeoutms>0) { - Portstatus.waitSecondsTillAvailable(timeoutms/1000, hosts); + if (timeoutms > 0) { + Portstatus.waitSecondsTillAvailable(timeoutms / 1000, hosts); } this.dbClient = new HtDatabaseClient(hosts, username, password, trustAll); } @@ -148,8 +149,7 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService { /** - * export data - * if file exists .1 (.n) will be created + * export data if file exists .1 (.n) will be created * */ @Override @@ -162,17 +162,17 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService { LOG.info("output will be written to {}", filename); //autodetect version Release dbRelease = this.autoDetectRelease(); - if(dbRelease==null) { + if (dbRelease == null) { report.error("unbable to detect db release. is database initialized?"); return report; } ReleaseInformation ri = ReleaseInformation.getInstance(dbRelease); boolean componentsSucceeded = true; - for(ComponentName c: ri.getComponents()) { + for (ComponentName c : ri.getComponents()) { ComponentData data = new ComponentData(c); - SearchResult<SearchHit> result = this.dbClient.doReadAllJsonData(ri.getAlias(c),ri.getDataType(c),false); + SearchResult<SearchHit> result = this.dbClient.doReadAllJsonData(ri.getAlias(c), ri.getDataType(c), false); data.addAll(result.getHits()); - container.addComponent(c, data ); + container.addComponent(c, data); } try { Files.write(new File(filename).toPath(), Arrays.asList(container.toJSON()), StandardCharsets.UTF_8); @@ -192,7 +192,7 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService { } private String checkFilenameForWrite(String filename, int apdx) { - File f = new File(String.format("$s.$d",filename,apdx)); + File f = new File(String.format("$s.$d", filename, apdx)); if (!f.exists()) { return filename; } @@ -209,18 +209,18 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService { EsVersion dbVersion = this.readActualVersion(); AliasesEntryList aliases = this.readAliases(); IndicesEntryList indices = this.readIndices(); - if(indices==null) { + if (indices == null) { return null; } List<Release> foundReleases = new ArrayList<>(); //if there are active aliases reduce indices to the active ones - if(aliases!=null && aliases.size()>0) { + if (aliases != null && aliases.size() > 0) { indices = indices.subList(aliases.getLinkedIndices()); } - for(Release r:Release.values()) { - if(r.isDbInRange(dbVersion)) { + for (Release r : Release.values()) { + if (r.isDbInRange(dbVersion)) { ReleaseInformation ri = ReleaseInformation.getInstance(r); - if(ri!=null && ri.containsIndices(indices)) { + if (ri != null && ri.containsIndices(indices)) { foundReleases.add(r); } } @@ -228,9 +228,11 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService { if (foundReleases.size() == 1) { return foundReleases.get(0); } - LOG.error("detect {} releases: {}. unable to detect for which one to do sth.",foundReleases.size(), foundReleases); + LOG.error("detect {} releases: {}. unable to detect for which one to do sth.", foundReleases.size(), + foundReleases); return null; } + private EsVersion readActualVersion() { try { GetInfoResponse response = this.dbClient.getInfo(); @@ -264,9 +266,9 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService { } @Override - public boolean initDatabase(Release release, int numShards, int numReplicas, String dbPrefix, - boolean forceRecreate,long timeoutms) { - if(timeoutms>0) { + public boolean initDatabase(Release release, int numShards, int numReplicas, String dbPrefix, boolean forceRecreate, + long timeoutms) { + if (timeoutms > 0) { this.dbClient.waitForYellowStatus(timeoutms); } EsVersion dbVersion = this.readActualVersion(); @@ -278,7 +280,7 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService { return false; } if (forceRecreate) { - this.clearDatabase(release, dbPrefix,0); + this.clearDatabase(release, dbPrefix, 0); } ReleaseInformation ri = ReleaseInformation.getInstance(release); AliasesEntryList aliases = this.readAliases(); @@ -287,7 +289,7 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService { return false; } AcknowledgedResponse response = null; - if(!ri.runPreInitCommands(this.dbClient)) { + if (!ri.runPreInitCommands(this.dbClient)) { return false; } for (ComponentName component : ri.getComponents()) { @@ -320,7 +322,7 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService { return false; } } - if(!ri.runPostInitCommands(this.dbClient)) { + if (!ri.runPostInitCommands(this.dbClient)) { return false; } return true; @@ -329,7 +331,7 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService { @Override public boolean clearDatabase(Release release, String dbPrefix, long timeoutms) { - if(timeoutms>0) { + if (timeoutms > 0) { this.dbClient.waitForYellowStatus(timeoutms); } //check aliases @@ -349,9 +351,9 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService { if (entryToDelete != null) { try { LOG.info("deleting alias {} for index {}", entryToDelete.getAlias(), entryToDelete.getIndex()); - response=this.dbClient.deleteAlias( + response = this.dbClient.deleteAlias( new DeleteAliasRequest(entryToDelete.getIndex(), entryToDelete.getAlias())); - LOG.info(response.isResponseSucceeded()?"succeeded":"failed"); + LOG.info(response.isResponseSucceeded() ? "succeeded" : "failed"); } catch (IOException e) { LOG.error(e.getMessage()); return false; @@ -373,8 +375,8 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService { if (entryToDelete != null) { try { LOG.info("deleting index {}", entryToDelete.getName()); - response=this.dbClient.deleteIndex(new DeleteIndexRequest(entryToDelete.getName())); - LOG.info(response.isResponseSucceeded()?"succeeded":"failed"); + response = this.dbClient.deleteIndex(new DeleteIndexRequest(entryToDelete.getName())); + LOG.info(response.isResponseSucceeded() ? "succeeded" : "failed"); } catch (IOException e) { LOG.error(e.getMessage()); return false; @@ -386,39 +388,39 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService { return true; } - /** - * @param timeoutms - * @return - */ - public boolean clearCompleteDatabase(long timeoutms) { - if(timeoutms>0) { + /** + * @param timeoutms + * @return + */ + public boolean clearCompleteDatabase(long timeoutms) { + if (timeoutms > 0) { this.dbClient.waitForYellowStatus(timeoutms); } //check aliases and indices - AliasesEntryList aliases = this.readAliases(); + AliasesEntryList aliases = this.readAliases(); IndicesEntryList indices = this.readIndices(); if (aliases == null || indices == null) { return false; } - for(AliasesEntry alias:aliases) { - try { - LOG.info("deleting alias {} for index {}",alias.getAlias(),alias.getIndex()); - this.dbClient.deleteAlias(new DeleteAliasRequest(alias.getIndex(), alias.getAlias())); - } catch (IOException e) { - LOG.error("problem deleting alias {}: {}",alias.getAlias(),e); - return false; - } - } - for(IndicesEntry index : indices) { - try { - LOG.info("deleting index {}",index.getName()); - this.dbClient.deleteIndex(new DeleteIndexRequest(index.getName())); - } catch (IOException e) { - LOG.error("problem deleting index {}: {}",index.getName(),e); - return false; - } + for (AliasesEntry alias : aliases) { + try { + LOG.info("deleting alias {} for index {}", alias.getAlias(), alias.getIndex()); + this.dbClient.deleteAlias(new DeleteAliasRequest(alias.getIndex(), alias.getAlias())); + } catch (IOException e) { + LOG.error("problem deleting alias {}: {}", alias.getAlias(), e); + return false; + } + } + for (IndicesEntry index : indices) { + try { + LOG.info("deleting index {}", index.getName()); + this.dbClient.deleteIndex(new DeleteIndexRequest(index.getName())); + } catch (IOException e) { + LOG.error("problem deleting index {}: {}", index.getName(), e); + return false; + } } return true; - } + } } diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderService.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderService.java index 5a0ec3b6a..0f1fc6c73 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 @@ -29,43 +29,46 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release; public interface DataMigrationProviderService { - /** - * import data from file and write these to database - * @param filename source - * @param dryrun only loading file and check consistency, not pushing into database - * @return report - * @throws FileNotFoundException - * @throws Exception - */ - DataMigrationReport importData(String filename,boolean dryrun) throws FileNotFoundException, Exception; - /** - * export current data to file - * @param filename - */ - DataMigrationReport exportData(String filename); - - /** - * - * @return - */ - Release getCurrentVersion(); - - /** - * @param release - * @param numShards - * @param numReplicas - * @param dbPrefix - * @param forceRecreate - * @param timeoutms - * @return - */ - 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, long timeoutms); + /** + * import data from file and write these to database + * + * @param filename source + * @param dryrun only loading file and check consistency, not pushing into database + * @return report + * @throws FileNotFoundException + * @throws Exception + */ + DataMigrationReport importData(String filename, boolean dryrun) throws FileNotFoundException, Exception; + + /** + * export current data to file + * + * @param filename + */ + DataMigrationReport exportData(String filename); + + /** + * + * @return + */ + Release getCurrentVersion(); + + /** + * @param release + * @param numShards + * @param numReplicas + * @param dbPrefix + * @param forceRecreate + * @param timeoutms + * @return + */ + 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, 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 d06ffe1ee..c7775a96b 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,7 +43,7 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release; */ public class Program { - // constants + // constants private static final String CMD_INITDB = "init"; private static final String CMD_CLEAR_DB = "delete"; private static final String CMD_CLEAR_DB_COMPLETE = "clear"; @@ -59,11 +59,11 @@ public class Program { 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 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; @@ -81,24 +81,24 @@ public class Program { private static final String OPTION_TRUSTINSECURESSL_SHORT = "k"; private static final String OPTION_DATABASE_SHORT = "db"; private static final String OPTION_COMMAND_SHORT = "c"; - private static final String OPTION_DATABASEUSER_SHORT = "dbu"; - private static final String OPTION_DATABASEPASSWORD_SHORT = "dbp"; - private static final String OPTION_DATABASEPREFIX_SHORT = "p"; - private static final String OPTION_DATABASEWAIT_SHORT = "w"; - private static final String OPTION_HELP_SHORT = "h"; + private static final String OPTION_DATABASEUSER_SHORT = "dbu"; + private static final String OPTION_DATABASEPASSWORD_SHORT = "dbp"; + private static final String OPTION_DATABASEPREFIX_SHORT = "p"; + private static final String OPTION_DATABASEWAIT_SHORT = "w"; + private static final String OPTION_HELP_SHORT = "h"; // end of constants - - // variables + + // variables private static Options options = init(); private static Log LOG = null; // end of variables - + // public methods public static void main(String[] args) { - System.exit( main2(args) ); + System.exit(main2(args)); } // end of public methods - + // private methods @SuppressWarnings("unchecked") private static <T> T getOptionOrDefault(CommandLine cmd, String option, T def) throws ParseException { @@ -156,7 +156,7 @@ public class Program { CommandLineParser parser = new DefaultParser(); HelpFormatter formatter = new HelpFormatter(); CommandLine cmd = null; - + try { cmd = parser.parse(options, args); } catch (ParseException e) { @@ -175,72 +175,72 @@ public class Program { } try { - if(getOptionOrDefault(cmd, OPTION_HELP_SHORT, false)) { - printHelp(formatter); - return 0; - } - } catch (ParseException e2) { - return exit(e2); - } + if (getOptionOrDefault(cmd, OPTION_HELP_SHORT, false)) { + printHelp(formatter); + return 0; + } + } catch (ParseException e2) { + return exit(e2); + } final String command = cmd.getOptionValue(OPTION_COMMAND_SHORT); - if(command==null) { - printHelp(formatter); + if (command == null) { + printHelp(formatter); return 1; } switch (command) { - case CMD_INITDB: - try { - cmd_init_db(cmd); - } catch (Exception e1) { - return exit(e1); - } - break; - case CMD_CLEAR_DB: - try { - cmd_clear_db(cmd); - } catch (Exception e1) { - return exit(e1); - } - break; - case CMD_CLEAR_DB_COMPLETE: - try { - cmd_clear_db_complete(cmd); - } catch (Exception e1) { - return exit(e1); - } - break; - case CMD_CREATE_PLUGIN_INIT_FILE: - try { - String of = getOptionOrDefault(cmd, OPTION_OUTPUTFILE_SHORT, null); - if (of == null) { - throw new Exception("please add the parameter output-file"); + case CMD_INITDB: + try { + cmd_init_db(cmd); + } catch (Exception e1) { + return exit(e1); } - MavenDatabasePluginInitFile.create(Release.CURRENT_RELEASE, of); - } catch (Exception e) { - return exit(e); - } - break; - case CMD_IMPORT: - try { - cmd_dbimport(cmd); - } catch (Exception e1) { - return exit(e1); - } - break; - case CMD_EXPORT: - try { - cmd_dbexport(cmd); - } catch (Exception e) { - return exit(e); - } - break; - case CMD_LIST_VERSION: - cmd_listversion(); - break; + break; + case CMD_CLEAR_DB: + try { + cmd_clear_db(cmd); + } catch (Exception e1) { + return exit(e1); + } + break; + case CMD_CLEAR_DB_COMPLETE: + try { + cmd_clear_db_complete(cmd); + } catch (Exception e1) { + return exit(e1); + } + break; + case CMD_CREATE_PLUGIN_INIT_FILE: + try { + String of = getOptionOrDefault(cmd, OPTION_OUTPUTFILE_SHORT, null); + if (of == null) { + throw new Exception("please add the parameter output-file"); + } + MavenDatabasePluginInitFile.create(Release.CURRENT_RELEASE, of); + } catch (Exception e) { + return exit(e); + } + break; + case CMD_IMPORT: + try { + cmd_dbimport(cmd); + } catch (Exception e1) { + return exit(e1); + } + break; + case CMD_EXPORT: + try { + cmd_dbexport(cmd); + } catch (Exception e) { + return exit(e); + } + break; + case CMD_LIST_VERSION: + cmd_listversion(); + break; - default: - printHelp(formatter); - return 1; + default: + printHelp(formatter); + return 1; } return 0; } @@ -266,7 +266,7 @@ public class Program { } - private static void cmd_dbimport(CommandLine cmd) throws Exception { + private static void cmd_dbimport(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); @@ -275,12 +275,12 @@ public class Program { if (filename == null) { throw new Exception("please add output file parameter"); } - long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30)*1000; - DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) }, + long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30) * 1000; + DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] {HostInfo.parse(dbUrl)}, username, password, trustAll, timeoutms); DataMigrationReport report = service.importData(filename, false); LOG.info(report); - if(!report.completed()) { + if (!report.completed()) { throw new Exception("db import seems to be not executed completed"); } } @@ -294,12 +294,12 @@ public class Program { if (filename == null) { throw new Exception("please add output file parameter"); } - long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30)*1000; - DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) }, + long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30) * 1000; + DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] {HostInfo.parse(dbUrl)}, username, password, trustAll, timeoutms); DataMigrationReport report = service.exportData(filename); LOG.info(report); - if(!report.completed()) { + if (!report.completed()) { throw new Exception("db export seems to be not executed completed"); } @@ -321,23 +321,24 @@ public class Program { 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; - DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) }, + long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30) * 1000; + DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] {HostInfo.parse(dbUrl)}, username, password, trustAll, timeoutms); - if (!service.clearDatabase(r, dbPrefix,timeoutms)) { + if (!service.clearDatabase(r, dbPrefix, timeoutms)) { throw new Exception("failed to init database"); } } + 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; - DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) }, + long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30) * 1000; + DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] {HostInfo.parse(dbUrl)}, username, password, trustAll, timeoutms); if (!service.clearCompleteDatabase(timeoutms)) { - throw new Exception("failed to init database"); + throw new Exception("failed to init database"); } } @@ -348,13 +349,13 @@ public class Program { 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); + 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; - DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) }, + long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30) * 1000; + 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)) { + if (!service.initDatabase(r, numShards, numReplicas, dbPrefix, forceRecreate, timeoutms)) { throw new Exception("failed to init database"); } @@ -364,8 +365,10 @@ public class Program { 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, "database basic auth password", false)); + result.addOption( + createOption(OPTION_DATABASEUSER_SHORT, "db-username", true, "database basic auth username", false)); + result.addOption(createOption(OPTION_DATABASEPASSWORD_SHORT, "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(OPTION_DATABASEPREFIX_SHORT, "prefix", true, "prefix for db indices", false)); @@ -373,13 +376,14 @@ public class Program { 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(OPTION_DATABASEWAIT_SHORT, "wait", true, "wait for yellow status with timeout in seconds", false)); + result.addOption(createOption(OPTION_DATABASEWAIT_SHORT, "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)); - result.addOption(createOption(OPTION_HELP_SHORT,"help",false,"show help",false)); + result.addOption(createOption(OPTION_HELP_SHORT, "help", false, "show help", false)); return result; } 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 ccae07c0e..cb20025ff 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 @@ -37,152 +37,159 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.guilin.GuilinReleaseIn public abstract class ReleaseInformation { - // variables - private final Release release; - private final Map<ComponentName, DatabaseInfo> dbMap; - // end of variables - - // constructors - public ReleaseInformation(Release r, Map<ComponentName, DatabaseInfo> dbMap) { - this.release = r; - this.dbMap = dbMap; - } - // end of constructors - - /** - * get database alias for component - * @param name - * @return alias or null if not exists - */ - public String getAlias(ComponentName name) { - return this.getAlias(name, ""); - } - - public String getAlias(ComponentName name, String prefix) { - return dbMap.get(name) == null ? null : prefix + dbMap.get(name).alias; - } - - /** - * get index name for component - * @param comp - * @return null if component does not exists in this release, otherwise index name - */ - public String getIndex(ComponentName comp) { - return this.getIndex(comp, ""); - } - - /** - * get index name for component with prefix - * @param comp - * @param prefix - * @return null if component does not exists in this release, otherwise index name - */ - public String getIndex(ComponentName comp, String prefix) { - return dbMap.get(comp) == null ? null : (prefix + dbMap.get(comp).getIndex(this.release.getDBSuffix())); - } - - /** - * get database datatype (doctype) for component - * @param name - * @return datatype or null if not exists - */ - public String getDataType(ComponentName name) { - return dbMap.get(name) == null ? null : dbMap.get(name).doctype; - } - - public String getDatabaseMapping(ComponentName name) { - return dbMap.get(name) == null ? null : dbMap.get(name).getMapping(); - } - - /** - * get database doctype definition for component - * @param name - * @return mappings or null if not exists - */ - public String getDatabaseMapping(ComponentName name, boolean useStrict) { - return dbMap.get(name) == null ? null : dbMap.get(name).getMapping(useStrict); - } - - /** - * get database settings definition for component - * @param name - * @return settings or null if not exists - */ - public String getDatabaseSettings(ComponentName name, int shards, int replicas) { - return dbMap.get(name) == null ? null : dbMap.get(name).getSettings(shards, replicas); - } - - /** - * get converter for component data - * @param dst destination release - * @param comp component to convert - * @return - */ - public SearchHitConverter getConverter(Release dst, ComponentName comp) { - if (dst == this.release && this.getComponents().contains(comp)) { - return new KeepDataSearchHitConverter(comp); - } - return null; - } - - public static ReleaseInformation getInstance(Release r) { - switch (r) { - case EL_ALTO: - return new ElAltoReleaseInformation(); - case FRANKFURT_R1: - return new FrankfurtReleaseInformation(); - case GUILIN: - return new GuilinReleaseInformation(); - default: - return null; - } - } - - /** - * @return - */ - public Set<ComponentName> getComponents() { - return dbMap.keySet(); - } - - /** - * @param component - * @return - */ - public boolean hasOwnDbIndex(ComponentName component) { - return this.getDatabaseMapping(component) != null; - } - - /** - * @param indices - * @return true if components of this release are covered by the given indices - */ - protected boolean containsIndices(IndicesEntryList indices) { - - if (this.dbMap.size() <= 0) { - return false; - } - for (DatabaseInfo entry : this.dbMap.values()) { - String dbIndexName = entry.getIndex(this.release.getDBSuffix()); - if (indices.findByIndex(dbIndexName) == null) { - return false; - } - } - return true; - - } - - /** - * @param dbClient - * @return if succeeded or not - */ - protected abstract boolean runPreInitCommands(HtDatabaseClient dbClient); - - /** - * - * @param dbClient - * @return if succeeded or not - */ - protected abstract boolean runPostInitCommands(HtDatabaseClient dbClient); + // variables + private final Release release; + private final Map<ComponentName, DatabaseInfo> dbMap; + // end of variables + + // constructors + public ReleaseInformation(Release r, Map<ComponentName, DatabaseInfo> dbMap) { + this.release = r; + this.dbMap = dbMap; + } + // end of constructors + + /** + * get database alias for component + * + * @param name + * @return alias or null if not exists + */ + public String getAlias(ComponentName name) { + return this.getAlias(name, ""); + } + + public String getAlias(ComponentName name, String prefix) { + return dbMap.get(name) == null ? null : prefix + dbMap.get(name).alias; + } + + /** + * get index name for component + * + * @param comp + * @return null if component does not exists in this release, otherwise index name + */ + public String getIndex(ComponentName comp) { + return this.getIndex(comp, ""); + } + + /** + * get index name for component with prefix + * + * @param comp + * @param prefix + * @return null if component does not exists in this release, otherwise index name + */ + public String getIndex(ComponentName comp, String prefix) { + return dbMap.get(comp) == null ? null : (prefix + dbMap.get(comp).getIndex(this.release.getDBSuffix())); + } + + /** + * get database datatype (doctype) for component + * + * @param name + * @return datatype or null if not exists + */ + public String getDataType(ComponentName name) { + return dbMap.get(name) == null ? null : dbMap.get(name).doctype; + } + + public String getDatabaseMapping(ComponentName name) { + return dbMap.get(name) == null ? null : dbMap.get(name).getMapping(); + } + + /** + * get database doctype definition for component + * + * @param name + * @return mappings or null if not exists + */ + public String getDatabaseMapping(ComponentName name, boolean useStrict) { + return dbMap.get(name) == null ? null : dbMap.get(name).getMapping(useStrict); + } + + /** + * get database settings definition for component + * + * @param name + * @return settings or null if not exists + */ + public String getDatabaseSettings(ComponentName name, int shards, int replicas) { + return dbMap.get(name) == null ? null : dbMap.get(name).getSettings(shards, replicas); + } + + /** + * get converter for component data + * + * @param dst destination release + * @param comp component to convert + * @return + */ + public SearchHitConverter getConverter(Release dst, ComponentName comp) { + if (dst == this.release && this.getComponents().contains(comp)) { + return new KeepDataSearchHitConverter(comp); + } + return null; + } + + public static ReleaseInformation getInstance(Release r) { + switch (r) { + case EL_ALTO: + return new ElAltoReleaseInformation(); + case FRANKFURT_R1: + return new FrankfurtReleaseInformation(); + case GUILIN: + return new GuilinReleaseInformation(); + default: + return null; + } + } + + /** + * @return + */ + public Set<ComponentName> getComponents() { + return dbMap.keySet(); + } + + /** + * @param component + * @return + */ + public boolean hasOwnDbIndex(ComponentName component) { + return this.getDatabaseMapping(component) != null; + } + + /** + * @param indices + * @return true if components of this release are covered by the given indices + */ + protected boolean containsIndices(IndicesEntryList indices) { + + if (this.dbMap.size() <= 0) { + return false; + } + for (DatabaseInfo entry : this.dbMap.values()) { + String dbIndexName = entry.getIndex(this.release.getDBSuffix()); + if (indices.findByIndex(dbIndexName) == null) { + return false; + } + } + return true; + + } + + /** + * @param dbClient + * @return if succeeded or not + */ + protected abstract boolean runPreInitCommands(HtDatabaseClient dbClient); + + /** + * + * @param dbClient + * @return if succeeded or not + */ + protected abstract boolean runPostInitCommands(HtDatabaseClient dbClient); } diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/BaseSearchHitConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/BaseSearchHitConverter.java index 2f4f067bd..c58c3cdf7 100644 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/BaseSearchHitConverter.java +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/BaseSearchHitConverter.java @@ -26,26 +26,28 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit; public abstract class BaseSearchHitConverter implements SearchHitConverter { - private ComponentName name; - public BaseSearchHitConverter(ComponentName name) { - this.name = name; - } - - protected SearchHit getSearchHit(String index, String type, String id, JSONObject data) { - JSONObject o = new JSONObject(); - o.put("_index", index); - o.put("_type", type); - o.put("_id", id); - o.put("_source", data); - return new SearchHit(o); - } - @Override - public ComponentData convert(DataContainer container) { - ComponentData srcData = container.getComponents().get(this.name); - ComponentData dstData = new ComponentData(srcData.getName()); - for(SearchHit sh:srcData) { - dstData.add(this.convert(sh)); - } - return dstData; - } + private ComponentName name; + + public BaseSearchHitConverter(ComponentName name) { + this.name = name; + } + + protected SearchHit getSearchHit(String index, String type, String id, JSONObject data) { + JSONObject o = new JSONObject(); + o.put("_index", index); + o.put("_type", type); + o.put("_id", id); + o.put("_source", data); + return new SearchHit(o); + } + + @Override + public ComponentData convert(DataContainer container) { + ComponentData srcData = container.getComponents().get(this.name); + ComponentData dstData = new ComponentData(srcData.getName()); + for (SearchHit sh : srcData) { + dstData.add(this.convert(sh)); + } + return dstData; + } } diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentData.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentData.java index fd361843c..5d6f0079f 100644 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentData.java +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentData.java @@ -25,38 +25,38 @@ import java.util.ArrayList; import org.json.JSONArray; import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit; -public class ComponentData extends ArrayList<SearchHit>{ - - /** - * - */ - private static final long serialVersionUID = 1L; - private final ComponentName name; - - public ComponentData(ComponentName name) { - this(name,null); - } - - public ComponentData(ComponentName name,JSONArray a) { - this.name = name; - if(a!=null) { - for(int i=0;i<a.length();i++) { - this.add(new SearchHit(a.getJSONObject(i))); - } - } - - } - - public ComponentName getName() { - return this.name; - } - - public JSONArray toJsonArray() { - JSONArray a = new JSONArray(); - for(SearchHit h:this) { - a.put(h.getRaw()); - } - return a; - } - +public class ComponentData extends ArrayList<SearchHit> { + + /** + * + */ + private static final long serialVersionUID = 1L; + private final ComponentName name; + + public ComponentData(ComponentName name) { + this(name, null); + } + + public ComponentData(ComponentName name, JSONArray a) { + this.name = name; + if (a != null) { + for (int i = 0; i < a.length(); i++) { + this.add(new SearchHit(a.getJSONObject(i))); + } + } + + } + + public ComponentName getName() { + return this.name; + } + + public JSONArray toJsonArray() { + JSONArray a = new JSONArray(); + for (SearchHit h : this) { + a.put(h.getRaw()); + } + return a; + } + } diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentName.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentName.java index 9c5ef5c53..ab3f311a1 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 @@ -23,37 +23,34 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data; public enum ComponentName { - CONNECTIONLOG("connectionlog"), - EVENTLOG("eventlog"), - FAULTLOG("faultlog"), - FAULTCURRENT("faultcurrent"), - HISTORICAL_PERFORMANCE_15M("historicalperformance15m"), - HISTORICAL_PERFORMANCE_24H("historicalperformance24h"), - INVENTORY("inventory"), - INVENTORYTOPLEVEL("inventorytoplevel"), - MAINTENANCE("maintenance"), - MEDIATOR_SERVER("mediator-server"), - REQUIRED_NETWORKELEMENT("required-networkelement"); - - private final String value; + CONNECTIONLOG("connectionlog"), EVENTLOG("eventlog"), FAULTLOG("faultlog"), FAULTCURRENT( + "faultcurrent"), HISTORICAL_PERFORMANCE_15M("historicalperformance15m"), HISTORICAL_PERFORMANCE_24H( + "historicalperformance24h"), INVENTORY("inventory"), INVENTORYTOPLEVEL( + "inventorytoplevel"), MAINTENANCE("maintenance"), MEDIATOR_SERVER( + "mediator-server"), REQUIRED_NETWORKELEMENT("required-networkelement"); - private ComponentName(String s) { - this.value = s; - } - @Override - public String toString() { - return this.value; - } - public String getValue() { - return value; - } - public static ComponentName getValueOf(String s) throws Exception { - s = s.toLowerCase(); - for(ComponentName p:ComponentName.values()) { - if(p.value.equals(s)) { - return p; - } - } - throw new Exception("value not found for "+s); - } -}
\ No newline at end of file + private final String value; + + private ComponentName(String s) { + this.value = s; + } + + @Override + public String toString() { + return this.value; + } + + public String getValue() { + return value; + } + + public static ComponentName getValueOf(String s) throws Exception { + s = s.toLowerCase(); + for (ComponentName p : ComponentName.values()) { + if (p.value.equals(s)) { + return p; + } + } + throw new Exception("value not found for " + s); + } +} diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigData.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigData.java index 95c483736..49600320f 100644 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigData.java +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigData.java @@ -23,13 +23,14 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data; public class ConfigData { - private final String[] lines; + private final String[] lines; - public String[] getLines() { - return this.lines; - } - public ConfigData(String content) { - this.lines = content.split("\n"); - } + public String[] getLines() { + return this.lines; + } + + public ConfigData(String content) { + this.lines = content.split("\n"); + } } diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigName.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigName.java index 181fe2006..da00cb24a 100644 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigName.java +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigName.java @@ -23,30 +23,31 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data; public enum ConfigName { - APIGATEWAY("apigateway"), - DEVICEMANAGER("devicemanager"), - DATAPROVIDER("dataprovider"); - - - private final String value; - - private ConfigName(String s) { - this.value = s; - } - @Override - public String toString() { - return this.value; - } - public String getValue() { - return value; - } - public static ConfigName getValueOf(String s) throws Exception { - s = s.toLowerCase(); - for(ConfigName p:ConfigName.values()) { - if(p.value.equals(s)) { - return p; - } - } - throw new Exception("value not found"); - } -}
\ No newline at end of file + APIGATEWAY("apigateway"), DEVICEMANAGER("devicemanager"), DATAPROVIDER("dataprovider"); + + + private final String value; + + private ConfigName(String s) { + this.value = s; + } + + @Override + public String toString() { + return this.value; + } + + public String getValue() { + return value; + } + + public static ConfigName getValueOf(String s) throws Exception { + s = s.toLowerCase(); + for (ConfigName p : ConfigName.values()) { + if (p.value.equals(s)) { + return p; + } + } + throw new Exception("value not found"); + } +} diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataContainer.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataContainer.java index f50969ed6..f23723773 100644 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataContainer.java +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataContainer.java @@ -41,101 +41,101 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStamp */ public class DataContainer { - private final Release release; - private final Date created; - private final Map<ComponentName, ComponentData> components; - private final Map<ConfigName, ConfigData> configs; - - public Release getRelease() { - return this.release; - } - - public boolean isCurrentRelease() { - return this.release.equals(Release.CURRENT_RELEASE); - } - - public Date getCreated() { - return this.created; - } - - public Map<ComponentName, ComponentData> getComponents() { - return this.components; - } - - public Map<ConfigName, ConfigData> getConfigs() { - return this.configs; - } - - public DataContainer() { - this(Release.CURRENT_RELEASE); - } - - public DataContainer(Release release) { - this(release, new Date()); - } - - public DataContainer(Release release, Date dt) { - this.release = release; - this.created = dt; - this.components = new HashMap<>(); - this.configs = new HashMap<>(); - } - - public void addComponent(ComponentName name, ComponentData data) { - this.components.put(name, data); - } - - public void addConfig(ConfigName name, ConfigData data) { - this.configs.put(name, data); - } - - public static DataContainer load(File file) throws Exception { - if(!file.exists()) { - throw new FileNotFoundException(); - } - SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'"); - JSONObject o = new JSONObject(new String(Files.readAllBytes(file.toPath()))); - DataContainer c = new DataContainer(Release.getValueOf(o.getString("release")), - format.parse(o.getString("created"))); - JSONObject comps = o.getJSONObject("components"); - - String k; - ComponentName compKey; - JSONArray compData; - for (Object key : comps.keySet()) { - k = String.valueOf(key); - // check component if exists - compKey = ComponentName.getValueOf(k); - compData = comps.getJSONArray(k); - c.addComponent(compKey, new ComponentData(compKey, compData)); - } - ConfigName confKey; - ConfigData confData; - JSONObject confs = o.getJSONObject("configs"); - for (Object key : confs.keySet()) { - k = String.valueOf(key); - confKey = ConfigName.getValueOf(k); - confData = new ConfigData(confs.getString(k)); - c.addConfig(confKey, confData); - } - return c; - } - - public String toJSON() { - JSONObject o = new JSONObject(); - o.put("release", this.release.getValue()); - o.put("created", NetconfTimeStampImpl.getConverter().getTimeStampAsNetconfString(this.created)); - JSONObject compsJson = new JSONObject(); - JSONObject confsJson = new JSONObject(); - for (Entry<ComponentName, ComponentData> entry : this.components.entrySet()) { - compsJson.put(entry.getKey().getValue(), entry.getValue().toJsonArray()); - } - for (Entry<ConfigName, ConfigData> entry : this.configs.entrySet()) { - confsJson.put(entry.getKey().getValue(), entry.getValue().toString()); - } - o.put("components", compsJson); - o.put("configs", confsJson); - return o.toString(); - } - -}
\ No newline at end of file + private final Release release; + private final Date created; + private final Map<ComponentName, ComponentData> components; + private final Map<ConfigName, ConfigData> configs; + + public Release getRelease() { + return this.release; + } + + public boolean isCurrentRelease() { + return this.release.equals(Release.CURRENT_RELEASE); + } + + public Date getCreated() { + return this.created; + } + + public Map<ComponentName, ComponentData> getComponents() { + return this.components; + } + + public Map<ConfigName, ConfigData> getConfigs() { + return this.configs; + } + + public DataContainer() { + this(Release.CURRENT_RELEASE); + } + + public DataContainer(Release release) { + this(release, new Date()); + } + + public DataContainer(Release release, Date dt) { + this.release = release; + this.created = dt; + this.components = new HashMap<>(); + this.configs = new HashMap<>(); + } + + public void addComponent(ComponentName name, ComponentData data) { + this.components.put(name, data); + } + + public void addConfig(ConfigName name, ConfigData data) { + this.configs.put(name, data); + } + + public static DataContainer load(File file) throws Exception { + if (!file.exists()) { + throw new FileNotFoundException(); + } + SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'"); + JSONObject o = new JSONObject(new String(Files.readAllBytes(file.toPath()))); + DataContainer c = + new DataContainer(Release.getValueOf(o.getString("release")), format.parse(o.getString("created"))); + JSONObject comps = o.getJSONObject("components"); + + String k; + ComponentName compKey; + JSONArray compData; + for (Object key : comps.keySet()) { + k = String.valueOf(key); + // check component if exists + compKey = ComponentName.getValueOf(k); + compData = comps.getJSONArray(k); + c.addComponent(compKey, new ComponentData(compKey, compData)); + } + ConfigName confKey; + ConfigData confData; + JSONObject confs = o.getJSONObject("configs"); + for (Object key : confs.keySet()) { + k = String.valueOf(key); + confKey = ConfigName.getValueOf(k); + confData = new ConfigData(confs.getString(k)); + c.addConfig(confKey, confData); + } + return c; + } + + public String toJSON() { + JSONObject o = new JSONObject(); + o.put("release", this.release.getValue()); + o.put("created", NetconfTimeStampImpl.getConverter().getTimeStampAsNetconfString(this.created)); + JSONObject compsJson = new JSONObject(); + JSONObject confsJson = new JSONObject(); + for (Entry<ComponentName, ComponentData> entry : this.components.entrySet()) { + compsJson.put(entry.getKey().getValue(), entry.getValue().toJsonArray()); + } + for (Entry<ConfigName, ConfigData> entry : this.configs.entrySet()) { + confsJson.put(entry.getKey().getValue(), entry.getValue().toString()); + } + o.put("components", compsJson); + o.put("configs", confsJson); + return o.toString(); + } + +} diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataMigrationReport.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataMigrationReport.java index c8270bad6..9e0831631 100644 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataMigrationReport.java +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataMigrationReport.java @@ -26,29 +26,35 @@ import java.util.List; public class DataMigrationReport { - private boolean completed; - private final List<String> logs; - private final List<String> errors; - public void setCompleted(boolean s) { - this.completed = s; - } - public boolean completed() { - return this.completed; - } - public void log(String format,Object ...params) { - this.logs.add(String.format(format, params)); - } - public void error(String format,Object ...params) { - this.errors.add(String.format(format, params)); - } - public DataMigrationReport() { - this.completed = false; - this.logs = new ArrayList<>(); - this.errors = new ArrayList<>(); - } - @Override - public String toString() { - return "DataMigrationReport [completed=" + completed + ", logs=" + logs + ", errors=" + errors + "]"; - } + private boolean completed; + private final List<String> logs; + private final List<String> errors; + + public void setCompleted(boolean s) { + this.completed = s; + } + + public boolean completed() { + return this.completed; + } + + public void log(String format, Object... params) { + this.logs.add(String.format(format, params)); + } + + public void error(String format, Object... params) { + this.errors.add(String.format(format, params)); + } + + public DataMigrationReport() { + this.completed = false; + this.logs = new ArrayList<>(); + this.errors = new ArrayList<>(); + } + + @Override + public String toString() { + return "DataMigrationReport [completed=" + completed + ", logs=" + logs + ", errors=" + errors + "]"; + } } diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DatabaseInfo.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DatabaseInfo.java index 4d82a0901..4c38b5032 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 @@ -26,43 +26,45 @@ 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; - private final String settingsFormat; - private final String index; + public final String doctype; + public final String alias; + private final String mapping; + private final String settingsFormat; + private final String index; - public String getIndex(String version) { - return this.index + version; - } + public String getIndex(String version) { + return this.index + version; + } - public DatabaseInfo(String alias, String doctype, String mapping) { - this(alias, alias, doctype, mapping); - } + public DatabaseInfo(String alias, String doctype, String mapping) { + this(alias, alias, doctype, mapping); + } - public DatabaseInfo(String index, String alias, String doctype, String mapping) { - this(index, alias, doctype, mapping, - "{\"index\":{\"number_of_shards\":%d,\"number_of_replicas\":%d},\"analysis\":{\"analyzer\":{\"content\":" - + "{\"type\":\"custom\",\"tokenizer\":\"whitespace\"}}}}"); - } + public DatabaseInfo(String index, String alias, String doctype, String mapping) { + this(index, alias, doctype, mapping, + "{\"index\":{\"number_of_shards\":%d,\"number_of_replicas\":%d},\"analysis\":{\"analyzer\":{\"content\":" + + "{\"type\":\"custom\",\"tokenizer\":\"whitespace\"}}}}"); + } - public DatabaseInfo(String index, String alias, String doctype, String mapping, String settingsformat) { - this.index = index; - this.alias = alias; - this.doctype = doctype; - this.mapping = mapping; - this.settingsFormat = settingsformat; - } - - public String getMapping() { - return this.getMapping(false); - } - public String getMapping(boolean useStrict) { - return this.mapping == null ? null - : String.format("{\"%s\":{%s\"properties\":%s}}", this.doctype,useStrict?"\"dynamic\": \"strict\",":"", this.mapping); - } + public DatabaseInfo(String index, String alias, String doctype, String mapping, String settingsformat) { + this.index = index; + this.alias = alias; + this.doctype = doctype; + this.mapping = mapping; + this.settingsFormat = settingsformat; + } - public String getSettings(int shards, int replicas) { - return String.format(this.settingsFormat, shards, replicas); - } -}
\ No newline at end of file + public String getMapping() { + return this.getMapping(false); + } + + public String getMapping(boolean useStrict) { + return this.mapping == null ? null + : String.format("{\"%s\":{%s\"properties\":%s}}", this.doctype, + useStrict ? "\"dynamic\": \"strict\"," : "", this.mapping); + } + + public String getSettings(int shards, int replicas) { + return String.format(this.settingsFormat, shards, replicas); + } +} diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/KeepDataSearchHitConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/KeepDataSearchHitConverter.java index fa86c90e2..04bdfd38f 100644 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/KeepDataSearchHitConverter.java +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/KeepDataSearchHitConverter.java @@ -25,19 +25,20 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit; public class KeepDataSearchHitConverter implements SearchHitConverter { - - private final ComponentName name; - public KeepDataSearchHitConverter(ComponentName name) { - this.name = name; - } - @Override - public SearchHit convert(SearchHit source) { - return source; - } + private final ComponentName name; - @Override - public ComponentData convert(DataContainer container) { - return container.getComponents().get(this.name); - } + public KeepDataSearchHitConverter(ComponentName name) { + this.name = name; + } + + @Override + public SearchHit convert(SearchHit source) { + return source; + } + + @Override + public ComponentData convert(DataContainer container) { + return container.getComponents().get(this.name); + } } diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/MavenDatabasePluginInitFile.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/MavenDatabasePluginInitFile.java index e923b2728..66a5e16d0 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 @@ -38,27 +38,29 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation; * */ public class MavenDatabasePluginInitFile { - private static final int replicas=1; - private static final int shards=5; - private static final String mappings="\"mappings\":%s"; - private static final String settings="\"settings\":{\"index\":{\"number_of_shards\":%d,\"number_of_replicas\":%d},\"analysis\":{\"analyzer\":{\"content\":"+ - "{\"type\":\"custom\",\"tokenizer\":\"whitespace\"}}}}"; + private static final int replicas = 1; + private static final int shards = 5; + private static final String mappings = "\"mappings\":%s"; + private static final String settings = + "\"settings\":{\"index\":{\"number_of_shards\":%d,\"number_of_replicas\":%d},\"analysis\":{\"analyzer\":{\"content\":" + + "{\"type\":\"custom\",\"tokenizer\":\"whitespace\"}}}}"; - public static void create(Release release, String filename) throws IOException { + public static void create(Release release, String filename) throws IOException { - ReleaseInformation ri = ReleaseInformation.getInstance(release); - Set<ComponentName> comps=ri.getComponents(); - List<String> lines = new ArrayList<>(); - for(ComponentName c:comps) { - lines.add(String.format("PUT:%s/:{"+settings+","+mappings+"}",ri.getIndex(c),shards,replicas,ri.getDatabaseMapping(c))); - lines.add(String.format("PUT:%s/_alias/%s/:{}", ri.getIndex(c),ri.getAlias(c))); - } + ReleaseInformation ri = ReleaseInformation.getInstance(release); + Set<ComponentName> comps = ri.getComponents(); + List<String> lines = new ArrayList<>(); + for (ComponentName c : comps) { + lines.add(String.format("PUT:%s/:{" + settings + "," + mappings + "}", ri.getIndex(c), shards, replicas, + ri.getDatabaseMapping(c))); + lines.add(String.format("PUT:%s/_alias/%s/:{}", ri.getIndex(c), ri.getAlias(c))); + } - File filePath = new File(filename); - if (filePath.getParentFile() != null && !filePath.getParentFile().exists()){ - //Crate Directory if missing - filePath.getParentFile().mkdirs(); - } - Files.write(filePath.toPath(), lines); - } + File filePath = new File(filename); + if (filePath.getParentFile() != null && !filePath.getParentFile().exists()) { + //Crate Directory if missing + filePath.getParentFile().mkdirs(); + } + Files.write(filePath.toPath(), lines); + } } 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 ae4522dc5..13c604716 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 @@ -25,74 +25,82 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.data.AliasesEntry; import org.onap.ccsdk.features.sdnr.wt.common.database.data.EsVersion; public enum Release { - - EL_ALTO("el alto","_v1",new EsVersion(2,2,0),new EsVersion(2,2,0)), - FRANKFURT_R1("frankfurt-R1","-v2",new EsVersion(6,4,3),new EsVersion(6,8,6)), - FRANKFURT_R2("frankfurt-R2","",new EsVersion(6,4,3),new EsVersion(6,8,6)), - FRANKFURT_R3("frankfurt-R3","",new EsVersion(6,4,3),new EsVersion(6,8,6)), - - GUILIN("guilin","",new EsVersion(6,4,3),new EsVersion(6,8,6)); - - public static final Release CURRENT_RELEASE = Release.FRANKFURT_R1; - - private final String value; - private final String dbSuffix; - private final EsVersion minDbVersion; - private final EsVersion maxDbVersion; - - private Release(String s,String dbsuffix,EsVersion minDbVersion,EsVersion maxDbVersion) { - this.value = s; - this.dbSuffix=dbsuffix; - this.minDbVersion = minDbVersion; - this.maxDbVersion = maxDbVersion; - } - @Override - public String toString() { - return this.value; - } - public String getValue() { - return value; - } - public static Release getValueOf(String s) throws Exception { - //s = s.toLowerCase(); - for(Release p:Release.values()) { - if(p.value.equals(s)) { - return p; - } - } - throw new Exception("value not found"); - } - public static Release getValueBySuffix(String suffix) { - for(Release r:Release.values()) { - if(r.dbSuffix.equals(suffix)) - return r; - } - return null; - } - public static String getDbSuffix(AliasesEntry entry) throws Exception { - ComponentName comp = ComponentName.getValueOf(entry.getAlias()); - if(comp!=null) { - return entry.getIndex().substring(entry.getAlias().length()); - } - return null; - } - /** - * @return - */ - public String getDBSuffix() { - return this.dbSuffix; - } - /** - * @return - */ - public EsVersion getDBVersion() { - return this.minDbVersion; - } - /** - * @param dbVersion2 - * @return - */ - public boolean isDbInRange(EsVersion dbVersion) { - return dbVersion.isNewerOrEqualThan(minDbVersion) && dbVersion.isOlderOrEqualThan(maxDbVersion); - } + + EL_ALTO("el alto", "_v1", new EsVersion(2, 2, 0), new EsVersion(2, 2, 0)), FRANKFURT_R1("frankfurt-R1", "-v2", + new EsVersion(6, 4, 3), new EsVersion(6, 8, 6)), FRANKFURT_R2("frankfurt-R2", "", new EsVersion(6, 4, 3), + new EsVersion(6, 8, 6)), FRANKFURT_R3("frankfurt-R3", "", new EsVersion(6, 4, 3), + new EsVersion(6, 8, 6)), + + GUILIN("guilin", "", new EsVersion(6, 4, 3), new EsVersion(6, 8, 6)); + + public static final Release CURRENT_RELEASE = Release.FRANKFURT_R1; + + private final String value; + private final String dbSuffix; + private final EsVersion minDbVersion; + private final EsVersion maxDbVersion; + + private Release(String s, String dbsuffix, EsVersion minDbVersion, EsVersion maxDbVersion) { + this.value = s; + this.dbSuffix = dbsuffix; + this.minDbVersion = minDbVersion; + this.maxDbVersion = maxDbVersion; + } + + @Override + public String toString() { + return this.value; + } + + public String getValue() { + return value; + } + + public static Release getValueOf(String s) throws Exception { + //s = s.toLowerCase(); + for (Release p : Release.values()) { + if (p.value.equals(s)) { + return p; + } + } + throw new Exception("value not found"); + } + + public static Release getValueBySuffix(String suffix) { + for (Release r : Release.values()) { + if (r.dbSuffix.equals(suffix)) + return r; + } + return null; + } + + public static String getDbSuffix(AliasesEntry entry) throws Exception { + ComponentName comp = ComponentName.getValueOf(entry.getAlias()); + if (comp != null) { + return entry.getIndex().substring(entry.getAlias().length()); + } + return null; + } + + /** + * @return + */ + public String getDBSuffix() { + return this.dbSuffix; + } + + /** + * @return + */ + public EsVersion getDBVersion() { + return this.minDbVersion; + } + + /** + * @param dbVersion2 + * @return + */ + public boolean isDbInRange(EsVersion dbVersion) { + return dbVersion.isNewerOrEqualThan(minDbVersion) && dbVersion.isOlderOrEqualThan(maxDbVersion); + } } diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/SearchHitConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/SearchHitConverter.java index 7a549ca86..a95a405d6 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 @@ -28,37 +28,38 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.guilin.GuilinReleaseIn public interface SearchHitConverter { - /** - * convert single entry of database - * @param source - * @return - */ - public SearchHit convert(SearchHit source); - - /** - * @param component destination component - * @param container source data - * @return data for destination component - */ - public ComponentData convert(DataContainer container); + /** + * convert single entry of database + * + * @param source + * @return + */ + public SearchHit convert(SearchHit source); + + /** + * @param component destination component + * @param container source data + * @return data for destination component + */ + public ComponentData convert(DataContainer container); + + + public static class Factory { + public static SearchHitConverter getInstance(Release src, Release dst, ComponentName component) { + switch (src) { + case EL_ALTO: + return new ElAltoReleaseInformation().getConverter(dst, component); + case FRANKFURT_R1: + return new FrankfurtReleaseInformation().getConverter(dst, component); + case GUILIN: + return new GuilinReleaseInformation().getConverter(dst, component); + default: + return null; + + } + } + } - - public static class Factory{ - public static SearchHitConverter getInstance(Release src,Release dst, ComponentName component) { - switch(src) { - case EL_ALTO: - return new ElAltoReleaseInformation().getConverter(dst, component); - case FRANKFURT_R1: - return new FrankfurtReleaseInformation().getConverter(dst, component); - case GUILIN: - return new GuilinReleaseInformation().getConverter(dst, component); - default: - return null; - - } - } - } - } diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/ElAltoReleaseInformation.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/ElAltoReleaseInformation.java index 1236bd8e5..739afaf0e 100644 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/ElAltoReleaseInformation.java +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/ElAltoReleaseInformation.java @@ -33,70 +33,76 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation; public class ElAltoReleaseInformation extends ReleaseInformation { - - private Map<Release, Map<ComponentName, SearchHitConverter>> converters; - public ElAltoReleaseInformation() { - super(Release.EL_ALTO, createDbInfos()); - this.converters = generateConverters(); - } + private Map<Release, Map<ComponentName, SearchHitConverter>> converters; - private static Map<ComponentName, DatabaseInfo> createDbInfos() { - Map<ComponentName,DatabaseInfo> map = new HashMap<>(); - map.put(ComponentName.EVENTLOG, new DatabaseInfo("sdnevents","eventlog","")); - map.put(ComponentName.FAULTCURRENT, new DatabaseInfo("sdnevents","faultcurrent","")); - map.put(ComponentName.FAULTLOG, new DatabaseInfo("sdnevents","faultlog","")); - map.put(ComponentName.INVENTORY, new DatabaseInfo("sdnevents","inventoryequipment","")); - map.put(ComponentName.INVENTORYTOPLEVEL, new DatabaseInfo("sdnevents","inventorytoplevel","")); - map.put(ComponentName.HISTORICAL_PERFORMANCE_15M, new DatabaseInfo("sdnperformance","historicalperformance15min","")); - map.put(ComponentName.HISTORICAL_PERFORMANCE_24H, new DatabaseInfo("sdnperformance","historicalperformance24h","")); - map.put(ComponentName.REQUIRED_NETWORKELEMENT, new DatabaseInfo("mwtn","required-networkelement","{\"required-networkelement\": {\"date_detection\": false }}")); - map.put(ComponentName.MEDIATOR_SERVER, new DatabaseInfo("mwtn","mediator-server","")); - map.put(ComponentName.MAINTENANCE, new DatabaseInfo("mwtn","maintenancemode","")); - return map; - } + public ElAltoReleaseInformation() { + super(Release.EL_ALTO, createDbInfos()); + this.converters = generateConverters(); + } - /** - * @return components used in el alto - */ - - - private static Map<Release, Map<ComponentName, SearchHitConverter>> generateConverters() { - Map<Release, Map<ComponentName, SearchHitConverter>> c = new HashMap<>(); - Map<ComponentName, SearchHitConverter> frankfurtConverters = new HashMap<>(); - frankfurtConverters.put(ComponentName.EVENTLOG, new FrankfurtEventlogConverter()); - frankfurtConverters.put(ComponentName.FAULTCURRENT, new FrankfurtFaultcurrentConverter()); - frankfurtConverters.put(ComponentName.FAULTLOG, new FrankfurtFaultlogConverter()); - frankfurtConverters.put(ComponentName.INVENTORY, new KeepDataSearchHitConverter(ComponentName.INVENTORY)); - //obsolete in frankfurt - //frankfurtConverters.put(ComponentName.INVENTORYTOPLEVEL, new KeepDataSearchHitConverter(ComponentName.INVENTORYTOPLEVEL)); - frankfurtConverters.put(ComponentName.HISTORICAL_PERFORMANCE_15M, new KeepDataSearchHitConverter(ComponentName.HISTORICAL_PERFORMANCE_15M)); - frankfurtConverters.put(ComponentName.HISTORICAL_PERFORMANCE_24H, new KeepDataSearchHitConverter(ComponentName.HISTORICAL_PERFORMANCE_24H)); - frankfurtConverters.put(ComponentName.MAINTENANCE, new FrankfurtMaintenanceConverter()); - frankfurtConverters.put(ComponentName.MEDIATOR_SERVER, new KeepDataSearchHitConverter(ComponentName.MEDIATOR_SERVER)); - frankfurtConverters.put(ComponentName.REQUIRED_NETWORKELEMENT, new FrankfurtRequiredNetworkElementConverter()); - frankfurtConverters.put(ComponentName.CONNECTIONLOG,new FrankfurtConnectionlogConverter()); - c.put(Release.FRANKFURT_R1,frankfurtConverters); - return c; - } + private static Map<ComponentName, DatabaseInfo> createDbInfos() { + Map<ComponentName, DatabaseInfo> map = new HashMap<>(); + map.put(ComponentName.EVENTLOG, new DatabaseInfo("sdnevents", "eventlog", "")); + map.put(ComponentName.FAULTCURRENT, new DatabaseInfo("sdnevents", "faultcurrent", "")); + map.put(ComponentName.FAULTLOG, new DatabaseInfo("sdnevents", "faultlog", "")); + map.put(ComponentName.INVENTORY, new DatabaseInfo("sdnevents", "inventoryequipment", "")); + map.put(ComponentName.INVENTORYTOPLEVEL, new DatabaseInfo("sdnevents", "inventorytoplevel", "")); + map.put(ComponentName.HISTORICAL_PERFORMANCE_15M, + new DatabaseInfo("sdnperformance", "historicalperformance15min", "")); + map.put(ComponentName.HISTORICAL_PERFORMANCE_24H, + new DatabaseInfo("sdnperformance", "historicalperformance24h", "")); + map.put(ComponentName.REQUIRED_NETWORKELEMENT, new DatabaseInfo("mwtn", "required-networkelement", + "{\"required-networkelement\": {\"date_detection\": false }}")); + map.put(ComponentName.MEDIATOR_SERVER, new DatabaseInfo("mwtn", "mediator-server", "")); + map.put(ComponentName.MAINTENANCE, new DatabaseInfo("mwtn", "maintenancemode", "")); + return map; + } - @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; - } + /** + * @return components used in el alto + */ - @Override - protected boolean runPreInitCommands(HtDatabaseClient dbClient) { - return true; - } - @Override - protected boolean runPostInitCommands(HtDatabaseClient dbClient) { - return true; - } - + private static Map<Release, Map<ComponentName, SearchHitConverter>> generateConverters() { + Map<Release, Map<ComponentName, SearchHitConverter>> c = new HashMap<>(); + Map<ComponentName, SearchHitConverter> frankfurtConverters = new HashMap<>(); + frankfurtConverters.put(ComponentName.EVENTLOG, new FrankfurtEventlogConverter()); + frankfurtConverters.put(ComponentName.FAULTCURRENT, new FrankfurtFaultcurrentConverter()); + frankfurtConverters.put(ComponentName.FAULTLOG, new FrankfurtFaultlogConverter()); + frankfurtConverters.put(ComponentName.INVENTORY, new KeepDataSearchHitConverter(ComponentName.INVENTORY)); + //obsolete in frankfurt + //frankfurtConverters.put(ComponentName.INVENTORYTOPLEVEL, new KeepDataSearchHitConverter(ComponentName.INVENTORYTOPLEVEL)); + frankfurtConverters.put(ComponentName.HISTORICAL_PERFORMANCE_15M, + new KeepDataSearchHitConverter(ComponentName.HISTORICAL_PERFORMANCE_15M)); + frankfurtConverters.put(ComponentName.HISTORICAL_PERFORMANCE_24H, + new KeepDataSearchHitConverter(ComponentName.HISTORICAL_PERFORMANCE_24H)); + frankfurtConverters.put(ComponentName.MAINTENANCE, new FrankfurtMaintenanceConverter()); + frankfurtConverters.put(ComponentName.MEDIATOR_SERVER, + new KeepDataSearchHitConverter(ComponentName.MEDIATOR_SERVER)); + frankfurtConverters.put(ComponentName.REQUIRED_NETWORKELEMENT, new FrankfurtRequiredNetworkElementConverter()); + frankfurtConverters.put(ComponentName.CONNECTIONLOG, new FrankfurtConnectionlogConverter()); + c.put(Release.FRANKFURT_R1, frankfurtConverters); + return c; + } + + @Override + public SearchHitConverter getConverter(Release dst, ComponentName comp) { + SearchHitConverter c = this.converters.containsKey(dst) ? this.converters.get(dst).get(comp) : null; + if (c == null) { + c = super.getConverter(dst, comp); + } + return c; + } + + @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/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtConnectionlogConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtConnectionlogConverter.java index d68373199..55fa0d88a 100644 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtConnectionlogConverter.java +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtConnectionlogConverter.java @@ -35,86 +35,73 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.frankfurt.data.Connect * * @author Michael Dürre * - * Convert data from el alto to frankfurt + * Convert data from el alto to frankfurt * - * src: eventlog - * dst: connectionlog + * src: eventlog dst: connectionlog * * - * { - * "event": { - * "nodeName": "SDN-Controller-5a150173d678", - * "counter": "48", - * "timeStamp": "2019-10-07T09:57:08.2Z", - * "objectId": "Sim2230", - * "attributeName": "ConnectionStatus", - * "newValue": "connecting", - * "type": "AttributeValueChangedNotificationXml" - * } - * } + * { "event": { "nodeName": "SDN-Controller-5a150173d678", "counter": "48", "timeStamp": + * "2019-10-07T09:57:08.2Z", "objectId": "Sim2230", "attributeName": "ConnectionStatus", "newValue": + * "connecting", "type": "AttributeValueChangedNotificationXml" } } * - * => + * => * - * { - * "timestamp": "2020-01-28T12:00:10.2Z", - * "status": "Connected", - * "node-id": "sim1" - * } + * { "timestamp": "2020-01-28T12:00:10.2Z", "status": "Connected", "node-id": "sim1" } * */ public class FrankfurtConnectionlogConverter extends BaseSearchHitConverter { - public FrankfurtConnectionlogConverter() { - super(ComponentName.CONNECTIONLOG); - } + public FrankfurtConnectionlogConverter() { + super(ComponentName.CONNECTIONLOG); + } - /** - * @source eventlog searchhit converted to connectionlog entry - */ - @Override - public SearchHit convert(SearchHit source) { + /** + * @source eventlog searchhit converted to connectionlog entry + */ + @Override + public SearchHit convert(SearchHit source) { - JSONObject data = new JSONObject(); - JSONObject inner = source.getSource().getJSONObject("event"); - String eventType = inner.getString("type"); - String eventSource = inner.getString("nodeName"); - if (!eventSource.startsWith("SDN-Controller")) { - return null; - } - data.put("node-id", inner.getString("objectId")); - data.put("timestamp", inner.getString("timeStamp")); - if (eventType.equals("AttributeValueChangedNotificationXml")) { - String event = inner.getString("newValue").toLowerCase(); - if (event.equals("connected")) { - data.put("status", ConnectionLogStatus.Connected.getName()); - } else if (event.equals("connecting")) { - data.put("status", ConnectionLogStatus.Connecting.getName()); - } else { - data.put("status", ConnectionLogStatus.UnableToConnect.getName()); - } + JSONObject data = new JSONObject(); + JSONObject inner = source.getSource().getJSONObject("event"); + String eventType = inner.getString("type"); + String eventSource = inner.getString("nodeName"); + if (!eventSource.startsWith("SDN-Controller")) { + return null; + } + data.put("node-id", inner.getString("objectId")); + data.put("timestamp", inner.getString("timeStamp")); + if (eventType.equals("AttributeValueChangedNotificationXml")) { + String event = inner.getString("newValue").toLowerCase(); + if (event.equals("connected")) { + data.put("status", ConnectionLogStatus.Connected.getName()); + } else if (event.equals("connecting")) { + data.put("status", ConnectionLogStatus.Connecting.getName()); + } else { + data.put("status", ConnectionLogStatus.UnableToConnect.getName()); + } - } else if (eventType.equals("ObjectCreationNotificationXml")) { - data.put("status", ConnectionLogStatus.Mounted.getName()); + } else if (eventType.equals("ObjectCreationNotificationXml")) { + data.put("status", ConnectionLogStatus.Mounted.getName()); - } else if (eventType.equals("ObjectDeletionNotificationXml")) { - data.put("status", ConnectionLogStatus.Unmounted.getName()); - } + } else if (eventType.equals("ObjectDeletionNotificationXml")) { + data.put("status", ConnectionLogStatus.Unmounted.getName()); + } - return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data); - } + return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data); + } - @Override - public ComponentData convert(DataContainer container) { - Map<ComponentName, ComponentData> src = container.getComponents(); - if (!src.containsKey(ComponentName.EVENTLOG)) { - return null; - } - ComponentData eventData = src.get(ComponentName.EVENTLOG); - ComponentData dstData = new ComponentData(ComponentName.CONNECTIONLOG); - for (SearchHit sh : eventData) { - dstData.add(this.convert(sh)); - } - return dstData; - } + @Override + public ComponentData convert(DataContainer container) { + Map<ComponentName, ComponentData> src = container.getComponents(); + if (!src.containsKey(ComponentName.EVENTLOG)) { + return null; + } + ComponentData eventData = src.get(ComponentName.EVENTLOG); + ComponentData dstData = new ComponentData(ComponentName.CONNECTIONLOG); + for (SearchHit sh : eventData) { + dstData.add(this.convert(sh)); + } + return dstData; + } } diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtEventlogConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtEventlogConverter.java index e04378bbe..3bd70dd95 100644 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtEventlogConverter.java +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtEventlogConverter.java @@ -32,24 +32,23 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DataContainer; * @author Michael Dürre * * - * Cannot be converted from el alto to frankfurt - * most of the entries are in connectionlog + * Cannot be converted from el alto to frankfurt most of the entries are in connectionlog * */ -public class FrankfurtEventlogConverter extends BaseSearchHitConverter{ +public class FrankfurtEventlogConverter extends BaseSearchHitConverter { - public FrankfurtEventlogConverter() { - super(ComponentName.EVENTLOG); - } + public FrankfurtEventlogConverter() { + super(ComponentName.EVENTLOG); + } - @Override - public SearchHit convert(SearchHit source) { - return null; - } + @Override + public SearchHit convert(SearchHit source) { + return null; + } - @Override - public ComponentData convert(DataContainer container) { - return null; - } + @Override + public ComponentData convert(DataContainer container) { + return null; + } } diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultcurrentConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultcurrentConverter.java index 060434fe9..40541dcae 100644 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultcurrentConverter.java +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultcurrentConverter.java @@ -30,51 +30,36 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName; * * @author Michael Dürre * - * { - * "faultCurrent": { - * "nodeName": "sim9090", - * "counter": "50443", - * "timeStamp": "2017-07-27T13:33:49.0Z", - * "objectId": "a2.module-1.1.5.6", - * "problem": "Ais", - * "severity": "Major", - * "type": "ProblemNotificationXml" - * } - * } + * { "faultCurrent": { "nodeName": "sim9090", "counter": "50443", "timeStamp": "2017-07-27T13:33:49.0Z", + * "objectId": "a2.module-1.1.5.6", "problem": "Ais", "severity": "Major", "type": "ProblemNotificationXml" } } * - * => + * => * - * { - * "timestamp": "2017-01-01T00:00:00.0Z", - * "object-id": "LP-MWS-TTP-01", - * "severity": "Warning", - * "counter": 2, - * "node-id": "sim1", - * "problem": "unknownProblem2" - * } + * { "timestamp": "2017-01-01T00:00:00.0Z", "object-id": "LP-MWS-TTP-01", "severity": "Warning", "counter": 2, + * "node-id": "sim1", "problem": "unknownProblem2" } */ public class FrankfurtFaultcurrentConverter extends BaseSearchHitConverter { - /** - * @param name - */ - public FrankfurtFaultcurrentConverter() { - super(ComponentName.FAULTCURRENT); - } + /** + * @param name + */ + public FrankfurtFaultcurrentConverter() { + super(ComponentName.FAULTCURRENT); + } - @Override - public SearchHit convert(SearchHit source) { - - JSONObject data = new JSONObject(); - JSONObject src = source.getSource(); - JSONObject srcInner = src.getJSONObject("faultCurrent"); - data.put("node-id", srcInner.getString("nodeName")); - data.put("severity", srcInner.getString("severity")); - data.put("counter", Long.parseLong(srcInner.getString("counter"))); - data.put("timestamp", srcInner.getString("timeStamp")); - data.put("object-id",srcInner.getString("objectId")); - data.put("problem", srcInner.getString("problem")); - - return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data ); - } + @Override + public SearchHit convert(SearchHit source) { + + JSONObject data = new JSONObject(); + JSONObject src = source.getSource(); + JSONObject srcInner = src.getJSONObject("faultCurrent"); + data.put("node-id", srcInner.getString("nodeName")); + data.put("severity", srcInner.getString("severity")); + data.put("counter", Long.parseLong(srcInner.getString("counter"))); + data.put("timestamp", srcInner.getString("timeStamp")); + data.put("object-id", srcInner.getString("objectId")); + data.put("problem", srcInner.getString("problem")); + + return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data); + } } diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultlogConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultlogConverter.java index 87e71c612..f8319020d 100644 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultlogConverter.java +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultlogConverter.java @@ -28,51 +28,34 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName; /** * - * @author Michael Dürre - *{ - * "fault": { - * "nodeName": "SDN-Controller-5a150173d678", - * "counter": "380", - * "timeStamp": "2019-10-18T18:40:25.0Z", - * "objectId": "ADVA-DTAG-Nuernberg-3", - * "problem": "connectionLossOAM", - * "severity": "Major", - * "type": "ProblemNotificationXml" - * } - *} + * @author Michael Dürre { "fault": { "nodeName": "SDN-Controller-5a150173d678", "counter": "380", "timeStamp": + * "2019-10-18T18:40:25.0Z", "objectId": "ADVA-DTAG-Nuernberg-3", "problem": "connectionLossOAM", "severity": + * "Major", "type": "ProblemNotificationXml" } } * - * => - *{ - * "timestamp": "2017-01-01T00:00:00.0Z", - * "object-id": "LP-MWPS-RADIO", - * "severity": "Critical", - * "counter": -1, - * "node-id": "sim1", - * "source-type": "Netconf", - * "problem": "signalIsLost" - *} + * => { "timestamp": "2017-01-01T00:00:00.0Z", "object-id": "LP-MWPS-RADIO", "severity": "Critical", "counter": + * -1, "node-id": "sim1", "source-type": "Netconf", "problem": "signalIsLost" } * */ -public class FrankfurtFaultlogConverter extends BaseSearchHitConverter{ +public class FrankfurtFaultlogConverter extends BaseSearchHitConverter { - public FrankfurtFaultlogConverter() { - super(ComponentName.FAULTLOG); - } + public FrankfurtFaultlogConverter() { + super(ComponentName.FAULTLOG); + } - @Override - public SearchHit convert(SearchHit source) { - - JSONObject data = new JSONObject(); - JSONObject src = source.getSource(); - JSONObject srcInner = src.getJSONObject("fault"); - data.put("node-id", srcInner.getString("nodeName")); - data.put("severity", srcInner.getString("severity")); - data.put("counter", Long.parseLong(srcInner.getString("counter"))); - data.put("timestamp", srcInner.getString("timeStamp")); - data.put("object-id",srcInner.getString("objectId")); - data.put("problem", srcInner.getString("problem")); - data.put("type", "Netconf"); - return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data ); - } + @Override + public SearchHit convert(SearchHit source) { + + JSONObject data = new JSONObject(); + JSONObject src = source.getSource(); + JSONObject srcInner = src.getJSONObject("fault"); + data.put("node-id", srcInner.getString("nodeName")); + data.put("severity", srcInner.getString("severity")); + data.put("counter", Long.parseLong(srcInner.getString("counter"))); + data.put("timestamp", srcInner.getString("timeStamp")); + data.put("object-id", srcInner.getString("objectId")); + data.put("problem", srcInner.getString("problem")); + data.put("type", "Netconf"); + return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data); + } } diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtMaintenanceConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtMaintenanceConverter.java index 16be5d97b..69b9a9934 100644 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtMaintenanceConverter.java +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtMaintenanceConverter.java @@ -31,56 +31,37 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName; * * @author jack * - *{ - * "node": "ddd", - * "filter": [ - * { - * "definition": { - * "object-id-ref": "", - * "problem": "" - * }, - * "description": "", - * "start": "2019-11-26T15:37+00:00", - * "end": "2019-11-26T23:37+00:00" - * }], - * "active": false - *} - * => - *{ - * "id": "sim1" - * "node-id": "sim1", - * "description": "", - * "start": "2020-01-28T12:00:17.6Z", - * "end": "2020-01-28T12:00:17.6Z", - * "active": false, - * "object-id-ref": "", - * "problem": "" + * { "node": "ddd", "filter": [ { "definition": { "object-id-ref": "", "problem": "" }, "description": "", + * "start": "2019-11-26T15:37+00:00", "end": "2019-11-26T23:37+00:00" }], "active": false } => { "id": "sim1" + * "node-id": "sim1", "description": "", "start": "2020-01-28T12:00:17.6Z", "end": "2020-01-28T12:00:17.6Z", + * "active": false, "object-id-ref": "", "problem": "" * */ public class FrankfurtMaintenanceConverter extends BaseSearchHitConverter { - public FrankfurtMaintenanceConverter() { - super(ComponentName.MAINTENANCE); - } + public FrankfurtMaintenanceConverter() { + super(ComponentName.MAINTENANCE); + } - @Override - public SearchHit convert(SearchHit source) { + @Override + public SearchHit convert(SearchHit source) { - JSONObject src = source.getSource(); - JSONObject data = new JSONObject(); - data.put("id", src.getString("node")); - data.put("node-id", src.getString("node")); - data.put("active", src.getBoolean("active")); - JSONObject filter = null; - if (src.has("filter")) { - filter = src.getJSONArray("filter").length() > 0 ? src.getJSONArray("filter").getJSONObject(0) : null; - } - data.put("start", filter != null ? filter.getString("start") : ""); - data.put("end", filter != null ? filter.getString("end") : ""); - data.put("description", filter != null ? filter.getString("description") : ""); - JSONObject definition = filter!=null?filter.has("definition")?filter.getJSONObject("definition"):null:null; - data.put("problem", definition!=null?definition.getString("problem"):""); - data.put("object-id-ref", definition!=null?definition.getString("object-id-ref"):""); - return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data); - } + JSONObject src = source.getSource(); + JSONObject data = new JSONObject(); + data.put("id", src.getString("node")); + data.put("node-id", src.getString("node")); + data.put("active", src.getBoolean("active")); + JSONObject filter = null; + if (src.has("filter")) { + filter = src.getJSONArray("filter").length() > 0 ? src.getJSONArray("filter").getJSONObject(0) : null; + } + data.put("start", filter != null ? filter.getString("start") : ""); + data.put("end", filter != null ? filter.getString("end") : ""); + data.put("description", filter != null ? filter.getString("description") : ""); + JSONObject definition = + filter != null ? filter.has("definition") ? filter.getJSONObject("definition") : null : null; + data.put("problem", definition != null ? definition.getString("problem") : ""); + data.put("object-id-ref", definition != null ? definition.getString("object-id-ref") : ""); + return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data); + } } diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtRequiredNetworkElementConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtRequiredNetworkElementConverter.java index ef6de907e..7cf18dd43 100644 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtRequiredNetworkElementConverter.java +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtRequiredNetworkElementConverter.java @@ -31,48 +31,35 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.frankfurt.data.Connect * * @author Michael Dürre * - * { - * "mountId":"nts-manager-dev-micha", - * "host":"10.20.5.2", - * "port":8300, - * "username":"netconf", - * "password":"netconf" - * } + * { "mountId":"nts-manager-dev-micha", "host":"10.20.5.2", "port":8300, "username":"netconf", + * "password":"netconf" } * - * => + * => * - * { - * "node-id": "sim1", - * "is-required": true, - * "password": "ads", - * "port": 12600, - * "host": "10.20.5.2", - * "id": "sim1", - * "username": "ad", - * "status": "Connected" - * } + * { "node-id": "sim1", "is-required": true, "password": "ads", "port": 12600, "host": "10.20.5.2", "id": + * "sim1", "username": "ad", "status": "Connected" } * */ -public class FrankfurtRequiredNetworkElementConverter extends BaseSearchHitConverter{ +public class FrankfurtRequiredNetworkElementConverter extends BaseSearchHitConverter { - public FrankfurtRequiredNetworkElementConverter() { - super(ComponentName.REQUIRED_NETWORKELEMENT); - } + public FrankfurtRequiredNetworkElementConverter() { + super(ComponentName.REQUIRED_NETWORKELEMENT); + } - @Override - public SearchHit convert(SearchHit source) { - - JSONObject data = new JSONObject(); - JSONObject src = source.getSource(); - data.put("id", src.getString("mountId")); - data.put("node-id", src.getString("mountId")); - data.put("username", src.getString("username")); - data.put("password", src.getString("password")); - data.put("host", src.getString("host")); - data.put("port", src.getInt("port")); - data.put("status", ConnectionLogStatus.Undefined.getName()); - data.put("is-required", true); - return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data ); - } + @Override + public SearchHit convert(SearchHit source) { + + JSONObject data = new JSONObject(); + JSONObject src = source.getSource(); + data.put("id", src.getString("mountId")); + data.put("node-id", src.getString("mountId")); + data.put("username", src.getString("username")); + data.put("password", src.getString("password")); + data.put("host", src.getString("host")); + data.put("port", src.getInt("port")); + data.put("status", ConnectionLogStatus.Undefined.getName()); + data.put("is-required", true); + return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data); + } } diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformation.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformation.java index bbbde1f22..ad0abee89 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 @@ -37,65 +37,65 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation; public class FrankfurtReleaseInformation extends ReleaseInformation { - private final Logger LOG = LoggerFactory.getLogger(FrankfurtReleaseInformation.class); - private final Map<Release, Map<ComponentName, SearchHitConverter>> converters = new HashMap<>(); + private final Logger LOG = LoggerFactory.getLogger(FrankfurtReleaseInformation.class); + private final Map<Release, Map<ComponentName, SearchHitConverter>> converters = new HashMap<>(); - public FrankfurtReleaseInformation() { - super(Release.FRANKFURT_R1, createDBMap()); - } + public FrankfurtReleaseInformation() { + super(Release.FRANKFURT_R1, createDBMap()); + } - private static Map<ComponentName, DatabaseInfo> createDBMap() { - Map<ComponentName, DatabaseInfo> map = new HashMap<>(); - map.put(ComponentName.CONNECTIONLOG, new DatabaseInfo("connectionlog", "connectionlog", - "{\"node-id\": {\"type\": \"keyword\"},\"timestamp\": {\"type\": \"date\"},\"status\": {\"type\": \"keyword\"}}")); - map.put(ComponentName.EVENTLOG, new DatabaseInfo("eventlog", "eventlog", - "{\"node-id\": {\"type\": \"keyword\"},\"source-type\": {\"type\": \"keyword\"},\"timestamp\": {\"type\": \"date\"},\"new-value\": {\"type\": \"keyword\"},\"attribute-name\": {\"type\": \"keyword\"},\"counter\": {\"type\": \"long\"},\"object-id\": {\"type\": \"keyword\"}}")); - map.put(ComponentName.FAULTCURRENT, new DatabaseInfo("faultcurrent", "faultcurrent", - "{\"node-id\": {\"type\": \"keyword\"},\"severity\": {\"type\": \"keyword\"},\"timestamp\": {\"type\": \"date\"},\"problem\": {\"type\": \"keyword\"},\"counter\": {\"type\": \"long\"},\"object-id\":{\"type\": \"keyword\"}}")); - map.put(ComponentName.FAULTLOG, new DatabaseInfo("faultlog", "faultlog", - "{\"node-id\": {\"type\": \"keyword\"},\"severity\": {\"type\": \"keyword\"},\"timestamp\": {\"type\": \"date\"},\"problem\": {\"type\": \"keyword\"},\"counter\": {\"type\": \"long\"},\"object-id\":{\"type\": \"keyword\"},\"source-type\":{\"type\": \"keyword\"}}")); - map.put(ComponentName.INVENTORY, new DatabaseInfo("inventoryequipment", "inventoryequipment", - "{\"date\": {\"type\": \"keyword\"},\"model-identifier\": {\"type\": \"keyword\"},\"manufacturer-identifier\": {\"type\": \"keyword\"},\"type-name\": {\"type\": \"keyword\"},\"description\": {\"type\": \"keyword\"},\"uuid\": {\"type\": \"keyword\"},\"version\": {\"type\": \"keyword\"},\"parent-uuid\": {\"type\": \"keyword\"},\"contained-holder\": {\"type\": \"keyword\"},\"node-id\": {\"type\": \"keyword\"},\"tree-level\": {\"type\": \"long\"},\"part-type-id\": {\"type\": \"keyword\"},\"serial\": {\"type\": \"keyword\"}}")); - map.put(ComponentName.HISTORICAL_PERFORMANCE_15M, new DatabaseInfo("historicalperformance15min", - "historicalperformance15min", - "{\"node-name\":{\"type\": \"keyword\"},\"timestamp\":{\"type\": \"date\"},\"suspect-interval-flag\":{\"type\":\"boolean\"},\"scanner-id\":{\"type\": \"keyword\"},\"uuid-interface\":{\"type\": \"keyword\"},\"layer-protocol-name\":{\"type\": \"keyword\"},\"granularity-period\":{\"type\": \"keyword\"},\"radio-signal-id\":{\"type\": \"keyword\"}}")); - map.put(ComponentName.HISTORICAL_PERFORMANCE_24H, new DatabaseInfo("historicalperformance24h", - "historicalperformance24h", - "{\"node-name\":{\"type\": \"keyword\"},\"timestamp\":{\"type\": \"date\"},\"suspect-interval-flag\":{\"type\":\"boolean\"},\"scanner-id\":{\"type\": \"keyword\"},\"uuid-interface\":{\"type\": \"keyword\"},\"layer-protocol-name\":{\"type\": \"keyword\"},\"granularity-period\":{\"type\": \"keyword\"},\"radio-signal-id\":{\"type\": \"keyword\"}}")); - map.put(ComponentName.REQUIRED_NETWORKELEMENT, new DatabaseInfo("networkelement-connection", - "networkelement-connection", - "{\"node-id\": {\"type\": \"keyword\"},\"host\": {\"type\": \"keyword\"},\"port\": {\"type\": \"long\"},\"username\": {\"type\": \"keyword\"},\"password\": {\"type\": \"keyword\"},\"core-model-capability\": {\"type\": \"keyword\"},\"device-type\": {\"type\": \"keyword\"},\"is-required\": {\"type\": \"boolean\"},\"status\": {\"type\": \"keyword\"}}")); - map.put(ComponentName.MEDIATOR_SERVER, new DatabaseInfo("mediator-server", "mediator-server", - "{\"url\":{\"type\": \"keyword\"},\"name\":{\"type\": \"keyword\"}}")); - map.put(ComponentName.MAINTENANCE, new DatabaseInfo("maintenancemode", "maintenancemode", - "{\"node-id\": {\"type\": \"keyword\"},\"start\": {\"type\": \"date\"},\"end\": {\"type\": \"date\"},\"description\": {\"type\": \"keyword\"},\"active\": {\"type\": \"boolean\"}},\"date_detection\":false}}")); - return map; - } + private static Map<ComponentName, DatabaseInfo> createDBMap() { + Map<ComponentName, DatabaseInfo> map = new HashMap<>(); + map.put(ComponentName.CONNECTIONLOG, new DatabaseInfo("connectionlog", "connectionlog", + "{\"node-id\": {\"type\": \"keyword\"},\"timestamp\": {\"type\": \"date\"},\"status\": {\"type\": \"keyword\"}}")); + map.put(ComponentName.EVENTLOG, new DatabaseInfo("eventlog", "eventlog", + "{\"node-id\": {\"type\": \"keyword\"},\"source-type\": {\"type\": \"keyword\"},\"timestamp\": {\"type\": \"date\"},\"new-value\": {\"type\": \"keyword\"},\"attribute-name\": {\"type\": \"keyword\"},\"counter\": {\"type\": \"long\"},\"object-id\": {\"type\": \"keyword\"}}")); + map.put(ComponentName.FAULTCURRENT, new DatabaseInfo("faultcurrent", "faultcurrent", + "{\"node-id\": {\"type\": \"keyword\"},\"severity\": {\"type\": \"keyword\"},\"timestamp\": {\"type\": \"date\"},\"problem\": {\"type\": \"keyword\"},\"counter\": {\"type\": \"long\"},\"object-id\":{\"type\": \"keyword\"}}")); + map.put(ComponentName.FAULTLOG, new DatabaseInfo("faultlog", "faultlog", + "{\"node-id\": {\"type\": \"keyword\"},\"severity\": {\"type\": \"keyword\"},\"timestamp\": {\"type\": \"date\"},\"problem\": {\"type\": \"keyword\"},\"counter\": {\"type\": \"long\"},\"object-id\":{\"type\": \"keyword\"},\"source-type\":{\"type\": \"keyword\"}}")); + map.put(ComponentName.INVENTORY, new DatabaseInfo("inventoryequipment", "inventoryequipment", + "{\"date\": {\"type\": \"keyword\"},\"model-identifier\": {\"type\": \"keyword\"},\"manufacturer-identifier\": {\"type\": \"keyword\"},\"type-name\": {\"type\": \"keyword\"},\"description\": {\"type\": \"keyword\"},\"uuid\": {\"type\": \"keyword\"},\"version\": {\"type\": \"keyword\"},\"parent-uuid\": {\"type\": \"keyword\"},\"contained-holder\": {\"type\": \"keyword\"},\"node-id\": {\"type\": \"keyword\"},\"tree-level\": {\"type\": \"long\"},\"part-type-id\": {\"type\": \"keyword\"},\"serial\": {\"type\": \"keyword\"}}")); + map.put(ComponentName.HISTORICAL_PERFORMANCE_15M, new DatabaseInfo("historicalperformance15min", + "historicalperformance15min", + "{\"node-name\":{\"type\": \"keyword\"},\"timestamp\":{\"type\": \"date\"},\"suspect-interval-flag\":{\"type\":\"boolean\"},\"scanner-id\":{\"type\": \"keyword\"},\"uuid-interface\":{\"type\": \"keyword\"},\"layer-protocol-name\":{\"type\": \"keyword\"},\"granularity-period\":{\"type\": \"keyword\"},\"radio-signal-id\":{\"type\": \"keyword\"}}")); + map.put(ComponentName.HISTORICAL_PERFORMANCE_24H, new DatabaseInfo("historicalperformance24h", + "historicalperformance24h", + "{\"node-name\":{\"type\": \"keyword\"},\"timestamp\":{\"type\": \"date\"},\"suspect-interval-flag\":{\"type\":\"boolean\"},\"scanner-id\":{\"type\": \"keyword\"},\"uuid-interface\":{\"type\": \"keyword\"},\"layer-protocol-name\":{\"type\": \"keyword\"},\"granularity-period\":{\"type\": \"keyword\"},\"radio-signal-id\":{\"type\": \"keyword\"}}")); + map.put(ComponentName.REQUIRED_NETWORKELEMENT, new DatabaseInfo("networkelement-connection", + "networkelement-connection", + "{\"node-id\": {\"type\": \"keyword\"},\"host\": {\"type\": \"keyword\"},\"port\": {\"type\": \"long\"},\"username\": {\"type\": \"keyword\"},\"password\": {\"type\": \"keyword\"},\"core-model-capability\": {\"type\": \"keyword\"},\"device-type\": {\"type\": \"keyword\"},\"is-required\": {\"type\": \"boolean\"},\"status\": {\"type\": \"keyword\"}}")); + map.put(ComponentName.MEDIATOR_SERVER, new DatabaseInfo("mediator-server", "mediator-server", + "{\"url\":{\"type\": \"keyword\"},\"name\":{\"type\": \"keyword\"}}")); + map.put(ComponentName.MAINTENANCE, new DatabaseInfo("maintenancemode", "maintenancemode", + "{\"node-id\": {\"type\": \"keyword\"},\"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 + 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) { + @Override + protected boolean runPreInitCommands(HtDatabaseClient dbClient) { - ClusterSettingsResponse response = null; - try { - response = dbClient.setupClusterSettings(new ClusterSettingsRequest(false)); - } catch (IOException e) { - LOG.warn("problem setting up cluster: {}", e); - } - return response == null ? false : response.isAcknowledged(); - } + ClusterSettingsResponse response = null; + try { + response = dbClient.setupClusterSettings(new ClusterSettingsRequest(false)); + } catch (IOException e) { + LOG.warn("problem setting up cluster: {}", e); + } + return response == null ? false : response.isAcknowledged(); + } - @Override - protected boolean runPostInitCommands(HtDatabaseClient dbClient) { - return true; - } + @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/frankfurt/data/ConnectionLogStatus.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/data/ConnectionLogStatus.java index 7615c4452..1ecae6782 100644 --- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/data/ConnectionLogStatus.java +++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/data/ConnectionLogStatus.java @@ -26,13 +26,13 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.frankfurt.data; * */ public enum ConnectionLogStatus { - Connected, Connecting, UnableToConnect, Mounted, Unmounted, Undefined; + Connected, Connecting, UnableToConnect, Mounted, Unmounted, Undefined; - /** - * @return - */ - public String getName() { - return this.name(); - } + /** + * @return + */ + public String getName() { + return this.name(); + } } diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformation.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformation.java index 7b5e38116..a81a6f0fd 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 @@ -35,48 +35,48 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DatabaseInfo; public class GuilinReleaseInformation extends ReleaseInformation { - /** - * @param r - * @param dbMap - */ - public GuilinReleaseInformation() { - super(Release.GUILIN, createDBMap()); + /** + * @param r + * @param dbMap + */ + public GuilinReleaseInformation() { + super(Release.GUILIN, createDBMap()); - } + } - private static Map<ComponentName, DatabaseInfo> createDBMap() { - Map<ComponentName, DatabaseInfo> map = new HashMap<>(); - map.put(ComponentName.EVENTLOG, new DatabaseInfo("eventlog", "eventlog", "")); - map.put(ComponentName.FAULTCURRENT, new DatabaseInfo("faultcurrent", "faultcurrent", "")); - map.put(ComponentName.FAULTLOG, new DatabaseInfo("faultlog", "faultlog", "")); - map.put(ComponentName.INVENTORY, new DatabaseInfo("inventoryequipment", "inventoryequipment", "")); - map.put(ComponentName.HISTORICAL_PERFORMANCE_15M, - new DatabaseInfo("historicalperformance15min", "historicalperformance15min", "")); - map.put(ComponentName.HISTORICAL_PERFORMANCE_24H, - new DatabaseInfo("historicalperformance24h", "historicalperformance24h", "")); - map.put(ComponentName.REQUIRED_NETWORKELEMENT, - new DatabaseInfo("networkelement-connection", "networkelement-connection", "")); - map.put(ComponentName.MEDIATOR_SERVER, new DatabaseInfo("mediator-server", "mediator-server", "")); - map.put(ComponentName.MAINTENANCE, new DatabaseInfo("maintenancemode", "maintenancemode", "")); - return map; - } + private static Map<ComponentName, DatabaseInfo> createDBMap() { + Map<ComponentName, DatabaseInfo> map = new HashMap<>(); + map.put(ComponentName.EVENTLOG, new DatabaseInfo("eventlog", "eventlog", "")); + map.put(ComponentName.FAULTCURRENT, new DatabaseInfo("faultcurrent", "faultcurrent", "")); + map.put(ComponentName.FAULTLOG, new DatabaseInfo("faultlog", "faultlog", "")); + map.put(ComponentName.INVENTORY, new DatabaseInfo("inventoryequipment", "inventoryequipment", "")); + map.put(ComponentName.HISTORICAL_PERFORMANCE_15M, + new DatabaseInfo("historicalperformance15min", "historicalperformance15min", "")); + map.put(ComponentName.HISTORICAL_PERFORMANCE_24H, + new DatabaseInfo("historicalperformance24h", "historicalperformance24h", "")); + map.put(ComponentName.REQUIRED_NETWORKELEMENT, + new DatabaseInfo("networkelement-connection", "networkelement-connection", "")); + map.put(ComponentName.MEDIATOR_SERVER, new DatabaseInfo("mediator-server", "mediator-server", "")); + map.put(ComponentName.MAINTENANCE, new DatabaseInfo("maintenancemode", "maintenancemode", "")); + return map; + } - @Override - public SearchHitConverter getConverter(Release dst, ComponentName comp) { - if (dst == Release.GUILIN) { - return new KeepDataSearchHitConverter(comp); - } - return null; - } + @Override + public SearchHitConverter getConverter(Release dst, ComponentName comp) { + if (dst == Release.GUILIN) { + return new KeepDataSearchHitConverter(comp); + } + return null; + } - @Override - protected boolean runPreInitCommands(HtDatabaseClient dbClient) { - return true; - } + @Override + protected boolean runPreInitCommands(HtDatabaseClient dbClient) { + return true; + } - @Override - protected boolean runPostInitCommands(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 03629edaa..c7864560b 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,128 +48,111 @@ 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" + - "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" + - ""; - @Test - public void testComponentData() { - JSONArray hits = new JSONArray(); - hits.put(EVENTLOG_SEARCHHIT); - hits.put(EVENTLOG_SEARCHHIT2); - ComponentData data = new ComponentData(ComponentName.EVENTLOG,hits); - JSONArray out = data.toJsonArray(); - assertEquals(ComponentName.EVENTLOG, data.getName()); - JSONAssert.assertEquals(EVENTLOG_SEARCHHIT.toString(),out.getJSONObject(0).toString(),false); - JSONAssert.assertEquals(EVENTLOG_SEARCHHIT2.toString(),out.getJSONObject(1).toString(),false); - - } - @Test - public void testConfigData() { - ConfigData data = new ConfigData(CONFIG_CONTENT); - assertTrue(data.getLines().length>10); - } - @Test - public void testConfigName() { - ConfigName name = ConfigName.APIGATEWAY; - assertEquals("apigateway", name.getValue()); - try { - assertEquals(ConfigName.APIGATEWAY,ConfigName.getValueOf("apigateway")); - } catch (Exception e) { - fail(e.getMessage()); - } - - } - @Test - public void testDataContainer() { - DataContainer container = new DataContainer(); - assertEquals(Release.CURRENT_RELEASE,container.getRelease()); - assertNotNull(container.getCreated()); - - try { - container = DataContainer.load(new File("src/test/resources/test.bak.json")); - } catch (Exception e) { - fail(e.getMessage()); - } - assertNotNull(container); - assertEquals(Release.EL_ALTO,container.getRelease()); - assertNotNull(container.getCreated()); - assertTrue(container.getComponents().size()>0); - assertTrue(container.getConfigs().size()==0); - } - @Test - public void testReport() { - DataMigrationReport report = new DataMigrationReport(); - - assertFalse(report.completed()); - long myvar = 42; - String myvar2 = "come"; - report.log("%d was wrong",myvar); - report.error("%s to me",myvar2); - assertTrue(report.toString().contains("42 was wrong")); - assertTrue(report.toString().contains("come to me")); - report.setCompleted(true); - assertTrue(report.completed()); - - } - @Test - public void TestPluginFileCreation() { - - final String TESTFILE = "asi324po.sa"; - try { - MavenDatabasePluginInitFile.create(Release.FRANKFURT_R1, TESTFILE); - } catch (IOException e) { - fail(e.getMessage()); - } - File f = new File(TESTFILE); - if(f.exists()) { - f.delete(); - } - } - + 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" + ""; + + @Test + public void testComponentData() { + JSONArray hits = new JSONArray(); + hits.put(EVENTLOG_SEARCHHIT); + hits.put(EVENTLOG_SEARCHHIT2); + ComponentData data = new ComponentData(ComponentName.EVENTLOG, hits); + JSONArray out = data.toJsonArray(); + assertEquals(ComponentName.EVENTLOG, data.getName()); + JSONAssert.assertEquals(EVENTLOG_SEARCHHIT.toString(), out.getJSONObject(0).toString(), false); + JSONAssert.assertEquals(EVENTLOG_SEARCHHIT2.toString(), out.getJSONObject(1).toString(), false); + + } + + @Test + public void testConfigData() { + ConfigData data = new ConfigData(CONFIG_CONTENT); + assertTrue(data.getLines().length > 10); + } + + @Test + public void testConfigName() { + ConfigName name = ConfigName.APIGATEWAY; + assertEquals("apigateway", name.getValue()); + try { + assertEquals(ConfigName.APIGATEWAY, ConfigName.getValueOf("apigateway")); + } catch (Exception e) { + fail(e.getMessage()); + } + + } + + @Test + public void testDataContainer() { + DataContainer container = new DataContainer(); + assertEquals(Release.CURRENT_RELEASE, container.getRelease()); + assertNotNull(container.getCreated()); + + try { + container = DataContainer.load(new File("src/test/resources/test.bak.json")); + } catch (Exception e) { + fail(e.getMessage()); + } + assertNotNull(container); + assertEquals(Release.EL_ALTO, container.getRelease()); + assertNotNull(container.getCreated()); + assertTrue(container.getComponents().size() > 0); + assertTrue(container.getConfigs().size() == 0); + } + + @Test + public void testReport() { + DataMigrationReport report = new DataMigrationReport(); + + assertFalse(report.completed()); + long myvar = 42; + String myvar2 = "come"; + report.log("%d was wrong", myvar); + report.error("%s to me", myvar2); + assertTrue(report.toString().contains("42 was wrong")); + assertTrue(report.toString().contains("come to me")); + report.setCompleted(true); + assertTrue(report.completed()); + + } + + @Test + public void TestPluginFileCreation() { + + final String TESTFILE = "asi324po.sa"; + try { + MavenDatabasePluginInitFile.create(Release.FRANKFURT_R1, TESTFILE); + } catch (IOException e) { + fail(e.getMessage()); + } + File f = new File(TESTFILE); + if (f.exists()) { + f.delete(); + } + } + } diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestElAltoReleaseInformation.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestElAltoReleaseInformation.java index 4d5ebaa4a..05a2ffe7a 100644 --- a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestElAltoReleaseInformation.java +++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestElAltoReleaseInformation.java @@ -42,9 +42,9 @@ public class TestElAltoReleaseInformation { Set<ComponentName> components = ri.getComponents(); assertFalse(components.contains(ComponentName.CONNECTIONLOG)); assertTrue(components.contains(ComponentName.EVENTLOG)); - assertEquals("sdnevents",ri.getAlias(ComponentName.FAULTLOG)); - assertEquals("sdnevents_v1",ri.getIndex(ComponentName.FAULTLOG)); - assertNull(ri.getConverter(Release.EL_ALTO,ComponentName.CONNECTIONLOG)); + assertEquals("sdnevents", ri.getAlias(ComponentName.FAULTLOG)); + assertEquals("sdnevents_v1", ri.getIndex(ComponentName.FAULTLOG)); + assertNull(ri.getConverter(Release.EL_ALTO, ComponentName.CONNECTIONLOG)); assertNotNull(ri.getConverter(Release.EL_ALTO, ComponentName.FAULTCURRENT)); } diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestElAltoToFrankfurtConversion.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestElAltoToFrankfurtConversion.java index 07a60a0f1..d515e2a6b 100644 --- a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestElAltoToFrankfurtConversion.java +++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestElAltoToFrankfurtConversion.java @@ -38,100 +38,85 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.elalto.ElAltoReleaseIn */ public class TestElAltoToFrankfurtConversion { - private static final JSONObject FAULTLOG_SEARCHHIT = new JSONObject("{\n" + "\"_index\": \"sdnevents_v1\",\n" - + "\"_type\": \"faultlog\",\n" + "\"_id\": \"sim12600/LP-MWS-TTP-01/unknownProblem1\",\n" - + "\"_version\": 1,\n" + "\"_score\": 1,\n" + "\"_source\": {\n" + "\"fault\": {\n" - + "\"nodeName\": \"sim12600\",\n" + "\"counter\": \"1\",\n" + "\"timeStamp\": \"2017-01-01T00:00:00.0Z\",\n" - + "\"objectId\": \"LP-MWS-TTP-01\",\n" + "\"problem\": \"unknownProblem1\",\n" - + "\"severity\": \"Critical\",\n" + "\"type\": \"ProblemNotificationXml\"\n" + "}\n" + "}\n" + "}"); - private static final JSONObject FAULTCURRENT_SEARCHHIT = new JSONObject("{\n" + "\"_index\": \"sdnevents_v1\",\n" - + "\"_type\": \"faultcurrent\",\n" + "\"_id\": \"sim12600/LP-MWS-TTP-01/unknownProblem1\",\n" - + "\"_version\": 1,\n" + "\"_score\": 1,\n" + "\"_source\": {\n" + "\"faultCurrent\": {\n" - + "\"nodeName\": \"sim12600\",\n" + "\"counter\": \"1\",\n" + "\"timeStamp\": \"2017-01-01T00:00:00.0Z\",\n" - + "\"objectId\": \"LP-MWS-TTP-01\",\n" + "\"problem\": \"unknownProblem1\",\n" - + "\"severity\": \"Critical\",\n" + "\"type\": \"ProblemNotificationXml\"\n" + "}\n" + "}\n" + "}"); - private static final JSONObject INVENTORY_SEARCHHIT = new JSONObject( - "{\n" + "\"_index\": \"sdnevents_v1\",\n" + "\"_type\": \"inventoryequipment\",\n" - + "\"_id\": \"sim12600/a2.module-1.1.5.5\",\n" + "\"_version\": 1,\n" + "\"_score\": 1,\n" - + "\"_source\": {\n" + "\"treeLevel\": 2,\n" + "\"parentUuid\": \"CARD-1.1.5.0\",\n" - + "\"mountpoint\": \"sim12600\",\n" + "\"uuid\": \"a2.module-1.1.5.5\",\n" - + "\"containedHolder\": [\n" + "\"SUBRACK-1.55.0.0\"\n" + "],\n" + "\"manufacturerName\": null,\n" - + "\"manufacturerIdentifier\": \"ONF-Wireless-Transport\",\n" + "\"serial\": \"310330015\",\n" - + "\"date\": \"2013-04-13T00:00:00.0Z\",\n" + "\"version\": \"a2.module-newest\",\n" - + "\"description\": \"WS/p8.module/a2.module#5\",\n" + "\"partTypeId\": \"3EM23141AD01\",\n" - + "\"modelIdentifier\": \"CRPQABVFAA\",\n" + "\"typeName\": \"a2.module\"\n" + "}\n" + "}"); - private static final JSONObject REQUIREDNE_SEARCHHIT = new JSONObject("{\n" + "\"_index\": \"mwtn_v1\",\n" - + "\"_type\": \"required-networkelement\",\n" + "\"_id\": \"sim2230\",\n" + "\"_version\": 1,\n" - + "\"_score\": 1,\n" + "\"_source\": {\n" + "\"mountId\": \"sim2230\",\n" + "\"host\": \"10.20.5.2\",\n" - + "\"port\": 2230,\n" + "\"username\": \"adsa\",\n" + "\"password\": \"asda\"\n" + "}\n" + "}"); - 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 MAINTENANCE_SEARCHHIT = new JSONObject("{\n" + - "\"_index\": \"mwtn_v1\",\n" + - "\"_type\": \"maintenancemode\",\n" + - "\"_id\": \"sim2230\",\n" + - "\"_version\": 1,\n" + - "\"_score\": 1,\n" + - "\"_source\": {\n" + - "\"node\": \"sim2230\",\n" + - "\"filter\": [\n" + - "{\n" + - "\"definition\": {\n" + - "\"object-id-ref\": \"\",\n" + - "\"problem\": \"\"\n" + - "},\n" + - "\"description\": \"\",\n" + - "\"start\": \"\",\n" + - "\"end\": \"\"\n" + - "}\n" + - "],\n" + - "\"active\": false\n" + - "}\n" + - "}"); - @Test - public void test() { - ElAltoReleaseInformation ri = new ElAltoReleaseInformation(); - //faultlog - SearchHitConverter faultlogConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.FAULTLOG); - assertNotNull(faultlogConverter); - SearchHit frankfurtFaultlogEntry = faultlogConverter.convert(new SearchHit(FAULTLOG_SEARCHHIT)); - assertNotNull(frankfurtFaultlogEntry); - //faultcurrent - SearchHitConverter faultcurrentConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.FAULTCURRENT); - assertNotNull(faultcurrentConverter); - SearchHit frankfurtFaultcurrentEntry = faultcurrentConverter.convert(new SearchHit(FAULTCURRENT_SEARCHHIT)); - assertNotNull(frankfurtFaultcurrentEntry); - //inventory - SearchHitConverter inventoryConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.INVENTORY); - assertNotNull(inventoryConverter); - SearchHit frankfurtInventory = inventoryConverter.convert(new SearchHit(INVENTORY_SEARCHHIT)); - assertNotNull(frankfurtInventory); - //inventory - SearchHitConverter neConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.REQUIRED_NETWORKELEMENT); - assertNotNull(neConverter); - SearchHit frankfurtNE = neConverter.convert(new SearchHit(REQUIREDNE_SEARCHHIT)); - assertNotNull(frankfurtNE); - //eventlog - SearchHitConverter eventlogConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.EVENTLOG); - assertNotNull(eventlogConverter); - SearchHit frankfurtEvent = eventlogConverter.convert(new SearchHit(EVENTLOG_SEARCHHIT)); - assertNull(frankfurtEvent); - //eventlog->connectionlog - SearchHitConverter conlogConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.CONNECTIONLOG); - assertNotNull(conlogConverter); - SearchHit frankfurtconlog = conlogConverter.convert(new SearchHit(EVENTLOG_SEARCHHIT)); - assertNotNull(frankfurtconlog); - //maintenance - SearchHitConverter maintenanceConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.MAINTENANCE); - assertNotNull(maintenanceConverter); - SearchHit frankfurtmaint = maintenanceConverter.convert(new SearchHit(MAINTENANCE_SEARCHHIT)); - assertNotNull(frankfurtmaint); + private static final JSONObject FAULTLOG_SEARCHHIT = new JSONObject("{\n" + "\"_index\": \"sdnevents_v1\",\n" + + "\"_type\": \"faultlog\",\n" + "\"_id\": \"sim12600/LP-MWS-TTP-01/unknownProblem1\",\n" + + "\"_version\": 1,\n" + "\"_score\": 1,\n" + "\"_source\": {\n" + "\"fault\": {\n" + + "\"nodeName\": \"sim12600\",\n" + "\"counter\": \"1\",\n" + "\"timeStamp\": \"2017-01-01T00:00:00.0Z\",\n" + + "\"objectId\": \"LP-MWS-TTP-01\",\n" + "\"problem\": \"unknownProblem1\",\n" + + "\"severity\": \"Critical\",\n" + "\"type\": \"ProblemNotificationXml\"\n" + "}\n" + "}\n" + "}"); + private static final JSONObject FAULTCURRENT_SEARCHHIT = new JSONObject("{\n" + "\"_index\": \"sdnevents_v1\",\n" + + "\"_type\": \"faultcurrent\",\n" + "\"_id\": \"sim12600/LP-MWS-TTP-01/unknownProblem1\",\n" + + "\"_version\": 1,\n" + "\"_score\": 1,\n" + "\"_source\": {\n" + "\"faultCurrent\": {\n" + + "\"nodeName\": \"sim12600\",\n" + "\"counter\": \"1\",\n" + "\"timeStamp\": \"2017-01-01T00:00:00.0Z\",\n" + + "\"objectId\": \"LP-MWS-TTP-01\",\n" + "\"problem\": \"unknownProblem1\",\n" + + "\"severity\": \"Critical\",\n" + "\"type\": \"ProblemNotificationXml\"\n" + "}\n" + "}\n" + "}"); + private static final JSONObject INVENTORY_SEARCHHIT = + new JSONObject("{\n" + "\"_index\": \"sdnevents_v1\",\n" + "\"_type\": \"inventoryequipment\",\n" + + "\"_id\": \"sim12600/a2.module-1.1.5.5\",\n" + "\"_version\": 1,\n" + "\"_score\": 1,\n" + + "\"_source\": {\n" + "\"treeLevel\": 2,\n" + "\"parentUuid\": \"CARD-1.1.5.0\",\n" + + "\"mountpoint\": \"sim12600\",\n" + "\"uuid\": \"a2.module-1.1.5.5\",\n" + + "\"containedHolder\": [\n" + "\"SUBRACK-1.55.0.0\"\n" + "],\n" + "\"manufacturerName\": null,\n" + + "\"manufacturerIdentifier\": \"ONF-Wireless-Transport\",\n" + "\"serial\": \"310330015\",\n" + + "\"date\": \"2013-04-13T00:00:00.0Z\",\n" + "\"version\": \"a2.module-newest\",\n" + + "\"description\": \"WS/p8.module/a2.module#5\",\n" + "\"partTypeId\": \"3EM23141AD01\",\n" + + "\"modelIdentifier\": \"CRPQABVFAA\",\n" + "\"typeName\": \"a2.module\"\n" + "}\n" + "}"); + private static final JSONObject REQUIREDNE_SEARCHHIT = new JSONObject("{\n" + "\"_index\": \"mwtn_v1\",\n" + + "\"_type\": \"required-networkelement\",\n" + "\"_id\": \"sim2230\",\n" + "\"_version\": 1,\n" + + "\"_score\": 1,\n" + "\"_source\": {\n" + "\"mountId\": \"sim2230\",\n" + "\"host\": \"10.20.5.2\",\n" + + "\"port\": 2230,\n" + "\"username\": \"adsa\",\n" + "\"password\": \"asda\"\n" + "}\n" + "}"); + 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 MAINTENANCE_SEARCHHIT = + new JSONObject("{\n" + "\"_index\": \"mwtn_v1\",\n" + "\"_type\": \"maintenancemode\",\n" + + "\"_id\": \"sim2230\",\n" + "\"_version\": 1,\n" + "\"_score\": 1,\n" + "\"_source\": {\n" + + "\"node\": \"sim2230\",\n" + "\"filter\": [\n" + "{\n" + "\"definition\": {\n" + + "\"object-id-ref\": \"\",\n" + "\"problem\": \"\"\n" + "},\n" + "\"description\": \"\",\n" + + "\"start\": \"\",\n" + "\"end\": \"\"\n" + "}\n" + "],\n" + "\"active\": false\n" + "}\n" + "}"); - } + @Test + public void test() { + ElAltoReleaseInformation ri = new ElAltoReleaseInformation(); + //faultlog + SearchHitConverter faultlogConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.FAULTLOG); + assertNotNull(faultlogConverter); + SearchHit frankfurtFaultlogEntry = faultlogConverter.convert(new SearchHit(FAULTLOG_SEARCHHIT)); + assertNotNull(frankfurtFaultlogEntry); + //faultcurrent + SearchHitConverter faultcurrentConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.FAULTCURRENT); + assertNotNull(faultcurrentConverter); + SearchHit frankfurtFaultcurrentEntry = faultcurrentConverter.convert(new SearchHit(FAULTCURRENT_SEARCHHIT)); + assertNotNull(frankfurtFaultcurrentEntry); + //inventory + SearchHitConverter inventoryConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.INVENTORY); + assertNotNull(inventoryConverter); + SearchHit frankfurtInventory = inventoryConverter.convert(new SearchHit(INVENTORY_SEARCHHIT)); + assertNotNull(frankfurtInventory); + //inventory + SearchHitConverter neConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.REQUIRED_NETWORKELEMENT); + assertNotNull(neConverter); + SearchHit frankfurtNE = neConverter.convert(new SearchHit(REQUIREDNE_SEARCHHIT)); + assertNotNull(frankfurtNE); + //eventlog + SearchHitConverter eventlogConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.EVENTLOG); + assertNotNull(eventlogConverter); + SearchHit frankfurtEvent = eventlogConverter.convert(new SearchHit(EVENTLOG_SEARCHHIT)); + assertNull(frankfurtEvent); + //eventlog->connectionlog + SearchHitConverter conlogConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.CONNECTIONLOG); + assertNotNull(conlogConverter); + SearchHit frankfurtconlog = conlogConverter.convert(new SearchHit(EVENTLOG_SEARCHHIT)); + assertNotNull(frankfurtconlog); + //maintenance + SearchHitConverter maintenanceConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.MAINTENANCE); + assertNotNull(maintenanceConverter); + SearchHit frankfurtmaint = maintenanceConverter.convert(new SearchHit(MAINTENANCE_SEARCHHIT)); + assertNotNull(frankfurtmaint); + + } } diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestFrankfurtReleaseInformation.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestFrankfurtReleaseInformation.java index 47a3a8f74..1d7a6eb6d 100644 --- a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestFrankfurtReleaseInformation.java +++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestFrankfurtReleaseInformation.java @@ -42,9 +42,9 @@ public class TestFrankfurtReleaseInformation { Set<ComponentName> components = ri.getComponents(); assertFalse(components.contains(ComponentName.INVENTORYTOPLEVEL)); assertTrue(components.contains(ComponentName.EVENTLOG)); - assertEquals("faultlog",ri.getAlias(ComponentName.FAULTLOG)); - assertEquals("faultlog-v2",ri.getIndex(ComponentName.FAULTLOG)); - assertNull(ri.getConverter(Release.FRANKFURT_R1,ComponentName.INVENTORYTOPLEVEL)); + assertEquals("faultlog", ri.getAlias(ComponentName.FAULTLOG)); + assertEquals("faultlog-v2", ri.getIndex(ComponentName.FAULTLOG)); + assertNull(ri.getConverter(Release.FRANKFURT_R1, ComponentName.INVENTORYTOPLEVEL)); assertNotNull(ri.getConverter(Release.FRANKFURT_R1, ComponentName.FAULTCURRENT)); } 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 1ec19117b..02877f0c8 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 @@ -37,17 +37,17 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release; */ public class TestMigrationProvider { - private static final String FRANKFURT_BACKUP_FILE = "src/test/resources/test2.bak.json"; - public static HostInfo[] hosts = new HostInfo[] { new HostInfo("localhost", Integer - .valueOf(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200")) }; + private static final String FRANKFURT_BACKUP_FILE = "src/test/resources/test2.bak.json"; + public static HostInfo[] hosts = new HostInfo[] {new HostInfo("localhost", Integer + .valueOf(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200"))}; @Test public void testCreateImport() { - DataMigrationProviderImpl provider = new DataMigrationProviderImpl(hosts, null, null,true,5000); + DataMigrationProviderImpl provider = new DataMigrationProviderImpl(hosts, null, null, true, 5000); try { //create el alto db infrastructure - provider.initDatabase(Release.FRANKFURT_R1, 5, 1, "", true,10000); + 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()); |