From 17859bdd1f24904d2a9162a1a43f9db222750f4a Mon Sep 17 00:00:00 2001 From: Piotr Jaszczyk Date: Wed, 11 Apr 2018 16:29:30 +0200 Subject: Optimize and refactor EventPublisher class in VES * Remove need for having sendEvent synchronized by means of using Guava LoadingCache. The only thing that made it synchronized was the creation of new entries in the map but the synchronization was made on each incoming event. * Split the class to smaller classes which conform to SRP. This makes us able to... * ... write unit tests for affected classes * TODO: upgrade to Java8 so lambdas will simplify the code even more Change-Id: I14cf4cfab0570ce5aecc9a5e5dc9f541c499f9d7 Issue-ID: DCAEGEN2-440 Signed-off-by: Piotr Jaszczyk --- pom.xml | 8 + .../commonFunction/CambriaPublisherFactory.java | 69 +++++++ .../onap/dcae/commonFunction/DmaapPublishers.java | 96 ++++++++++ .../dcae/commonFunction/EventPublisherHash.java | 213 +++++++-------------- .../dcae/commonFunction/DmaapPublishersTest.java | 143 ++++++++++++++ .../commonFunction/EventPublisherHashTest.java | 90 +++++++++ .../org/onap/dcae/vestest/TestEventProcessor.java | 64 +++---- src/test/resources/test_collector_ip_op.properties | 156 +++++++-------- 8 files changed, 577 insertions(+), 262 deletions(-) create mode 100644 src/main/java/org/onap/dcae/commonFunction/CambriaPublisherFactory.java create mode 100644 src/main/java/org/onap/dcae/commonFunction/DmaapPublishers.java create mode 100644 src/test/java/org/onap/dcae/commonFunction/DmaapPublishersTest.java create mode 100644 src/test/java/org/onap/dcae/commonFunction/EventPublisherHashTest.java diff --git a/pom.xml b/pom.xml index 04a0d3a9..9540d409 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,7 @@