From d8542b5a55d19584454215cd22d2f86cfb30e0a6 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Wed, 13 May 2020 12:55:37 -0400 Subject: Handle duplicate events in drools-apps Modified the frankfurt rules to compare the event objects instead of comparing the request ID when determining if an event is new. The event object's equals() method ignores the request ID when doing the comparison, thus it will treat an event as a duplicate even if the request ID is different, which is the behavior we want. Also removed the @Ignore from the junit that tests for duplicate events in the hope that this change will fix it. If the docker build still breaks, then @Ignore can be added back in. Issue-ID: POLICY-2557 Change-Id: If2b9fd26473d78a356218b951bfe160f93daeb32 Signed-off-by: Jim Hahn --- .../eventmanager/ControlLoopEventManager2.java | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'controlloop/common/eventmanager/src/main/java/org/onap') diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2.java index c79737ae6..5f611c098 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2.java @@ -36,6 +36,7 @@ import java.util.concurrent.Executor; import java.util.concurrent.ExecutorService; import java.util.concurrent.ForkJoinPool; import java.util.concurrent.TimeUnit; +import java.util.concurrent.atomic.AtomicLong; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; import java.util.stream.Collectors; @@ -97,6 +98,12 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable { private static final Set TRUE_VALUES = Set.of("true", "t", "yes", "y"); + /** + * Counts the number of these objects that have been created. This is used by junit + * tests. + */ + private static final AtomicLong createCount = new AtomicLong(0); + public enum NewEventStatus { FIRST_ONSET, SUBSEQUENT_ONSET, FIRST_ABATEMENT, SUBSEQUENT_ABATEMENT, SYNTAX_ERROR } @@ -114,6 +121,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable { @Getter @ToString.Include private final UUID requestId; + @Getter private final ControlLoopEventContext context; @ToString.Include private int numOnsets = 1; @@ -169,6 +177,8 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable { public ControlLoopEventManager2(ControlLoopParams params, VirtualControlLoopEvent event, WorkingMemory workMem) throws ControlLoopException { + createCount.incrementAndGet(); + checkEventSyntax(event); if (isClosedLoopDisabled(event)) { @@ -191,6 +201,14 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable { this.endTimeMs = System.currentTimeMillis() + detmControlLoopTimeoutMs(); } + /** + * Gets the number of managers objects that have been created. + * @return the number of managers objects that have been created + */ + public static long getCreateCount() { + return createCount.get(); + } + /** * Starts the manager. * -- cgit 1.2.3-korg