Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

StepDescription Result
Modify DecisionMaker Policy
  • Split into two seperate policies:
    • One which contains the answer logic
    • One which contains the decision logic
    • Policy A & Policy B will share AnswerAlbum and LastAnswerAlbum context


Code Block
languagetext
titleDecisionMakerAnswerPolicy
linenumberstrue
collapsetrue
#-------------------------------------------------------------------------------
# ============LICENSE_START=======================================================
#  Copyright (C) 2016-2018 Ericsson. 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=========================================================
#-------------------------------------------------------------------------------
# POLICY A

model create name=DecisionMakerPolicyModel

schema create name=SimpleStringType  flavour=Java schema=java.lang.String
schema create name=SimpleIntegerType flavour=Java schema=java.lang.Integer

album create name=AnswerAlbum scope=policy writable=true schemaName=SimpleStringType
album create name=LastAnswerAlbum scope=policy writable=true schemaName=SimpleIntegerType

event create name=AnswerEvent nameSpace=org.onap.policy.apex.domains.decisionmaker source=DCAE target=apex
event parameter create name=AnswerEvent parName=a0 schemaName=SimpleStringType
event parameter create name=AnswerEvent parName=a1 schemaName=SimpleStringType
event parameter create name=AnswerEvent parName=a2 schemaName=SimpleStringType
event parameter create name=AnswerEvent parName=a3 schemaName=SimpleStringType
event parameter create name=AnswerEvent parName=a4 schemaName=SimpleStringType
event parameter create name=AnswerEvent parName=a5 schemaName=SimpleStringType
event parameter create name=AnswerEvent parName=a6 schemaName=SimpleStringType

event create name=MakeDecisionEvent nameSpace=org.onap.policy.apex.domains.decisionmaker source=DCAE target=apex
event parameter create name=MakeDecisionEvent parName=mode schemaName=SimpleStringType

event create name=DecisionEvent nameSpace=org.onap.policy.apex.domains.decisionmaker source=DCAE target=apex
event parameter create name=DecisionEvent parName=decision schemaName=SimpleStringType

task create name=AnswerInitTask
task inputfield create name=AnswerInitTask fieldName=a0 schemaName=SimpleStringType
task inputfield create name=AnswerInitTask fieldName=a1 schemaName=SimpleStringType
task inputfield create name=AnswerInitTask fieldName=a2 schemaName=SimpleStringType
task inputfield create name=AnswerInitTask fieldName=a3 schemaName=SimpleStringType
task inputfield create name=AnswerInitTask fieldName=a4 schemaName=SimpleStringType
task inputfield create name=AnswerInitTask fieldName=a5 schemaName=SimpleStringType
task inputfield create name=AnswerInitTask fieldName=a6 schemaName=SimpleStringType

task outputfield create name=AnswerInitTask fieldName=a0 schemaName=SimpleStringType
task outputfield create name=AnswerInitTask fieldName=a1 schemaName=SimpleStringType
task outputfield create name=AnswerInitTask fieldName=a2 schemaName=SimpleStringType
task outputfield create name=AnswerInitTask fieldName=a3 schemaName=SimpleStringType
task outputfield create name=AnswerInitTask fieldName=a4 schemaName=SimpleStringType
task outputfield create name=AnswerInitTask fieldName=a5 schemaName=SimpleStringType
task outputfield create name=AnswerInitTask fieldName=a6 schemaName=SimpleStringType

task contextref create name=AnswerInitTask albumName=AnswerAlbum
task contextref create name=AnswerInitTask albumName=LastAnswerAlbum

task logic create name=AnswerInitTask logicFlavour=JAVASCRIPT logic=LS
#MACROFILE:"src/main/resources/logic/AnswerInitTask.js"
LE

taskpolicy create name=RandomAnswerTask=AnswerInitPolicy template=freestyle firstState=AnswerInitState

taskpolicy inputfieldstate create name=AnswerInitPolicy stateName=RandomAnswerTaskAnswerInitState fieldNametriggerName=modeAnswerEvent schemaNamedefaultTaskName=SimpleStringType

task outputfieldAnswerInitTask
policy state output create name=RandomAnswerTask fieldName=decision schemaName=SimpleStringType

task contextrefAnswerInitPolicy stateName=AnswerInitState outputName=AnswerInitOutput eventName=AnswerEvent
policy state taskref create name=RandomAnswerTaskAnswerInitPolicy albumName=AnswerAlbum

task logic create name=RandomAnswerTask logicFlavour=JAVASCRIPT logic=LS
#MACROFILE:"src/main/resources/logic/RandomAnswerTask.js"
LE

