aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop/common/eventmanager/src
diff options
context:
space:
mode:
authorJoshua Reich <jreich@research.att.com>2018-09-13 14:24:43 -0700
committerJoshua Reich <jreich@research.att.com>2018-09-14 12:13:23 -0700
commit910dc65cba60b0dafe975b88d69df6559dee7abb (patch)
tree69cae99ac556f1b81a1bef7e284c46d340a33b8d /controlloop/common/eventmanager/src
parent97956f188f4a8d92d734bf491d5e15a78a03459f (diff)
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 <jreich@research.att.com>
Diffstat (limited to 'controlloop/common/eventmanager/src')
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java29
1 files changed, 26 insertions, 3 deletions
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<GuardResult, TargetLock> 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;