diff options
Diffstat (limited to 'controlloop/common/eventmanager/src')
-rw-r--r-- | controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java | 59 |
1 files changed, 58 insertions, 1 deletions
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java index f1d912ef5..1ad1e5af7 100644 --- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java +++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopOperationManager.java @@ -26,8 +26,8 @@ import java.time.Instant; import java.util.AbstractMap; import java.util.LinkedList; import java.util.List; -import java.util.Properties; import java.util.NoSuchElementException; +import java.util.Properties; import javax.persistence.EntityManager; import javax.persistence.Persistence; @@ -43,12 +43,14 @@ import org.onap.policy.controlloop.ControlLoopOperation; import org.onap.policy.controlloop.VirtualControlLoopEvent; import org.onap.policy.controlloop.actor.appc.APPCActorServiceProvider; import org.onap.policy.controlloop.actor.appclcm.AppcLcmActorServiceProvider; +import org.onap.policy.controlloop.actor.sdnr.SdnrActorServiceProvider; import org.onap.policy.controlloop.actor.so.SOActorServiceProvider; import org.onap.policy.controlloop.actor.vfc.VFCActorServiceProvider; import org.onap.policy.controlloop.policy.Policy; import org.onap.policy.controlloop.policy.PolicyResult; import org.onap.policy.drools.system.PolicyEngine; import org.onap.policy.guard.Util; +import org.onap.policy.sdnr.PciResponseWrapper; import org.onap.policy.so.SOResponseWrapper; import org.onap.policy.vfc.VFCResponse; import org.slf4j.Logger; @@ -214,6 +216,8 @@ public class ControlLoopOperationManager implements Serializable { break; case "SO": break; + case "SDNR": + break; case "VFC": break; default: @@ -284,6 +288,21 @@ public class ControlLoopOperationManager implements Serializable { this.policyResult = PolicyResult.FAILURE; } return operationRequest; + case "SDNR": + /* + * If the recipe is ModifyConfig, a SDNR request is constructed. + */ + this.currentOperation = operation; + this.operationRequest = SdnrActorServiceProvider.constructRequest((VirtualControlLoopEvent) onset, + operation.clOperation, this.policy); + // + // Save the operation + // + if (this.operationRequest == null) { + this.policyResult = PolicyResult.FAILURE; + } + + return operationRequest; default: throw new ControlLoopException("invalid actor " + policy.getActor() + " on policy"); } @@ -309,6 +328,11 @@ public class ControlLoopOperationManager implements Serializable { // Cast LCM response and handle it // return onResponse((LcmResponseWrapper) response); + } else if (response instanceof PciResponseWrapper) { + // + // Cast SDNR response and handle it + // + return onResponse((PciResponseWrapper) response); } else if (response instanceof SOResponseWrapper) { // // Cast SO response and handle it @@ -451,6 +475,39 @@ public class ControlLoopOperationManager implements Serializable { } /** + * This method handles operation responses from SDNR. + * + * @param dmaapResponse the SDNR response + * @return the result of the response handling + */ + private PolicyResult onResponse(PciResponseWrapper dmaapResponse) { + /* + * Parse out the operation attempt using the subrequestid + */ + Integer operationAttempt = SdnrActorServiceProvider + .parseOperationAttempt(dmaapResponse.getBody().getCommonHeader().getSubRequestId()); + if (operationAttempt == null) { + this.completeOperation(operationAttempt, "Policy was unable to parse SDNR SubRequestID.", + PolicyResult.FAILURE_EXCEPTION); + } + + /* + * Process the SDNR response to see what PolicyResult should be returned + */ + SdnrActorServiceProvider.Pair<PolicyResult, String> result = + SdnrActorServiceProvider.processResponse(dmaapResponse); + + if (result.getResult() != null) { + this.completeOperation(operationAttempt, result.getMessage(), result.getResult()); + if (PolicyResult.FAILURE_TIMEOUT.equals(this.policyResult)) { + return null; + } + return result.getResult(); + } + return null; + } + + /** * This method handles operation responses from SO. * * @param msoResponse the SO response |