diff options
author | Jorge Hernandez <jorge.hernandez-herrero@att.com> | 2020-05-13 19:56:07 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-05-13 19:56:07 +0000 |
commit | 2cbc4178e4242349782a6dab66a9cec74cf8703a (patch) | |
tree | 3dc0aa2309a37dac5d65e02e47f785351a6a9137 /controlloop/common/eventmanager | |
parent | adc24d773806687215b3dc4fc129dddd84b58014 (diff) | |
parent | d8542b5a55d19584454215cd22d2f86cfb30e0a6 (diff) |
Merge "Handle duplicate events in drools-apps"
Diffstat (limited to 'controlloop/common/eventmanager')
-rw-r--r-- | controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2.java | 18 |
1 files changed, 18 insertions, 0 deletions
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<String> 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)) { @@ -192,6 +202,14 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable { } /** + * 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. * * @throws ControlLoopException if the processor cannot get a policy |