From 2f75e9d08d1e47e2b9b39ec21653bc3b4d65d00a Mon Sep 17 00:00:00 2001 From: liamfallon Date: Mon, 23 Mar 2020 17:49:50 +0000 Subject: Launch separate threads for Javascript task execution When a policy is loaded, a separate thread is spawned for each Javascript script executor. This allows us to precompile the Javascript scripts and also to have a larger stack available for script execution. Issue-ID: POLICY-2106 Change-Id: I97323aafb623ba537ac1889b3c9504b345b4f67e Signed-off-by: liamfallon --- .../main/resources/logic/MakeDecisionStateTSL.js | 6 ++--- .../resources/policy/DecisionMakerPolicyModel.apex | 26 +++++++++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) (limited to 'examples/examples-decisionmaker/src') diff --git a/examples/examples-decisionmaker/src/main/resources/logic/MakeDecisionStateTSL.js b/examples/examples-decisionmaker/src/main/resources/logic/MakeDecisionStateTSL.js index 33af49534..e49438d14 100644 --- a/examples/examples-decisionmaker/src/main/resources/logic/MakeDecisionStateTSL.js +++ b/examples/examples-decisionmaker/src/main/resources/logic/MakeDecisionStateTSL.js @@ -34,9 +34,9 @@ else if (executor.inFields.get("mode").equals("optimistic")) { else if (executor.inFields.get("mode").equals("dithering")) { executor.subject.getTaskKey("DitheringAnswerTask").copyTo(executor.selectedTask); } -//else if (executor.inFields.get("mode").equals("roundrobin")) { -// executor.subject.getTaskKey("RoundRobinAnswerTask").copyTo(executor.selectedTask); -//} +else if (executor.inFields.get("mode").equals("roundrobin")) { + executor.subject.getTaskKey("RoundRobinAnswerTask").copyTo(executor.selectedTask); +} executor.logger.info("Answer Selected Task:" + executor.selectedTask); diff --git a/examples/examples-decisionmaker/src/main/resources/policy/DecisionMakerPolicyModel.apex b/examples/examples-decisionmaker/src/main/resources/policy/DecisionMakerPolicyModel.apex index 295afa159..672ff894f 100644 --- a/examples/examples-decisionmaker/src/main/resources/policy/DecisionMakerPolicyModel.apex +++ b/examples/examples-decisionmaker/src/main/resources/policy/DecisionMakerPolicyModel.apex @@ -113,18 +113,18 @@ 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 +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 @@ -140,7 +140,7 @@ policy state taskref create name=DecisionMakerPolicy stateName=MakeDecisionState 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 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" -- cgit 1.2.3-korg