summaryrefslogtreecommitdiffstats
path: root/controlloop/common/eventmanager/src/main/java
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/common/eventmanager/src/main/java')
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager2.java14
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager2.java21
2 files changed, 27 insertions, 8 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 dc2b513a6..f2e99a9ad 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
@@ -25,6 +25,7 @@ import static org.onap.policy.controlloop.ControlLoopTargetType.VM;
import static org.onap.policy.controlloop.ControlLoopTargetType.VNF;
import java.io.Serializable;
+import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Map;
@@ -268,11 +269,11 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable {
} catch (ControlLoopException | RuntimeException e) {
// processor problem - this is fatal
logger.warn("{}: cannot start next step for {}", closedLoopControlName, requestId, e);
+ finalResult = FinalResult.FINAL_FAILURE_EXCEPTION;
notification = makeNotification();
notification.setNotification(ControlLoopNotificationType.FINAL_FAILURE);
notification.setMessage("Policy processing aborted due to policy error");
notification.setHistory(controlLoopHistory);
- finalResult = FinalResult.FINAL_FAILURE_EXCEPTION;
}
}
@@ -301,8 +302,6 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable {
VirtualControlLoopEvent event = context.getEvent();
- notification.setHistory(operation.getHistory());
-
switch (operation.getState()) {
case LOCK_DENIED:
notification.setNotification(ControlLoopNotificationType.REJECTED);
@@ -327,6 +326,11 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable {
notification.setMessage("Guard result for " + operation.getActor() + " " + operation.getOperation()
+ " is Deny");
break;
+ case OPERATION_STARTED:
+ notification.setNotification(ControlLoopNotificationType.OPERATION);
+ notification.setMessage(operation.getOperationMessage());
+ notification.setHistory(Collections.emptyList());
+ break;
case OPERATION_SUCCESS:
notification.setNotification(ControlLoopNotificationType.OPERATION_SUCCESS);
break;
@@ -375,7 +379,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable {
* @return a new notification
*/
public VirtualControlLoopNotification makeNotification() {
- VirtualControlLoopNotification notif = new VirtualControlLoopNotification();
+ VirtualControlLoopNotification notif = new VirtualControlLoopNotification(context.getEvent());
notif.setNotification(ControlLoopNotificationType.OPERATION);
notif.setFrom("policy");
notif.setPolicyScope(policyScope);
@@ -384,7 +388,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable {
if (finalResult == null) {
ControlLoopOperationManager2 oper = currentOperation.get();
if (oper != null) {
- notif.setMessage(oper.getOperationMessage());
+ notif.setMessage(oper.getOperationHistory());
notif.setHistory(oper.getHistory());
}
}
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 6bdaa1575..b880fd190 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
@@ -76,6 +76,7 @@ public class ControlLoopOperationManager2 implements Serializable {
GUARD_STARTED,
GUARD_PERMITTED,
GUARD_DENIED,
+ OPERATION_STARTED,
OPERATION_SUCCESS,
OPERATION_FAILURE,
CONTROL_LOOP_TIMEOUT
@@ -197,6 +198,7 @@ public class ControlLoopOperationManager2 implements Serializable {
attempt = ControlLoopOperationManager2.this.attempts;
policyResult = outcome.getResult();
clOperation = outcome.toControlLoopOperation();
+ clOperation.setTarget(policy.getTarget().toString());
}
}
@@ -356,7 +358,7 @@ public class ControlLoopOperationManager2 implements Serializable {
* @param outcome outcome provided to the callback
*/
private void onStart(OperationOutcome outcome) {
- if (GUARD_ACTOR.equals(outcome.getActor())) {
+ if (outcome.isFor(actor, operation) || GUARD_ACTOR.equals(outcome.getActor())) {
addOutcome(outcome);
}
}
@@ -477,10 +479,23 @@ public class ControlLoopOperationManager2 implements Serializable {
break;
default:
- // operation completed
- ++attempts;
+ if (outcome.getEnd() == null) {
+ // operation started
+ ++attempts;
+ state = State.OPERATION_STARTED;
+ operationHistory.add(new Operation(outcome));
+ break;
+ }
+
+ /*
+ * Operation completed. If the last entry was a "start" (i.e., "end" field
+ * is null), then replace it. Otherwise, just add the completion.
+ */
state = (outcome.getResult() == PolicyResult.SUCCESS ? State.OPERATION_SUCCESS
: State.OPERATION_FAILURE);
+ if (!operationHistory.isEmpty() && operationHistory.peekLast().getClOperation().getEnd() == null) {
+ operationHistory.removeLast();
+ }
operationHistory.add(new Operation(outcome));
storeOperationInDataBase();
break;