From 910dc65cba60b0dafe975b88d69df6559dee7abb Mon Sep 17 00:00:00 2001 From: Joshua Reich Date: Thu, 13 Sep 2018 14:24:43 -0700 Subject: Option to disable target locking. Needed by CLC. When used, the ControlLoopEventManager will set useTargetLock to false converting TargetLock lock/unlock operations to no-ops. Allows CLC-specified logic to coordinate closed loops instead of hard-coded mutual-exclusion enforced by target locking. Change-Id: Ic067c1e1ce47b12d12742ed4bc04d59aa42751d6 Issue-ID: POLICY-953 Signed-off-by: Joshua Reich --- .../eventmanager/ControlLoopEventManager.java | 29 +++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) (limited to 'controlloop/common/eventmanager') diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java index 8641ddc27..bd1904904 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java @@ -104,6 +104,7 @@ public class ControlLoopEventManager implements LockCallback, Serializable { private TargetLock targetLock = null; private AaiGetVnfResponse vnfResponse = null; private AaiGetVserverResponse vserverResponse = null; + private boolean useTargetLock = true; /** * Wrapper for AAI vserver named-query response. This is initialized in a lazy @@ -161,6 +162,14 @@ public class ControlLoopEventManager implements LockCallback, Serializable { this.isActivated = isActivated; } + public boolean useTargetLock() { + return useTargetLock(); + } + + public void setUseTargetLock(boolean useTargetLock) { + this.useTargetLock = useTargetLock; + } + public VirtualControlLoopEvent getOnsetEvent() { return this.onset; } @@ -268,7 +277,6 @@ public class ControlLoopEventManager implements LockCallback, Serializable { // Parse the YAML specification // this.processor = new ControlLoopProcessor(yamlSpecification); - // // At this point we are good to go with this event // @@ -480,6 +488,17 @@ public class ControlLoopEventManager implements LockCallback, Serializable { throw new ControlLoopException("Do not have a current operation."); } // + // Not using target locks? Create and return a lock w/o actually locking. + // + if (!this.useTargetLock) { + TargetLock lock = PolicyGuard.createTargetLock(this.currentOperation.policy.getTarget().getType(), + this.currentOperation.getTargetEntity(), + this.onset.getRequestId(), this); + this.targetLock = lock; + LockResult lockResult = LockResult.createLockResult(GuardResult.LOCK_ACQUIRED, lock); + return lockResult; + } + // // Have we acquired it already? // if (this.targetLock != null) { @@ -523,8 +542,12 @@ public class ControlLoopEventManager implements LockCallback, Serializable { TargetLock returnLock = this.targetLock; this.targetLock = null; - - PolicyGuard.unlockTarget(returnLock); + // + // if using target locking unlock before returning + // + if (this.useTargetLock) { + PolicyGuard.unlockTarget(returnLock); + } // always return the old target lock so rules can retract it return returnLock; -- cgit 1.2.3-korg