From d7d3b5bd8f1c69fdaddffb3c200468feee424564 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Mon, 2 Aug 2021 15:56:00 -0400 Subject: Use lombok in apex-pdp #4 Updated model, testsuites, and tools. Issue-ID: POLICY-3391 Change-Id: I187d84380661f5d4222967c1c5f004c318d65982 Signed-off-by: Jim Hahn --- .../benchmark/eventgenerator/EventBatch.java | 17 ++--- .../benchmark/eventgenerator/EventBatchStats.java | 55 +------------- .../eventgenerator/EventGeneratorEndpoint.java | 19 ++--- .../eventgenerator/EventGeneratorStats.java | 7 +- .../eventgenerator/events/InputEvent.java | 83 +++------------------- .../eventgenerator/events/OutputEvent.java | 77 ++------------------ 6 files changed, 30 insertions(+), 228 deletions(-) (limited to 'testsuites/performance') diff --git a/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatch.java b/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatch.java index 95d3ad8d5..99f480b6c 100644 --- a/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatch.java +++ b/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatch.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -23,6 +24,7 @@ package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.atomic.AtomicInteger; +import lombok.Getter; import org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.events.InputEvent; import org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.events.OutputEvent; @@ -32,11 +34,14 @@ import org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.even public class EventBatch { private static AtomicInteger nextBatchNumber = new AtomicInteger(); + @Getter private final int batchNumber = nextBatchNumber.getAndIncrement(); private final Map inputEventMap = new ConcurrentHashMap<>(); private final Map outputEventMap = new ConcurrentHashMap<>(); + @Getter private final int batchSize; + @Getter private final String apexClient; /** @@ -83,18 +88,6 @@ public class EventBatch { return jsonBuilder.toString(); } - public int getBatchNumber() { - return batchNumber; - } - - public int getBatchSize() { - return batchSize; - } - - public String getApexClient() { - return apexClient; - } - /** * Get the event slogan. * diff --git a/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatchStats.java b/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatchStats.java index 930e2af95..fa5083ed0 100644 --- a/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatchStats.java +++ b/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventBatchStats.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2019 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,6 +23,7 @@ package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator; import java.util.List; +import lombok.Getter; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; import org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.events.OutputEvent; @@ -29,6 +31,7 @@ import org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.even /** * This POJO class returns statistics on a event batch execution in Apex. */ +@Getter public class EventBatchStats { private final int batchNumber; private final int batchSize; @@ -183,56 +186,4 @@ public class EventBatchStats { return new ImmutablePair<>(roundTrip, apexExecution); } - - public int getBatchNumber() { - return batchNumber; - } - - public int getBatchSize() { - return batchSize; - } - - public String getApexClient() { - return apexClient; - } - - public long getEventsNotSent() { - return eventsNotSent; - } - - public long getEventsSent() { - return eventsSent; - } - - public long getEventsNotReceived() { - return eventsNotReceived; - } - - public long getEventsReceived() { - return eventsReceived; - } - - public long getAverageRoundTripNano() { - return averageRoundTripNano; - } - - public long getShortestRoundTripNano() { - return shortestRoundTripNano; - } - - public long getLongestRoundTripNano() { - return longestRoundTripNano; - } - - public long getAverageApexExecutionNano() { - return averageApexExecutionNano; - } - - public long getShortestApexExecutionNano() { - return shortestApexExecutionNano; - } - - public long getLongestApexExecutionNano() { - return longestApexExecutionNano; - } } diff --git a/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorEndpoint.java b/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorEndpoint.java index 1b3558730..6cbee6935 100644 --- a/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorEndpoint.java +++ b/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorEndpoint.java @@ -2,6 +2,7 @@ * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. * Modifications Copyright (C) 2020 Nordix Foundation. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -30,6 +31,9 @@ import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.Path; import javax.ws.rs.core.Response; +import lombok.AccessLevel; +import lombok.Getter; +import lombok.Setter; import org.glassfish.grizzly.http.server.Request; import org.onap.policy.apex.core.infrastructure.threading.ThreadUtilities; import org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.events.OutputEvent; @@ -53,6 +57,8 @@ public class EventGeneratorEndpoint { private static ConcurrentHashMap batchMap = new ConcurrentHashMap<>(); // Flag indicating that event processing has finished + @Getter(AccessLevel.PROTECTED) + @Setter(AccessLevel.PROTECTED) private static boolean finished = false; // The current HTTP request @@ -163,17 +169,4 @@ public class EventGeneratorEndpoint { protected static void clearEventGenerationStats() { batchMap.clear(); } - - /** - * Check if event generation has finished. - * - * @return true if event generation has finished - */ - protected static boolean isFinished() { - return finished; - } - - protected static void setFinished(boolean finished) { - EventGeneratorEndpoint.finished = finished; - } } diff --git a/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorStats.java b/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorStats.java index 9d926e2ad..9cdb3315f 100644 --- a/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorStats.java +++ b/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/EventGeneratorStats.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,11 +25,13 @@ import com.google.gson.GsonBuilder; import java.util.ArrayList; import java.util.List; import java.util.Map; +import lombok.Getter; /** * This class creates statistics for the event generator's current status. */ public class EventGeneratorStats { + @Getter private final EventBatchStats totalStats; private final List batchStatsList = new ArrayList<>(); @@ -51,8 +54,4 @@ public class EventGeneratorStats { public String getStatsAsJsonString() { return new GsonBuilder().setPrettyPrinting().create().toJson(this); } - - public EventBatchStats getTotalStats() { - return totalStats; - } } diff --git a/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/InputEvent.java b/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/InputEvent.java index 2cccc7dc0..d24405bea 100644 --- a/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/InputEvent.java +++ b/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/InputEvent.java @@ -21,14 +21,21 @@ package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.events; +import com.google.gson.Gson; import com.google.gson.GsonBuilder; import com.google.gson.annotations.SerializedName; import java.util.Random; +import lombok.Getter; +import lombok.Setter; /** * This class is a POJO representing an input event for load testing. */ +@Getter +@Setter public class InputEvent { + private static final Gson gson = new GsonBuilder().setPrettyPrinting().create(); + private String nameSpace = "org.onap.policy.apex.sample.events"; private String name; private String version = "0.0.1"; @@ -61,86 +68,12 @@ public class InputEvent { testTemperature = rand.nextDouble() * 1000; } - public String getNameSpace() { - return nameSpace; - - } - - public void setNameSpace(String nameSpace) { - this.nameSpace = nameSpace; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getSource() { - return source; - } - - public void setSource(String source) { - this.source = source; - } - - public String getTarget() { - return target; - } - - - public void setTarget(String target) { - this.target = target; - } - - public String getTestSlogan() { - return testSlogan; - } - - public void setTestSlogan(String testSlogan) { - this.testSlogan = testSlogan; - } - - public int getTestMatchCase() { - return testMatchCase; - } - - public void setTestMatchCase(int testMatchCase) { - this.testMatchCase = testMatchCase; - } - - public long getTestTimestamp() { - return testTimestamp; - } - - public void setTestTimestamp(long testTimestamp) { - this.testTimestamp = testTimestamp; - } - - public double getTestTemperature() { - return testTemperature; - } - - public void setTestTemperature(double testTemperature) { - this.testTemperature = testTemperature; - } - /** * Get a JSON representation of the input event. * * @return the event in JSON format */ public String asJson() { - return new GsonBuilder().setPrettyPrinting().create().toJson(this); + return gson.toJson(this); } } diff --git a/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/OutputEvent.java b/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/OutputEvent.java index 0350b3f2e..fe7829c1e 100644 --- a/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/OutputEvent.java +++ b/testsuites/performance/performance-benchmark-test/src/main/java/org/onap/policy/apex/testsuites/performance/benchmark/eventgenerator/events/OutputEvent.java @@ -1,6 +1,7 @@ /*- * ============LICENSE_START======================================================= * Copyright (C) 2018 Ericsson. All rights reserved. + * Modifications Copyright (C) 2021 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,10 +22,14 @@ package org.onap.policy.apex.testsuites.performance.benchmark.eventgenerator.events; import com.google.gson.annotations.SerializedName; +import lombok.Getter; +import lombok.Setter; /** * This class is a POJO representing an output event for load testing. */ +@Getter +@Setter public class OutputEvent extends InputEvent { @SerializedName(value = "TestMatchCaseSelected") private int testMatchCaseSelected; @@ -52,78 +57,6 @@ public class OutputEvent extends InputEvent { private long testReceviedTimestamp = System.nanoTime(); - public int getTestMatchCaseSelected() { - return testMatchCaseSelected; - } - - public void setTestMatchCaseSelected(int testMatchCaseSelected) { - this.testMatchCaseSelected = testMatchCaseSelected; - } - - public long getTestMatchStateTime() { - return testMatchStateTime; - } - - public void setTestMatchStateTime(long testMatchStateTime) { - this.testMatchStateTime = testMatchStateTime; - } - - public int getTestEstablishCaseSelected() { - return testEstablishCaseSelected; - } - - public void setTestEstablishCaseSelected(int testEstablishCaseSelected) { - this.testEstablishCaseSelected = testEstablishCaseSelected; - } - - public long getTestEstablishStateTime() { - return testEstablishStateTime; - } - - public void setTestEstablishStateTime(long testEstablishStateTime) { - this.testEstablishStateTime = testEstablishStateTime; - } - - public int getTestDecideCaseSelected() { - return testDecideCaseSelected; - } - - public void setTestDecideCaseSelected(int testDecideCaseSelected) { - this.testDecideCaseSelected = testDecideCaseSelected; - } - - public long getTestDecideStateTime() { - return testDecideStateTime; - } - - public void setTestDecideStateTime(long testDecideStateTime) { - this.testDecideStateTime = testDecideStateTime; - } - - public int getTestActCaseSelected() { - return testActCaseSelected; - } - - public void setTestActCaseSelected(int testActCaseSelected) { - this.testActCaseSelected = testActCaseSelected; - } - - public long getTestActStateTime() { - return testActStateTime; - } - - public void setTestActStateTime(long testActStateTime) { - this.testActStateTime = testActStateTime; - } - - public long getTestReceviedTimestamp() { - return testReceviedTimestamp; - } - - public void setTestReceviedTimestamp(long testReceviedTimestamp) { - this.testReceviedTimestamp = testReceviedTimestamp; - } - public int findBatchNumber() { return Integer.valueOf(getTestSlogan().substring(0, getTestSlogan().indexOf('-'))); } -- cgit 1.2.3-korg