Uploaded image for project: 'OptaPlanner'
  1. OptaPlanner
  2. PLANNER-281

Score configuration should allow combining <scoreDrl> with <scoreDrlFile>

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Major
    • 6.2.0.Final
    • 6.1.0.Final
    • optaplanner-core
    • None

    Description

      We are trying to add a support for user provided rules to our ovirt-optimizer project. The default ruleset is stored in the jar distribution as a resource. Users are supposed to put the rule extensions to /etc/ovirt-optimizer-rules.d and we are supposed to pick those up and merge them with the default file.

      When we try to accomplish this using:

      private void addCustomDrlFiles(ScoreDirectorFactoryConfig config, List<File> customDrlFiles) {
          if (config.getScoreDrlFileList() != null) {
              config.getScoreDrlFileList().addAll(customDrlFiles);
          } else {
              config.setScoreDrlFileList(customDrlFiles);
          }
      }
      

      This method is then used in:

      SolverFactory solverFactory = SolverFactory.createFromXmlResource("org/ovirt/optimizer/service/rules/solver.xml");
      addCustomDrlFiles(solverFactory.getSolverConfig().getScoreDirectorFactoryConfig(), this.customDrlFiles);
      solver = solverFactory.buildSolver();
      

      We get an exception telling us that this is not possible:

      [STDOUT] java.lang.IllegalArgumentException: The scoreDrlList ([/org/ovirt/optimizer/service/rules/default.drl]) and the scoreDrlFileList ([/tmp/rule.d/test.drl]) cannot both be non empty.
      [STDOUT] 	at org.optaplanner.core.config.score.director.ScoreDirectorFactoryConfig.buildKieBase(ScoreDirectorFactoryConfig.java:340)
      [STDOUT] 	at org.optaplanner.core.config.score.director.ScoreDirectorFactoryConfig.buildDroolsScoreDirectorFactory(ScoreDirectorFactoryConfig.java:319)
      [STDOUT] 	at org.optaplanner.core.config.score.director.ScoreDirectorFactoryConfig.buildScoreDirectorFactory(ScoreDirectorFactoryConfig.java:209)
      [STDOUT] 	at org.optaplanner.core.config.score.director.ScoreDirectorFactoryConfig.buildScoreDirectorFactory(ScoreDirectorFactoryConfig.java:197)
      [STDOUT] 	at org.optaplanner.core.config.solver.SolverConfig.buildSolver(SolverConfig.java:185)
      [STDOUT] 	at org.optaplanner.core.impl.solver.XStreamXmlSolverFactory.buildSolver(XStreamXmlSolverFactory.java:134)
      [STDOUT] 	at org.ovirt.optimizer.service.ClusterOptimizer.<init>(ClusterOptimizer.java:184)
      [STDOUT] 	at org.ovirt.optimizer.service.ClusterOptimizer.optimizeCluster(ClusterOptimizer.java:166)
      

      We do not think there is a good reason for this and believe this limitation should be removed.

      Attachments

        Activity

          People

            gdesmet@redhat.com Geoffrey De Smet (Inactive)
            msivak@redhat.com Martin Sivak
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: