summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2020-04-02 09:57:52 -0400
committerJim Hahn <jrh3@att.com>2020-04-02 09:57:52 -0400
commit6665b07ea30db54331b3bf3a9cbedb6aa629e35d (patch)
tree9edbefcf26e34168197a26e3ff6d9973508cb65e
parentba08880be9f3164bcad11f8daf995bb70e76f3af (diff)
Synchronize methods for rules
Added "synchronized" to a few more methods in the event manager class, just to be safe, as they view/modify data that may be viewed/modified by other threads. Issue-ID: POLICY-2385 Signed-off-by: Jim Hahn <jrh3@att.com> Change-Id: Ia8404fd3fd53b0de95f939dfff2088867e0f3b24
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2.java18
1 files changed, 9 insertions, 9 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 05563ca8d..cc54b73be 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
@@ -249,7 +249,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable {
/**
* Starts the next step, whatever that may be.
*/
- public void nextStep() {
+ public synchronized void nextStep() {
if (!isActive()) {
return;
}
@@ -280,7 +280,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable {
*
* @return {@code true} if the manager is still active, {@code false} otherwise
*/
- public boolean isActive() {
+ public synchronized boolean isActive() {
return (createdByThisJvmInstance && finalResult == null);
}
@@ -355,7 +355,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable {
/**
* Cancels the current operation and frees all locks.
*/
- public void destroy() {
+ public synchronized void destroy() {
ControlLoopOperationManager2 oper = currentOperation.get();
if (oper != null) {
oper.cancel();
@@ -376,7 +376,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable {
*
* @return a new notification
*/
- public VirtualControlLoopNotification makeNotification() {
+ public synchronized VirtualControlLoopNotification makeNotification() {
VirtualControlLoopNotification notif = new VirtualControlLoopNotification(context.getEvent());
notif.setNotification(ControlLoopNotificationType.OPERATION);
notif.setFrom("policy");
@@ -400,7 +400,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable {
* @param event the event
* @return the status
*/
- public NewEventStatus onNewEvent(VirtualControlLoopEvent event) {
+ public synchronized NewEventStatus onNewEvent(VirtualControlLoopEvent event) {
try {
checkEventSyntax(event);
@@ -446,7 +446,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable {
* @param event the event syntax
* @throws ControlLoopException if an error occurs
*/
- public void checkEventSyntax(VirtualControlLoopEvent event) throws ControlLoopException {
+ protected void checkEventSyntax(VirtualControlLoopEvent event) throws ControlLoopException {
validateStatus(event);
if (StringUtils.isBlank(event.getClosedLoopControlName())) {
throw new ControlLoopException("No control loop name");
@@ -514,7 +514,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable {
* @return <code>true</code> if the control loop is disabled, <code>false</code>
* otherwise
*/
- public static boolean isClosedLoopDisabled(VirtualControlLoopEvent event) {
+ private static boolean isClosedLoopDisabled(VirtualControlLoopEvent event) {
Map<String, String> aai = event.getAai();
return (isAaiTrue(aai.get(VSERVER_IS_CLOSED_LOOP_DISABLED))
|| isAaiTrue(aai.get(GENERIC_VNF_IS_CLOSED_LOOP_DISABLED))
@@ -528,7 +528,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable {
* @return {@code true} if the provisioning status is neither ACTIVE nor {@code null},
* {@code false} otherwise
*/
- protected static boolean isProvStatusInactive(VirtualControlLoopEvent event) {
+ private static boolean isProvStatusInactive(VirtualControlLoopEvent event) {
Map<String, String> aai = event.getAai();
return !(PROV_STATUS_ACTIVE.equals(aai.getOrDefault(VSERVER_PROV_STATUS, PROV_STATUS_ACTIVE))
&& PROV_STATUS_ACTIVE.equals(aai.getOrDefault(GENERIC_VNF_PROV_STATUS, PROV_STATUS_ACTIVE)));
@@ -541,7 +541,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable {
* @return the boolean value represented by the field value, or {@code false} if the
* value is {@code null}
*/
- protected static boolean isAaiTrue(String aaiValue) {
+ private static boolean isAaiTrue(String aaiValue) {
return (aaiValue != null && TRUE_VALUES.contains(aaiValue.toLowerCase()));
}