summaryrefslogtreecommitdiffstats
path: root/sparkybe-onap-service
diff options
context:
space:
mode:
Diffstat (limited to 'sparkybe-onap-service')
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregation/sync/HistoricalEntitySyncController.java8
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/analytics/HistogramSampler.java2
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/analytics/HistoricalCounter.java2
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/dal/ActiveInventoryAdapter.java4
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/SyncControllerImpl.java6
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/SynchronizerConstants.java6
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/TransactionRateMonitor.java2
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/config/SyncControllerConfig.java5
-rw-r--r--sparkybe-onap-service/src/main/java/org/onap/aai/sparky/util/NodeUtils.java4
-rw-r--r--sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregation/sync/HistoricalEntitySyncControllerTest.java16
10 files changed, 38 insertions, 17 deletions
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregation/sync/HistoricalEntitySyncController.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregation/sync/HistoricalEntitySyncController.java
index 03534e0..da1f290 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregation/sync/HistoricalEntitySyncController.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/aggregation/sync/HistoricalEntitySyncController.java
@@ -33,6 +33,8 @@ import org.onap.aai.sparky.sync.config.ElasticSearchSchemaConfig;
import org.onap.aai.sparky.sync.config.NetworkStatisticsConfig;
import org.onap.aai.sparky.sync.config.SyncControllerConfig;
+import java.util.concurrent.TimeUnit;
+
public class HistoricalEntitySyncController extends SyncControllerImpl
implements SyncControllerRegistrar {
@@ -48,7 +50,7 @@ public class HistoricalEntitySyncController extends SyncControllerImpl
// final String controllerName = "Historical Entity Count Synchronizer";
- long taskFrequencyInMs = syncFrequencyInMinutes * 60 * 1000;
+ long taskFrequencyInMs = getTaskFrequencyInMs(syncFrequencyInMinutes);
setDelayInMs(taskFrequencyInMs);
setSyncFrequencyInMs(taskFrequencyInMs);
@@ -70,6 +72,10 @@ public class HistoricalEntitySyncController extends SyncControllerImpl
}
+ static long getTaskFrequencyInMs(int syncFrequencyInMinutes) {
+ return TimeUnit.MINUTES.toMillis(Integer.toUnsignedLong(syncFrequencyInMinutes));
+ }
+
public SyncControllerRegistry getSyncControllerRegistry() {
return syncControllerRegistry;
}
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/analytics/HistogramSampler.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/analytics/HistogramSampler.java
index c1fa9f1..1350d28 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/analytics/HistogramSampler.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/analytics/HistogramSampler.java
@@ -173,7 +173,7 @@ public final class HistogramSampler {
this.minValue = -1;
this.maxValue = 0;
initializeHistogramBins(numBins);
- this.stepSize = (maxValue / numBins);
+ this.stepSize = ((double) maxValue / (double) numBins);
clear();
}
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/analytics/HistoricalCounter.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/analytics/HistoricalCounter.java
index 68305f8..b53c1e8 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/analytics/HistoricalCounter.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/analytics/HistoricalCounter.java
@@ -75,7 +75,7 @@ public class HistoricalCounter {
} else {
- if (min == -1) {
+ if (Double.valueOf(min).equals(-1.0)) {
min = value;
}
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/dal/ActiveInventoryAdapter.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/dal/ActiveInventoryAdapter.java
index 33d2ff4..e168f43 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/dal/ActiveInventoryAdapter.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/dal/ActiveInventoryAdapter.java
@@ -143,9 +143,11 @@ public class ActiveInventoryAdapter {
protected String getResourceBasePath() {
- String versionStr = null;
+ String versionStr;
if (oxmModelLoader != null) {
versionStr = String.valueOf(oxmModelLoader.getLatestVersionNum());
+ } else {
+ throw new RuntimeException("Unable to resolve aai version.");
}
return "/aai/" + versionStr.toLowerCase();
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/SyncControllerImpl.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/SyncControllerImpl.java
index 8b008de..7c81074 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/SyncControllerImpl.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/SyncControllerImpl.java
@@ -22,6 +22,7 @@ package org.onap.aai.sparky.sync;
import static java.util.concurrent.CompletableFuture.supplyAsync;
+import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Collection;
import java.util.Date;
@@ -58,6 +59,8 @@ public class SyncControllerImpl implements SyncController {
TEST_INDEX_INTEGRITY, GENERATE_FINAL_REPORT
}
+ private final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
+
/**
* The Enum SyncActions.
*/
@@ -93,7 +96,6 @@ public class SyncControllerImpl implements SyncController {
/**
* Instantiates a new sync controller.
*
- * @param name the name
* @throws Exception the exception
*/
public SyncControllerImpl(SyncControllerConfig syncControllerConfig) throws Exception {
@@ -251,7 +253,7 @@ public class SyncControllerImpl implements SyncController {
LOG.info(AaiUiMsgs.INFO_GENERIC,
getControllerName() + " started synchronization at "
- + SynchronizerConstants.SIMPLE_DATE_FORMAT.format(opStartTime).replaceAll(
+ + this.simpleDateFormat.format(opStartTime).replaceAll(
SynchronizerConstants.TIME_STD, SynchronizerConstants.TIME_CONFIG_STD));
runCount.incrementAndGet();
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/SynchronizerConstants.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/SynchronizerConstants.java
index 24279c6..ccc9934 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/SynchronizerConstants.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/SynchronizerConstants.java
@@ -20,8 +20,8 @@
*/
package org.onap.aai.sparky.sync;
-import java.text.SimpleDateFormat;
import java.util.Date;
+import java.util.concurrent.TimeUnit;
/**
* The Class SynchronizerConstants.
@@ -30,8 +30,6 @@ public final class SynchronizerConstants {
// Error values for invalid user input
public static final int DEFAULT_CONFIG_ERROR_INT_VALUE = Integer.MAX_VALUE;
public static final Date DEFAULT_CONFIG_ERROR_DATE_VALUE = new Date(Long.MAX_VALUE);
- public static final SimpleDateFormat SIMPLE_DATE_FORMAT =
- new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
public static final String DEPTH_MODIFIER = "?depth=0";
public static final String DEPTH_ALL_MODIFIER = "?depth=all";
@@ -48,7 +46,7 @@ public final class SynchronizerConstants {
public static final int IDX_TIME_IN_TIMESTAMP = 0;
public static final int IDX_TIMEZONE_IN_TIMESTAMP = 1;
public static final long MILLISEC_IN_A_MIN = 60000;
- public static final long MILLISEC_IN_A_DAY = 24 * 60 * 60 * 1000;
+ public static final long MILLISEC_IN_A_DAY = TimeUnit.HOURS.toMillis(24);
public static final String TIME_STD = "GMT";
public static final String TIME_CONFIG_STD = "UTC";
public static final String TIMESTAMP24HOURS_PATTERN =
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/TransactionRateMonitor.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/TransactionRateMonitor.java
index 07d5e84..464875c 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/TransactionRateMonitor.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/TransactionRateMonitor.java
@@ -60,7 +60,7 @@ public class TransactionRateMonitor {
public double getCurrentTps() {
if (numTransactions.get() > 0) {
- double timeDelta = System.currentTimeMillis() - startTimeInMs;
+ long timeDelta = System.currentTimeMillis() - startTimeInMs;
double numTxns = numTransactions.get();
return (numTxns / timeDelta) * 1000.0;
}
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/config/SyncControllerConfig.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/config/SyncControllerConfig.java
index f71c660..555f8cc 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/config/SyncControllerConfig.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/sync/config/SyncControllerConfig.java
@@ -36,6 +36,7 @@ import org.onap.aai.sparky.sync.SynchronizerConstants;
public class SyncControllerConfig {
private static final String UNKNOWN_CONTROLLER_NAME = "UnknownControllerName";
+ private final SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z");
private String controllerName;
private boolean enabled;
@@ -242,12 +243,12 @@ public class SyncControllerConfig {
Calendar targetSyncTime = Calendar.getInstance(tz);
targetSyncTime.add(Calendar.SECOND, taskFrequencyInSeconds);
- return SynchronizerConstants.SIMPLE_DATE_FORMAT.format(targetSyncTime.getTimeInMillis())
+ return this.simpleDateFormat.format(targetSyncTime.getTimeInMillis())
.replaceAll(SynchronizerConstants.TIME_STD, SynchronizerConstants.TIME_CONFIG_STD);
} else {
- return SynchronizerConstants.SIMPLE_DATE_FORMAT
+ return this.simpleDateFormat
.format(getNextSyncTime(getTargetSyncTime(), taskFrequencyInSeconds))
.replaceAll(SynchronizerConstants.TIME_STD, SynchronizerConstants.TIME_CONFIG_STD);
diff --git a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/util/NodeUtils.java b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/util/NodeUtils.java
index 7a9d0e0..b75fa91 100644
--- a/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/util/NodeUtils.java
+++ b/sparkybe-onap-service/src/main/java/org/onap/aai/sparky/util/NodeUtils.java
@@ -880,11 +880,7 @@ public class NodeUtils {
throw ex;
} finally {
if (bufferedReader != null) {
- try {
bufferedReader.close();
- } catch (IOException ex) {
- throw ex;
- }
}
}
diff --git a/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregation/sync/HistoricalEntitySyncControllerTest.java b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregation/sync/HistoricalEntitySyncControllerTest.java
new file mode 100644
index 0000000..9527520
--- /dev/null
+++ b/sparkybe-onap-service/src/test/java/org/onap/aai/sparky/aggregation/sync/HistoricalEntitySyncControllerTest.java
@@ -0,0 +1,16 @@
+package org.onap.aai.sparky.aggregation.sync;
+
+
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class HistoricalEntitySyncControllerTest {
+
+ @Test
+ public void shouldConvertMinutesToMs() {
+ assertEquals(60000, HistoricalEntitySyncController.getTaskFrequencyInMs(1));
+ assertEquals(120000, HistoricalEntitySyncController.getTaskFrequencyInMs(2));
+ }
+
+} \ No newline at end of file