Interface RuleEngineKieModuleSwapper
- All Known Implementing Classes:
DefaultRuleEngineKieModuleSwapper
public interface RuleEngineKieModuleSwapper
Drools - specific interface incapsulating the logic of swapping to a new KieContainer during the RuleEngine
initialization phase
-
Method Summary
Modifier and TypeMethodDescriptionUpdates the instance ofDroolsKIEModuleModelwith information about affectively deployedReleaseIdversionvoidaddKieBase(org.kie.api.builder.model.KieModuleModel module, DroolsKIEBaseModel base) Adds newKieBaseModelto aKieModuleModelwith all rulesvoidaddKieBase(org.kie.api.builder.model.KieModuleModel module, org.kie.api.builder.KieFileSystem kfs, DroolsKIEBaseModel base, KIEModuleCacheBuilder cache) Adds newKieBaseModelto aKieModuleModelwith all rulesvoidaddKieSession(org.kie.api.builder.model.KieBaseModel base, DroolsKIESessionModel session) Adds instance of newKieSessionModeltoKieBaseModelvoidaddRules(org.kie.api.builder.KieFileSystem kfs, DroolsKIEBaseModel base, KIEModuleCacheBuilder cache) Adds rules from a givenDroolsKIEBaseModeltoKieFileSystemvoidaddRulesToCache(DroolsKIEBaseModel base, KIEModuleCacheBuilder cache) Add cacheable data of rules of the latest versions belonging to the KieBase into the cache.static MessageLevelconvertLevel(org.kie.api.builder.Message.Level level) converts a drools messageMessage.Levelto aMessageLevel.org.apache.commons.lang3.tuple.Pair<org.kie.api.builder.KieModule,KIEModuleCacheBuilder> createKieModule(DroolsKIEModuleModel module, RuleEngineActionResult result) Creates the new instance ofKieModule, based on information contained inDroolsKIEModuleModelOptional<org.kie.api.builder.ReleaseId>getDeployedReleaseId(DroolsKIEModuleModel module, String deployedMvnVersion) Returns (optional)ReleaseIdfor a deployed version of theKieModuleModelstatic org.kie.api.conf.EqualityBehaviorOptionconverts between hybris and drools equality behaviorstatic org.kie.api.conf.EventProcessingOptiongetEventProcessingOption(DroolsEventProcessingMode eventProcessingMode) converts between hybris and drools event processing modeorg.kie.api.builder.ReleaseIdgetReleaseId(DroolsKIEModuleModel module) Creates the new instance ofReleaseIdbased onDroolsKIEModuleModelstatic org.kie.api.builder.model.KieSessionModel.KieSessionTypegetSessionType(DroolsSessionType sessionType) converts between hybris and drools session typeorg.kie.api.runtime.KieContainerinitializeNewKieContainer(DroolsKIEModuleModel module, org.kie.api.builder.KieModule kieModule, RuleEngineActionResult result) Creates the new instance ofKieContainerfor a givenKieModulebooleanremoveKieModuleIfPresent(org.kie.api.builder.ReleaseId releaseId, RuleEngineActionResult result) Tries to remove theKieModulewith givenReleaseIdfromKieRepositorybooleanTries to remove the oldKieModulefromKieRepositoryvoidInitializes theKieServicesinstanceswitchKieModule(DroolsKIEModuleModel module, KieContainerListener listener, LinkedList<Supplier<Object>> postTaskList, boolean enableIncrementalUpdate, RuleEngineActionResult result) Swaps synchroneously to a new KieModule.voidswitchKieModuleAsync(String moduleName, KieContainerListener listener, List<Object> resultsAccumulator, Supplier<Object> resetFlagSupplier, List<Supplier<Object>> postTaskList, boolean enableIncrementalUpdate, RuleEngineActionResult result) Swaps asynchroneously to a new KieModule.voidBlock until the whole swapping task/tasks are finishedvoidwriteKModuleXML(org.kie.api.builder.model.KieModuleModel module, org.kie.api.builder.KieFileSystem kfs) Creates the XML representation ofKieModuleModeland writes it toKieFileSystemvoidwritePomXML(DroolsKIEModuleModel module, org.kie.api.builder.KieFileSystem kfs) Write the building POM XML toKieFileSystem
-
Method Details
-
switchKieModule
List<Object> switchKieModule(DroolsKIEModuleModel module, KieContainerListener listener, LinkedList<Supplier<Object>> postTaskList, boolean enableIncrementalUpdate, RuleEngineActionResult result) Swaps synchroneously to a new KieModule. It's a blocking call- Parameters:
module- instance of theAbstractRulesModuleModelmodulelistener- instance ofKieContainerListenerthat fires when the switch of Kie Container is completepostTaskList- chain of post-task operations incapsulated as a linked list ofSupplierinstancesenableIncrementalUpdate- flag, if true, enables for incremental updates of the rule engine kie moduleresult- instance ofRuleEngineActionResultto be used in cluster nodes notification- Returns:
- the list that will contain the method execution results including the post-tasks
-
switchKieModuleAsync
void switchKieModuleAsync(String moduleName, KieContainerListener listener, List<Object> resultsAccumulator, Supplier<Object> resetFlagSupplier, List<Supplier<Object>> postTaskList, boolean enableIncrementalUpdate, RuleEngineActionResult result) Swaps asynchroneously to a new KieModule. It's a non-blocking call- Parameters:
moduleName- kie module namelistener- instance ofKieContainerListenerthat fires when the switch of Kie Container is completeresultsAccumulator- the list that will contain the method execution results including the post-tasksresetFlagSupplier- the task to perform after the sync call finishes the task (whether it was successfull or not )postTaskList- chain of post-task operations incapsulated as a linked list ofSupplierinstancesenableIncrementalUpdate- flag, if true, enables for incremental updates of the rule engine kie moduleresult- instance ofRuleEngineActionResultto be used in cluster nodes notification
-
initializeNewKieContainer
org.kie.api.runtime.KieContainer initializeNewKieContainer(DroolsKIEModuleModel module, org.kie.api.builder.KieModule kieModule, RuleEngineActionResult result) Creates the new instance ofKieContainerfor a givenKieModule- Parameters:
module- instance ofDroolsKIEModuleModelkieModule- instance ofKieModuleresult- instance ofRuleEngineActionResultto be used in cluster nodes notification- Returns:
- new
KieContainerinstance
-
createKieModule
org.apache.commons.lang3.tuple.Pair<org.kie.api.builder.KieModule,KIEModuleCacheBuilder> createKieModule(DroolsKIEModuleModel module, RuleEngineActionResult result) Creates the new instance ofKieModule, based on information contained inDroolsKIEModuleModel- Parameters:
module- instance ofDroolsKIEModuleModelresult- instance ofRuleEngineActionResultto be used in cluster nodes notification- Returns:
- pair of the newly created instance of
KieModuleand the corresponding caching structure for the created module
-
addKieBase
void addKieBase(org.kie.api.builder.model.KieModuleModel module, org.kie.api.builder.KieFileSystem kfs, DroolsKIEBaseModel base, KIEModuleCacheBuilder cache) Adds newKieBaseModelto aKieModuleModelwith all rules- Parameters:
module- instance ofKieModuleModelto add theKieBaseModeltokfs- instance ofKieFileSystembase- instance ofDroolsKIEBaseModelthat keeps the information for aKieBaseModelto be createdcache- the caching structure for the module being initialized
-
addKieBase
Adds newKieBaseModelto aKieModuleModelwith all rules- Parameters:
module- instance ofKieModuleModelto add theKieBaseModeltobase- instance ofDroolsKIEBaseModelthat keeps the information for aKieBaseModelto be created
-
activateKieModule
Updates the instance ofDroolsKIEModuleModelwith information about affectively deployedReleaseIdversion- Parameters:
module- instance ofDroolsKIEModuleModel- Returns:
- version of deployed
ReleaseId
-
removeKieModuleIfPresent
boolean removeKieModuleIfPresent(org.kie.api.builder.ReleaseId releaseId, RuleEngineActionResult result) Tries to remove theKieModulewith givenReleaseIdfromKieRepository- Parameters:
releaseId- the instance ofReleaseIdcorresponding to aKieModuleto be removedresult- instance ofRuleEngineActionResultto be used in cluster nodes notification removal- Returns:
- true if the module was found and removed, false otherwise
-
removeOldKieModuleIfPresent
Tries to remove the oldKieModulefromKieRepository- Parameters:
result- instance ofRuleEngineActionResultto be used in cluster nodes notification removal- Returns:
- true if the module was found and removed, false otherwise
-
addKieSession
Adds instance of newKieSessionModeltoKieBaseModel- Parameters:
base- instance ofKieBaseModelsession- instance ofDroolsKIESessionModelcontaining the information for newKieSessionModel
-
addRules
void addRules(org.kie.api.builder.KieFileSystem kfs, DroolsKIEBaseModel base, KIEModuleCacheBuilder cache) Adds rules from a givenDroolsKIEBaseModeltoKieFileSystem- Parameters:
kfs- instance ofKieFileSystembase- instance ofDroolsKIEBaseModelcontaining the reference to the rules to publishcache- the caching structure for the module being initialized
-
writeKModuleXML
void writeKModuleXML(org.kie.api.builder.model.KieModuleModel module, org.kie.api.builder.KieFileSystem kfs) Creates the XML representation ofKieModuleModeland writes it toKieFileSystem- Parameters:
module- instance ofKieModuleModelkfs- instance ofKieFileSystem
-
writePomXML
Write the building POM XML toKieFileSystem- Parameters:
module- instance ofDroolsKIEModuleModelto be used forReleaseIdcreationkfs- instance ofKieFileSystem
-
getReleaseId
Creates the new instance ofReleaseIdbased onDroolsKIEModuleModel- Parameters:
module- instance ofDroolsKIEModuleModel- Returns:
- newly created
ReleaseId
-
getDeployedReleaseId
Optional<org.kie.api.builder.ReleaseId> getDeployedReleaseId(DroolsKIEModuleModel module, String deployedMvnVersion) Returns (optional)ReleaseIdfor a deployed version of theKieModuleModel- Parameters:
module- instance ofDroolsKIEModuleModeldeployedMvnVersion- currently deployed releaseId version of the Kie Module, if known- Returns:
- instance of
Optional.of(ReleaseId) if theReleaseIdcould be created,Optional.empty() otherwise
-
setUpKieServices
void setUpKieServices()Initializes theKieServicesinstance -
waitForSwappingToFinish
void waitForSwappingToFinish()Block until the whole swapping task/tasks are finished -
addRulesToCache
Add cacheable data of rules of the latest versions belonging to the KieBase into the cache.- Parameters:
base- KieBase of the rules to be processedcache- CacheBuilder to cache rule data
-
getSessionType
static org.kie.api.builder.model.KieSessionModel.KieSessionType getSessionType(DroolsSessionType sessionType) converts between hybris and drools session type -
getEqualityBehaviorOption
static org.kie.api.conf.EqualityBehaviorOption getEqualityBehaviorOption(DroolsEqualityBehavior behavior) converts between hybris and drools equality behavior -
getEventProcessingOption
static org.kie.api.conf.EventProcessingOption getEventProcessingOption(DroolsEventProcessingMode eventProcessingMode) converts between hybris and drools event processing mode -
convertLevel
converts a drools messageMessage.Levelto aMessageLevel.
-