task create name=PessimisticAnswerTask

task inputfield create name=PessimisticAnswerTask fieldName=mode schemaName=SimpleStringType

task outputfield create name=PessimisticAnswerTask fieldName=decision schemaName=SimpleStringType

task contextref create name=PessimisticAnswerTask albumName=AnswerAlbum

task logic create name=PessimisticAnswerTask logicFlavour=JAVASCRIPT logic=LS
#MACROFILE:"src/main/resources/logic/PessimisticAnswerTask.js"
LE

task create name=OptimisticAnswerTask

task inputfield create name=OptimisticAnswerTask fieldName=mode schemaName=SimpleStringType

task outputfield create name=OptimisticAnswerTask fieldName=decision schemaName=SimpleStringType

task contextref create name=OptimisticAnswerTask albumName=AnswerAlbum

task logic create name=OptimisticAnswerTask logicFlavour=JAVASCRIPT logic=LS
#MACROFILE:"src/main/resources/logic/OptimisticAnswerTask.js"
LE

task create name=DitheringAnswerTask

task inputfield create name=DitheringAnswerTask fieldName=mode schemaName=SimpleStringType

task outputfield create name=DitheringAnswerTask fieldName=decision schemaName=SimpleStringType

task contextref create name=DitheringAnswerTask albumName=AnswerAlbum

task logic create name=DitheringAnswerTask logicFlavour=JAVASCRIPT logic=LS
#MACROFILE:"src/main/resources/logic/DitheringAnswerTask.js"
LE

task create name=RoundRobinAnswerTask

task inputfield create name=RoundRobinAnswerTask fieldName=mode schemaName=SimpleStringType

task outputfield create name=RoundRobinAnswerTask fieldName=decision schemaName=SimpleStringType

task contextref create name=RoundRobinAnswerTask albumName=AnswerAlbum
task contextref create name=RoundRobinAnswerTask albumName=LastAnswerAlbum

task logic create name=RoundRobinAnswerTask logicFlavour=JAVASCRIPT logic=LS
#MACROFILE:"src/main/resources/logic/RoundRobinAnswerTask.js"
LE

policy create name=AnswerInitPolicy template=freestyle firstState=AnswerInitState

policy state create name=AnswerInitPolicy stateName=AnswerInitState triggerName=AnswerEvent defaultTaskName=AnswerInitTask
policy state output create name=AnswerInitPolicy stateName=AnswerInitState outputName=AnswerInitOutput eventName=AnswerEvent
policy state taskref create name=AnswerInitPolicy stateName=AnswerInitState taskName=AnswerInitTask outputType=DIRECT outputName=AnswerInitOutput

validate


Code Block
languagetext
titleDecisionMakerDecisionPolicy
linenumberstrue
collapsetrue
stateName=AnswerInitState taskName=AnswerInitTask outputType=DIRECT outputName=AnswerInitOutput

validate

   


Code Block
languagetext
titleDecisionMakerDecisionPolicy
linenumberstrue
collapsetrue
 #-------------------------------------------------------------------------------
# ============LICENSE_START=======================================================
#  Copyright (C) 2016-2018 Ericsson. 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=========================================================
#-------------------------------------------------------------------------------

model create name=DecisionMakerPolicyModelTwo

schema create name=SimpleStringType  flavour=Java schema=java.lang.String
schema create name=SimpleIntegerType flavour=Java schema=java.lang.Integer

album create name=AnswerAlbum scope=policy writable=true schemaName=SimpleStringType
album create name=LastAnswerAlbum scope=policy writable=true schemaName=SimpleIntegerType

event create name=MakeDecisionEvent nameSpace=org.onap.policy.apex.domains.decisionmaker source=DCAE target=apex
event parameter create name=MakeDecisionEvent parName=mode schemaName=SimpleStringType

event create name=DecisionEvent nameSpace=org.onap.policy.apex.domains.decisionmaker source=DCAE target=apex
event parameter create name=DecisionEvent parName=decision schemaName=SimpleStringType#-------------------------------------------------------------------------------
# ============LICENSE_START=======================================================
#  Copyright (C) 2016-2018 Ericsson. 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=========================================================
#-------------------------------------------------------------------------------
# POLICY B

model create name=DecisionMakerPolicyModelTwo

schema create name=SimpleStringType  flavour=Java schema=java.lang.String
schema create name=SimpleIntegerType flavour=Java schema=java.lang.Integer

