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 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 the AbstractRulesModuleModel module
      listener - instance of KieContainerListener that fires when the switch of Kie Container is complete
      postTaskList - chain of post-task operations incapsulated as a linked list of Supplier instances
      enableIncrementalUpdate - flag, if true, enables for incremental updates of the rule engine kie module
      result - instance of RuleEngineActionResult to 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 name
      listener - instance of KieContainerListener that fires when the switch of Kie Container is complete
      resultsAccumulator - the list that will contain the method execution results including the post-tasks
      resetFlagSupplier - 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 of Supplier instances
      enableIncrementalUpdate - flag, if true, enables for incremental updates of the rule engine kie module
      result - instance of RuleEngineActionResult to 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 of KieContainer for a given KieModule
      Parameters:
      module - instance of DroolsKIEModuleModel
      kieModule - instance of KieModule
      result - instance of RuleEngineActionResult to be used in cluster nodes notification
      Returns:
      new KieContainer instance
    • createKieModule

      org.apache.commons.lang3.tuple.Pair<org.kie.api.builder.KieModule,KIEModuleCacheBuilder> createKieModule(DroolsKIEModuleModel module, RuleEngineActionResult result)
      Creates the new instance of KieModule, based on information contained in DroolsKIEModuleModel
      Parameters:
      module - instance of DroolsKIEModuleModel
      result - instance of RuleEngineActionResult to be used in cluster nodes notification
      Returns:
      pair of the newly created instance of KieModule and 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 new KieBaseModel to a KieModuleModel with all rules
      Parameters:
      module - instance of KieModuleModel to add the KieBaseModel to
      kfs - instance of KieFileSystem
      base - instance of DroolsKIEBaseModel that keeps the information for a KieBaseModel to be created
      cache - the caching structure for the module being initialized
    • addKieBase

      void addKieBase(org.kie.api.builder.model.KieModuleModel module, DroolsKIEBaseModel base)
      Adds new KieBaseModel to a KieModuleModel with all rules
      Parameters:
      module - instance of KieModuleModel to add the KieBaseModel to
      base - instance of DroolsKIEBaseModel that keeps the information for a KieBaseModel to be created
    • activateKieModule

      String activateKieModule(DroolsKIEModuleModel module)
      Updates the instance of DroolsKIEModuleModel with information about affectively deployed ReleaseId version
      Parameters:
      module - instance of DroolsKIEModuleModel
      Returns:
      version of deployed ReleaseId
    • removeKieModuleIfPresent

      boolean removeKieModuleIfPresent(org.kie.api.builder.ReleaseId releaseId, RuleEngineActionResult result)
      Tries to remove the KieModule with given ReleaseId from KieRepository
      Parameters:
      releaseId - the instance of ReleaseId corresponding to a KieModule to be removed
      result - instance of RuleEngineActionResult to be used in cluster nodes notification removal
      Returns:
      true if the module was found and removed, false otherwise
    • removeOldKieModuleIfPresent

      boolean removeOldKieModuleIfPresent(RuleEngineActionResult result)
      Tries to remove the old KieModule from KieRepository
      Parameters:
      result - instance of RuleEngineActionResult to be used in cluster nodes notification removal
      Returns:
      true if the module was found and removed, false otherwise
    • addKieSession

      void addKieSession(org.kie.api.builder.model.KieBaseModel base, DroolsKIESessionModel session)
      Adds instance of new KieSessionModel to KieBaseModel
      Parameters:
      base - instance of KieBaseModel
      session - instance of DroolsKIESessionModel containing the information for new KieSessionModel
    • addRules

      void addRules(org.kie.api.builder.KieFileSystem kfs, DroolsKIEBaseModel base, KIEModuleCacheBuilder cache)
      Adds rules from a given DroolsKIEBaseModel to KieFileSystem
      Parameters:
      kfs - instance of KieFileSystem
      base - instance of DroolsKIEBaseModel containing the reference to the rules to publish
      cache - 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 of KieModuleModel and writes it to KieFileSystem
      Parameters:
      module - instance of KieModuleModel
      kfs - instance of KieFileSystem
    • writePomXML

      void writePomXML(DroolsKIEModuleModel module, org.kie.api.builder.KieFileSystem kfs)
      Write the building POM XML to KieFileSystem
      Parameters:
      module - instance of DroolsKIEModuleModel to be used for ReleaseId creation
      kfs - instance of KieFileSystem
    • getReleaseId

      org.kie.api.builder.ReleaseId getReleaseId(DroolsKIEModuleModel module)
      Creates the new instance of ReleaseId based on DroolsKIEModuleModel
      Parameters:
      module - instance of DroolsKIEModuleModel
      Returns:
      newly created ReleaseId
    • getDeployedReleaseId

      Optional<org.kie.api.builder.ReleaseId> getDeployedReleaseId(DroolsKIEModuleModel module, String deployedMvnVersion)
      Returns (optional) ReleaseId for a deployed version of the KieModuleModel
      Parameters:
      module - instance of DroolsKIEModuleModel
      deployedMvnVersion - currently deployed releaseId version of the Kie Module, if known
      Returns:
      instance of Optional.of(ReleaseId) if the ReleaseId could be created, Optional.empty() otherwise
    • setUpKieServices

      void setUpKieServices()
      Initializes the KieServices instance
    • waitForSwappingToFinish

      void waitForSwappingToFinish()
      Block until the whole swapping task/tasks are finished
    • addRulesToCache

      void addRulesToCache(DroolsKIEBaseModel base, KIEModuleCacheBuilder cache)
      Add cacheable data of rules of the latest versions belonging to the KieBase into the cache.
      Parameters:
      base - KieBase of the rules to be processed
      cache - 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

      static MessageLevel convertLevel(org.kie.api.builder.Message.Level level)
      converts a drools message Message.Level to a MessageLevel.