summaryrefslogtreecommitdiffstats
path: root/controlloop/templates
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop/templates')
-rw-r--r--controlloop/templates/archetype-cl-amsterdam/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl591
-rw-r--r--controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl144
-rw-r--r--controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/CallGuardTaskEmbedded.java11
-rw-r--r--controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelperEmbedded.java20
-rw-r--r--controlloop/templates/template.demo.clc/src/main/resources/__closedLoopControlName__.drl9
-rw-r--r--controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/ControlLoopCoordinationTest.java5
-rw-r--r--controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/Util.java7
7 files changed, 434 insertions, 353 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 87a477406..9a1a29239 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
@@ -31,7 +31,7 @@ import org.onap.policy.controlloop.policy.Policy;
import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager;
import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager.NEW_EVENT_STATUS;
import org.onap.policy.controlloop.eventmanager.ControlLoopOperationManager;
-import org.onap.policy.controlloop.actor.so.SOActorServiceProvider;
+import org.onap.policy.controlloop.actor.so.SoActorServiceProvider;
import org.onap.policy.aai.AaiNqResponseWrapper;
import org.onap.policy.appc.Request;
import org.onap.policy.appc.Response;
@@ -128,7 +128,8 @@ end
rule "${policyName}.SETUP"
salience 1
when
- not( Params( getClosedLoopControlName() == "${closedLoopControlName}", getControlLoopYaml() == "${controlLoopYaml}" ) )
+ not( Params( getClosedLoopControlName() == "${closedLoopControlName}",
+ getControlLoopYaml() == "${controlLoopYaml}" ) )
then
Params params = new Params();
@@ -140,7 +141,8 @@ rule "${policyName}.SETUP"
// hence explicitly getting the logger vs using a global
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
- logger.info("{}: {} : YAML=[{}]", params.getClosedLoopControlName(), drools.getRule().getName(), params.getControlLoopYaml());
+ logger.info("{}: {} : YAML=[{}]", params.getClosedLoopControlName(), drools.getRule().getName(),
+ params.getControlLoopYaml());
end
/*
@@ -153,7 +155,8 @@ rule "${policyName}.EVENT"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() )
- not ( ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() ) )
+ not ( ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId() ) )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -185,14 +188,16 @@ rule "${policyName}.EVENT"
//
retract($event);
} else if ($event.getClosedLoopEventStatus() != ControlLoopEventStatus.ONSET) {
- throw new ControlLoopException($event.getClosedLoopEventStatus() + " received with no prior onset");
+ throw new ControlLoopException($event.getClosedLoopEventStatus() + " received with no prior onset");
} else {
//
// Create an EventManager
//
- ControlLoopEventManager manager = new ControlLoopEventManager($params.getClosedLoopControlName(), $event.getRequestId());
+ ControlLoopEventManager manager = new ControlLoopEventManager($params.getClosedLoopControlName(),
+ $event.getRequestId());
//
- // Determine if EventManager can actively process the event (i.e. syntax, is_closed_loop_disabled checks etc.)
+ // Determine if EventManager can actively process the event
+ // (i.e. syntax, is_closed_loop_disabled checks etc.)
//
VirtualControlLoopNotification notification = manager.activate($params.getControlLoopYaml(), $event);
notification.setFrom("pdp-0001-controller=controlloop"); // Engine.getInstanceName()
@@ -270,8 +275,10 @@ rule "${policyName}.EVENT.MANAGER"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
- $clTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), timerType == "ClosedLoop", !expired )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId() )
+ $clTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId().toString(), timerType == "ClosedLoop", !expired )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -280,47 +287,47 @@ rule "${policyName}.EVENT.MANAGER"
$event, $manager, $clTimer);
try {
- //
- // Check which event this is.
- //
- ControlLoopEventManager.NEW_EVENT_STATUS eventStatus = $manager.onNewEvent($event);
- //
- // Check what kind of event this is
- //
- if (eventStatus == NEW_EVENT_STATUS.SUBSEQUENT_ONSET) {
- //
- // We don't care about subsequent onsets
- //
- logger.info("{}: {}: subsequent onset",
- $params.getClosedLoopControlName(), drools.getRule().getName());
- retract($event);
- return;
- }
- if (eventStatus == NEW_EVENT_STATUS.SYNTAX_ERROR) {
- //
- // Ignore any bad syntax events
- //
- logger.warn("{}: {}: syntax error",
- $params.getClosedLoopControlName(), drools.getRule().getName());
- retract($event);
- return;
- }
- //
- // We only want the initial ONSET event in memory,
- // all the other events need to be retracted to support
- // cleanup and avoid the other rules being fired for this event.
- //
- if (eventStatus != NEW_EVENT_STATUS.FIRST_ONSET) {
- logger.warn("{}: {}: not first onset",
- $params.getClosedLoopControlName(), drools.getRule().getName());
- retract($event);
- }
-
- logger.debug("{}: {}: target={}", $params.getClosedLoopControlName(),
- drools.getRule().getName(), $event.getTarget());
- //
- // Now start seeing if we need to process this event
- //
+ //
+ // Check which event this is.
+ //
+ ControlLoopEventManager.NEW_EVENT_STATUS eventStatus = $manager.onNewEvent($event);
+ //
+ // Check what kind of event this is
+ //
+ if (eventStatus == NEW_EVENT_STATUS.SUBSEQUENT_ONSET) {
+ //
+ // We don't care about subsequent onsets
+ //
+ logger.info("{}: {}: subsequent onset",
+ $params.getClosedLoopControlName(), drools.getRule().getName());
+ retract($event);
+ return;
+ }
+ if (eventStatus == NEW_EVENT_STATUS.SYNTAX_ERROR) {
+ //
+ // Ignore any bad syntax events
+ //
+ logger.warn("{}: {}: syntax error",
+ $params.getClosedLoopControlName(), drools.getRule().getName());
+ retract($event);
+ return;
+ }
+ //
+ // We only want the initial ONSET event in memory,
+ // all the other events need to be retracted to support
+ // cleanup and avoid the other rules being fired for this event.
+ //
+ if (eventStatus != NEW_EVENT_STATUS.FIRST_ONSET) {
+ logger.warn("{}: {}: not first onset",
+ $params.getClosedLoopControlName(), drools.getRule().getName());
+ retract($event);
+ }
+
+ logger.debug("{}: {}: target={}", $params.getClosedLoopControlName(),
+ drools.getRule().getName(), $event.getTarget());
+ //
+ // Now start seeing if we need to process this event
+ //
//
// Check if this is a Final Event
@@ -426,46 +433,45 @@ rule "${policyName}.EVENT.MANAGER"
$params.getClosedLoopControlName(), drools.getRule().getName(),
result.getB());
if (result.getA().equals(GuardResult.LOCK_ACQUIRED)) {
- //
- // insert the operation into memory
- //
- insert(operation);
-
- //
- // insert operation timeout object
- //
- ControlLoopTimer opTimer = new ControlLoopTimer();
- opTimer.setTimerType("Operation");
- opTimer.setClosedLoopControlName($event.getClosedLoopControlName());
- opTimer.setRequestID($event.getRequestId().toString());
- opTimer.setDelay(operation.getOperationTimeout().toString() + "s");
- insert(opTimer);
+ //
+ // insert the operation into memory
+ //
+ insert(operation);
+ //
+ // insert operation timeout object
+ //
+ ControlLoopTimer opTimer = new ControlLoopTimer();
+ opTimer.setTimerType("Operation");
+ opTimer.setClosedLoopControlName($event.getClosedLoopControlName());
+ opTimer.setRequestID($event.getRequestId().toString());
+ opTimer.setDelay(operation.getOperationTimeout().toString() + "s");
+ insert(opTimer);
- //
- // Insert lock into memory
- //
- insert(result.getB());
- }
- else {
- logger.debug("The target resource {} is already processing",
- $event.getAai().get($event.getTarget()));
- notification = new VirtualControlLoopNotification($event);
- notification.setNotification(ControlLoopNotificationType.REJECTED);
- notification.setMessage("The target " + $event.getAai().get($event.getTarget()) + " is already locked");
- notification.setFrom("policy");
- notification.setPolicyName(drools.getRule().getName());
- notification.setPolicyScope("${policyScope}");
- notification.setPolicyVersion("${policyVersion}");
+ //
+ // Insert lock into memory
+ //
+ insert(result.getB());
+ } else {
+ logger.debug("The target resource {} is already processing",
+ $event.getAai().get($event.getTarget()));
+ notification = new VirtualControlLoopNotification($event);
+ notification.setNotification(ControlLoopNotificationType.REJECTED);
+ notification.setMessage("The target " + $event.getAai().get($event.getTarget())
+ + " is already locked");
+ notification.setFrom("policy");
+ notification.setPolicyName(drools.getRule().getName());
+ notification.setPolicyScope("${policyScope}");
+ notification.setPolicyVersion("${policyVersion}");
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
-
- retract($event);
- retract($manager);
- retract($clTimer);
-
- if(result.getB() != null) {
- retract(result.getB());
- }
+ PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+
+ retract($event);
+ retract($manager);
+ retract($clTimer);
+
+ if (result.getB() != null) {
+ retract(result.getB());
+ }
}
logger.info("{}: {}: starting operation={}",
$params.getClosedLoopControlName(), drools.getRule().getName(),
@@ -479,23 +485,23 @@ rule "${policyName}.EVENT.MANAGER"
}
}
} catch (Exception e) {
- logger.warn("{}: {}: unexpected",
+ logger.warn("{}: {}: unexpected",
$params.getClosedLoopControlName(),
drools.getRule().getName(), e);
- VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
- notification.setNotification(ControlLoopNotificationType.FINAL_FAILURE);
- notification.setMessage(e.getMessage());
- notification.setFrom("policy");
- notification.setPolicyName(drools.getRule().getName());
- notification.setPolicyScope("${policyScope}");
- notification.setPolicyVersion("${policyVersion}");
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.setNotification(ControlLoopNotificationType.FINAL_FAILURE);
+ notification.setMessage(e.getMessage());
+ notification.setFrom("policy");
+ notification.setPolicyName(drools.getRule().getName());
+ notification.setPolicyScope("${policyScope}");
+ notification.setPolicyVersion("${policyVersion}");
- PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
-
- retract($event);
- retract($manager);
- retract($clTimer);
+ PolicyEngine.manager.deliver("POLICY-CL-MGT", notification);
+
+ retract($event);
+ retract($manager);
+ retract($clTimer);
}
end
@@ -509,10 +515,13 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId(), "Permit".equalsIgnoreCase(getGuardApprovalStatus()) )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(),
+ onset.getRequestId() == $event.getRequestId(), "Permit".equalsIgnoreCase(getGuardApprovalStatus()) )
$lock : TargetLock (requestID == $event.getRequestId())
- $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
+ $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -526,70 +535,71 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
try {
request = $operation.startOperation($event);
- 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)};
- }
- }
-
+ 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: {}",
@@ -598,17 +608,17 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
$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());
+ //
+ // 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);
}
@@ -635,8 +645,10 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_NOT_YET_QUERIED"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId(), getGuardApprovalStatus() == "NONE" )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(),
+ onset.getRequestId() == $event.getRequestId(), getGuardApprovalStatus() == "NONE" )
$lock : TargetLock (requestID == $event.getRequestId())
then
@@ -650,7 +662,8 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_NOT_YET_QUERIED"
//
VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
notification.setNotification(ControlLoopNotificationType.OPERATION);
- notification.setMessage("Sending guard query for " + $operation.policy.getActor() + " " + $operation.policy.getRecipe());
+ notification.setMessage("Sending guard query for " + $operation.policy.getActor() + " "
+ + $operation.policy.getRecipe());
notification.setHistory($operation.getHistory());
notification.setFrom("policy");
notification.setPolicyName(drools.getRule().getName());
@@ -699,11 +712,15 @@ end
rule "${policyName}.GUARD.RESPONSE"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
- $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(),
+ closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(),
+ onset.getRequestId() == $event.getRequestId() )
$lock : TargetLock (requestID == $event.getRequestId())
- $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
+ $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
$guardResponse : PolicyGuardResponse(requestID == $event.getRequestId(), $operation.policy.recipe == operation)
then
@@ -723,7 +740,8 @@ rule "${policyName}.GUARD.RESPONSE"
//
VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
notification.setNotification(ControlLoopNotificationType.OPERATION);
- notification.setMessage("Guard result for " + $operation.policy.getActor() + " " + $operation.policy.getRecipe() + " is " + $guardResponse.getResult());
+ notification.setMessage("Guard result for " + $operation.policy.getActor() + " " + $operation.policy.getRecipe()
+ + " is " + $guardResponse.getResult());
notification.setHistory($operation.getHistory());
notification.setFrom("policy");
notification.setPolicyName(drools.getRule().getName());
@@ -763,10 +781,14 @@ end
rule "${policyName}.APPC.RESPONSE"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
- $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
- $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(),
+ closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(),
+ onset.getRequestId() == $event.getRequestId() )
+ $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
$lock : TargetLock (requestID == $event.getRequestId())
$response : Response( getCommonHeader().RequestId == $event.getRequestId() )
then
@@ -877,10 +899,14 @@ end
rule "${policyName}.APPC.LCM.RESPONSE"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
- $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
- $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(),
+ closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(),
+ onset.getRequestId() == $event.getRequestId() )
+ $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
$lock : TargetLock (requestID == $event.getRequestId())
$response : LcmResponseWrapper( getBody().getCommonHeader().getRequestId() == $event.getRequestId() )
then
@@ -982,14 +1008,18 @@ end
rule "${policyName}.SO.RESPONSE"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
- $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
- $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(),
+ closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(),
+ onset.getRequestId() == $event.getRequestId() )
+ $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
$lock : TargetLock (requestID == $event.getRequestId())
$response : SOResponseWrapper(requestID.toString() == $event.getRequestId().toString() )
then
-
+
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
logger.info("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName());
logger.debug("{}: {}: event={} manager={} operation={} lock={} opTimer={} response={}",
@@ -1064,69 +1094,73 @@ end
*
*/
rule "${policyName}.VFC.RESPONSE"
- when
- $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
- $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(), closedLoopEventStatus == ControlLoopEventStatus.ONSET )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
- $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
+ when
+ $params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName(),
+ closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(),
+ onset.getRequestId() == $event.getRequestId() )
+ $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
$lock : TargetLock (requestID == $event.getRequestId())
- $response : VFCResponse( requestId.toString() == $event.getRequestId().toString() )
- then
- Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
- logger.info("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName());
- logger.debug("{}: {}: event={} manager={} operation={} lock={} opTimer={} response={}",
- $params.getClosedLoopControlName(), drools.getRule().getName(),
- $event, $manager, $operation, $lock, $operation, $opTimer, $response);
-
- // Get the result of the operation
- //
- PolicyResult policyResult = $operation.onResponse($response);
- if (policyResult != null) {
- //
- // This Operation has completed, construct a notification showing our results
- //
- VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
- notification.setFrom("policy");
- notification.setPolicyName(drools.getRule().getName());
- notification.setPolicyScope("${policyScope}");
- notification.setPolicyVersion("${policyVersion}");
- notification.setMessage($operation.getOperationHistory());
- notification.setHistory($operation.getHistory());
- //
- // Ensure the operation is complete
- //
- if ($operation.isOperationComplete() == true) {
- //
- // It is complete, remove it from memory
- //
- retract($operation);
- //
- // We must also retract the timer object
- // NOTE: We could write a Rule to do this
- //
- retract($opTimer);
- //
- // Complete the operation
- //
- modify($manager) {finishOperation($operation)};
- } else {
- //
- // Just doing this will kick off the LOCKED rule again
- //
- modify($operation) {};
- }
- } else {
- //
- // Its not finished yet (i.e. expecting more Response objects)
- //
- // Or possibly it is a leftover response that we timed the request out previously
- //
- }
- //
- // We are going to retract these objects from memory
- //
- retract($response);
+ $response : VFCResponse( requestId.toString() == $event.getRequestId().toString() )
+ then
+ Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
+ logger.info("{}: {}", $params.getClosedLoopControlName(), drools.getRule().getName());
+ logger.debug("{}: {}: event={} manager={} operation={} lock={} opTimer={} response={}",
+ $params.getClosedLoopControlName(), drools.getRule().getName(),
+ $event, $manager, $operation, $lock, $operation, $opTimer, $response);
+
+ // Get the result of the operation
+ //
+ PolicyResult policyResult = $operation.onResponse($response);
+ if (policyResult != null) {
+ //
+ // This Operation has completed, construct a notification showing our results
+ //
+ VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
+ notification.setFrom("policy");
+ notification.setPolicyName(drools.getRule().getName());
+ notification.setPolicyScope("${policyScope}");
+ notification.setPolicyVersion("${policyVersion}");
+ notification.setMessage($operation.getOperationHistory());
+ notification.setHistory($operation.getHistory());
+ //
+ // Ensure the operation is complete
+ //
+ if ($operation.isOperationComplete() == true) {
+ //
+ // It is complete, remove it from memory
+ //
+ retract($operation);
+ //
+ // We must also retract the timer object
+ // NOTE: We could write a Rule to do this
+ //
+ retract($opTimer);
+ //
+ // Complete the operation
+ //
+ modify($manager) {finishOperation($operation)};
+ } else {
+ //
+ // Just doing this will kick off the LOCKED rule again
+ //
+ modify($operation) {};
+ }
+ } else {
+ //
+ // Its not finished yet (i.e. expecting more Response objects)
+ //
+ // Or possibly it is a leftover response that we timed the request out previously
+ //
+ }
+ //
+ // We are going to retract these objects from memory
+ //
+ retract($response);
end
@@ -1155,9 +1189,12 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.TIMEOUT"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
- $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), expired, timerType == "Operation" )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(),
+ onset.getRequestId() == $event.getRequestId() )
+ $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId().toString(), expired, timerType == "Operation" )
$lock : TargetLock (requestID == $event.getRequestId())
then
@@ -1219,8 +1256,10 @@ rule "${policyName}.EVENT.MANAGER.TIMEOUT"
when
$params : Params( getClosedLoopControlName() == "${closedLoopControlName}" )
$event : VirtualControlLoopEvent( closedLoopControlName == $params.getClosedLoopControlName() )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
- $clTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), expired, timerType == "ClosedLoop" )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId() )
+ $clTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId().toString(), expired, timerType == "ClosedLoop" )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -1259,9 +1298,11 @@ rule "${policyName}.EVENT.MANAGER.CLEANUP"
when
$manager : ControlLoopEventManager( $clName : getClosedLoopControlName(), $requestId : getRequestID() )
$operations : LinkedList()
- from collect( ControlLoopOperationManager( onset.closedLoopControlName == $clName, onset.getRequestId() == $requestId ) )
+ from collect( ControlLoopOperationManager( onset.closedLoopControlName == $clName,
+ onset.getRequestId() == $requestId ) )
$timers : LinkedList()
- from collect( ControlLoopTimer( closedLoopControlName == $clName, requestID == $requestId.toString() ) )
+ from collect( ControlLoopTimer( closedLoopControlName == $clName,
+ requestID == $requestId.toString() ) )
$locks : LinkedList()
from collect( TargetLock (requestID == $requestId) )
not( VirtualControlLoopEvent( closedLoopControlName == $clName, requestId == $requestId ) )
@@ -1355,11 +1396,13 @@ end
rule "${policyName}.CLEANER.ACTIVE"
salience 2
when
- $cleaner: ParamsCleaner( getClosedLoopControlName() == "${closedLoopControlName}", getControlLoopYaml() == "${controlLoopYaml}" )
+ $cleaner: ParamsCleaner( getClosedLoopControlName() == "${closedLoopControlName}",
+ getControlLoopYaml() == "${controlLoopYaml}" )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
- logger.info("{}: {} : YAML=[{}]", $cleaner.getClosedLoopControlName(), drools.getRule().getName(), $cleaner.getControlLoopYaml());
+ logger.info("{}: {} : YAML=[{}]", $cleaner.getClosedLoopControlName(), drools.getRule().getName(),
+ $cleaner.getControlLoopYaml());
retract($cleaner);
end
@@ -1381,7 +1424,8 @@ rule "${policyName}.PARAMS.CLEANUP"
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
- logger.info("{}: {} : YAML=[{}]", $params.getClosedLoopControlName(), drools.getRule().getName(), $params.getControlLoopYaml());
+ logger.info("{}: {} : YAML=[{}]", $params.getClosedLoopControlName(), drools.getRule().getName(),
+ $params.getControlLoopYaml());
retract($params);
@@ -1400,7 +1444,8 @@ rule "${policyName}.CLEANER.CLEANUP"
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
- logger.info("{}: {} : YAML=[{}]", $cleaner.getClosedLoopControlName(), drools.getRule().getName(), $cleaner.getControlLoopYaml());
+ logger.info("{}: {} : YAML=[{}]", $cleaner.getClosedLoopControlName(), drools.getRule().getName(),
+ $cleaner.getControlLoopYaml());
retract($cleaner);
end
diff --git a/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl b/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
index ea8411aa0..f2fe23162 100644
--- a/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
+++ b/controlloop/templates/archetype-cl-casablanca/src/main/resources/archetype-resources/src/main/resources/__closedLoopControlName__.drl
@@ -32,7 +32,7 @@ import org.onap.policy.controlloop.policy.Policy;
import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager;
import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager.NEW_EVENT_STATUS;
import org.onap.policy.controlloop.eventmanager.ControlLoopOperationManager;
-import org.onap.policy.controlloop.actor.so.SOActorServiceProvider;
+import org.onap.policy.controlloop.actor.so.SoActorServiceProvider;
import org.onap.policy.aai.AaiNqResponseWrapper;
import org.onap.policy.appc.Request;
import org.onap.policy.appc.Response;
@@ -109,7 +109,8 @@ rule "INSERT.PARAMS"
// hence explicitly getting the logger vs using a global
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
- logger.info("{}: {} : YAML=[{}]", $params.getClosedLoopControlName(), $params.getPolicyName() + "." + drools.getRule().getName(), $params.getControlLoopYaml());
+ logger.info("{}: {} : YAML=[{}]", $params.getClosedLoopControlName(), $params.getPolicyName() + "."
+ + drools.getRule().getName(), $params.getControlLoopYaml());
end
/*
@@ -122,7 +123,8 @@ rule "EVENT"
when
$params : ControlLoopParams( $clName : getClosedLoopControlName() )
$event : VirtualControlLoopEvent( closedLoopControlName == $clName )
- not ( ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() ) )
+ not ( ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId() ) )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -161,7 +163,8 @@ rule "EVENT"
//
ControlLoopEventManager manager = new ControlLoopEventManager($clName, $event.getRequestId());
//
- // Determine if EventManager can actively process the event (i.e. syntax, is_closed_loop_disabled checks etc.)
+ // Determine if EventManager can actively process the event
+ // (i.e. syntax, is_closed_loop_disabled checks etc.)
//
VirtualControlLoopNotification notification = manager.activate($params.getControlLoopYaml(), $event);
notification.setFrom("pdp-0001-controller=controlloop"); // Engine.getInstanceName()
@@ -239,8 +242,10 @@ rule "EVENT.MANAGER"
when
$params : ControlLoopParams( $clName : getClosedLoopControlName() )
$event : VirtualControlLoopEvent( closedLoopControlName == $clName )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
- $clTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), timerType == "ClosedLoop", !expired )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId() )
+ $clTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId().toString(), timerType == "ClosedLoop", !expired )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -416,7 +421,8 @@ rule "EVENT.MANAGER"
$event.getAai().get($event.getTarget()));
notification = new VirtualControlLoopNotification($event);
notification.setNotification(ControlLoopNotificationType.REJECTED);
- notification.setMessage("The target " + $event.getAai().get($event.getTarget()) + " is already locked");
+ notification.setMessage("The target " + $event.getAai().get($event.getTarget())
+ + " is already locked");
notification.setFrom("policy");
notification.setPolicyName($params.getPolicyName() + "." + drools.getRule().getName());
notification.setPolicyScope($params.getPolicyScope());
@@ -445,8 +451,8 @@ rule "EVENT.MANAGER"
}
} catch (Exception e) {
logger.warn("{}: {}: unexpected",
- $clName,
- $params.getPolicyName() + "." + drools.getRule().getName(), e);
+ $clName,
+ $params.getPolicyName() + "." + drools.getRule().getName(), e);
VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
notification.setNotification(ControlLoopNotificationType.FINAL_FAILURE);
@@ -474,10 +480,13 @@ rule "EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
when
$params : ControlLoopParams( $clName : getClosedLoopControlName() )
$event : VirtualControlLoopEvent( closedLoopControlName == $clName )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId(), "Permit".equalsIgnoreCase(getGuardApprovalStatus()) )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(),
+ onset.getRequestId() == $event.getRequestId(), "Permit".equalsIgnoreCase(getGuardApprovalStatus()) )
$lock : TargetLock (requestID == $event.getRequestId())
- $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
+ $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -521,12 +530,12 @@ rule "EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
}
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
+ // 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);
+ SoActorServiceProvider.sendRequest($event.getRequestId().toString(), drools.getWorkingMemory(), request);
}
break;
case "VFC":
@@ -607,8 +616,10 @@ rule "EVENT.MANAGER.OPERATION.LOCKED.GUARD_NOT_YET_QUERIED"
when
$params : ControlLoopParams( $clName : getClosedLoopControlName() )
$event : VirtualControlLoopEvent( closedLoopControlName == $clName )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId(), getGuardApprovalStatus() == "NONE" )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(),
+ onset.getRequestId() == $event.getRequestId(), getGuardApprovalStatus() == "NONE" )
$lock : TargetLock (requestID == $event.getRequestId())
then
@@ -622,7 +633,8 @@ rule "EVENT.MANAGER.OPERATION.LOCKED.GUARD_NOT_YET_QUERIED"
//
VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
notification.setNotification(ControlLoopNotificationType.OPERATION);
- notification.setMessage("Sending guard query for " + $operation.policy.getActor() + " " + $operation.policy.getRecipe());
+ notification.setMessage("Sending guard query for " + $operation.policy.getActor() + " "
+ + $operation.policy.getRecipe());
notification.setHistory($operation.getHistory());
notification.setFrom("policy");
notification.setPolicyName($params.getPolicyName() + "." + drools.getRule().getName());
@@ -671,11 +683,15 @@ end
rule "GUARD.RESPONSE"
when
$params : ControlLoopParams( $clName : getClosedLoopControlName() )
- $event : VirtualControlLoopEvent( closedLoopControlName == $clName, closedLoopEventStatus == ControlLoopEventStatus.ONSET )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $clName,
+ closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(),
+ onset.getRequestId() == $event.getRequestId() )
$lock : TargetLock (requestID == $event.getRequestId())
- $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
+ $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
$guardResponse : PolicyGuardResponse(requestID == $event.getRequestId(), $operation.policy.recipe == operation)
then
@@ -695,7 +711,8 @@ rule "GUARD.RESPONSE"
//
VirtualControlLoopNotification notification = new VirtualControlLoopNotification($event);
notification.setNotification(ControlLoopNotificationType.OPERATION);
- notification.setMessage("Guard result for " + $operation.policy.getActor() + " " + $operation.policy.getRecipe() + " is " + $guardResponse.getResult());
+ notification.setMessage("Guard result for " + $operation.policy.getActor() + " " + $operation.policy.getRecipe()
+ + " is " + $guardResponse.getResult());
notification.setHistory($operation.getHistory());
notification.setFrom("policy");
notification.setPolicyName($params.getPolicyName() + "." + drools.getRule().getName());
@@ -735,10 +752,14 @@ end
rule "APPC.RESPONSE"
when
$params : ControlLoopParams( $clName : getClosedLoopControlName() )
- $event : VirtualControlLoopEvent( closedLoopControlName == $clName, closedLoopEventStatus == ControlLoopEventStatus.ONSET )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
- $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $clName,
+ closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(),
+ onset.getRequestId() == $event.getRequestId() )
+ $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
$lock : TargetLock (requestID == $event.getRequestId())
$response : Response( getCommonHeader().RequestId == $event.getRequestId() )
then
@@ -849,10 +870,14 @@ end
rule "APPC.LCM.RESPONSE"
when
$params : ControlLoopParams( $clName : getClosedLoopControlName() )
- $event : VirtualControlLoopEvent( closedLoopControlName == $clName, closedLoopEventStatus == ControlLoopEventStatus.ONSET )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
- $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $clName,
+ closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(),
+ onset.getRequestId() == $event.getRequestId() )
+ $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
$lock : TargetLock (requestID == $event.getRequestId())
$response : LcmResponseWrapper( getBody().getCommonHeader().getRequestId() == $event.getRequestId() )
then
@@ -954,10 +979,14 @@ end
rule "SO.RESPONSE"
when
$params : ControlLoopParams( $clName : getClosedLoopControlName() )
- $event : VirtualControlLoopEvent( closedLoopControlName == $clName, closedLoopEventStatus == ControlLoopEventStatus.ONSET )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
- $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $clName,
+ closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(),
+ onset.getRequestId() == $event.getRequestId() )
+ $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
$lock : TargetLock (requestID == $event.getRequestId())
$response : SOResponseWrapper(requestID.toString() == $event.getRequestId().toString() )
then
@@ -1038,10 +1067,14 @@ end
rule "VFC.RESPONSE"
when
$params : ControlLoopParams( $clName : getClosedLoopControlName() )
- $event : VirtualControlLoopEvent( closedLoopControlName == $clName, closedLoopEventStatus == ControlLoopEventStatus.ONSET )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
- $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $clName,
+ closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(),
+ onset.getRequestId() == $event.getRequestId() )
+ $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
$lock : TargetLock (requestID == $event.getRequestId())
$response : VFCResponse( requestId.toString() == $event.getRequestId().toString() )
then
@@ -1127,9 +1160,12 @@ rule "EVENT.MANAGER.OPERATION.TIMEOUT"
when
$params : ControlLoopParams( $clName : getClosedLoopControlName() )
$event : VirtualControlLoopEvent( closedLoopControlName == $clName )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
- $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), timerType == "Operation", expired )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(),
+ onset.getRequestId() == $event.getRequestId() )
+ $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId().toString(), timerType == "Operation", expired )
$lock : TargetLock (requestID == $event.getRequestId())
then
@@ -1191,8 +1227,10 @@ rule "EVENT.MANAGER.TIMEOUT"
when
$params : ControlLoopParams( $clName : getClosedLoopControlName() )
$event : VirtualControlLoopEvent( closedLoopControlName == $clName )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
- $clTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), timerType == "ClosedLoop", expired )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId() )
+ $clTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId().toString(), timerType == "ClosedLoop", expired )
then
Logger logger = LoggerFactory.getLogger(drools.getRule().getPackage());
@@ -1231,9 +1269,11 @@ rule "EVENT.MANAGER.CLEANUP"
when
$manager : ControlLoopEventManager( $clName : getClosedLoopControlName(), $requestId : getRequestID() )
$operations : LinkedList()
- from collect( ControlLoopOperationManager( onset.closedLoopControlName == $clName, onset.getRequestId() == $requestId ) )
+ from collect( ControlLoopOperationManager( onset.closedLoopControlName == $clName,
+ onset.getRequestId() == $requestId ) )
$timers : LinkedList()
- from collect( ControlLoopTimer( closedLoopControlName == $clName, requestID == $requestId.toString() ) )
+ from collect( ControlLoopTimer( closedLoopControlName == $clName,
+ requestID == $requestId.toString() ) )
$locks : LinkedList()
from collect( TargetLock (requestID == $requestId) )
not( VirtualControlLoopEvent( closedLoopControlName == $clName, requestId == $requestId ) )
@@ -1295,10 +1335,14 @@ end
rule "SDNR.RESPONSE"
when
$params : ControlLoopParams( $clName : getClosedLoopControlName() )
- $event : VirtualControlLoopEvent( closedLoopControlName == $clName, closedLoopEventStatus == ControlLoopEventStatus.ONSET )
- $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId() )
- $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(), onset.getRequestId() == $event.getRequestId() )
- $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(), requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
+ $event : VirtualControlLoopEvent( closedLoopControlName == $clName,
+ closedLoopEventStatus == ControlLoopEventStatus.ONSET )
+ $manager : ControlLoopEventManager( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId() )
+ $operation : ControlLoopOperationManager( onset.closedLoopControlName == $event.getClosedLoopControlName(),
+ onset.getRequestId() == $event.getRequestId() )
+ $opTimer : ControlLoopTimer( closedLoopControlName == $event.getClosedLoopControlName(),
+ requestID == $event.getRequestId().toString(), timerType == "Operation", !expired )
$lock : TargetLock (requestID == $event.getRequestId())
$response : PciResponseWrapper( getBody().getCommonHeader().getRequestId() == $event.getRequestId() )
then
diff --git a/controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/CallGuardTaskEmbedded.java b/controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/CallGuardTaskEmbedded.java
index aaa2a0a83..7abf38620 100644
--- a/controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/CallGuardTaskEmbedded.java
+++ b/controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/CallGuardTaskEmbedded.java
@@ -20,6 +20,8 @@
package org.onap.policy.guard;
+import com.att.research.xacml.api.DataTypeException;
+import com.att.research.xacml.std.annotations.RequestParser;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
@@ -27,8 +29,6 @@ import java.util.function.Supplier;
import org.drools.core.WorkingMemory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.att.research.xacml.api.DataTypeException;
-import com.att.research.xacml.std.annotations.RequestParser;
public class CallGuardTaskEmbedded implements Runnable {
@@ -36,14 +36,14 @@ public class CallGuardTaskEmbedded implements Runnable {
/**
* Actor/recipe pairs whose guard requests need a VF Module count. Each element is of
- * the form "<actor>:<recipe>".
+ * the form "&lt;actor&gt;:&lt;recipe&gt;".
*/
private static final Set<String> NEEDS_VF_COUNT = new HashSet<>();
/**
* Actor/recipe pairs whose guard requests need the VF Module count to be incremented
* (i.e., because a module is being added). Each element is of the form
- * "<actor>:<recipe>".
+ * "&lt;actor&gt;:&lt;recipe&gt;".
*/
private static final Set<String> INCR_VF_COUNT = new HashSet<>();
@@ -69,7 +69,8 @@ public class CallGuardTaskEmbedded implements Runnable {
/**
* Guard url is grabbed from PolicyEngine.manager properties
*/
- public CallGuardTaskEmbedded(WorkingMemory wm, String cl, String act, String rec, String tar, String reqId, Supplier<Integer> vfcnt) {
+ public CallGuardTaskEmbedded(WorkingMemory wm, String cl, String act, String rec,
+ String tar, String reqId, Supplier<Integer> vfcnt) {
workingMemory = wm;
clname = cl;
actor = act;
diff --git a/controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelperEmbedded.java b/controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelperEmbedded.java
index 947b187e4..e14946274 100644
--- a/controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelperEmbedded.java
+++ b/controlloop/templates/template.demo.clc/src/main/java/org/onap/policy/guard/PolicyGuardXacmlHelperEmbedded.java
@@ -25,12 +25,8 @@ import com.att.research.xacml.api.AttributeCategory;
import com.att.research.xacml.api.AttributeValue;
import com.att.research.xacml.api.Result;
import com.att.research.xacml.api.pdp.PDPEngine;
-import com.att.research.xacml.api.pdp.PDPException;
-import com.att.research.xacml.api.pdp.PDPEngineFactory;
-import com.att.research.xacmlatt.pdp.ATTPDPEngineFactory;
import com.att.research.xacml.std.annotations.RequestParser;
-
-import com.google.gson.Gson;
+import com.att.research.xacmlatt.pdp.ATTPDPEngineFactory;
import java.io.BufferedReader;
import java.io.ByteArrayInputStream;
@@ -52,8 +48,8 @@ import org.apache.commons.io.IOUtils;
import org.apache.http.entity.ContentType;
import org.json.JSONObject;
import org.onap.policy.drools.system.PolicyEngine;
-import org.onap.policy.guard.PolicyGuardXacmlRequestAttributes;
import org.onap.policy.guard.PolicyGuardResponse;
+import org.onap.policy.guard.PolicyGuardXacmlRequestAttributes;
import org.onap.policy.guard.Util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -152,7 +148,7 @@ public class PolicyGuardXacmlHelperEmbedded {
* @param environment the Environment
* @return response from guard which contains "Permit" or "Deny"
*/
- private String callRestfulPdp(InputStream is, URL restURL, String authorization, String clientauth,
+ private String callRestfulPdp(InputStream is, URL restUrl, String authorization, String clientauth,
String environment) {
HttpURLConnection connection = null;
@@ -160,7 +156,7 @@ public class PolicyGuardXacmlHelperEmbedded {
//
// Open up the connection
//
- connection = (HttpURLConnection) restURL.openConnection();
+ connection = (HttpURLConnection) restUrl.openConnection();
connection.setRequestProperty("Content-Type", "application/json");
//
// Setup our method and headers
@@ -202,7 +198,7 @@ public class PolicyGuardXacmlHelperEmbedded {
connection.connect();
if (connection.getResponseCode() != 200) {
- logger.error(connection.getResponseCode() + " " + connection.getResponseMessage());
+ logger.error("{} {}", connection.getResponseCode(), connection.getResponseMessage());
return Util.INDETERMINATE;
}
} catch (Exception e) {
@@ -266,7 +262,7 @@ public class PolicyGuardXacmlHelperEmbedded {
//
// Embedded call to PDP
//
- long lTimeStart = System.currentTimeMillis();
+ long timeStart = System.currentTimeMillis();
if (xacmlReq.getVfCount() == null ) {
xacmlReq.setVfCount(1);
}
@@ -275,8 +271,8 @@ public class PolicyGuardXacmlHelperEmbedded {
} catch (Exception e) {
logger.error(e.getMessage(), e);
}
- long lTimeEnd = System.currentTimeMillis();
- logger.debug("Elapsed Time: {} ms", (lTimeEnd - lTimeStart));
+ long timeEnd = System.currentTimeMillis();
+ logger.debug("Elapsed Time: {} ms", (timeEnd - timeStart));
//
// Convert response to string
//
diff --git a/controlloop/templates/template.demo.clc/src/main/resources/__closedLoopControlName__.drl b/controlloop/templates/template.demo.clc/src/main/resources/__closedLoopControlName__.drl
index 3981f0def..15de89850 100644
--- a/controlloop/templates/template.demo.clc/src/main/resources/__closedLoopControlName__.drl
+++ b/controlloop/templates/template.demo.clc/src/main/resources/__closedLoopControlName__.drl
@@ -32,7 +32,7 @@ import org.onap.policy.controlloop.policy.Policy;
import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager;
import org.onap.policy.controlloop.eventmanager.ControlLoopEventManager.NEW_EVENT_STATUS;
import org.onap.policy.controlloop.eventmanager.ControlLoopOperationManager;
-import org.onap.policy.controlloop.actor.so.SOActorServiceProvider;
+import org.onap.policy.controlloop.actor.so.SoActorServiceProvider;
import org.onap.policy.aai.AaiNqResponseWrapper;
import org.onap.policy.appc.Request;
import org.onap.policy.appc.Response;
@@ -577,12 +577,13 @@ rule "${policyName}.EVENT.MANAGER.OPERATION.LOCKED.GUARD_PERMITTED"
}
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
+ // at this point the AAI named query request should have already been made, the response received
+ // 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);
+ SoActorServiceProvider.sendRequest($event.getRequestId().toString(), drools.getWorkingMemory(),
+ request);
}
break;
case "VFC":
diff --git a/controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/ControlLoopCoordinationTest.java b/controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/ControlLoopCoordinationTest.java
index 2d6279f32..1d8779999 100644
--- a/controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/ControlLoopCoordinationTest.java
+++ b/controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/ControlLoopCoordinationTest.java
@@ -25,8 +25,6 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import com.att.research.xacml.util.XACMLProperties;
-
import com.google.gson.Gson;
import java.io.IOException;
@@ -218,7 +216,6 @@ public class ControlLoopCoordinationTest implements TopicListener {
String target,
KieSession kieSession,
String expectedDecision) {
- int waitMillis = 5000;
//
// if onset, set expected decision
//
@@ -233,7 +230,7 @@ public class ControlLoopCoordinationTest implements TopicListener {
//
// get dump of database entries and log
//
- List entries = Util.dumpDb();
+ List<?> entries = Util.dumpDb();
assertNotNull(entries);
logger.debug("dumpDB, {} entries", entries.size());
for (Object entry : entries) {
diff --git a/controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/Util.java b/controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/Util.java
index 5b5aa2d9c..6001331de 100644
--- a/controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/Util.java
+++ b/controlloop/templates/template.demo.clc/src/test/java/org/onap/policy/template/demo/clc/Util.java
@@ -24,7 +24,6 @@ import static org.junit.Assert.fail;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
@@ -34,7 +33,6 @@ import java.nio.file.Paths;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-import java.util.stream.Collectors;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
@@ -55,7 +53,6 @@ import org.onap.policy.common.endpoints.http.server.HttpServletServer;
import org.onap.policy.controlloop.policy.ControlLoopPolicy;
import org.onap.policy.controlloop.policy.guard.ControlLoopGuard;
import org.onap.policy.drools.system.PolicyEngine;
-import org.onap.policy.guard.PolicyGuardYamlToXacml;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.yaml.snakeyaml.Yaml;
@@ -261,7 +258,7 @@ public final class Util {
*
* @return a list of the database entries
*/
- public static List dumpDb() {
+ public static List<?> dumpDb() {
//
// Connect to in-mem db
//
@@ -272,7 +269,7 @@ public final class Util {
//
String sql = "select * from operationshistory10";
Query nq = em.createNativeQuery(sql);
- List results = null;
+ List<?> results = null;
//
// Execute query
//