album create name=AnswerAlbum scope=policy writable=true schemaName=SimpleStringType
album create name=LastAnswerAlbum scope=policy writable=true schemaName=SimpleIntegerType

event create name=AnswerEvent nameSpace=org.onap.policy.apex.domains.decisionmaker source=DCAE target=apex
event parameter create name=AnswerEvent parName=a0 schemaName=SimpleStringType
event parameter create name=AnswerEvent parName=a1 schemaName=SimpleStringType
event parameter create name=AnswerEvent parName=a2 schemaName=SimpleStringType
event parameter create name=AnswerEvent parName=a3 schemaName=SimpleStringType
event parameter create name=AnswerEvent parName=a4 schemaName=SimpleStringType
event parameter create name=AnswerEvent parName=a5 schemaName=SimpleStringType
event parameter create name=AnswerEvent parName=a6 schemaName=SimpleStringType

event create name=MakeDecisionEvent nameSpace=org.onap.policy.apex.domains.decisionmaker source=DCAE target=apex
event parameter create name=MakeDecisionEvent parName=mode schemaName=SimpleStringType

event create name=DecisionEvent nameSpace=org.onap.policy.apex.domains.decisionmaker source=DCAE target=apex
event parameter create name=DecisionEvent parName=decision schemaName=SimpleStringType

task create name=AnswerInitTask
task inputfield create name=AnswerInitTask fieldName=a0 schemaName=SimpleStringType
task inputfield create name=AnswerInitTask fieldName=a1 schemaName=SimpleStringType
task inputfield create name=AnswerInitTask fieldName=a2 schemaName=SimpleStringType
task inputfield create name=AnswerInitTask fieldName=a3 schemaName=SimpleStringType
task inputfield create name=AnswerInitTask fieldName=a4 schemaName=SimpleStringType
task inputfield create name=AnswerInitTask fieldName=a5 schemaName=SimpleStringType
task inputfield create name=AnswerInitTask fieldName=a6 schemaName=SimpleStringType

task outputfield create name=AnswerInitTask fieldName=a0 schemaName=SimpleStringType
task outputfield create name=AnswerInitTask fieldName=a1 schemaName=SimpleStringType
task outputfield create name=AnswerInitTask fieldName=a2 schemaName=SimpleStringType
task outputfield create name=AnswerInitTask fieldName=a3 schemaName=SimpleStringType
task outputfield create name=AnswerInitTask fieldName=a4 schemaName=SimpleStringType
task outputfield create name=AnswerInitTask fieldName=a5 schemaName=SimpleStringType
task outputfield create name=AnswerInitTask fieldName=a6 schemaName=SimpleStringType

task contextref create name=AnswerInitTask albumName=AnswerAlbum
task contextref create name=AnswerInitTask albumName=LastAnswerAlbum

task logic create name=AnswerInitTask logicFlavour=JAVASCRIPT logic=LS
#MACROFILE:"src/main/resources/logic/AnswerInitTask.js"
LE

task create name=RandomAnswerTask

task inputfield create name=RandomAnswerTask fieldName=mode schemaName=SimpleStringType

task outputfield create name=RandomAnswerTask fieldName=decision schemaName=SimpleStringType

task contextref create name=RandomAnswerTask albumName=AnswerAlbum

task logic create name=RandomAnswerTask logicFlavour=JAVASCRIPT logic=LS
#MACROFILE:"src/main/resources/logic/RandomAnswerTask.js"
LE

task create name=PessimisticAnswerTask

task inputfield create name=PessimisticAnswerTask fieldName=mode schemaName=SimpleStringType

task outputfield create name=PessimisticAnswerTask fieldName=decision schemaName=SimpleStringType

task contextref create name=PessimisticAnswerTask albumName=AnswerAlbum

task logic create name=PessimisticAnswerTask logicFlavour=JAVASCRIPT logic=LS
#MACROFILE:"src/main/resources/logic/PessimisticAnswerTask.js"
LE

task create name=OptimisticAnswerTask

task inputfield create name=OptimisticAnswerTask fieldName=mode schemaName=SimpleStringType

task outputfield create name=OptimisticAnswerTask fieldName=decision schemaName=SimpleStringType

task contextref create name=OptimisticAnswerTask albumName=AnswerAlbum

task logic create name=OptimisticAnswerTask logicFlavour=JAVASCRIPT logic=LS
#MACROFILE:"src/main/resources/logic/OptimisticAnswerTask.js"
LE

task create name=DitheringAnswerTask

task inputfield create name=DitheringAnswerTask fieldName=mode schemaName=SimpleStringType

task outputfield create name=DitheringAnswerTask fieldName=decision schemaName=SimpleStringType

task contextref create name=DitheringAnswerTask albumName=AnswerAlbum

task logic create name=DitheringAnswerTask logicFlavour=JAVASCRIPT logic=LS
#MACROFILE:"src/main/resources/logic/DitheringAnswerTask.js"
LE

task create name=RoundRobinAnswerTask

task inputfield create name=RoundRobinAnswerTask fieldName=mode schemaName=SimpleStringType

task outputfield create name=RoundRobinAnswerTask fieldName=decision schemaName=SimpleStringType

task contextref create name=RoundRobinAnswerTask albumName=AnswerAlbum
task contextref create name=RoundRobinAnswerTask albumName=LastAnswerAlbum

task logic create name=RoundRobinAnswerTask logicFlavour=JAVASCRIPT logic=LS
#MACROFILE:"src/main/resources/logic/RoundRobinAnswerTask.js"
LE

policy create name=DecisionMakerPolicy template=freestyle firstState=MakeDecisionState

policy state create name=DecisionMakerPolicy stateName=MakeDecisionState triggerName=MakeDecisionEvent defaultTaskName=RandomAnswerTask
policy state output create name=DecisionMakerPolicy stateName=MakeDecisionState outputName=DecisionFinalOutput eventName=DecisionEvent
policy state taskref create name=DecisionMakerPolicy stateName=MakeDecisionState taskName=RandomAnswerTask outputType=DIRECT outputName=DecisionFinalOutput
policy state taskref create name=DecisionMakerPolicy stateName=MakeDecisionState taskName=PessimisticAnswerTask outputType=DIRECT outputName=DecisionFinalOutput
policy state taskref create name=DecisionMakerPolicy stateName=MakeDecisionState taskName=OptimisticAnswerTask outputType=DIRECT outputName=DecisionFinalOutput
policy state taskref create name=DecisionMakerPolicy stateName=MakeDecisionState taskName=DitheringAnswerTask outputType=DIRECT outputName=DecisionFinalOutput
policy state taskref create name=DecisionMakerPolicy stateName=MakeDecisionState taskName=RoundRobinAnswerTask outputType=DIRECT outputName=DecisionFinalOutput

policy state selecttasklogic create name=DecisionMakerPolicy stateName=MakeDecisionState logicFlavour=JAVASCRIPT logic=LS
#MACROFILE:"src/main/resources/logic/MakeDecisionStateTSL.js"
LE

validate


  


Other Changes
  • Changes to config
  • Changes to html files for testing
  • Changes to pom to generate policies
  • Changes to ToscaTemplate


Code Block
languageyml
titleApexConfig.json
linenumberstrue
collapsetrue
{
    "engineServiceParameters": {
        "name": "MyApexEngine",
        "version": "0.0.1",
        "id": 45,
        "instanceCount": 4,
        "deploymentPort": 12345,
        "engineParameters": {
            "executorParameters": {
                "JAVASCRIPT": {
                    "parameterClassName": "org.onap.policy.apex.plugins.executor.javascript.JavascriptExecutorParameters"
                }
            }
        }
    },
    "eventInputParameters": {
        "RESTConsumerTwo": {
            "carrierTechnologyParameters": {
                "carrierTechnology": "RESTSERVER",
                "parameterClassName": "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters",
                "parameters": {
                    "standalone": true,
                    "host": "0.0.0.0",
                    "port": 23325
                }
            },
            "eventProtocolParameters": {
                "eventProtocol": "JSON"
            },
            "synchronousMode": true,
            "synchronousPeer": "RESTProducerTwo",
            "synchronousTimeout": 500
        }
    },
    "eventOutputParameters": {
        "logProducerTwo": {
            "carrierTechnologyParameters": {
                "carrierTechnology": "FILE",
                "parameters": {
                    "fileName": "/tmp/EventsOutTwo.json"
                }
            },
            "eventProtocolParameters": {
                "eventProtocol": "JSON"
            }
        },
        "RESTProducerTwo": {
            "carrierTechnologyParameters":{
                "carrierTechnology" : "RESTSERVER",
                "parameterClassName" : "org.onap.policy.apex.plugins.event.carrier.restserver.RestServerCarrierTechnologyParameters"
            },
            "eventProtocolParameters":{
                "eventProtocol" : "JSON"
            },
            "synchronousMode"    : true,
            "synchronousPeer"    : "RESTConsumerTwo",
            "synchronousTimeout" : 500
        }
    }
}


