summaryrefslogtreecommitdiffstats
path: root/controlloop/common/eventmanager
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/common/eventmanager')
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java13
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java2
2 files changed, 13 insertions, 2 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 bc9d3df79..5f36bcc20 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
@@ -60,6 +60,12 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
private static final String GENERIC_VNF_IS_CLOSED_LOOP_DISABLED = "generic-vnf.is-closed-loop-disabled";
private static final String VSERVER_IS_CLOSED_LOOP_DISABLED = "vserver.is-closed-loop-disabled";
+ /**
+ * Additional time, in seconds, to add to a "lock" request. This ensures that the lock
+ * won't expire right before an operation completes.
+ */
+ private static final int ADDITIONAL_LOCK_SEC = 60;
+
private static final Logger logger = LoggerFactory.getLogger(ControlLoopEventManager.class);
private static final long serialVersionUID = -1216568161322872641L;
@@ -447,14 +453,17 @@ public class ControlLoopEventManager implements LockCallback, Serializable {
// TODO: Make sure the current lock is for the same target.
// Currently, it should be. But in the future it may not.
//
- return new LockResult<>(GuardResult.LOCK_ACQUIRED, this.targetLock);
+ GuardResult result = PolicyGuard.lockTarget(targetLock,
+ this.currentOperation.getOperationTimeout() + ADDITIONAL_LOCK_SEC);
+ return new LockResult<>(result, this.targetLock);
} else {
//
// Ask the Guard
//
LockResult<GuardResult, TargetLock> lockResult =
PolicyGuard.lockTarget(this.currentOperation.policy.getTarget().getType(),
- this.currentOperation.getTargetEntity(), this.onset.getRequestId(), this);
+ this.currentOperation.getTargetEntity(), this.onset.getRequestId(), this,
+ this.currentOperation.getOperationTimeout() + ADDITIONAL_LOCK_SEC);
//
// Was it acquired?
//
diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java
index 182791d22..1af4a312d 100644
--- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java
+++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java
@@ -755,9 +755,11 @@ public class ControlLoopEventManagerTest {
LockResult<GuardResult, TargetLock> lockLock = manager.lockCurrentOperation();
assertNotNull(lockLock);
+ assertEquals(GuardResult.LOCK_ACQUIRED, lockLock.getA());
LockResult<GuardResult, TargetLock> lockLockAgain = manager.lockCurrentOperation();
assertNotNull(lockLockAgain);
+ assertEquals(GuardResult.LOCK_ACQUIRED, lockLockAgain.getA());
assertEquals(lockLock.getB(), lockLockAgain.getB());
assertEquals(lockLock.getB(), manager.unlockCurrentOperation());