0

我们使用 Optaplanner 7.0.0 Final 工作台和 KIE Server 以及 Wildfly 10.0.0 上的 optacloud 示例。

到目前为止,我们已经将一个容器部署到远程执行服务器,并使用 RESTful API 为该容器创建了一个求解器。

KIE Server 提供的求解器详细信息如下:

<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>

我们收到来自 wildfly 的 405 Method Not Allowed 响应,其 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
4

1 回答 1

1

KIE 服务器 API 在 7 系列中已更改,并且<solver-instance>在提交解决方案有效负载中不再需要包装器。

您需要将 POST 发送到http://${kie-server}/services/rest/server/containers/${container_id}/solvers/${solver_id}/state/solving有效负载只是规划问题(解决方案)对象的地方: <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-包含以新方式提交规划问题的示例的解决方案。

新的 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/solving

获得最佳解决方案: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}

于 2017-06-09T14:29:50.497 回答