Code Block
languageyml
titleToscaTemplate.json
linenumberstrue
collapsetrue
{
  "tosca_definitions_version": "tosca_simple_yaml_1_1_0",
  "topology_template": {
    "policies": [
      {
        "onap.policies.native.apex.DecisionMakerTwo": {
          "type": "onap.policies.native.Apex",
          "type_version": "1.0.0",
          "name": "onap.policies.native.apex.DecisionMakerTwo",
          "version": "1.0.0",
          "properties": {
          }
        }
      }
    ]
  }
}


Code Block
languagexml
titleMakeDecision_server.html
collapsetrue
<!--
  ============LICENSE_START=======================================================
   Copyright (C) 2016-2018 Ericsson. 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=========================================================
-->

<!-- http://localhost:23325/apex/eventInput/EventIn -->

<html>
<head>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
    $(document).ready(function() {
        $("#answerspost").click(function(e) {
            var elements = document.getElementById("answerform").elements;

            var formValues = new Object;
            formValues["name"] = "AnswerEvent";
            for (var i = 0, element; element = elements[i++];) {
                if (element.type === "text" && element.value != "") {
                    formValues[element.name] = element.value;
                }
            }
            console.log(formValues);
            var stringifiedForm = JSON.stringify(formValues);
            console.log(stringifiedForm);
            $.ajax({
                type : "POST",
                url : "http://localhost:23325/apex/RESTConsumerTwo/EventIn",
                data : stringifiedForm,
                crossDomain : true,
                contentType : "application/json; charset=utf-8",
                success : function(data) {
                    alert("Answers Set Successfully !!!");
                },
                failure : function(errMsg) {
                    alert(errMsg);
                }
            });
            e.preventDefault(); //STOP default action

        });
    });
</script>
<script>
    $(document).ready(function() {
        $("#modepost").click(function(e) {
            var elements = document.getElementById("modeform").elements;

            var formValues = new Object;
            formValues["name"] = "MakeDecisionEvent";
            for (var i = 0, element; element = elements[i++];) {
                if (element.type === "radio" && element.checked) {
                    formValues[element.name] = element.value;
                }
            }
            console.log(formValues);
            var stringifiedForm = JSON.stringify(formValues);
            console.log(stringifiedForm);
            $.ajax({
                type : "POST",
                url : "http://localhost:23325/apex/RESTConsumerTwo/EventIn",
                data : stringifiedForm,
                crossDomain : true,
                contentType : "application/json; charset=utf-8",
                success : function(data) {
                    alert("Decision Taken: " + data.decision);
                },
                failure : function(errMsg) {
                    alert(errMsg);
                }
            });
            e.preventDefault(); //STOP default action

        });
    });
</script>
</head>
<body>
    <h3>Decision Maker Answers</h3>
    <form name="answerform" id="answerform" method="POST">
        <table>
            <tr>
                <td>First Answer:</td>
                <td><input type="text" name="a0" value="Never Ever" /></td>
            </tr>
            <tr>
                <td>Second Answer:</td>
                <td><input type="text" name="a1" value="No" /></td>
            </tr>
            <tr>
                <td>Third Answer:</td>
                <td><input type="text" name="a2" value="Maybe not" /></td>
            </tr>
            <tr>
                <td>Fourth Answer</td>
                <td><input type="text" name="a3" value="Wait" /></td>
            </tr>
            <tr>
                <td>Fifth Answer:</td>
                <td><input type="text" name="a4" value="Maybe" /></td>
            </tr>
            <tr>
                <td>Sixth Answer:</td>
                <td><input type="text" name="a5" value="Yes" /></td>
            </tr>
            <tr>
                <td>Seventh Answer:</td>
                <td><input type="text" name="a6" value="Absolutely" /></td>
            </tr>
            <tr>
                <td />
                <td><input type="button" class="btn btn-info" id="answerspost"
                    value="Set Answers"></td>
            </tr>
        </table>
    </form>
    <h3>Decision Maker Mode</h3>
    <form name="modeform" id="modeform" method="POST">
        <table>
            <tr>
                <td><input name="mode" type="radio" value="random"
                    checked="checked">random</td>
                <td><input name="mode" type="radio" value="pessimistic">pessimistic</td>
                <td><input name="mode" type="radio" value="optimistic">
                    optimistic</td>
                <td><input name="mode" type="radio" value="dithering">dithering</td>
            </tr>
            <tr>
                <td />
                <td />
                <td />
                <td><input type="button" class="btn btn-info" id="modepost"
                    value="Make Decision"></td>
            </tr>
        </table>
    </form>
