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/ControlLoopOperationManager2.java23
-rw-r--r--controlloop/common/eventmanager/src/test/resources/eventService/event-svc-guard-disabled.properties3
-rw-r--r--controlloop/common/eventmanager/src/test/resources/eventService/event-svc-invalid-db.properties3
-rw-r--r--controlloop/common/eventmanager/src/test/resources/eventService/event-svc-with-db.properties3
4 files changed, 30 insertions, 2 deletions
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager2.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager2.java
index b880fd190..156dad7e6 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager2.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager2.java
@@ -107,6 +107,13 @@ public class ControlLoopOperationManager2 implements Serializable {
private final Deque<Operation> operationHistory = new ConcurrentLinkedDeque<>();
/**
+ * Set to {@code true} to prevent the last item in {@link #operationHistory} from
+ * being included in the outcome of {@link #getHistory()}. Used when the operation
+ * aborts prematurely due to lock-denied, guard-denied, etc.
+ */
+ private boolean holdLast = false;
+
+ /**
* Queue of outcomes yet to be processed. Outcomes are added to this each time the
* "start" or "complete" callback is invoked.
*/
@@ -417,6 +424,7 @@ public class ControlLoopOperationManager2 implements Serializable {
case LOCK_LOST:
case GUARD_DENIED:
case CONTROL_LOOP_TIMEOUT:
+ holdLast = false;
return false;
default:
break;
@@ -541,8 +549,16 @@ public class ControlLoopOperationManager2 implements Serializable {
* @return the list of control loop operations
*/
public List<ControlLoopOperation> getHistory() {
- return operationHistory.stream().map(Operation::getClOperation).map(ControlLoopOperation::new)
- .collect(Collectors.toList());
+ Operation last = (holdLast ? operationHistory.removeLast() : null);
+
+ List<ControlLoopOperation> result = operationHistory.stream().map(Operation::getClOperation)
+ .map(ControlLoopOperation::new).collect(Collectors.toList());
+
+ if (last != null) {
+ operationHistory.add(last);
+ }
+
+ return result;
}
/**
@@ -553,6 +569,9 @@ public class ControlLoopOperationManager2 implements Serializable {
* @param message message to put into the DB
*/
private void storeFailureInDataBase(OperationOutcome outcome, PolicyResult result, String message) {
+ // don't include this in history yet
+ holdLast = true;
+
outcome.setActor(actor);
outcome.setOperation(operation);
outcome.setMessage(message);
diff --git a/controlloop/common/eventmanager/src/test/resources/eventService/event-svc-guard-disabled.properties b/controlloop/common/eventmanager/src/test/resources/eventService/event-svc-guard-disabled.properties
index 65f6c0cc1..289de44eb 100644
--- a/controlloop/common/eventmanager/src/test/resources/eventService/event-svc-guard-disabled.properties
+++ b/controlloop/common/eventmanager/src/test/resources/eventService/event-svc-guard-disabled.properties
@@ -20,4 +20,7 @@
actor.service.GUARD.disabled=true
actor.service.GUARD.clientName=guard-client
+actor.service.GUARD.onapName=my-onap-name
+actor.service.GUARD.onapComponent=my-onap-component
+actor.service.GUARD.onapInstance=my-onap-instance
actor.service.GUARD.operations.Decision.path=decide
diff --git a/controlloop/common/eventmanager/src/test/resources/eventService/event-svc-invalid-db.properties b/controlloop/common/eventmanager/src/test/resources/eventService/event-svc-invalid-db.properties
index 59b0615b0..09a6fbb31 100644
--- a/controlloop/common/eventmanager/src/test/resources/eventService/event-svc-invalid-db.properties
+++ b/controlloop/common/eventmanager/src/test/resources/eventService/event-svc-invalid-db.properties
@@ -20,6 +20,9 @@
#actor.service.GUARD.disabled=true
actor.service.GUARD.clientName=guard-client
+actor.service.GUARD.onapName=my-onap-name
+actor.service.GUARD.onapComponent=my-onap-component
+actor.service.GUARD.onapInstance=my-onap-instance
actor.service.GUARD.operations.Decision.path=decide
# purposely missing the URL
diff --git a/controlloop/common/eventmanager/src/test/resources/eventService/event-svc-with-db.properties b/controlloop/common/eventmanager/src/test/resources/eventService/event-svc-with-db.properties
index 6e003f6d6..0fd886b46 100644
--- a/controlloop/common/eventmanager/src/test/resources/eventService/event-svc-with-db.properties
+++ b/controlloop/common/eventmanager/src/test/resources/eventService/event-svc-with-db.properties
@@ -20,6 +20,9 @@
#actor.service.GUARD.disabled=true
actor.service.GUARD.clientName=guard-client
+actor.service.GUARD.onapName=my-onap-name
+actor.service.GUARD.onapComponent=my-onap-component
+actor.service.GUARD.onapInstance=my-onap-instance
actor.service.GUARD.operations.Decision.path=decide
operation.history.url=jdbc:h2:mem:EventManagerServicesTest