From d40416898aa5c95eb22bf98af556dacb47d6cc6e Mon Sep 17 00:00:00 2001 From: Luca Molteni Date: Mon, 11 Mar 2024 16:29:04 +0100 Subject: [PATCH 1/5] Removed org.drools.util.RemoveCommentsMain as with the new quarkus version is not useful anymore --- .../deployment/pom.xml | 24 -------------- .../runtime/pom.xml | 25 --------------- .../deployment/pom.xml | 31 ------------------- .../runtime/pom.xml | 31 ------------------- .../deployment/pom.xml | 31 ------------------- .../optaplanner-quarkus-jsonb/runtime/pom.xml | 31 ------------------- .../optaplanner-quarkus/deployment/pom.xml | 25 --------------- .../optaplanner-quarkus/runtime/pom.xml | 28 ----------------- 8 files changed, 226 deletions(-) diff --git a/optaplanner-quarkus-integration/optaplanner-quarkus-benchmark/deployment/pom.xml b/optaplanner-quarkus-integration/optaplanner-quarkus-benchmark/deployment/pom.xml index 2f0c2960a3b..9ec3c94eda6 100644 --- a/optaplanner-quarkus-integration/optaplanner-quarkus-benchmark/deployment/pom.xml +++ b/optaplanner-quarkus-integration/optaplanner-quarkus-benchmark/deployment/pom.xml @@ -123,30 +123,6 @@ - - - - - org.codehaus.mojo - exec-maven-plugin - ${version.maven-exec-plugin} - - - Remove comments from quarkus-extension.properties - prepare-package - - java - - - org.drools.util.RemoveCommentsMain - - ${project.basedir}/target/classes/META-INF/quarkus-javadoc.properties - ${project.basedir}/target/generated-sources/annotations/org/optaplanner/benchmark/quarkus/deployment/OptaPlannerBenchmarkBuildTimeConfig.jdp - - - - - diff --git a/optaplanner-quarkus-integration/optaplanner-quarkus-benchmark/runtime/pom.xml b/optaplanner-quarkus-integration/optaplanner-quarkus-benchmark/runtime/pom.xml index bc6f9a49de7..2dcbb2d5a5d 100644 --- a/optaplanner-quarkus-integration/optaplanner-quarkus-benchmark/runtime/pom.xml +++ b/optaplanner-quarkus-integration/optaplanner-quarkus-benchmark/runtime/pom.xml @@ -111,31 +111,6 @@ - - - - - org.codehaus.mojo - exec-maven-plugin - ${version.maven-exec-plugin} - - - Remove comments from quarkus-extension.properties - prepare-package - - java - - - org.drools.util.RemoveCommentsMain - - ${project.basedir}/target/classes/META-INF/quarkus-extension.properties - ${project.basedir}/target/classes/META-INF/quarkus-javadoc.properties - ${project.basedir}/target/generated-sources/annotations/org/optaplanner/benchmark/quarkus/config/OptaPlannerBenchmarkRuntimeConfig.jdp - - - - - diff --git a/optaplanner-quarkus-integration/optaplanner-quarkus-jackson/deployment/pom.xml b/optaplanner-quarkus-integration/optaplanner-quarkus-jackson/deployment/pom.xml index 816c230f290..950f767c91e 100644 --- a/optaplanner-quarkus-integration/optaplanner-quarkus-jackson/deployment/pom.xml +++ b/optaplanner-quarkus-integration/optaplanner-quarkus-jackson/deployment/pom.xml @@ -75,37 +75,6 @@ - - - - - org.codehaus.mojo - exec-maven-plugin - ${version.maven-exec-plugin} - - - org.drools - drools-util - ${project.version} - - - - - Remove comments from quarkus-extension.properties - prepare-package - - java - - - true - org.drools.util.RemoveCommentsMain - - ${project.basedir}/target/classes/META-INF/quarkus-javadoc.properties - - - - - diff --git a/optaplanner-quarkus-integration/optaplanner-quarkus-jackson/runtime/pom.xml b/optaplanner-quarkus-integration/optaplanner-quarkus-jackson/runtime/pom.xml index 929f307ab8b..f42a2da5be1 100644 --- a/optaplanner-quarkus-integration/optaplanner-quarkus-jackson/runtime/pom.xml +++ b/optaplanner-quarkus-integration/optaplanner-quarkus-jackson/runtime/pom.xml @@ -102,37 +102,6 @@ - - - - - org.codehaus.mojo - exec-maven-plugin - ${version.maven-exec-plugin} - - - org.drools - drools-util - ${project.version} - - - - - Remove comments from quarkus-extension.properties - prepare-package - - java - - - true - org.drools.util.RemoveCommentsMain - - ${project.basedir}/target/classes/META-INF/quarkus-extension.properties - - - - - diff --git a/optaplanner-quarkus-integration/optaplanner-quarkus-jsonb/deployment/pom.xml b/optaplanner-quarkus-integration/optaplanner-quarkus-jsonb/deployment/pom.xml index c79575889bd..353abd04b76 100644 --- a/optaplanner-quarkus-integration/optaplanner-quarkus-jsonb/deployment/pom.xml +++ b/optaplanner-quarkus-integration/optaplanner-quarkus-jsonb/deployment/pom.xml @@ -75,37 +75,6 @@ - - - - - org.codehaus.mojo - exec-maven-plugin - ${version.maven-exec-plugin} - - - org.drools - drools-util - ${project.version} - - - - - Remove comments from quarkus-extension.properties - prepare-package - - java - - - true - org.drools.util.RemoveCommentsMain - - ${project.basedir}/target/classes/META-INF/quarkus-javadoc.properties - - - - - diff --git a/optaplanner-quarkus-integration/optaplanner-quarkus-jsonb/runtime/pom.xml b/optaplanner-quarkus-integration/optaplanner-quarkus-jsonb/runtime/pom.xml index 89e42704668..e1d07f03355 100644 --- a/optaplanner-quarkus-integration/optaplanner-quarkus-jsonb/runtime/pom.xml +++ b/optaplanner-quarkus-integration/optaplanner-quarkus-jsonb/runtime/pom.xml @@ -94,37 +94,6 @@ - - - - - org.codehaus.mojo - exec-maven-plugin - ${version.maven-exec-plugin} - - - org.drools - drools-util - ${project.version} - - - - - Remove comments from quarkus-extension.properties - prepare-package - - java - - - true - org.drools.util.RemoveCommentsMain - - ${project.basedir}/target/classes/META-INF/quarkus-extension.properties - - - - - diff --git a/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/pom.xml b/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/pom.xml index 631c13f0bed..139cd6f8809 100644 --- a/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/pom.xml +++ b/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/pom.xml @@ -130,31 +130,6 @@ - - - - - org.codehaus.mojo - exec-maven-plugin - ${version.maven-exec-plugin} - - - Run Script - prepare-package - - java - - - org.drools.util.RemoveCommentsMain - - ${project.basedir}/target/classes/META-INF/quarkus-javadoc.properties - ${project.basedir}/target/generated-sources/annotations/org/optaplanner/quarkus/deployment/config/OptaPlannerBuildTimeConfig.jdp - ${project.basedir}/target/generated-sources/annotations/org/optaplanner/quarkus/deployment/config/SolverBuildTimeConfig.jdp - - - - - diff --git a/optaplanner-quarkus-integration/optaplanner-quarkus/runtime/pom.xml b/optaplanner-quarkus-integration/optaplanner-quarkus/runtime/pom.xml index 31f1fa8dee3..f4e84490762 100644 --- a/optaplanner-quarkus-integration/optaplanner-quarkus/runtime/pom.xml +++ b/optaplanner-quarkus-integration/optaplanner-quarkus/runtime/pom.xml @@ -113,34 +113,6 @@ - - - - - org.codehaus.mojo - exec-maven-plugin - ${version.maven-exec-plugin} - - - Remove comments from quarkus-extension.properties - prepare-package - - java - - - org.drools.util.RemoveCommentsMain - - ${project.basedir}/target/classes/META-INF/quarkus-extension.properties - ${project.basedir}/target/classes/META-INF/quarkus-javadoc.properties - ${project.basedir}/target/generated-sources/annotations/org/optaplanner/quarkus/config/OptaPlannerRuntimeConfig.jdp - ${project.basedir}/target/generated-sources/annotations/org/optaplanner/quarkus/config/SolverManagerRuntimeConfig.jdp - ${project.basedir}/target/generated-sources/annotations/org/optaplanner/quarkus/config/SolverRuntimeConfig.jdp - ${project.basedir}/target/generated-sources/annotations/org/optaplanner/quarkus/config/TerminationRuntimeConfig.jdp - - - - - From 33614d65dea8c1e6e0f1b404de483aa96469f977 Mon Sep 17 00:00:00 2001 From: Luca Molteni Date: Wed, 13 Mar 2024 16:59:21 +0100 Subject: [PATCH 2/5] Backport of Timefold migration to new DevUI 2.0 https://github.com/TimefoldAI/timefold-solver/commit/8d5864df897c56b0ccfaaffbbf14908f04db61f4#diff-8b943be542be64385a97ac89619e4bcb7be615cf84f1623acd89357e131226af --- build/optaplanner-build-parent/pom.xml | 2 +- .../deployment/OptaPlannerProcessor.java | 52 ++++++-- .../resources/dev-templates/constraints.html | 38 ------ .../resources/dev-templates/embedded.html | 31 ----- .../main/resources/dev-templates/model.html | 66 ----------- .../resources/dev-templates/solverConfig.html | 28 ----- .../main/resources/dev-ui/config-component.js | 61 ++++++++++ .../resources/dev-ui/constraints-component.js | 76 ++++++++++++ .../main/resources/dev-ui/model-component.js | 104 ++++++++++++++++ .../devui-integration-test/pom.xml | 11 +- .../it/devui/OptaPlannerDevUITest.java | 111 +++++++----------- .../optaplanner-quarkus/runtime/pom.xml | 6 + ...OptaPlannerDevUIPropertiesRPCService.java} | 73 ++++++++---- .../devui/OptaPlannerDevUIRecorder.java | 16 +++ .../quarkus/devui/SolverConfigText.java | 17 +++ 15 files changed, 413 insertions(+), 279 deletions(-) delete mode 100644 optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-templates/constraints.html delete mode 100644 optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-templates/embedded.html delete mode 100644 optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-templates/model.html delete mode 100644 optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-templates/solverConfig.html create mode 100644 optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-ui/config-component.js create mode 100644 optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-ui/constraints-component.js create mode 100644 optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-ui/model-component.js rename optaplanner-quarkus-integration/optaplanner-quarkus/runtime/src/main/java/org/optaplanner/quarkus/devui/{OptaPlannerDevUIPropertiesSupplier.java => OptaPlannerDevUIPropertiesRPCService.java} (71%) create mode 100644 optaplanner-quarkus-integration/optaplanner-quarkus/runtime/src/main/java/org/optaplanner/quarkus/devui/OptaPlannerDevUIRecorder.java create mode 100644 optaplanner-quarkus-integration/optaplanner-quarkus/runtime/src/main/java/org/optaplanner/quarkus/devui/SolverConfigText.java diff --git a/build/optaplanner-build-parent/pom.xml b/build/optaplanner-build-parent/pom.xml index 43dfdba9e0d..9d7167b480b 100644 --- a/build/optaplanner-build-parent/pom.xml +++ b/build/optaplanner-build-parent/pom.xml @@ -46,7 +46,7 @@ 2.20.0 1.4.20 6.0.3 - 3.2.10.Final + 3.8.0 3.6.1 1.10.0 4.0.0 diff --git a/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/java/org/optaplanner/quarkus/deployment/OptaPlannerProcessor.java b/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/java/org/optaplanner/quarkus/deployment/OptaPlannerProcessor.java index 1a98bbbad81..c31adfd5e10 100644 --- a/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/java/org/optaplanner/quarkus/deployment/OptaPlannerProcessor.java +++ b/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/java/org/optaplanner/quarkus/deployment/OptaPlannerProcessor.java @@ -35,6 +35,7 @@ import java.util.stream.Collectors; import java.util.stream.Stream; +import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Singleton; import org.jboss.jandex.AnnotationInstance; @@ -68,7 +69,9 @@ import org.optaplanner.quarkus.bean.UnavailableOptaPlannerBeanProvider; import org.optaplanner.quarkus.config.OptaPlannerRuntimeConfig; import org.optaplanner.quarkus.deployment.config.OptaPlannerBuildTimeConfig; -import org.optaplanner.quarkus.devui.OptaPlannerDevUIPropertiesSupplier; +import org.optaplanner.quarkus.devui.OptaPlannerDevUIPropertiesRPCService; +import org.optaplanner.quarkus.devui.OptaPlannerDevUIRecorder; +import org.optaplanner.quarkus.devui.SolverConfigText; import org.optaplanner.quarkus.gizmo.OptaPlannerGizmoBeanFactory; import io.quarkus.arc.deployment.AdditionalBeanBuildItem; @@ -89,11 +92,12 @@ import io.quarkus.deployment.builditem.IndexDependencyBuildItem; import io.quarkus.deployment.builditem.nativeimage.ReflectiveHierarchyBuildItem; import io.quarkus.deployment.builditem.nativeimage.ServiceProviderBuildItem; -import io.quarkus.deployment.pkg.builditem.CurateOutcomeBuildItem; import io.quarkus.deployment.pkg.steps.NativeBuild; import io.quarkus.deployment.recording.RecorderContext; import io.quarkus.deployment.util.ServiceUtil; -import io.quarkus.devconsole.spi.DevConsoleRuntimeTemplateInfoBuildItem; +import io.quarkus.devui.spi.JsonRPCProvidersBuildItem; +import io.quarkus.devui.spi.page.CardPageBuildItem; +import io.quarkus.devui.spi.page.Page; import io.quarkus.gizmo.ClassOutput; import io.quarkus.gizmo.MethodDescriptor; import io.quarkus.gizmo.ResultHandle; @@ -167,20 +171,48 @@ DetermineIfNativeBuildItem ifNativeBuild() { } @BuildStep(onlyIf = IsDevelopment.class) - public DevConsoleRuntimeTemplateInfoBuildItem getSolverConfig(SolverConfigBuildItem solverConfigBuildItem, - CurateOutcomeBuildItem curateOutcomeBuildItem) { + @Record(STATIC_INIT) + public CardPageBuildItem registerDevUICard( + OptaPlannerDevUIRecorder devUIRecorder, + SolverConfigBuildItem solverConfigBuildItem, + BuildProducer syntheticBeans) { + CardPageBuildItem cardPageBuildItem = new CardPageBuildItem(); SolverConfig solverConfig = solverConfigBuildItem.getSolverConfig(); if (solverConfig != null) { StringWriter effectiveSolverConfigWriter = new StringWriter(); SolverConfigIO solverConfigIO = new SolverConfigIO(); solverConfigIO.write(solverConfig, effectiveSolverConfigWriter); - return new DevConsoleRuntimeTemplateInfoBuildItem("solverConfigProperties", - new OptaPlannerDevUIPropertiesSupplier(effectiveSolverConfigWriter.toString()), this.getClass(), - curateOutcomeBuildItem); + syntheticBeans.produce(SyntheticBeanBuildItem.configure(SolverConfigText.class) + .scope(ApplicationScoped.class) + .supplier(devUIRecorder.solverConfigTextSupplier(effectiveSolverConfigWriter.toString())) + .done()); } else { - return new DevConsoleRuntimeTemplateInfoBuildItem("solverConfigProperties", - new OptaPlannerDevUIPropertiesSupplier(), this.getClass(), curateOutcomeBuildItem); + syntheticBeans.produce(SyntheticBeanBuildItem.configure(SolverConfigText.class) + .scope(ApplicationScoped.class) + .supplier(devUIRecorder.solverConfigTextSupplier("")) + .done()); } + cardPageBuildItem.addPage(Page.webComponentPageBuilder() + .title("Configuration") + .icon("font-awesome-solid:wrench") + .componentLink("config-component.js")); + + cardPageBuildItem.addPage(Page.webComponentPageBuilder() + .title("Model") + .icon("font-awesome-solid:wrench") + .componentLink("model-component.js")); + + cardPageBuildItem.addPage(Page.webComponentPageBuilder() + .title("Constraints") + .icon("font-awesome-solid:wrench") + .componentLink("constraints-component.js")); + + return cardPageBuildItem; + } + + @BuildStep(onlyIf = IsDevelopment.class) + public JsonRPCProvidersBuildItem registerRPCService() { + return new JsonRPCProvidersBuildItem("OptaPlanner Solver", OptaPlannerDevUIPropertiesRPCService.class); } /** diff --git a/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-templates/constraints.html b/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-templates/constraints.html deleted file mode 100644 index a5aa440f474..00000000000 --- a/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-templates/constraints.html +++ /dev/null @@ -1,38 +0,0 @@ -{#include main} - -{#title}Constraints{/title} - -{#body} - - - - - - - - - - {#for constraint in info:solverConfigProperties.constraintList} - - {/for} - -
Constraints
{constraint}
-{/body} -{/include} \ No newline at end of file diff --git a/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-templates/embedded.html b/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-templates/embedded.html deleted file mode 100644 index 65f9ab012b0..00000000000 --- a/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-templates/embedded.html +++ /dev/null @@ -1,31 +0,0 @@ - - - - - View Effective Solver Configuration - - - - View Model - - - - View Constraints - \ No newline at end of file diff --git a/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-templates/model.html b/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-templates/model.html deleted file mode 100644 index f3ff0a56169..00000000000 --- a/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-templates/model.html +++ /dev/null @@ -1,66 +0,0 @@ -{#include main} - -{#title}Model{/title} - -{#body} - - -
-
Solution: {info:solverConfigProperties.optaPlannerModelProperties.solutionClass}
-
- {#for entityClass in info:solverConfigProperties.optaPlannerModelProperties.entityClassList} -
-
Entity: {entityClass}
-
- {#if !info:solverConfigProperties.optaPlannerModelProperties.entityClassToGenuineVariableListMap.get(entityClass).isEmpty()} - - - - - - - - {#for genuineVariable in info:solverConfigProperties.optaPlannerModelProperties.entityClassToGenuineVariableListMap.get(entityClass)} - - {/for} - -
Genuine Variables
{genuineVariable}
- {/if} - {#if !info:solverConfigProperties.optaPlannerModelProperties.entityClassToShadowVariableListMap.get(entityClass).isEmpty()} - - - - - - - - {#for shadowVariable in info:solverConfigProperties.optaPlannerModelProperties.entityClassToShadowVariableListMap.get(entityClass)} - - {/for} - -
Shadow Variables
{shadowVariable}
- {/if} -
-
- {/for} -
-
-{/body} -{/include} \ No newline at end of file diff --git a/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-templates/solverConfig.html b/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-templates/solverConfig.html deleted file mode 100644 index b9addea38dc..00000000000 --- a/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-templates/solverConfig.html +++ /dev/null @@ -1,28 +0,0 @@ -{#include main} - -{#title}Solver Configuration{/title} -{#body} - - -
-{info:solverConfigProperties.effectiveSolverConfig}
-
-{/body} -{/include} \ No newline at end of file diff --git a/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-ui/config-component.js b/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-ui/config-component.js new file mode 100644 index 00000000000..2394eb9ca50 --- /dev/null +++ b/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-ui/config-component.js @@ -0,0 +1,61 @@ +import {css, html, LitElement} from 'lit'; +import {JsonRpc} from 'jsonrpc'; +import '@vaadin/icon'; +import '@vaadin/button'; +import {until} from 'lit/directives/until.js'; +import '@vaadin/grid'; +import '@vaadin/grid/vaadin-grid-sort-column.js'; + +export class ConfigComponent extends LitElement { + + jsonRpc = new JsonRpc("OptaPlanner Solver"); + + // Component style + static styles = css` + .button { + background-color: transparent; + cursor: pointer; + } + + .clearIcon { + color: orange; + } + `; + + // Component properties + static properties = { + "_config": {state: true} + } + + // Components callbacks + + /** + * Called when displayed + */ + connectedCallback() { + super.connectedCallback(); + this.jsonRpc.getConfig().then(jsonRpcResponse => { + this._config = jsonRpcResponse.result.config; + }); + } + + /** + * Called when it needs to render the components + * @returns {*} + */ + render() { + return html`${until(this._renderConfig(), html`Loading config...`)}`; + } + + // View / Templates + + _renderConfig() { + if (this._config) { + let config = this._config; + return html` +
${config}
`; + } + } +} + +customElements.define('config-component', ConfigComponent); \ No newline at end of file diff --git a/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-ui/constraints-component.js b/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-ui/constraints-component.js new file mode 100644 index 00000000000..c8d1e7a43e4 --- /dev/null +++ b/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-ui/constraints-component.js @@ -0,0 +1,76 @@ +import {css, html, LitElement} from 'lit'; +import {JsonRpc} from 'jsonrpc'; +import '@vaadin/icon'; +import '@vaadin/button'; +import {until} from 'lit/directives/until.js'; +import '@vaadin/grid'; +import {columnBodyRenderer} from '@vaadin/grid/lit.js'; +import '@vaadin/grid/vaadin-grid-sort-column.js'; + +export class ConstraintsComponent extends LitElement { + + jsonRpc = new JsonRpc("OptaPlanner Solver"); + + // Component style + static styles = css` + .button { + background-color: transparent; + cursor: pointer; + } + + .clearIcon { + color: orange; + } + `; + + // Component properties + static properties = { + "_constraints": {state: true} + } + + // Components callbacks + + /** + * Called when displayed + */ + connectedCallback() { + super.connectedCallback(); + this.jsonRpc.getConstraints().then(jsonRpcResponse => { + this._constraints = []; + jsonRpcResponse.result.forEach(c => { + this._constraints.push(c); + }); + }); + } + + /** + * Called when it needs to render the components + * @returns {*} + */ + render() { + return html`${until(this._renderConstraintTable(), html`Loading constraints...`)}`; + } + + // View / Templates + + _renderConstraintTable() { + if (this._constraints) { + let constraints = this._constraints; + return html` + + + + `; + } + } + + _nameRenderer(constraint) { + return html` + ${constraint}`; + } + +} + +customElements.define('constraints-component', ConstraintsComponent); \ No newline at end of file diff --git a/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-ui/model-component.js b/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-ui/model-component.js new file mode 100644 index 00000000000..30fb0b34d6f --- /dev/null +++ b/optaplanner-quarkus-integration/optaplanner-quarkus/deployment/src/main/resources/dev-ui/model-component.js @@ -0,0 +1,104 @@ +import {css, html, LitElement} from 'lit'; +import {JsonRpc} from 'jsonrpc'; +import '@vaadin/icon'; +import '@vaadin/button'; +import {until} from 'lit/directives/until.js'; +import '@vaadin/grid'; +import {columnBodyRenderer} from '@vaadin/grid/lit.js'; +import '@vaadin/grid/vaadin-grid-sort-column.js'; + +export class ModelComponent extends LitElement { + + jsonRpc = new JsonRpc("OptaPlanner Solver"); + + // Component style + static styles = css` + .button { + background-color: transparent; + cursor: pointer; + } + + .clearIcon { + color: orange; + } + `; + + // Component properties + static properties = { + "_model": {state: true} + } + + // Components callbacks + + /** + * Called when displayed + */ + connectedCallback() { + super.connectedCallback(); + this.jsonRpc.getModelInfo().then(jsonRpcResponse => { + this._model = {}; + this._model.solutionClass = jsonRpcResponse.result.solutionClass; + this._model.entityInfoList = []; + jsonRpcResponse.result.entityClassList.forEach(entityClass => { + const entityInfo = {}; + entityInfo.name = entityClass; + entityInfo.genuineVariableList = jsonRpcResponse.result.entityClassToGenuineVariableListMap[entityClass]; + entityInfo.shadowVariableList = jsonRpcResponse.result.entityClassToShadowVariableListMap[entityClass]; + this._model.entityInfoList.push(entityInfo); + }); + }); + } + + /** + * Called when it needs to render the components + * @returns {*} + */ + render() { + return html`${until(this._renderModel(), html`Loading model...`)}`; + } + + // View / Templates + + _renderModel() { + if (this._model) { + let model = this._model; + return html` +
+ Solution Class: + ${model.solutionClass} +
+ + + + + + + + `; + } + } + + _entityClassNameRenderer(entityInfo) { + return html` + ${entityInfo.name}`; + } + + _genuineVariablesRenderer(entityInfo) { + return html` + ${entityInfo.genuineVariableList.join(', ')}`; + } + + _shadowVariablesRenderer(entityInfo) { + return html` + ${entityInfo.shadowVariableList.join(', ')}`; + } + +} + +customElements.define('model-component', ModelComponent); \ No newline at end of file diff --git a/optaplanner-quarkus-integration/optaplanner-quarkus/devui-integration-test/pom.xml b/optaplanner-quarkus-integration/optaplanner-quarkus/devui-integration-test/pom.xml index 8c8a5b23d8c..59b836c4f63 100644 --- a/optaplanner-quarkus-integration/optaplanner-quarkus/devui-integration-test/pom.xml +++ b/optaplanner-quarkus-integration/optaplanner-quarkus/devui-integration-test/pom.xml @@ -36,8 +36,6 @@ org.optaplanner.quarkus **/* - - /q/dev-v1 @@ -65,8 +63,8 @@ test - io.rest-assured - rest-assured + io.quarkus + quarkus-vertx-http-dev-ui-tests test @@ -92,11 +90,6 @@ org.apache.maven.plugins maven-surefire-plugin - - - ${dev.ui.root} - - org.apache.maven.plugins diff --git a/optaplanner-quarkus-integration/optaplanner-quarkus/devui-integration-test/src/test/java/org/optaplanner/quarkus/it/devui/OptaPlannerDevUITest.java b/optaplanner-quarkus-integration/optaplanner-quarkus/devui-integration-test/src/test/java/org/optaplanner/quarkus/it/devui/OptaPlannerDevUITest.java index 9c9f47bc2f7..674295e43e2 100644 --- a/optaplanner-quarkus-integration/optaplanner-quarkus/devui-integration-test/src/test/java/org/optaplanner/quarkus/it/devui/OptaPlannerDevUITest.java +++ b/optaplanner-quarkus-integration/optaplanner-quarkus/devui-integration-test/src/test/java/org/optaplanner/quarkus/it/devui/OptaPlannerDevUITest.java @@ -21,105 +21,74 @@ import static org.assertj.core.api.Assertions.assertThat; -import java.io.IOException; -import java.util.Objects; - -import javax.xml.parsers.ParserConfigurationException; - import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.RegisterExtension; -import org.xml.sax.SAXException; +import org.optaplanner.quarkus.it.devui.domain.TestdataStringLengthShadowEntity; +import org.optaplanner.quarkus.it.devui.domain.TestdataStringLengthShadowSolution; +import org.optaplanner.quarkus.it.devui.solver.TestdataStringLengthConstraintProvider; + +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.node.TextNode; -import groovy.util.Node; -import groovy.xml.XmlParser; +import io.quarkus.devui.tests.DevUIJsonRPCTest; import io.quarkus.test.QuarkusDevModeTest; -import io.restassured.RestAssured; -public class OptaPlannerDevUITest { +public class OptaPlannerDevUITest extends DevUIJsonRPCTest { @RegisterExtension static final QuarkusDevModeTest config = new QuarkusDevModeTest() .setArchiveProducer(() -> ShrinkWrap.create(JavaArchive.class) - .addPackages(true, "org.optaplanner.quarkus.it.devui")); + .addPackages(true, OptaPlannerTestResource.class.getPackage().getName())); - // Use the Quarkus 3 context root by default as the Quarkus platform does not pass the system property. - static final String OPTAPLANNER_DEV_UI_BASE_URL = - System.getProperty("dev.iu.root", "/q/dev-v1") + "/org.optaplanner.optaplanner-quarkus/"; - - public static String getPage(String pageName) { - return OPTAPLANNER_DEV_UI_BASE_URL + pageName; + public OptaPlannerDevUITest() { + super("OptaPlanner Solver"); } @Test - void testSolverConfigPage() throws ParserConfigurationException, SAXException, IOException { - String body = RestAssured.get(getPage("solverConfig")) - .then() - .extract() - .body() - .asPrettyString(); - XmlParser xmlParser = new XmlParser(); - Node node = xmlParser.parseText(body); - String solverConfig = Objects.requireNonNull(findById("optaplanner-solver-config", node)).text(); + void testSolverConfigPage() throws Exception { + JsonNode configResponse = super.executeJsonRPCMethod("getConfig"); + String solverConfig = configResponse.get("config").asText(); assertThat(solverConfig).isEqualToIgnoringWhitespace( "\n" + "\n" + "\n" - + " org.optaplanner.quarkus.it.devui.domain.TestdataStringLengthShadowSolution\n" - + " org.optaplanner.quarkus.it.devui.domain.TestdataStringLengthShadowEntity\n" + + " " + TestdataStringLengthShadowSolution.class.getCanonicalName() + + "\n" + + " " + TestdataStringLengthShadowEntity.class.getCanonicalName() + "\n" + " GIZMO\n" + " \n" - + " org.optaplanner.quarkus.it.devui.solver.TestdataStringLengthConstraintProvider\n" + + " " + TestdataStringLengthConstraintProvider.class.getCanonicalName() + + "\n" + " \n" + ""); } @Test - void testModelPage() throws ParserConfigurationException, SAXException, IOException { - String body = RestAssured.get(getPage("model")) - .then() - .extract() - .body() - .asPrettyString(); - XmlParser xmlParser = new XmlParser(); - Node node = xmlParser.parseText(body); - String model = Objects.requireNonNull(findById("optaplanner-model", node)).toString(); - assertThat(model) - .contains("value=[Solution: org.optaplanner.quarkus.it.devui.domain.TestdataStringLengthShadowSolution]"); - assertThat(model).contains("value=[Entity: org.optaplanner.quarkus.it.devui.domain.TestdataStringLengthShadowEntity]"); - assertThat(model).contains( - "value=[Genuine Variables]]]]]], tbody[attributes={}; value=[tr[attributes={}; value=[td[attributes={colspan=1, rowspan=1}; value=[value]]"); - assertThat(model).contains( - "value=[Shadow Variables]]]]]], tbody[attributes={}; value=[tr[attributes={}; value=[td[attributes={colspan=1, rowspan=1}; value=[length]]"); + void testModelPage() throws Exception { + JsonNode modelResponse = super.executeJsonRPCMethod("getModelInfo"); + assertThat(modelResponse.get("solutionClass").asText()) + .contains(TestdataStringLengthShadowSolution.class.getCanonicalName()); + assertThat(modelResponse.get("entityClassList")) + .containsExactly( + new TextNode(TestdataStringLengthShadowEntity.class.getCanonicalName())); + assertThat(modelResponse.get("entityClassToGenuineVariableListMap")).hasSize(1); + assertThat(modelResponse.get("entityClassToGenuineVariableListMap") + .get(TestdataStringLengthShadowEntity.class.getCanonicalName())) + .containsExactly(new TextNode("value")); + assertThat(modelResponse.get("entityClassToShadowVariableListMap")).hasSize(1); + assertThat(modelResponse.get("entityClassToShadowVariableListMap") + .get(TestdataStringLengthShadowEntity.class.getCanonicalName())) + .containsExactly(new TextNode("length")); } @Test - void testConstraintsPage() throws ParserConfigurationException, SAXException, IOException { - String body = RestAssured.get(getPage("constraints")) - .then() - .extract() - .body() - .asPrettyString(); - XmlParser xmlParser = new XmlParser(); - Node node = xmlParser.parseText(body); - String constraints = Objects.requireNonNull(findById("optaplanner-constraints", node)).text(); - assertThat(constraints).contains("org.optaplanner.quarkus.it.devui.domain/Don't assign 2 entities the same value"); - assertThat(constraints).contains("org.optaplanner.quarkus.it.devui.domain/Maximize value length"); - } - - private Node findById(String id, Node node) { - if (id.equals(node.attribute("id"))) { - return node; - } - for (Object child : node.children()) { - if (child instanceof Node) { - Node maybeFoundNodeText = findById(id, (Node) child); - if (maybeFoundNodeText != null) { - return maybeFoundNodeText; - } - } - } - return null; + void testConstraintsPage() throws Exception { + JsonNode constraintsResponse = super.executeJsonRPCMethod("getConstraints"); + assertThat(constraintsResponse).containsExactly( + new TextNode(TestdataStringLengthShadowSolution.class.getPackage() + .getName() + "/Don't assign 2 entities the same value."), + new TextNode(TestdataStringLengthShadowSolution.class.getPackage().getName() + "/Maximize value length")); } } diff --git a/optaplanner-quarkus-integration/optaplanner-quarkus/runtime/pom.xml b/optaplanner-quarkus-integration/optaplanner-quarkus/runtime/pom.xml index f4e84490762..e3420bf10b4 100644 --- a/optaplanner-quarkus-integration/optaplanner-quarkus/runtime/pom.xml +++ b/optaplanner-quarkus-integration/optaplanner-quarkus/runtime/pom.xml @@ -41,6 +41,12 @@ io.quarkus quarkus-core + + + io.quarkus + quarkus-vertx-http + true + io.quarkus quarkus-arc diff --git a/optaplanner-quarkus-integration/optaplanner-quarkus/runtime/src/main/java/org/optaplanner/quarkus/devui/OptaPlannerDevUIPropertiesSupplier.java b/optaplanner-quarkus-integration/optaplanner-quarkus/runtime/src/main/java/org/optaplanner/quarkus/devui/OptaPlannerDevUIPropertiesRPCService.java similarity index 71% rename from optaplanner-quarkus-integration/optaplanner-quarkus/runtime/src/main/java/org/optaplanner/quarkus/devui/OptaPlannerDevUIPropertiesSupplier.java rename to optaplanner-quarkus-integration/optaplanner-quarkus/runtime/src/main/java/org/optaplanner/quarkus/devui/OptaPlannerDevUIPropertiesRPCService.java index d7df012b303..025578b77d8 100644 --- a/optaplanner-quarkus-integration/optaplanner-quarkus/runtime/src/main/java/org/optaplanner/quarkus/devui/OptaPlannerDevUIPropertiesSupplier.java +++ b/optaplanner-quarkus-integration/optaplanner-quarkus/runtime/src/main/java/org/optaplanner/quarkus/devui/OptaPlannerDevUIPropertiesRPCService.java @@ -25,9 +25,12 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import java.util.function.Supplier; import java.util.stream.Collectors; +import jakarta.annotation.PostConstruct; +import jakarta.enterprise.context.ApplicationScoped; +import jakarta.inject.Inject; + import org.optaplanner.constraint.streams.common.AbstractConstraintStreamScoreDirectorFactory; import org.optaplanner.core.api.domain.entity.PlanningEntity; import org.optaplanner.core.api.domain.solution.PlanningSolution; @@ -40,46 +43,66 @@ import org.optaplanner.core.impl.solver.DefaultSolverFactory; import io.quarkus.arc.Arc; +import io.vertx.core.json.JsonArray; +import io.vertx.core.json.JsonObject; -public class OptaPlannerDevUIPropertiesSupplier implements Supplier { - private String effectiveSolverConfigXml; - - public OptaPlannerDevUIPropertiesSupplier() { - this.effectiveSolverConfigXml = null; - } +@ApplicationScoped +public class OptaPlannerDevUIPropertiesRPCService { - public OptaPlannerDevUIPropertiesSupplier(String effectiveSolverConfigXml) { - this.effectiveSolverConfigXml = effectiveSolverConfigXml; - } + private final String effectiveSolverConfigXml; - // Needed for Quarkus Dev UI serialization - public String getEffectiveSolverConfigXml() { - return effectiveSolverConfigXml; - } + private OptaPlannerDevUIProperties devUIProperties; - public void setEffectiveSolverConfigXml(String effectiveSolverConfigXml) { - this.effectiveSolverConfigXml = effectiveSolverConfigXml; + @Inject + public OptaPlannerDevUIPropertiesRPCService(SolverConfigText solverConfigText) { + this.effectiveSolverConfigXml = solverConfigText.getSolverConfigText(); } - @Override - public OptaPlannerDevUIProperties get() { + @PostConstruct + public void init() { if (effectiveSolverConfigXml != null) { // SolverConfigIO does not work at runtime, // but the build time SolverConfig does not have properties // that can be set at runtime (ex: termination), so the // effective solver config will be missing some properties - return new OptaPlannerDevUIProperties(getModelInfo(), - getXmlContentWithComment("Properties that can be set at runtime are not included"), - getConstraintList()); + devUIProperties = new OptaPlannerDevUIProperties(buildModelInfo(), + buildXmlContentWithComment("Properties that can be set at runtime are not included"), + buildConstraintList()); } else { - return new OptaPlannerDevUIProperties(getModelInfo(), + devUIProperties = new OptaPlannerDevUIProperties(buildModelInfo(), "\n", Collections.emptyList()); } } - private OptaPlannerModelProperties getModelInfo() { + public JsonObject getConfig() { + JsonObject out = new JsonObject(); + out.put("config", devUIProperties.getEffectiveSolverConfig()); + return out; + } + + public JsonArray getConstraints() { + return JsonArray.of(devUIProperties.getConstraintList().toArray()); + } + + public JsonObject getModelInfo() { + OptaPlannerModelProperties modelProperties = devUIProperties.getOptaPlannerModelProperties(); + JsonObject out = new JsonObject(); + out.put("solutionClass", modelProperties.solutionClass); + out.put("entityClassList", JsonArray.of(modelProperties.entityClassList.toArray())); + out.put("entityClassToGenuineVariableListMap", + new JsonObject(modelProperties.entityClassToGenuineVariableListMap.entrySet() + .stream() + .collect(Collectors.toMap(Map.Entry::getKey, entry -> JsonArray.of(entry.getValue().toArray()))))); + out.put("entityClassToShadowVariableListMap", + new JsonObject(modelProperties.entityClassToShadowVariableListMap.entrySet() + .stream() + .collect(Collectors.toMap(Map.Entry::getKey, entry -> JsonArray.of(entry.getValue().toArray()))))); + return out; + } + + private OptaPlannerModelProperties buildModelInfo() { if (effectiveSolverConfigXml != null) { DefaultSolverFactory solverFactory = (DefaultSolverFactory) Arc.container().instance(SolverFactory.class).get(); @@ -114,7 +137,7 @@ private OptaPlannerModelProperties getModelInfo() { } } - private List getConstraintList() { + private List buildConstraintList() { if (effectiveSolverConfigXml != null) { DefaultSolverFactory solverFactory = (DefaultSolverFactory) Arc.container().instance(SolverFactory.class).get(); @@ -128,7 +151,7 @@ private List getConstraintList() { return Collections.emptyList(); } - private String getXmlContentWithComment(String comment) { + private String buildXmlContentWithComment(String comment) { int indexOfPreambleEnd = effectiveSolverConfigXml.indexOf("?>"); if (indexOfPreambleEnd != -1) { return effectiveSolverConfigXml.substring(0, indexOfPreambleEnd + 2) + diff --git a/optaplanner-quarkus-integration/optaplanner-quarkus/runtime/src/main/java/org/optaplanner/quarkus/devui/OptaPlannerDevUIRecorder.java b/optaplanner-quarkus-integration/optaplanner-quarkus/runtime/src/main/java/org/optaplanner/quarkus/devui/OptaPlannerDevUIRecorder.java new file mode 100644 index 00000000000..6ba141f8b29 --- /dev/null +++ b/optaplanner-quarkus-integration/optaplanner-quarkus/runtime/src/main/java/org/optaplanner/quarkus/devui/OptaPlannerDevUIRecorder.java @@ -0,0 +1,16 @@ +package org.optaplanner.quarkus.devui; + +import java.util.function.Supplier; + +import io.quarkus.runtime.annotations.Recorder; + +@Recorder +public class OptaPlannerDevUIRecorder { + + public Supplier solverConfigTextSupplier(final String solverConfigText) { + return () -> { + return new SolverConfigText(solverConfigText); + }; + } + +} diff --git a/optaplanner-quarkus-integration/optaplanner-quarkus/runtime/src/main/java/org/optaplanner/quarkus/devui/SolverConfigText.java b/optaplanner-quarkus-integration/optaplanner-quarkus/runtime/src/main/java/org/optaplanner/quarkus/devui/SolverConfigText.java new file mode 100644 index 00000000000..e0ae76f32b3 --- /dev/null +++ b/optaplanner-quarkus-integration/optaplanner-quarkus/runtime/src/main/java/org/optaplanner/quarkus/devui/SolverConfigText.java @@ -0,0 +1,17 @@ +package org.optaplanner.quarkus.devui; + +public class SolverConfigText { + private String solverConfigText; + + public SolverConfigText(String solverConfigText) { + this.solverConfigText = solverConfigText; + } + + public String getSolverConfigText() { + return solverConfigText; + } + + public void setSolverConfigText(String solverConfigText) { + this.solverConfigText = solverConfigText; + } +} From 3c2b33b07d9fd76b42ff742d909f7930014dafb5 Mon Sep 17 00:00:00 2001 From: Luca Molteni Date: Thu, 14 Mar 2024 17:00:04 +0100 Subject: [PATCH 3/5] Fix Optaplanner Operator, disabled SSA as with the current version of the code it's broken --- build/optaplanner-build-parent/pom.xml | 2 +- optaplanner-operator/pom.xml | 13 ------------- .../solver/OptaPlannerSolverReconciler.java | 19 ++++++++++++------- .../model/ConfigMapDependentResource.java | 6 ++---- .../model/DeploymentDependentResource.java | 4 +--- .../keda/ScaledObjectDependentResource.java | 4 +--- ...riggerAuthenticationDependentResource.java | 4 +--- .../ArtemisQueueDependentResource.java | 4 +--- .../src/main/resources/application.properties | 8 ++++++++ 9 files changed, 27 insertions(+), 37 deletions(-) diff --git a/build/optaplanner-build-parent/pom.xml b/build/optaplanner-build-parent/pom.xml index 9d7167b480b..f8c339e706d 100644 --- a/build/optaplanner-build-parent/pom.xml +++ b/build/optaplanner-build-parent/pom.xml @@ -45,7 +45,7 @@ 1.4.6 2.20.0 1.4.20 - 6.0.3 + 6.6.4 3.8.0 3.6.1 1.10.0 diff --git a/optaplanner-operator/pom.xml b/optaplanner-operator/pom.xml index b61caf36426..d49f08a2b87 100644 --- a/optaplanner-operator/pom.xml +++ b/optaplanner-operator/pom.xml @@ -44,19 +44,6 @@ org.optaplanner.operator - - - - - io.quarkus - quarkus-bom - ${version.io.quarkus} - import - pom - - - - io.quarkiverse.operatorsdk diff --git a/optaplanner-operator/src/main/java/org/optaplanner/operator/impl/solver/OptaPlannerSolverReconciler.java b/optaplanner-operator/src/main/java/org/optaplanner/operator/impl/solver/OptaPlannerSolverReconciler.java index 11b61cc73c1..d3946a4b250 100644 --- a/optaplanner-operator/src/main/java/org/optaplanner/operator/impl/solver/OptaPlannerSolverReconciler.java +++ b/optaplanner-operator/src/main/java/org/optaplanner/operator/impl/solver/OptaPlannerSolverReconciler.java @@ -46,6 +46,7 @@ import io.javaoperatorsdk.operator.api.reconciler.UpdateControl; import io.javaoperatorsdk.operator.processing.event.ResourceID; import io.javaoperatorsdk.operator.processing.event.source.EventSource; +import io.quarkiverse.operatorsdk.runtime.QuarkusConfigurationService; @ControllerConfiguration(name = "optaplanner-solver") public final class OptaPlannerSolverReconciler implements Reconciler, ErrorStatusHandler, @@ -61,13 +62,17 @@ public final class OptaPlannerSolverReconciler implements Reconciler( optaPlannerSolver -> new ResourceID(optaPlannerSolver.getInputMessageAddressName(), diff --git a/optaplanner-operator/src/main/java/org/optaplanner/operator/impl/solver/model/ConfigMapDependentResource.java b/optaplanner-operator/src/main/java/org/optaplanner/operator/impl/solver/model/ConfigMapDependentResource.java index 61b6d4c4a79..cb8ed095416 100644 --- a/optaplanner-operator/src/main/java/org/optaplanner/operator/impl/solver/model/ConfigMapDependentResource.java +++ b/optaplanner-operator/src/main/java/org/optaplanner/operator/impl/solver/model/ConfigMapDependentResource.java @@ -24,7 +24,6 @@ import io.fabric8.kubernetes.api.model.ConfigMap; import io.fabric8.kubernetes.api.model.ConfigMapBuilder; -import io.fabric8.kubernetes.client.KubernetesClient; import io.javaoperatorsdk.operator.api.reconciler.Context; import io.javaoperatorsdk.operator.processing.dependent.kubernetes.CRUDKubernetesDependentResource; import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependent; @@ -37,9 +36,8 @@ public final class ConfigMapDependentResource extends CRUDKubernetesDependentRes public static final String SOLVER_MESSAGE_AMQ_HOST_KEY = "solver.amq.host"; public static final String SOLVER_MESSAGE_AMQ_PORT_KEY = "solver.amq.port"; - public ConfigMapDependentResource(KubernetesClient kubernetesClient) { + public ConfigMapDependentResource() { super(ConfigMap.class); - setKubernetesClient(kubernetesClient); } @Override @@ -63,7 +61,7 @@ protected ConfigMap desired(OptaPlannerSolver solver, Context public ConfigMap update(ConfigMap actual, ConfigMap target, OptaPlannerSolver solver, Context context) { ConfigMap resultingConfigMap = super.update(actual, target, solver, context); String namespace = actual.getMetadata().getNamespace(); - getKubernetesClient() + context.getClient() .pods() .inNamespace(namespace) .withLabel("app", solver.getMetadata().getName()) diff --git a/optaplanner-operator/src/main/java/org/optaplanner/operator/impl/solver/model/DeploymentDependentResource.java b/optaplanner-operator/src/main/java/org/optaplanner/operator/impl/solver/model/DeploymentDependentResource.java index 297f68fa2b2..b78f4bffc04 100644 --- a/optaplanner-operator/src/main/java/org/optaplanner/operator/impl/solver/model/DeploymentDependentResource.java +++ b/optaplanner-operator/src/main/java/org/optaplanner/operator/impl/solver/model/DeploymentDependentResource.java @@ -32,7 +32,6 @@ import io.fabric8.kubernetes.api.model.apps.Deployment; import io.fabric8.kubernetes.api.model.apps.DeploymentBuilder; import io.fabric8.kubernetes.api.model.apps.DeploymentSpecBuilder; -import io.fabric8.kubernetes.client.KubernetesClient; import io.javaoperatorsdk.operator.api.reconciler.Context; import io.javaoperatorsdk.operator.processing.dependent.kubernetes.CRUDKubernetesDependentResource; import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependent; @@ -47,9 +46,8 @@ public final class DeploymentDependentResource extends CRUDKubernetesDependentRe private static final String ENV_AMQ_USERNAME = "SOLVER_MESSAGE_AMQ_USERNAME"; private static final String ENV_AMQ_PASSWORD = "SOLVER_MESSAGE_AMQ_PASSWORD"; - public DeploymentDependentResource(KubernetesClient k8s) { + public DeploymentDependentResource() { super(Deployment.class); - setKubernetesClient(k8s); } @Override diff --git a/optaplanner-operator/src/main/java/org/optaplanner/operator/impl/solver/model/keda/ScaledObjectDependentResource.java b/optaplanner-operator/src/main/java/org/optaplanner/operator/impl/solver/model/keda/ScaledObjectDependentResource.java index 98a68427764..d5b0f8f3966 100644 --- a/optaplanner-operator/src/main/java/org/optaplanner/operator/impl/solver/model/keda/ScaledObjectDependentResource.java +++ b/optaplanner-operator/src/main/java/org/optaplanner/operator/impl/solver/model/keda/ScaledObjectDependentResource.java @@ -25,7 +25,6 @@ import io.fabric8.kubernetes.api.model.ObjectMeta; import io.fabric8.kubernetes.api.model.ObjectMetaBuilder; -import io.fabric8.kubernetes.client.KubernetesClient; import io.javaoperatorsdk.operator.api.reconciler.Context; import io.javaoperatorsdk.operator.processing.dependent.kubernetes.CRUDKubernetesDependentResource; import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependent; @@ -75,9 +74,8 @@ public final class ScaledObjectDependentResource extends CRUDKubernetesDependent */ private static final int TARGET_QUEUE_LENGTH = 1; - public ScaledObjectDependentResource(KubernetesClient kubernetesClient) { + public ScaledObjectDependentResource() { super(ScaledObject.class); - setKubernetesClient(kubernetesClient); } @Override diff --git a/optaplanner-operator/src/main/java/org/optaplanner/operator/impl/solver/model/keda/TriggerAuthenticationDependentResource.java b/optaplanner-operator/src/main/java/org/optaplanner/operator/impl/solver/model/keda/TriggerAuthenticationDependentResource.java index 51398a1e391..a788fe81ea2 100644 --- a/optaplanner-operator/src/main/java/org/optaplanner/operator/impl/solver/model/keda/TriggerAuthenticationDependentResource.java +++ b/optaplanner-operator/src/main/java/org/optaplanner/operator/impl/solver/model/keda/TriggerAuthenticationDependentResource.java @@ -24,7 +24,6 @@ import io.fabric8.kubernetes.api.model.ObjectMeta; import io.fabric8.kubernetes.api.model.ObjectMetaBuilder; import io.fabric8.kubernetes.api.model.SecretKeySelector; -import io.fabric8.kubernetes.client.KubernetesClient; import io.javaoperatorsdk.operator.api.reconciler.Context; import io.javaoperatorsdk.operator.processing.dependent.kubernetes.CRUDKubernetesDependentResource; import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependent; @@ -54,9 +53,8 @@ public final class TriggerAuthenticationDependentResource public static final String PARAM_USERNAME = "username"; public static final String PARAM_PASSWORD = "password"; - public TriggerAuthenticationDependentResource(KubernetesClient kubernetesClient) { + public TriggerAuthenticationDependentResource() { super(TriggerAuthentication.class); - setKubernetesClient(kubernetesClient); } @Override diff --git a/optaplanner-operator/src/main/java/org/optaplanner/operator/impl/solver/model/messaging/ArtemisQueueDependentResource.java b/optaplanner-operator/src/main/java/org/optaplanner/operator/impl/solver/model/messaging/ArtemisQueueDependentResource.java index 082a3a3943b..0c5bf820025 100644 --- a/optaplanner-operator/src/main/java/org/optaplanner/operator/impl/solver/model/messaging/ArtemisQueueDependentResource.java +++ b/optaplanner-operator/src/main/java/org/optaplanner/operator/impl/solver/model/messaging/ArtemisQueueDependentResource.java @@ -23,7 +23,6 @@ import io.fabric8.kubernetes.api.model.ObjectMeta; import io.fabric8.kubernetes.api.model.ObjectMetaBuilder; -import io.fabric8.kubernetes.client.KubernetesClient; import io.javaoperatorsdk.operator.api.reconciler.Context; import io.javaoperatorsdk.operator.processing.dependent.kubernetes.CRUDKubernetesDependentResource; import io.javaoperatorsdk.operator.processing.dependent.kubernetes.KubernetesDependent; @@ -31,10 +30,9 @@ @KubernetesDependent public final class ArtemisQueueDependentResource extends CRUDKubernetesDependentResource { - public ArtemisQueueDependentResource(MessageAddress messageAddress, KubernetesClient kubernetesClient) { + public ArtemisQueueDependentResource(MessageAddress messageAddress) { super(ArtemisQueue.class); this.messageAddress = messageAddress; - setKubernetesClient(kubernetesClient); } private final MessageAddress messageAddress; diff --git a/optaplanner-operator/src/main/resources/application.properties b/optaplanner-operator/src/main/resources/application.properties index be41ebafb56..8672871dc98 100644 --- a/optaplanner-operator/src/main/resources/application.properties +++ b/optaplanner-operator/src/main/resources/application.properties @@ -17,7 +17,15 @@ # under the License. # + quarkus.operator-sdk.crd.apply=true + +# New version of the operator use SSA, a different algorithm for creating resources +# that needs some changes. In the meanwhile this feature flag reverts to the old behaviour +# See https://javaoperatorsdk.io/docs/dependent-resources#comparing-desired-and-actual-state-matching +# And https://github.com/operator-framework/java-operator-sdk/blob/main/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/ConfigurationService.java#L332-L358 +quarkus.operator-sdk.enable-ssa=false + quarkus.log.category."io.quarkiverse.operatorsdk".level=ERROR ######################## From ab859128f39444327bd42433c48756e7b57980f4 Mon Sep 17 00:00:00 2001 From: Luca Molteni Date: Wed, 20 Mar 2024 15:45:12 +0100 Subject: [PATCH 4/5] Fixed unstable test --- .../org/optaplanner/quarkus/it/devui/OptaPlannerDevUITest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/optaplanner-quarkus-integration/optaplanner-quarkus/devui-integration-test/src/test/java/org/optaplanner/quarkus/it/devui/OptaPlannerDevUITest.java b/optaplanner-quarkus-integration/optaplanner-quarkus/devui-integration-test/src/test/java/org/optaplanner/quarkus/it/devui/OptaPlannerDevUITest.java index 674295e43e2..3fe650cab7e 100644 --- a/optaplanner-quarkus-integration/optaplanner-quarkus/devui-integration-test/src/test/java/org/optaplanner/quarkus/it/devui/OptaPlannerDevUITest.java +++ b/optaplanner-quarkus-integration/optaplanner-quarkus/devui-integration-test/src/test/java/org/optaplanner/quarkus/it/devui/OptaPlannerDevUITest.java @@ -86,7 +86,7 @@ void testModelPage() throws Exception { @Test void testConstraintsPage() throws Exception { JsonNode constraintsResponse = super.executeJsonRPCMethod("getConstraints"); - assertThat(constraintsResponse).containsExactly( + assertThat(constraintsResponse).containsExactlyInAnyOrder( new TextNode(TestdataStringLengthShadowSolution.class.getPackage() .getName() + "/Don't assign 2 entities the same value."), new TextNode(TestdataStringLengthShadowSolution.class.getPackage().getName() + "/Maximize value length")); From 9bf5de77d30b045662bef12bc850f088b4eedd11 Mon Sep 17 00:00:00 2001 From: Luca Molteni Date: Thu, 4 Apr 2024 17:14:46 +0200 Subject: [PATCH 5/5] Quarkus 3.8.3 --- build/optaplanner-build-parent/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/optaplanner-build-parent/pom.xml b/build/optaplanner-build-parent/pom.xml index f8c339e706d..b069ef46956 100644 --- a/build/optaplanner-build-parent/pom.xml +++ b/build/optaplanner-build-parent/pom.xml @@ -46,7 +46,7 @@ 2.20.0 1.4.20 6.6.4 - 3.8.0 + 3.8.3 3.6.1 1.10.0 4.0.0