aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/data-provider/setup
diff options
context:
space:
mode:
authorMichael DÜrre <michael.duerre@highstreet-technologies.com>2021-08-24 06:16:11 +0200
committerMichael DÜrre <michael.duerre@highstreet-technologies.com>2021-08-24 06:17:47 +0200
commitc8f7e3f376992b202ba26464b9b329d6c4b2821d (patch)
treec61507b22b28ccc536485a8bf291826d0461b031 /sdnr/wt/data-provider/setup
parent2a55fbf61c4450bfc2bb3f90b060c3aa65af91f3 (diff)
fix some sdnr sonar bugs
sonar fixes for some sdnr components Issue-ID: SDNC-1590 Change-Id: I02e44b6f5477bcd0490c3499caf20228eb9772ed Signed-off-by: Michael DÜrre <michael.duerre@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/data-provider/setup')
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/Program.java2
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/database/ElasticsearchDataMigrationProvider.java19
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/database/MariaDbDataMigrationProvider.java13
3 files changed, 18 insertions, 16 deletions
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 56973f459..8afc440fd 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
@@ -413,7 +413,7 @@ public class Program {
}
private static long getTimeoutOptionMillis(CommandLine cmd) throws ParseException {
- return getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, DEFAULT_DATABASEWAIT_SECONDS) * 1000;
+ return getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, DEFAULT_DATABASEWAIT_SECONDS) * 1000L;
}
/**
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/database/ElasticsearchDataMigrationProvider.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/database/ElasticsearchDataMigrationProvider.java
index 3cfa8c17f..0254f843b 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/database/ElasticsearchDataMigrationProvider.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/database/ElasticsearchDataMigrationProvider.java
@@ -66,12 +66,13 @@ public class ElasticsearchDataMigrationProvider implements DataMigrationProvider
private static final Logger LOG = LoggerFactory.getLogger(ElasticsearchDataMigrationProvider.class);
+ private static final String LOG_DELETING_INDEX = "deleting index {}";
private final HtDatabaseClient dbClient;
public ElasticsearchDataMigrationProvider(String url, String username, String password, boolean trustAll,
long timeoutms) throws Exception {
- dbClient = HtDatabaseClient.getClient(new HostInfo[] {HostInfo.parse(url)}, username, password, trustAll,
- true, timeoutms);
+ dbClient = HtDatabaseClient.getClient(new HostInfo[] {HostInfo.parse(url)}, username, password, trustAll, true,
+ timeoutms);
}
@Override
@@ -215,7 +216,7 @@ public class ElasticsearchDataMigrationProvider implements DataMigrationProvider
}
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.isEmpty()) {
indices = indices.subList(aliases.getLinkedIndices());
}
for (Release r : Release.values()) {
@@ -368,7 +369,7 @@ public class ElasticsearchDataMigrationProvider implements DataMigrationProvider
}
ReleaseInformation ri = ReleaseInformation.getInstance(release);
AcknowledgedResponse response;
- if (entries.size() <= 0) {
+ if (entries.isEmpty()) {
LOG.info("no aliases to clear");
} else {
//check for every component of release if alias exists
@@ -387,10 +388,10 @@ public class ElasticsearchDataMigrationProvider implements DataMigrationProvider
}
} else {
//try to find malformed typed index with alias name
- IndicesEntry entry2ToDelete = entries2.findByIndex(aliasToDelete);
+ IndicesEntry entry2ToDelete = entries2 == null ? null : entries2.findByIndex(aliasToDelete);
if (entry2ToDelete != null) {
try {
- LOG.info("deleting index {}", entry2ToDelete.getName());
+ LOG.info(LOG_DELETING_INDEX, entry2ToDelete.getName());
response = this.dbClient.deleteIndex(new DeleteIndexRequest(entry2ToDelete.getName()));
LOG.info(response.isResponseSucceeded() ? "succeeded" : "failed");
} catch (IOException e) {
@@ -404,7 +405,7 @@ public class ElasticsearchDataMigrationProvider implements DataMigrationProvider
if (entries2 == null) {
return false;
}
- if (entries2.size() <= 0) {
+ if (entries2.isEmpty()) {
LOG.info("no indices to clear");
} else {
//check for every component of release if index exists
@@ -413,7 +414,7 @@ public class ElasticsearchDataMigrationProvider implements DataMigrationProvider
IndicesEntry entryToDelete = entries2.findByIndex(indexToDelete);
if (entryToDelete != null) {
try {
- LOG.info("deleting index {}", entryToDelete.getName());
+ LOG.info(LOG_DELETING_INDEX, entryToDelete.getName());
response = this.dbClient.deleteIndex(new DeleteIndexRequest(entryToDelete.getName()));
LOG.info(response.isResponseSucceeded() ? "succeeded" : "failed");
} catch (IOException e) {
@@ -452,7 +453,7 @@ public class ElasticsearchDataMigrationProvider implements DataMigrationProvider
}
for (IndicesEntry index : indices) {
try {
- LOG.info("deleting index {}", index.getName());
+ LOG.info(LOG_DELETING_INDEX, index.getName());
this.dbClient.deleteIndex(new DeleteIndexRequest(index.getName()));
} catch (IOException e) {
LOG.error("problem deleting index {}: {}", index.getName(), e);
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/database/MariaDbDataMigrationProvider.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/database/MariaDbDataMigrationProvider.java
index d46fc4e2e..55ba66ba6 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/database/MariaDbDataMigrationProvider.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/database/MariaDbDataMigrationProvider.java
@@ -58,6 +58,7 @@ public class MariaDbDataMigrationProvider implements DataMigrationProviderServic
private static final Logger LOG = LoggerFactory.getLogger(MariaDbDataMigrationProvider.class);
private static final SdnrDbType DBTYPE = SdnrDbType.MARIADB;
+ private static final String LOG_DELETING_INDEX = "deleting index {}";
private final SqlDBClient dbClient;
public MariaDbDataMigrationProvider(String url, String username, String password, boolean trustAll,
@@ -211,7 +212,7 @@ public class MariaDbDataMigrationProvider implements DataMigrationProviderServic
}
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.isEmpty()) {
indices = indices.subList(aliases.getLinkedIndices());
}
for (Release r : Release.values()) {
@@ -337,7 +338,7 @@ public class MariaDbDataMigrationProvider implements DataMigrationProviderServic
}
ReleaseInformation ri = ReleaseInformation.getInstance(release);
boolean response;
- if (entries.size() <= 0) {
+ if (entries.isEmpty()) {
LOG.info("no aliases to clear");
} else {
//check for every component of release if alias exists
@@ -358,7 +359,7 @@ public class MariaDbDataMigrationProvider implements DataMigrationProviderServic
IndicesEntry entry2ToDelete = entries2.findByIndex(aliasToDelete);
if (entry2ToDelete != null) {
try {
- LOG.info("deleting index {}", entry2ToDelete.getName());
+ LOG.info(LOG_DELETING_INDEX, entry2ToDelete.getName());
response = this.dbClient.deleteTable(entry2ToDelete.getName());
LOG.info(response ? "succeeded" : "failed");
} catch (SQLException e) {
@@ -372,7 +373,7 @@ public class MariaDbDataMigrationProvider implements DataMigrationProviderServic
if (entries2 == null) {
return false;
}
- if (entries2.size() <= 0) {
+ if (entries2.isEmpty()) {
LOG.info("no indices to clear");
} else {
//check for every component of release if index exists
@@ -381,7 +382,7 @@ public class MariaDbDataMigrationProvider implements DataMigrationProviderServic
IndicesEntry entryToDelete = entries2.findByIndex(indexToDelete);
if (entryToDelete != null) {
try {
- LOG.info("deleting index {}", entryToDelete.getName());
+ LOG.info(LOG_DELETING_INDEX, entryToDelete.getName());
response = this.dbClient.deleteTable(entryToDelete.getName());
LOG.info(response ? "succeeded" : "failed");
} catch (SQLException e) {
@@ -420,7 +421,7 @@ public class MariaDbDataMigrationProvider implements DataMigrationProviderServic
}
for (IndicesEntry index : indices) {
try {
- LOG.info("deleting index {}", index.getName());
+ LOG.info(LOG_DELETING_INDEX, index.getName());
this.dbClient.deleteTable(index.getName());
} catch (SQLException e) {
LOG.error("problem deleting index {}: {}", index.getName(), e);