aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop
diff options
context:
space:
mode:
authorJim Hahn <jrh3@att.com>2018-07-10 16:29:13 -0400
committerJim Hahn <jrh3@att.com>2018-07-11 12:14:00 -0400
commit26e713754fa52b03b0d0fd246b59db3188dd36a6 (patch)
tree3b841cc53d51b96f54ab060ac5050a77f13f6f84 /controlloop
parent865dd094c03a145dc0588534263d1a62fef809eb (diff)
Catch exception from missing property in operation
When a new operation is started it will throw an IllegalArgumentException if a property is missing. Modified the rules to catch this exception, indicate the failure, and move on to the next operation. Modified code to catch generic exception. Change-Id: Ie8c24371eb84ee55ff0a0a5fcacda3670483efc5 Issue-ID: POLICY-869 Signed-off-by: Jim Hahn <jrh3@att.com>
Diffstat (limited to 'controlloop')
-rw-r--r--controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl150
1 files changed, 84 insertions, 66 deletions
diff --git a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
index 888d2b6e5..71715c075 100644
--- a/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
+++ b/controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
@@ -521,15 +521,97 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
Object request = null;
boolean caughtException = false;
+
try {
request = $operation.startOperation($event);
- }
- catch (ControlLoopException e) {
+
+ if (request != null) {
+ logger.debug("{}: {}: starting operation ..",
+ $params.getClosedLoopControlName(), drools.getRule().getName());
+ //
+ // Tell interested parties we are performing this Operation
+ //
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.setNotification(ControlLoopNotificationType.OPERATION);
+ notification.setMessage($operation.getOperationMessage());
+ notification.setHistory($operation.getHistory());
+ notification.setFrom("policy");
+ notification.setPolicyName(drools.getRule().getName());
+ notification.setPolicyScope("${policyScope}");
+ notification.setPolicyVersion("${policyVersion}");
+
+ PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+
+ switch ($operation.policy.getActor()){
+
+ case "APPC":
+
+ if (request instanceof Request) {
+ PolicyEngine.manager.deliver("APPC-CL", request);
+ }
+ else if (request instanceof LcmRequestWrapper) {
+ PolicyEngine.manager.deliver("APPC-LCM-READ", request);
+ }
+ break;
+ case "SO":
+ // at this point the AAI named query request should have already been made, the response recieved and used
+ // in the construction of the SO Request which is stored in operationRequest
+
+ if(request instanceof SORequest) {
+ // Call SO. The response will be inserted into memory once it's received
+ SOActorServiceProvider.sendRequest($event.getRequestId().toString(), drools.getWorkingMemory(), request);
+ }
+ break;
+ case "VFC":
+ if (request instanceof VFCRequest) {
+ // Start VFC thread
+ Thread t = new Thread(new VFCManager(drools.getWorkingMemory(), (VFCRequest)request));
+ t.start();
+ }
+ break;
+ }
+ } else {
+ //
+ // What happens if its null?
+ //
+ logger.warn("{}: {}: unexpected null operation request",
+ $params.getClosedLoopControlName(),
+ drools.getRule().getName());
+ if ("SO".equals($operation.policy.getActor())) {
+ retract($opTimer);
+ retract($operation);
+ modify($manager) {finishOperation($operation)};
+ }
+ else if ("vfc".equalsIgnoreCase($operation.policy.getActor())) {
+ retract($opTimer);
+ retract($operation);
+ modify($manager) {finishOperation($operation)};
+ }
+ }
+
+ } catch (Exception e) {
String msg = e.getMessage();
logger.warn("{}: {}: operation={}: AAI failure: {}",
$params.getClosedLoopControlName(), drools.getRule().getName(),
$operation, msg, e);
$operation.setOperationHasException(msg);
+
+ if(request != null) {
+ //
+ // Create a notification for it ("DB Write - end operation")
+ //
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.setFrom("policy");
+ notification.setPolicyName(drools.getRule().getName());
+ notification.setPolicyScope("${policyScope}");
+ notification.setPolicyVersion("${policyVersion}");
+ notification.setNotification(ControlLoopNotificationType.OPERATION_FAILURE);
+ notification.setMessage($operation.getOperationHistory());
+ notification.setHistory($operation.getHistory());
+
+ PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+ }
+
retract($opTimer);
retract($operation);
caughtException = true;
@@ -539,70 +621,6 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
if (caughtException) {
modify($manager) {finishOperation($operation)};
}
- else if (request != null) {
- logger.debug("{}: {}: starting operation ..",
- $params.getClosedLoopControlName(), drools.getRule().getName());
- //
- // Tell interested parties we are performing this Operation
- //
- VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
- notification.setNotification(ControlLoopNotificationType.OPERATION);
- notification.setMessage($operation.getOperationMessage());
- notification.setHistory($operation.getHistory());
- notification.setFrom("policy");
- notification.setPolicyName(drools.getRule().getName());
- notification.setPolicyScope("${policyScope}");
- notification.setPolicyVersion("${policyVersion}");
-
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
-
- switch ($operation.policy.getActor()){
-
- case "APPC":
-
- if (request instanceof Request) {
- PolicyEngine.manager.deliver("APPC-CL", request);
- }
- else if (request instanceof LcmRequestWrapper) {
- PolicyEngine.manager.deliver("APPC-LCM-READ", request);
- }
- break;
- case "SO":
- // at this point the AAI named query request should have already been made, the response recieved and used
- // in the construction of the SO Request which is stored in operationRequest
-
- if(request instanceof SORequest) {
- // Call SO. The response will be inserted into memory once it's received
- SOActorServiceProvider.sendRequest($event.getRequestId().toString(), drools.getWorkingMemory(), request);
- }
- break;
- case "VFC":
- if (request instanceof VFCRequest) {
- // Start VFC thread
- Thread t = new Thread(new VFCManager(drools.getWorkingMemory(), (VFCRequest)request));
- t.start();
- }
- break;
- }
- } else {
- //
- // What happens if its null?
- //
- logger.warn("{}: {}: unexpected null operation request",
- $params.getClosedLoopControlName(),
- drools.getRule().getName());
- if ("SO".equals($operation.policy.getActor())) {
- retract($opTimer);
- retract($operation);
- modify($manager) {finishOperation($operation)};
- }
- else if ("vfc".equalsIgnoreCase($operation.policy.getActor())) {
- retract($opTimer);
- retract($operation);
- modify($manager) {finishOperation($operation)};
- }
-
- }
end