aboutsummaryrefslogtreecommitdiffstats
path: root/controlloop
diff options
context:
space:
mode:
Diffstat (limited to 'controlloop')
-rw-r--r--controlloop/common/controller-usecases/src/main/resources/usecases.drl16
-rw-r--r--controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java16
-rw-r--r--controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java17
-rw-r--r--controlloop/packages/apps-controlloop/pom.xml8
-rw-r--r--controlloop/packages/docker-controlloop/src/main/docker/Dockerfile22
5 files changed, 74 insertions, 5 deletions
diff --git a/controlloop/common/controller-usecases/src/main/resources/usecases.drl b/controlloop/common/controller-usecases/src/main/resources/usecases.drl
index d3365e6cc..12c9849f9 100644
--- a/controlloop/common/controller-usecases/src/main/resources/usecases.drl
+++ b/controlloop/common/controller-usecases/src/main/resources/usecases.drl
@@ -20,6 +20,7 @@
package org.onap.policy.controlloop;
+import java.time.Instant;
import java.util.Collections;
import java.util.stream.Collectors;
import org.onap.policy.controlloop.CanonicalOnset;
@@ -32,6 +33,7 @@ import org.onap.policy.controlloop.actor.aai.AaiGetTenantOperation;
import org.onap.policy.controlloop.actor.guard.GuardActor;
import org.onap.policy.controlloop.actor.guard.DecisionOperation;
import org.onap.policy.controlloop.actorserviceprovider.Operation;
+import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.OperationFinalResult;
import org.onap.policy.controlloop.actorserviceprovider.OperationProperties;
import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
@@ -388,7 +390,19 @@ rule "EVENT.MANAGER.EXECUTE.STEP"
$step.init();
$step.setProperties();
- if ($manager.executeStep()) {
+ boolean guardDisabled = "true".equalsIgnoreCase(
+ PolicyEngineConstants.getManager().getEnvironmentProperty("guard.disabled"));
+
+ if (guardDisabled && "GUARD".equals($step.getActorName())) {
+ // guard is disabled - just enqueue a "SUCCESS" (i.e., "Permit")
+ OperationOutcome outcome = $step.getParams().makeOutcome();
+ outcome.setStart(Instant.now());
+ outcome.setEnd(outcome.getStart());
+
+ $manager.getOutcomes().add(outcome);
+ $manager.setState(State.AWAITING_OUTCOME);
+
+ } else if ($manager.executeStep()) {
$manager.setState(State.AWAITING_OUTCOME);
} else {
diff --git a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
index 12128554f..248a41be6 100644
--- a/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
+++ b/controlloop/common/eventmanager/src/main/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManager.java
@@ -41,6 +41,7 @@ import org.onap.policy.controlloop.actorserviceprovider.ActorService;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.drl.legacy.ControlLoopParams;
import org.onap.policy.controlloop.ophistory.OperationHistoryDataManager;
+import org.onap.policy.controlloop.ophistory.OperationHistoryDataManagerStub;
import org.onap.policy.controlloop.processor.ControlLoopProcessor;
import org.onap.policy.drools.core.lock.LockCallback;
import org.onap.policy.drools.system.PolicyEngineConstants;
@@ -59,6 +60,12 @@ public class ControlLoopEventManager implements StepContext, Serializable {
private static final Logger logger = LoggerFactory.getLogger(ControlLoopEventManager.class);
private static final long serialVersionUID = -1216568161322872641L;
+ /**
+ * Data manager used when the policy engine's guard.disabled property is "true".
+ */
+ private static final OperationHistoryDataManager STUB_DATA_MANAGER = new OperationHistoryDataManagerStub();
+
+ private static final String GUARD_DISABLED_PROPERTY = "guard.disabled";
private static final String EVENT_MANAGER_SERVICE_CONFIG = "event-manager";
/**
@@ -269,8 +276,6 @@ public class ControlLoopEventManager implements StepContext, Serializable {
private static final ActorService ACTOR_SERVICE;
static {
- // TODO how to dynamically change data manager, depending whether or not
- // guards are enabled?
EventManagerServices services = new EventManagerServices(EVENT_MANAGER_SERVICE_CONFIG);
ACTOR_SERVICE = services.getActorService();
DATA_MANAGER = services.getDataManager();
@@ -296,6 +301,11 @@ public class ControlLoopEventManager implements StepContext, Serializable {
}
public OperationHistoryDataManager getDataManager() {
- return LazyInitData.DATA_MANAGER;
+ boolean guardDisabled = "true".equalsIgnoreCase(getEnvironmentProperty(GUARD_DISABLED_PROPERTY));
+ return (guardDisabled ? STUB_DATA_MANAGER : LazyInitData.DATA_MANAGER);
+ }
+
+ protected String getEnvironmentProperty(String propName) {
+ return PolicyEngineConstants.getManager().getEnvironmentProperty(propName);
}
}
diff --git a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java
index e4c233281..a8632642a 100644
--- a/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java
+++ b/controlloop/common/eventmanager/src/test/java/org/onap/policy/controlloop/eventmanager/ControlLoopEventManagerTest.java
@@ -49,6 +49,7 @@ import org.onap.policy.controlloop.ControlLoopException;
import org.onap.policy.controlloop.actorserviceprovider.OperationOutcome;
import org.onap.policy.controlloop.actorserviceprovider.OperationResult;
import org.onap.policy.controlloop.drl.legacy.ControlLoopParams;
+import org.onap.policy.controlloop.ophistory.OperationHistoryDataManagerStub;
import org.onap.policy.drools.core.lock.LockCallback;
import org.onap.policy.drools.core.lock.LockImpl;
import org.onap.policy.drools.core.lock.LockState;
@@ -241,6 +242,22 @@ public class ControlLoopEventManagerTest {
assertFalse(mgr.contains(MY_KEY));
}
+ /**
+ * Tests getDataManager() when guard.disabled=true.
+ */
+ @Test
+ public void testGetDataManagerDisabled() throws ControlLoopException {
+ mgr = new MyManager(params, REQ_ID) {
+ private static final long serialVersionUID = 1L;
+ @Override
+ protected String getEnvironmentProperty(String propName) {
+ return ("guard.disabled".equals(propName) ? "true" : null);
+ }
+ };
+
+ assertThat(mgr.getDataManager()).isInstanceOf(OperationHistoryDataManagerStub.class);
+ }
+
@Test
public void testToString() {
assertNotNull(mgr.toString());
diff --git a/controlloop/packages/apps-controlloop/pom.xml b/controlloop/packages/apps-controlloop/pom.xml
index f7776b5a4..5d5821300 100644
--- a/controlloop/packages/apps-controlloop/pom.xml
+++ b/controlloop/packages/apps-controlloop/pom.xml
@@ -2,7 +2,7 @@
============LICENSE_START=======================================================
ONAP
================================================================================
- Copyright (C) 2017-2019 AT&T Intellectual Property. All rights reserved.
+ Copyright (C) 2017-2020 AT&T Intellectual Property. All rights reserved.
Modifications Copyright (C) 2019-2020 Bell Canada.
================================================================================
Licensed under the Apache License, Version 2.0 (the "License");
@@ -101,6 +101,12 @@
<version>${project.version}</version>
<type>zip</type>
</dependency>
+ <dependency>
+ <groupId>org.onap.policy.drools-applications.controlloop.common</groupId>
+ <artifactId>feature-controlloop-tdjam</artifactId>
+ <version>${project.version}</version>
+ <type>zip</type>
+ </dependency>
</dependencies>
</project>
diff --git a/controlloop/packages/docker-controlloop/src/main/docker/Dockerfile b/controlloop/packages/docker-controlloop/src/main/docker/Dockerfile
index efb54b6e4..c36947dfa 100644
--- a/controlloop/packages/docker-controlloop/src/main/docker/Dockerfile
+++ b/controlloop/packages/docker-controlloop/src/main/docker/Dockerfile
@@ -1,3 +1,24 @@
+#-------------------------------------------------------------------------------
+# Dockerfile
+# ============LICENSE_START=======================================================
+# Copyright (C) 2020 AT&T Intellectual Property. All rights reserved.
+# ================================================================================
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# SPDX-License-Identifier: Apache-2.0
+# ============LICENSE_END=========================================================
+#-------------------------------------------------------------------------------
+
FROM onap/policy-drools:@version.policy.drools-pdp@
ARG BUILD_VERSION_APP_CL=${BUILD_VERSION_APP_CL}
@@ -14,6 +35,7 @@ RUN unzip apps-controlloop.zip && \
$POLICY_HOME/bin/features install controlloop-utils controlloop-trans controlloop-management && \
$POLICY_HOME/bin/features install controlloop-frankfurt && \
$POLICY_HOME/bin/features install controlloop-usecases && \
+ $POLICY_HOME/bin/features install controlloop-tdjam && \
$POLICY_HOME/bin/features enable healthcheck distributed-locking lifecycle && \
$POLICY_HOME/bin/features enable controlloop-trans controlloop-management && \
$POLICY_HOME/bin/features enable controlloop-frankfurt && \