</body>
</html>


Code Block
languagexml
titlepom.xml
linenumberstrue
collapsetrue
              ....     
                   <execution>
                        <id>generate-decisionmaker-policy</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>org.onap.policy.apex.auth.clieditor.tosca.ApexCliToscaEditorMain</mainClass>
                            <classpathScope>compile</classpathScope>
                            <arguments>
                                <argument>--command-file=${project.basedir}/src/main/resources/policy/${policymodel.decisionmaker.name}.apex</argument>
                                <argument>--output-tosca-file=${project.build.directory}/classes/${policymodel.decisionmaker.name}.json</argument>
                                <argument>--log-file=${project.build.directory}/${policymodel.decisionmaker.name}_policygeneration.log</argument>
                                <argument>--apex-config-file=${project.basedir}/src/main/resources/examples/config/DecisionMaker/ApexConfigRESTServerNoModel.json</argument>
                                <argument>--tosca-template-file=${project.basedir}/src/main/resources/tosca/ToscaTemplate.json</argument>
                            </arguments>
                        </configuration>
                    </execution>
                    <execution>
                        <id>generate-decisionmakertwo-policy</id>
                        <phase>compile</phase>
                        <goals>
                            <goal>java</goal>
                        </goals>
                        <configuration>
                            <mainClass>org.onap.policy.apex.auth.clieditor.tosca.ApexCliToscaEditorMain</mainClass>
                            <classpathScope>compile</classpathScope>
                            <arguments>
                                <argument>--command-file=${project.basedir}/src/main/resources/policy/${policymodel.decisionmakertwo.name}.apex</argument>
                                <argument>--output-tosca-file=${project.build.directory}/classes/${policymodel.decisionmakertwo.name}.json</argument>
                                <argument>--log-file=${project.build.directory}/${policymodel.decisionmakertwo.name}_policygeneration.log</argument>
                                <argument>--apex-config-file=${project.basedir}/src/main/resources/examples/config/DecisionMaker/ApexConfigRESTServerNoModelTwo.json</argument>
                                <argument>--tosca-template-file=${project.basedir}/src/main/resources/tosca/ToscaTemplateTwo.json</argument>
                            </arguments>
                        </configuration>
                    </execution>
               ....


Deploy both policiesDeploy both policies on single Apex instance


Code Block
languageyml
titleResult
{
    "groups": [
        {
            "name": "defaultGroup",
            "description": "The default group that registers all supported policy types and pdps.",
            "pdpGroupState": "ACTIVE",
            "properties": {},
            "pdpSubgroups": [
                {
                    "pdpType": "apex",
                    "supportedPolicyTypes": [
                        {
                            "name": "onap.policies.controlloop.operational.common.Apex",
                            "version": "1.0.0"
                        },
                        {
                            "name": "onap.policies.native.Apex",
                            "version": "1.0.0"
                        }
                    ],
                    "policies": [
                        {
                            "name": "onap.policies.native.apex.DecisionMakerTwo",
                            "version": "1.0.0"
                        },
                        {
                            "name": "onap.policies.native.apex.DecisionMaker",
                            "version": "1.0.0"
                        }
                    ],
                    "currentInstanceCount": 1,
                    "desiredInstanceCount": 1,
                    "properties": {},
                    "pdpInstances": [
                        {
                            "instanceId": "apex-a309a391-a1d3-4a90-8acb-07cfc2326c9b",
                            "pdpState": "ACTIVE",
                            "healthy": "HEALTHY",
                            "message": "Pdp Heartbeat",
                            "lastUpdate": "2023-09-13T11:16:13Z"
                        }
                    ]
                }
            ]
        }
    ]
}


Set Answers (Policy A)Use Policy A to set the answers

Code Block
languagetext
titleLogs
[2023-09-13T11:18:13.556+00:00|INFO|RequestLog|qtp1245550638-104] 172.30.0.1 - - [13/Sep/2023:11:18:13 +0000] "OPTIONS /apex/RESTConsumer/EventIn HTTP/1.1" 200 1022 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0"
[2023-09-13T11:18:13.565+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-5:0] AnswerInitTask:0.0.1
[2023-09-13T11:18:13.565+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-5:0] {a0=Never Ever Answer01, a1=No Answer01, a2=Maybe not Answer01, a3=Waiting Answer01, a4=Maybe Answer01, a5=Yes Answer01, a6=Absolutely Answer01}
[2023-09-13T11:18:13.566+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-5:0] {a0=Never Ever Answer01, a1=No Answer01, a2=Maybe not Answer01, a3=Waiting Answer01, a4=Maybe Answer01, a5=Yes Answer01, a6=Absolutely Answer01}
[2023-09-13T11:18:13.666+00:00|INFO|RequestLog|qtp1245550638-82] 172.30.0.1 - - [13/Sep/2023:11:18:13 +0000] "POST /apex/RESTConsumer/EventIn HTTP/1.1" 200 369 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0"


