From 3ac3f212d7127e887625a344c3e4846269a01df0 Mon Sep 17 00:00:00 2001 From: Stanislav Marszalek Date: Wed, 15 Sep 2021 18:52:34 +0200 Subject: O1 PM Bulk support in DataCollector RAPP - removing trafficModel Issue-ID: INT-1947 Signed-off-by: Stanislav Marszalek Change-Id: I02d3684c98d563d7f386de2fdf032e984ac74b3f --- .../onap/rapp/datacollector/entity/ves/MeasurementFields.java | 2 +- .../main/java/org/onap/rapp/datacollector/service/PMService.java | 5 +++-- .../org/onap/rapp/datacollector/service/VesRetrievalService.java | 9 ++++++++- .../rapp/datacollector/entity/ves/MeasurementFieldsTest.java | 9 +++++++-- 4 files changed, 19 insertions(+), 6 deletions(-) diff --git a/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/MeasurementFields.java b/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/MeasurementFields.java index c11c490..7ed10b1 100644 --- a/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/MeasurementFields.java +++ b/datacollector/src/main/java/org/onap/rapp/datacollector/entity/ves/MeasurementFields.java @@ -41,7 +41,7 @@ public class MeasurementFields { private MeasurementFields(Long eventId, long measurementInterval, List additionalMeasurements) { this.eventId = eventId; this.measurementInterval = measurementInterval; - this.additionalMeasurements = Collections.unmodifiableList(additionalMeasurements); + this.additionalMeasurements = additionalMeasurements; } public static MeasurementFields of(Long eventId) { diff --git a/datacollector/src/main/java/org/onap/rapp/datacollector/service/PMService.java b/datacollector/src/main/java/org/onap/rapp/datacollector/service/PMService.java index 1e2931c..bd0b439 100644 --- a/datacollector/src/main/java/org/onap/rapp/datacollector/service/PMService.java +++ b/datacollector/src/main/java/org/onap/rapp/datacollector/service/PMService.java @@ -13,6 +13,7 @@ package org.onap.rapp.datacollector.service; +import java.math.BigInteger; import java.time.OffsetDateTime; import java.util.List; import java.util.Map; @@ -67,8 +68,8 @@ public class PMService { } private long getTimeIntervalEndTime(int slot, int count, long startDate) { - int timeIntervalMicrosec = slot * count * MICRO_SECONDS_OF_SECOND; - return startDate + timeIntervalMicrosec; + BigInteger timeIntervalMicrosec = BigInteger.valueOf(slot).multiply(BigInteger.valueOf(count)).multiply(BigInteger.valueOf(MICRO_SECONDS_OF_SECOND)); + return startDate + timeIntervalMicrosec.longValue(); } private Map> groupByCell(List events) { diff --git a/datacollector/src/main/java/org/onap/rapp/datacollector/service/VesRetrievalService.java b/datacollector/src/main/java/org/onap/rapp/datacollector/service/VesRetrievalService.java index a3825f6..1cdacd8 100644 --- a/datacollector/src/main/java/org/onap/rapp/datacollector/service/VesRetrievalService.java +++ b/datacollector/src/main/java/org/onap/rapp/datacollector/service/VesRetrievalService.java @@ -95,8 +95,8 @@ public class VesRetrievalService implements DmaapRestReader { } private void saveAllEvents(List events) { - persister.persistAll(events); saveUesOfVes(events); + persister.persistAll(removeTrafficModelFromEvents(events)); } private void saveUesOfVes(List events) { @@ -113,6 +113,13 @@ public class VesRetrievalService implements DmaapRestReader { .collect(Collectors.toSet())).orElse(Collections.emptySet()); } + private List removeTrafficModelFromEvents(List events) { + return events.stream().map(event -> { + event.getMeasurementFields().getAdditionalMeasurements() + .removeIf(additionalMeasurements -> UE_FIELD_NAME.equalsIgnoreCase(additionalMeasurements.getName())); + return event; + }).collect(Collectors.toList()); + } } diff --git a/datacollector/src/test/java/org/onap/rapp/datacollector/entity/ves/MeasurementFieldsTest.java b/datacollector/src/test/java/org/onap/rapp/datacollector/entity/ves/MeasurementFieldsTest.java index 1283bd5..9844694 100644 --- a/datacollector/src/test/java/org/onap/rapp/datacollector/entity/ves/MeasurementFieldsTest.java +++ b/datacollector/src/test/java/org/onap/rapp/datacollector/entity/ves/MeasurementFieldsTest.java @@ -15,8 +15,13 @@ package org.onap.rapp.datacollector.entity.ves; import static org.junit.Assert.assertEquals; +import static org.onap.rapp.datacollector.entity.ves.MeasurementFields.MEASUREMENT_FIELDS_VERSION; + +import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Map; + import org.junit.Test; public class MeasurementFieldsTest { @@ -37,7 +42,7 @@ public class MeasurementFieldsTest { static MeasurementFields createDummy(AdditionalMeasurements v) { return MeasurementFields.builder() .measurementInterval(1234567L) - .additionalMeasurements(List.of(v)) + .additionalMeasurements(new ArrayList<>(Arrays.asList(v))) .build(); } @@ -48,7 +53,7 @@ public class MeasurementFieldsTest { MeasurementFields actual = createDummy(v); assertEquals(1234567L, actual.measurementInterval); - assertEquals("4.0", actual.MEASUREMENT_FIELDS_VERSION); + assertEquals("4.0", MEASUREMENT_FIELDS_VERSION); assertEquals(List.of(v), actual.additionalMeasurements); } } -- cgit 1.2.3-korg