restoptaplannerkie-serverkie-wb

Optaplanner REST API solve issue


We're using Optaplanner 7.0.0 Final work bench and KIE Server with the optacloud example on Wildfly 10.0.0.

So far we have deployed a container to a remote execution server and created a solver for that container using the RESTful API.

Solver details as provided by KIE Server are:

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

We are receiving a 405 Method Not Allowed response from wildfly with the following URL:

http://xxx.xxx.xxx.xxx:8080/kie-server-7.0.0.Final-ee7/services/rest/server/containers/test/solvers/testsolver/

Is this URL structure correct or are we missing anything else?

we are posting the following data:

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

with the following headers:

Content-Type: application/xml
X-KIE-ContentType: xstream

Solution

  • The KIE Server API has changed in 7 series and <solver-instance> wrapper is no longer required in the submit solution payload.

    You need to send a POST to http://${kie-server}/services/rest/server/containers/${container_id}/solvers/${solver_id}/state/solving where the payload is just a planning problem (solution) object: <planning-problem class="optacloud.optacloud.CloudSolution">...</planning-problem>.

    Please see the quickstart https://github.com/kiegroup/kie-docs/blob/master/docs/optaplanner-wb-es-docs/src/main/asciidoc/Workbench/Quickstart/Quickstart-section.adoc#submit-solution containing an example of submitting the planning problem in a new way.

    The new API overview:

    Register a solver: PUT http://${kie-server}/services/rest/server/containers/${container_id}/solvers/${solver_id}

    Submit a solution: POST http://${kie-server}/services/rest/server/containers/${container_id}/solvers/${solver_id}/state/solving

    Get the best solution: GET http://${kie-server}/services/rest/server/containers/${container_id}/solvers/${solver_id}/bestsolution

    Terminate the solver: POST http://${kie-server}/services/rest/server/containers/${container_id}/solvers/${solver_id}/state/terminating-early

    Dispose a solver: DELETE http://${kie-server}/services/rest/server/containers/${container_id}/solvers/${solver_id}