From dc272e0912390292fa09e84d56380ac3697250cd Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Wed, 8 Apr 2020 14:40:37 -0400 Subject: Add SDNR notifications to frankfurt rules Issue-ID: POLICY-2468 Change-Id: Ibf4d3e5f62fa3106028dcf85050c270b8eab0a89 Signed-off-by: Jim Hahn --- .../controller-frankfurt/src/main/resources/frankfurt.drl | 14 ++++++++++++++ .../src/test/resources/config/event-manager.properties | 2 +- .../test/resources/config/frankfurt-controller.properties | 5 ++++- .../controlloop/eventmanager/ControlLoopEventManager2.java | 6 ++++++ .../eventmanager/ControlLoopOperationManager2.java | 10 ++++++++++ .../src/main/feature/config/event-manager.properties | 2 +- 6 files changed, 36 insertions(+), 3 deletions(-) (limited to 'controlloop/common') diff --git a/controlloop/common/controller-frankfurt/src/main/resources/frankfurt.drl b/controlloop/common/controller-frankfurt/src/main/resources/frankfurt.drl index 00c4f5f10..f54786da9 100644 --- a/controlloop/common/controller-frankfurt/src/main/resources/frankfurt.drl +++ b/controlloop/common/controller-frankfurt/src/main/resources/frankfurt.drl @@ -243,6 +243,20 @@ rule "EVENT.MANAGER.PROCESSING" $manager, e); } // + // Generate Response notification + // + try { + ControlLoopResponse clResponse = $manager.getControlLoopResponse(); + if (clResponse != null) { + PolicyEngineConstants.getManager().deliver("DCAE_CL_RSP", clResponse); + } + + } catch(RuntimeException e) { + logger.warn("{}: {}.{}: manager={} exception generating Response notification", + $manager.getClosedLoopControlName(), $manager.getPolicyName(), drools.getRule().getName(), + $manager, e); + } + // // Discard this message and wait for the next response. // $manager.nextStep(); diff --git a/controlloop/common/controller-frankfurt/src/test/resources/config/event-manager.properties b/controlloop/common/controller-frankfurt/src/test/resources/config/event-manager.properties index e5bd83c92..384346e84 100644 --- a/controlloop/common/controller-frankfurt/src/test/resources/config/event-manager.properties +++ b/controlloop/common/controller-frankfurt/src/test/resources/config/event-manager.properties @@ -67,7 +67,7 @@ actor.service.SDNC.operations.Reroute.path=\ actor.service.SDNR.sinkTopic=SDNR-CL actor.service.SDNR.sourceTopic=SDNR-CL-RSP -actor.service.SDNR.operations.ModifyConfig.placeholder= +actor.service.SDNR.operations.any.placeholder= actor.service.SO.clientName=SO actor.service.SO.pathGet=orchestrationRequests/v5/ diff --git a/controlloop/common/controller-frankfurt/src/test/resources/config/frankfurt-controller.properties b/controlloop/common/controller-frankfurt/src/test/resources/config/frankfurt-controller.properties index 8ed43c492..2839e0d2e 100644 --- a/controlloop/common/controller-frankfurt/src/test/resources/config/frankfurt-controller.properties +++ b/controlloop/common/controller-frankfurt/src/test/resources/config/frankfurt-controller.properties @@ -53,10 +53,13 @@ noop.source.topics.POLICY-CL-MGT.events.custom.gson=org.onap.policy.controlloop. noop.source.topics.APPC-LCM-READ.events=org.onap.policy.appclcm.AppcLcmDmaapWrapper noop.source.topics.APPC-LCM-READ.events.custom.gson=org.onap.policy.appclcm.util.Serialization,gson -noop.sink.topics=APPC-CL,APPC-LCM-READ,POLICY-CL-MGT,SDNR-CL +noop.sink.topics=APPC-CL,APPC-LCM-READ,POLICY-CL-MGT,SDNR-CL,DCAE_CL_RSP noop.sink.topics.POLICY-CL-MGT.events=org.onap.policy.controlloop.VirtualControlLoopNotification noop.sink.topics.POLICY-CL-MGT.events.custom.gson=org.onap.policy.controlloop.util.Serialization,gsonPretty noop.sink.topics.SDNR-CL.events=org.onap.policy.sdnr.PciRequestWrapper noop.sink.topics.SDNR-CL.events.custom.gson=org.onap.policy.sdnr.util.Serialization,gson + +noop.sink.topics.DCAE_CL_RSP.events=org.onap.policy.controlloop.ControlLoopResponse +noop.sink.topics.DCAE_CL_RSP.events.custom.gson=org.onap.policy.controlloop.util.Serialization,gsonPretty 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 cc54b73be..c79737ae6 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 @@ -49,6 +49,7 @@ import org.onap.policy.controlloop.ControlLoopEventStatus; import org.onap.policy.controlloop.ControlLoopException; import org.onap.policy.controlloop.ControlLoopNotificationType; import org.onap.policy.controlloop.ControlLoopOperation; +import org.onap.policy.controlloop.ControlLoopResponse; import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.VirtualControlLoopNotification; import org.onap.policy.controlloop.actorserviceprovider.ActorService; @@ -146,6 +147,8 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable { @Getter private VirtualControlLoopNotification notification; + @Getter + private ControlLoopResponse controlLoopResponse; @Getter private boolean updated = false; @@ -225,6 +228,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable { logger.info("final={} oper state={} for {}", finalResult, currentOperation.get().getState(), requestId); + controlLoopResponse = null; notification = makeNotification(); notification.setHistory(controlLoopHistory); @@ -268,6 +272,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable { // processor problem - this is fatal logger.warn("{}: cannot start next step for {}", closedLoopControlName, requestId, e); finalResult = FinalResult.FINAL_FAILURE_EXCEPTION; + controlLoopResponse = null; notification = makeNotification(); notification.setNotification(ControlLoopNotificationType.FINAL_FAILURE); notification.setMessage("Policy processing aborted due to policy error"); @@ -296,6 +301,7 @@ public class ControlLoopEventManager2 implements ManagerContext, Serializable { return; } + controlLoopResponse = operation.getControlLoopResponse(); notification = makeNotification(); VirtualControlLoopEvent event = context.getEvent(); 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 a096522bc..9d7ca586c 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 @@ -41,6 +41,7 @@ import lombok.ToString; import org.onap.policy.aai.AaiConstants; import org.onap.policy.aai.AaiCqResponse; import org.onap.policy.controlloop.ControlLoopOperation; +import org.onap.policy.controlloop.ControlLoopResponse; import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome; import org.onap.policy.controlloop.actorserviceprovider.controlloop.ControlLoopEventContext; import org.onap.policy.controlloop.actorserviceprovider.parameters.ControlLoopOperationParams; @@ -137,6 +138,9 @@ public class ControlLoopOperationManager2 implements Serializable { private final transient ControlLoopOperationParams params; private final transient PipelineUtil taskUtil; + @Getter + private ControlLoopResponse controlLoopResponse; + /** * Time when the lock was first requested. */ @@ -195,6 +199,7 @@ public class ControlLoopOperationManager2 implements Serializable { private int attempt; private PolicyResult policyResult; private ControlLoopOperation clOperation; + private ControlLoopResponse clResponse; /** * Constructs the object. @@ -206,6 +211,7 @@ public class ControlLoopOperationManager2 implements Serializable { policyResult = outcome.getResult(); clOperation = outcome.toControlLoopOperation(); clOperation.setTarget(policy.getTarget().toString()); + clResponse = outcome.getControlLoopResponse(); } } @@ -437,6 +443,7 @@ public class ControlLoopOperationManager2 implements Serializable { } if (outcome.isFinalOutcome() && outcome.isFor(actor, operation)) { + controlLoopResponse = null; return false; } @@ -458,6 +465,8 @@ public class ControlLoopOperationManager2 implements Serializable { OperationOutcome outcome = outcomes.peek(); logger.debug("process outcome={} for {}", outcome, requestId); + controlLoopResponse = null; + switch (outcome.getActor()) { case CL_TIMEOUT_ACTOR: @@ -501,6 +510,7 @@ public class ControlLoopOperationManager2 implements Serializable { */ state = (outcome.getResult() == PolicyResult.SUCCESS ? State.OPERATION_SUCCESS : State.OPERATION_FAILURE); + controlLoopResponse = outcome.getControlLoopResponse(); if (!operationHistory.isEmpty() && operationHistory.peekLast().getClOperation().getEnd() == null) { operationHistory.removeLast(); } diff --git a/controlloop/common/feature-controlloop-management/src/main/feature/config/event-manager.properties b/controlloop/common/feature-controlloop-management/src/main/feature/config/event-manager.properties index 6f925314e..8d770d717 100644 --- a/controlloop/common/feature-controlloop-management/src/main/feature/config/event-manager.properties +++ b/controlloop/common/feature-controlloop-management/src/main/feature/config/event-manager.properties @@ -68,7 +68,7 @@ actor.service.SDNC.operations.Reroute.path=\ actor.service.SDNR.sinkTopic=SDNR-CL actor.service.SDNR.sourceTopic=SDNR-CL-RSP -actor.service.SDNR.operations.ModifyConfig.placeholder= +actor.service.SDNR.operations.any.placeholder= actor.service.SO.clientName=SO actor.service.SO.pathGet=orchestrationRequests/v5/ -- cgit 1.2.3-korg