diff options
author | eeginux <henry.xie@est.tech> | 2019-11-20 13:23:49 +0000 |
---|---|---|
committer | Xuefeng Xie <henry.xie@est.tech> | 2020-01-24 10:12:25 +0000 |
commit | 8c9f2c73f4366ae42ad7e2c1742885b5ad793360 (patch) | |
tree | 7664c0f06c29b67bba254b14873c4d18f20d6b45 /bpmn/so-bpmn-infrastructure-common/src | |
parent | 8d77d8544d88dfb91e9287b1620212cc9821bd54 (diff) |
decision point API
ControllerRunnable interface: implemented by controller
ControllerContext: Controller Context for controller execution
ControllerPreparable interface:used to setup execution context
ControllerExecutionBB:controller execution for building block
ControllerExecutionDE:controller execution for camunda
Skeleton implementation for APPC controller
Skeleton implementation for SDNC controller
Use ControllerExecutionDE for existing PNF configuration.
Add integration tests for controllerExecutionBB/DE
Add GenericControllerExecution activity for BuildingBlockExecution based
Add GenericControllerExecutionDE activity for DelegateExecution based.
CDS controller to be implemented by SO-CDS generic buildingBlock
Actor seletion based on ingested metadata
Issue-ID: SO-2070
Change-Id: I4020c2ce21468939690e2cef78bbadbfff4bd3e4
Signed-off-by: eeginux<henry.xie@est.tech>
Diffstat (limited to 'bpmn/so-bpmn-infrastructure-common/src')
5 files changed, 219 insertions, 10 deletions
diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/api/ControllerContext.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/api/ControllerContext.java new file mode 100644 index 0000000000..0de211bd7d --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/api/ControllerContext.java @@ -0,0 +1,95 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix + * ================================================================================ + * 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========================================================= + */ +package org.onap.so.bpmn.infrastructure.decisionpoint.api; + +import java.util.Map; +import org.camunda.bpm.engine.delegate.DelegateExecution; + +/** + * This class is used to represent the Context used by {@ref ControllerRunnable}. + */ +public class ControllerContext<T> { + + /** + * Action to be executed against controller. + * + * e.g, healthcheck, scaleout, config-assign + * + * Action is case insensitive. + */ + private String controllerAction; + + /** + * Controller actor. + * + * e.g., CDS, SDNC, APPC. + * + * actor name is case insensitive. + */ + private String controllerActor; + + /** + * scope: PNF, VNF, VF. + */ + private String controllerScope; + + /** + * Execution context, buildingblockExecution or DelegateExecution. + */ + private T execution; + + public ControllerContext() {} + + public void setExecution(T execution) { + this.execution = execution; + } + + public T getExecution() { + return execution; + } + + public String getControllerAction() { + return controllerAction; + } + + public void setControllerAction(String controllerAction) { + this.controllerAction = controllerAction; + } + + public String getControllerActor() { + return controllerActor; + } + + public void setControllerActor(String controllerActor) { + this.controllerActor = controllerActor; + } + + public String getControllerScope() { + return controllerScope; + } + + public void setControllerScope(String controllerScope) { + this.controllerScope = controllerScope; + } + + public String toString() { + return "Controller context for actor: " + controllerActor + ", action: " + controllerAction + ",scope: " + + controllerScope; + } +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/api/ControllerRunnable.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/api/ControllerRunnable.java new file mode 100644 index 0000000000..670f4d399e --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/api/ControllerRunnable.java @@ -0,0 +1,56 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix + * ================================================================================ + * 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========================================================= + */ +package org.onap.so.bpmn.infrastructure.decisionpoint.api; + +/** + * the ControllerRunnable interface should be implemented by any class intended to execute against controller northbound + * interface. + * + */ +public interface ControllerRunnable<T> { + + /** + * This method is used to decide whether the implementation is to serve the controller northbound interface. + * + * @param context {@link ControllerContext} is used as the input to the execution. + * @return + */ + Boolean understand(final ControllerContext<T> context); + + /** + * this method is used to check whether the controller Northbound interface is ready to use. + * + * @param context {@link ControllerContext} is used as the input to the execution. + * @return True if the controller is ready to use or return false. + */ + Boolean ready(final ControllerContext<T> context); + + /** + * This method is used to set up the context so it can be used to run against the controller NB. + */ + void prepare(final ControllerContext<T> context); + + /** + * This method is used to run against the controller northbound interface. + * + * @param context {@link ControllerContext} is used as the input to the execution. + */ + void run(final ControllerContext<T> context); + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/api/controller/ControllerPreparable.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/api/controller/ControllerPreparable.java new file mode 100644 index 0000000000..98bab2c1ed --- /dev/null +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/decisionpoint/api/controller/ControllerPreparable.java @@ -0,0 +1,48 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix + * ================================================================================ + * 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========================================================= + */ + +package org.onap.so.bpmn.infrastructure.decisionpoint.api.controller; + +import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerContext; +import org.onap.so.bpmn.infrastructure.decisionpoint.api.ControllerRunnable; + +/** + * This interface is used by {@link ControllerRunnable} to prepare the Context. + * + * The interface should be implementation by controller preparation instance to configure the context required for + * execution. + */ +public interface ControllerPreparable<T> { + + /** + * This method is used to decide whether the implementation is used to configure the {@link ControllerContext}. + * + * @param controllerContext + * @return + */ + boolean understand(final ControllerContext<T> controllerContext); + + /** + * This method is used to prepare the {@link ControllerContext}. + * + * @param controllerContext + */ + void prepare(final ControllerContext<T> controllerContext); + +} diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegate.java index ee86ca4292..37b9376e14 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegate.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegate.java @@ -1,15 +1,20 @@ -/* - * ============LICENSE_START======================================================= Copyright (C) 2019 Nordix - * Foundation. ================================================================================ 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 +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix + * ================================================================================ + * 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. + * 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========================================================= + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= */ package org.onap.so.bpmn.infrastructure.pnf.delegate; @@ -17,6 +22,7 @@ package org.onap.so.bpmn.infrastructure.pnf.delegate; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.MODEL_UUID; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_NAME; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_BLUEPRINT_VERSION; +import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_CONTROLLER_ACTOR; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_CUSTOMIZATION_UUID; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.PRC_INSTANCE_NAME; import static org.onap.so.bpmn.infrastructure.pnf.delegate.ExecutionVariableNames.SERVICE_MODEL_INFO; @@ -75,6 +81,7 @@ public class ConfigCheckerDelegate implements JavaDelegate { delegateExecution.setVariable(PRC_CUSTOMIZATION_UUID, pnfResourceCustomization.getModelCustomizationUUID()); delegateExecution.setVariable(PRC_INSTANCE_NAME, pnfResourceCustomization.getModelInstanceName()); + delegateExecution.setVariable(PRC_CONTROLLER_ACTOR, pnfResourceCustomization.getControllerActor()); } else { logger.warn("Unable to find the PNF resource customizations of model service UUID: {}", serviceModelUuid); diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java index c16175b8e2..fab3496559 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ExecutionVariableNames.java @@ -5,6 +5,7 @@ * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. * ================================================================================ * Modifications Copyright 2018 Nokia + * Modifications Copyright 2019 Nordix * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -51,6 +52,8 @@ public class ExecutionVariableNames { public static final String PRC_BLUEPRINT_VERSION = "PRC_blueprintVersion"; public static final String PRC_CUSTOMIZATION_UUID = "PRC_customizationUuid"; public static final String PRC_INSTANCE_NAME = "PRC_instanceName"; + public static final String PRC_CONTROLLER_ACTOR = "actor"; + /** * Variable used to contain skipPostInstantiationConfiguration flag. |