Make Decision (Policy B)Use Policy B to select an answer

Code Block
languagetext
titleResult
linenumberstrue
collapsetrue
[2023-09-13T11:20:03.342+00:00|INFO|RequestLog|qtp592898653-106] 172.30.0.1 - - [13/Sep/2023:11:20:03 +0000] "OPTIONS /apex/RESTConsumerTwo/EventIn HTTP/1.1" 200 1025 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0"
[2023-09-13T11:20:03.348+00:00|INFO|TaskSelectionExecutionLogging|Apex-apex-engine-service-0:0] DecisionMakerPolicy:0.0.1:NULL:MakeDecisionState
[2023-09-13T11:20:03.348+00:00|INFO|TaskSelectionExecutionLogging|Apex-apex-engine-service-0:0] EnEvent [axEvent=AxEvent:(key=AxArtifactKey:(name=MakeDecisionEvent,version=0.0.1),nameSpace=org.onap.policy.apex.domains.decisionmaker,source=DCAE,target=apex,parameter={mode=AxField:(key=AxReferenceKey:(parentKeyName=MakeDecisionEvent,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=mode),fieldSchemaKey=AxArtifactKey:(name=SimpleStringType,version=0.0.1),optional=false)},toscaPolicyState=), userArtifactStack=[AxArtifactKey:(name=DecisionMakerPolicy,version=0.0.1), AxReferenceKey:(parentKeyName=DecisionMakerPolicy,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=MakeDecisionState), AxArtifactKey:(name=MakeDecisionEvent,version=0.0.1)], map={mode=random}]
[2023-09-13T11:20:03.349+00:00|INFO|TaskSelectionExecutionLogging|Apex-apex-engine-service-0:0] Answer Selected Task:AxArtifactKey:(name=RandomAnswerTask,version=0.0.1)
[2023-09-13T11:20:03.350+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-0:0] RandomAnswerTask:0.0.1
[2023-09-13T11:20:03.350+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-0:0] {mode=random}
[2023-09-13T11:20:03.350+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-0:0] 7
[2023-09-13T11:20:03.350+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-0:0] a4
[2023-09-13T11:20:03.350+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-0:0] {decision=Maybe Answer01}


Code Block
languagetext
titleResult
linenumberstrue
collapsetrue
[2023-09-13T11:20:24.289+00:00|INFO|RequestLog|qtp592898653-95] 172.30.0.1 - - [13/Sep/2023:11:20:24 +0000] "OPTIONS /apex/RESTConsumerTwo/EventIn HTTP/1.1" 200 1025 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0"
[2023-09-13T11:20:24.295+00:00|INFO|TaskSelectionExecutionLogging|Apex-apex-engine-service-0:1] DecisionMakerPolicy:0.0.1:NULL:MakeDecisionState
[2023-09-13T11:20:24.296+00:00|INFO|TaskSelectionExecutionLogging|Apex-apex-engine-service-0:1] EnEvent [axEvent=AxEvent:(key=AxArtifactKey:(name=MakeDecisionEvent,version=0.0.1),nameSpace=org.onap.policy.apex.domains.decisionmaker,source=DCAE,target=apex,parameter={mode=AxField:(key=AxReferenceKey:(parentKeyName=MakeDecisionEvent,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=mode),fieldSchemaKey=AxArtifactKey:(name=SimpleStringType,version=0.0.1),optional=false)},toscaPolicyState=), userArtifactStack=[AxArtifactKey:(name=DecisionMakerPolicy,version=0.0.1), AxReferenceKey:(parentKeyName=DecisionMakerPolicy,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=MakeDecisionState), AxArtifactKey:(name=MakeDecisionEvent,version=0.0.1)], map={mode=pessimistic}]
[2023-09-13T11:20:24.296+00:00|INFO|TaskSelectionExecutionLogging|Apex-apex-engine-service-0:1] Answer Selected Task:AxArtifactKey:(name=PessimisticAnswerTask,version=0.0.1)
[2023-09-13T11:20:24.297+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-0:1] PessimisticAnswerTask:0.0.1
[2023-09-13T11:20:24.297+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-0:1] {mode=pessimistic}
[2023-09-13T11:20:24.298+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-0:1] 7
[2023-09-13T11:20:24.298+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-0:1] a1
[2023-09-13T11:20:24.298+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-0:1] {decision=No Answer01}


Code Block
languagetext
titleResult
linenumberstrue
collapsetrue
[2023-09-13T11:20:46.662+00:00|INFO|TaskSelectionExecutionLogging|Apex-apex-engine-service-0:2] DecisionMakerPolicy:0.0.1:NULL:MakeDecisionState
[2023-09-13T11:20:46.663+00:00|INFO|TaskSelectionExecutionLogging|Apex-apex-engine-service-0:2] EnEvent [axEvent=AxEvent:(key=AxArtifactKey:(name=MakeDecisionEvent,version=0.0.1),nameSpace=org.onap.policy.apex.domains.decisionmaker,source=DCAE,target=apex,parameter={mode=AxField:(key=AxReferenceKey:(parentKeyName=MakeDecisionEvent,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=mode),fieldSchemaKey=AxArtifactKey:(name=SimpleStringType,version=0.0.1),optional=false)},toscaPolicyState=), userArtifactStack=[AxArtifactKey:(name=DecisionMakerPolicy,version=0.0.1), AxReferenceKey:(parentKeyName=DecisionMakerPolicy,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=MakeDecisionState), AxArtifactKey:(name=MakeDecisionEvent,version=0.0.1)], map={mode=optimistic}]
[2023-09-13T11:20:46.663+00:00|INFO|TaskSelectionExecutionLogging|Apex-apex-engine-service-0:2] Answer Selected Task:AxArtifactKey:(name=OptimisticAnswerTask,version=0.0.1)
[2023-09-13T11:20:46.664+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-0:2] OptimisticAnswerTask:0.0.1
[2023-09-13T11:20:46.664+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-0:2] {mode=optimistic}
[2023-09-13T11:20:46.664+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-0:2] 7
[2023-09-13T11:20:46.664+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-0:2] a6
[2023-09-13T11:20:46.664+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-0:2] {decision=Absolutely Answer01}


Code Block
languagetext
titleResult
linenumberstrue
collapsetrue
[2023-09-13T11:21:07.437+00:00|INFO|RequestLog|qtp592898653-95] 172.30.0.1 - - [13/Sep/2023:11:21:07 +0000] "OPTIONS /apex/RESTConsumerTwo/EventIn HTTP/1.1" 200 1025 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/117.0"
[2023-09-13T11:21:07.444+00:00|INFO|TaskSelectionExecutionLogging|Apex-apex-engine-service-0:3] DecisionMakerPolicy:0.0.1:NULL:MakeDecisionState
[2023-09-13T11:21:07.445+00:00|INFO|TaskSelectionExecutionLogging|Apex-apex-engine-service-0:3] EnEvent [axEvent=AxEvent:(key=AxArtifactKey:(name=MakeDecisionEvent,version=0.0.1),nameSpace=org.onap.policy.apex.domains.decisionmaker,source=DCAE,target=apex,parameter={mode=AxField:(key=AxReferenceKey:(parentKeyName=MakeDecisionEvent,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=mode),fieldSchemaKey=AxArtifactKey:(name=SimpleStringType,version=0.0.1),optional=false)},toscaPolicyState=), userArtifactStack=[AxArtifactKey:(name=DecisionMakerPolicy,version=0.0.1), AxReferenceKey:(parentKeyName=DecisionMakerPolicy,parentKeyVersion=0.0.1,parentLocalName=NULL,localName=MakeDecisionState), AxArtifactKey:(name=MakeDecisionEvent,version=0.0.1)], map={mode=dithering}]
[2023-09-13T11:21:07.445+00:00|INFO|TaskSelectionExecutionLogging|Apex-apex-engine-service-0:3] Answer Selected Task:AxArtifactKey:(name=DitheringAnswerTask,version=0.0.1)
[2023-09-13T11:21:07.447+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-0:3] DitheringAnswerTask:0.0.1
[2023-09-13T11:21:07.447+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-0:3] {mode=dithering}
[2023-09-13T11:21:07.447+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-0:3] 7
[2023-09-13T11:21:07.447+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-0:3] a4
[2023-09-13T11:21:07.448+00:00|INFO|TaskExecutionLogging|Apex-apex-engine-service-0:3] {decision=Maybe Answer01}







Conclusion

Apex-pdp engine is capable of sharing context across separate policy sets running in the same apex-pdp engine.

No further changes are required.