我们正在使用 Optaplanner 7.0.0 Final 工作台和 KIE Server 以及 Wildfly 10.0.0 上的 optacloud 示例。
到目前为止,我们已经将容器部署到远程执行服务器,并使用 RESTful API 为该容器创建了一个求解器。
KIE 服务器提供的求解器详细信息如下:
<org.kie.server.api.model.instance.SolverInstanceList>
<solvers>
<solver-instance>
<container-id>test</container-id>
<solver-id>testsolver</solver-id>
<solver-config-file>optacloud/optacloud/cloudSolverConfig.solver.xml</solver-config-file>
<status>NOT_SOLVING</status>
<score />
</solver-instance>
</solvers>
</org.kie.server.api.model.instance.SolverInstanceList>
我们收到来自野蝇的 405 方法不允许响应,其中包含以下 URL:
http://xxx.xxx.xxx.xxx:8080/kie-server-7.0.0.Final-ee7/services/rest/server/containers/test/solvers/testsolver/
此 URL 结构是否正确,还是我们缺少其他内容?
我们发布以下数据:
<solver-instance>
<status>SOLVING</status>
<planning-problem class="optacloud.optacloud.CloudSolution">
<computerList>
<optacloud.optacloud.Computer>
<cpuPower>10</cpuPower>
<memory>4</memory>
<networkBandwidth>100</networkBandwidth>
<cost>1000</cost>
</optacloud.optacloud.Computer>
<optacloud.optacloud.Computer>
<cpuPower>20</cpuPower>
<memory>8</memory>
<networkBandwidth>100</networkBandwidth>
<cost>3000</cost>
</optacloud.optacloud.Computer>
</computerList>
<processList>
<optacloud.optacloud.Process>
<requiredCpuPower>1</requiredCpuPower>
<requiredMemory>7</requiredMemory>
<requiredNetworkBandwidth>1</requiredNetworkBandwidth>
</optacloud.optacloud.Process>
</processList>
</planning-problem>
</solver-instance>
使用以下标头:
Content-Type: application/xml
X-KIE-ContentType: xstream
KIE 服务器 API 在 7 个系列中已更改,提交解决方案有效负载中不再需要<solver-instance>
包装器。
您需要向有效负载只是规划问题(解决方案)对象的http://${kie-server}/services/rest/server/containers/${container_id}/solvers/${solver_id}/state/solving
发送 POST:<planning-problem class="optacloud.optacloud.CloudSolution">...</planning-problem>
.
请参阅快速入门 https://github.com/kiegroup/kie-docs/blob/master/docs/optaplanner-wb-es-docs/src/main/asciidoc/Workbench/Quickstart/Quickstart-section.adoc#submit-solution,其中包含以新方式提交规划问题的示例。
新的 API 概述:
注册求解器: PUT http://${kie-server}/services/rest/server/containers/${container_id}/solvers/${solver_id}
提交解决方案: POST http://${kie-server}/services/rest/server/containers/${container_id}/solvers/${solver_id}/state/solve
获得最佳解决方案: GET http://${kie-server}/services/rest/server/containers/${container_id}/solvers/${solver_id}/bestsolution
终止求解器: POST http://${kie-server}/services/rest/server/containers/${container_id}/solvers/${solver_id}/state/terminating-early
释放求解器: DELETE http://${kie-server}/services/rest/server/containers/${container_id}/solvers/${solver_id}