Commit bb2da612 authored by Alicja Reniewicz's avatar Alicja Reniewicz
Browse files

Merge pull request #76 in MEL/integration from MEL-1102-new-types-of-solvers to rc3.1

* commit 'b5257480':
  setting default time limit
  adding timelimit to constraint problem solution requests
  fixes in choice in Mule
  fix in global.xml definition
  new types of solvers in mule
  new types of solvers in metasolver.raml
  solver types in uppercase
  changes in Mule with support designatedSolver variable
  add http configuration for pt solver
  usage of designated Solver variable in mule
  new types of solvers
parents db1e6a28 b5257480
......@@ -18,6 +18,9 @@ types:
notificationURI:
description: The URI of an endpoint to sent the result of Constraint Problem Solution creation.
type: string
timeLimit:
description: The deadline for returning some solution
type: integer
watermark:
type: ApiLib.Watermark
ConstraintProblemSolutionFromFileRequest:
......@@ -32,6 +35,10 @@ types:
nodeCandidatesFilePath:
type: string
description: The path in filesystem where map with Node Candidates required for solvers can be found.
timeLimit:
type: integer
description: The deadline for returning some solution
/constraintProblemSolution:
post:
body:
......@@ -46,4 +53,4 @@ types:
type: ConstraintProblemSolutionFromFileRequest
responses:
200:
500:
\ No newline at end of file
500:
......@@ -27,7 +27,7 @@ types:
type: ApiLib.NotificationResult
designatedSolver:
type: string
enum: [cpsolver, lasolver, milpsolver, none]
enum: [CPSOLVER, LASOLVER, MILPSOLVER, NONE, PTSOLVER, GENETICSOLVER, NCSOLVER]
watermark:
type: ApiLib.Watermark
SolutionEvaluationRequest:
......
......@@ -41,7 +41,7 @@ types:
type: ApiLib.NotificationResult
designatedSolver:
type: string
enum: [cpsolver, lasolver, milpsolver, none]
enum: [CPSOLVER, LASOLVER, MILPSOLVER, NONE, PTSOLVER, GENETICSOLVER, NCSOLVER]
watermark:
type: ApiLib.Watermark
SolutionRequest:
......@@ -56,6 +56,9 @@ types:
cdoResourcePath:
type: string
description: Path in the CDO where CP and PAM models can be found.
designatedSolver:
type: string
enum: [CPSOLVER, LASOLVER, MILPSOLVER, NONE, PTSOLVER, GENETICSOLVER, NCSOLVER]
notificationSubject:
type: string
description: Notification subject that will be used when reporting the CP notification.
......
......@@ -37,7 +37,7 @@ http://www.mulesoft.org/schema/mule/tls http://www.mulesoft.org/schema/mule/tls/
</http:request-config>
<http:request-config name="EMS_HTTP_Request_Configuration" host="${ems.http.host}" port="${ems.http.port}" doc:name="HTTP Request Configuration" responseTimeout="40000" protocol="HTTPS">
<tcp:client-socket-properties connectionTimeout="30000"/>
<tls:context>
<tls:context>
<tls:trust-store path="${eai.http.truststore.file}" password="${eai.http.truststore.password}" type="pkcs12"/>
</tls:context>
</http:request-config>
......@@ -57,6 +57,15 @@ http://www.mulesoft.org/schema/mule/tls http://www.mulesoft.org/schema/mule/tls/
<spring:bean id="emsTransformer" class="transformers.ems.EMSTransformer"></spring:bean>
</spring:beans>
<http:request-config name="jwt_server_HTTP_Request_Configuration" host="${jwt_server.http.host}" port="${jwt_server.http.port}" responseTimeout="40000" doc:name="HTTP Request Configuration"/>
<http:request-config name="PT_Solver_HTTP_Request_Configuration" host="${pt_solver.http.host}" port="${pt_solver.http.port}" doc:name="HTTP Request Configuration" responseTimeout="40000">
<tcp:client-socket-properties connectionTimeout="30000"/>
</http:request-config>
<http:request-config name="NC_Solver_HTTP_Request_Configuration" host="${nc_solver.http.host}" port="${nc_solver.http.port}" doc:name="HTTP Request Configuration" responseTimeout="40000">
<tcp:client-socket-properties connectionTimeout="30000"/>
</http:request-config>
<http:request-config name="Genetic_Solver_HTTP_Request_Configuration" host="${genetic_solver.http.host}" port="${genetic_solver.http.port}" doc:name="HTTP Request Configuration" responseTimeout="40000">
<tcp:client-socket-properties connectionTimeout="30000"/>
</http:request-config>
</mule>
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns:jackson2="http://www.mulesoft.org/schema/mule/jackson2" xmlns:ftp="http://www.mulesoft.org/schema/mule/ee/ftp" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns:orika="http://www.mulesoft.org/schema/mule/orika" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
<mule xmlns:imap="http://www.mulesoft.org/schema/mule/imap" xmlns:scripting="http://www.mulesoft.org/schema/mule/scripting" xmlns:jackson2="http://www.mulesoft.org/schema/mule/jackson2" xmlns:ftp="http://www.mulesoft.org/schema/mule/ee/ftp" xmlns:cxf="http://www.mulesoft.org/schema/mule/cxf" xmlns:orika="http://www.mulesoft.org/schema/mule/orika" xmlns:mulexml="http://www.mulesoft.org/schema/mule/xml" xmlns:tracking="http://www.mulesoft.org/schema/mule/ee/tracking" xmlns:dw="http://www.mulesoft.org/schema/mule/ee/dw" xmlns:db="http://www.mulesoft.org/schema/mule/db" xmlns:json="http://www.mulesoft.org/schema/mule/json" xmlns:metadata="http://www.mulesoft.org/schema/mule/metadata" xmlns:http="http://www.mulesoft.org/schema/mule/http" xmlns="http://www.mulesoft.org/schema/mule/core" xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
......@@ -15,7 +15,8 @@ http://www.mulesoft.org/schema/mule/orika http://www.mulesoft.org/schema/mule/or
http://www.mulesoft.org/schema/mule/cxf http://www.mulesoft.org/schema/mule/cxf/current/mule-cxf.xsd
http://www.mulesoft.org/schema/mule/ee/ftp http://www.mulesoft.org/schema/mule/ee/ftp/current/mule-ftp-ee.xsd
http://www.mulesoft.org/schema/mule/jackson2 http://www.mulesoft.org/schema/mule/jackson2/current/mule-jackson2.xsd
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd">
http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mule/scripting/current/mule-scripting.xsd
http://www.mulesoft.org/schema/mule/imap http://www.mulesoft.org/schema/mule/imap/current/mule-imap.xsd">
<cxf:configuration name="CXF_Configuration" enableMuleSoapHeaders="true" initializeStaticBusInstance="true" doc:name="CXF Configuration"/>
<jackson2:config name="ToConstraintProblemRequestImpl" returnClass="eu.melodic.models.services.process.ConstraintProblemRequestImpl" doc:name="Jackson2: Configuration"/>
<jackson2:config name="ToSolutionRequestImpl" returnClass="eu.melodic.models.services.process.SolutionRequestImpl" doc:name="Jackson2: Configuration"/>
......@@ -35,6 +36,7 @@ http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mul
<jackson2:config name="ToDataModelRequestImpl" returnClass="eu.melodic.models.services.process.DataModelRequestImpl" doc:name="Jackson2: Configuration"/>
<jackson2:config name="ToEventModelRequestImpl" returnClass="eu.melodic.models.services.process.EventModelRequestImpl" doc:name="Jackson2: Configuration"/>
<jackson2:config name="ToMonitorsDataRequestImpl" returnClass="eu.melodic.models.services.adapter.MonitorsDataRequestImpl" doc:name="Jackson2: Configuration"/>
<http:request-config name="PTSolver_HTTP_Request_Configuration" host="${pt_solver.http.host}" port="${pt_solver.http.port}" responseTimeout="40000" doc:name="HTTP Request Configuration"/>
<flow name="FeedAndDeploy">
<logger message="Token basen authorization." level="INFO" doc:name="Logger"/>
<set-variable variableName="melodicAuthorizationToken" value="#[message.inboundProperties['authorization']]" doc:name="Variable"/>
......@@ -361,6 +363,7 @@ http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mul
<set-property propertyName="http.status" value="#[message.inboundProperties.'http.status']" doc:name="Copy_of_Copy_of_Set Http status"/>
<flow-ref name="LogPayload" doc:name="LogPayload"/>
</flow>
<flow name="constraintProblemNotification_POST">
<flow-ref name="saveEntryRequest" doc:name="saveEntryRequest"/>
<set-variable variableName="processVariables" value="{ &quot;cpCdoPath&quot; : {&quot;value&quot; : &quot;#[flowVars.entryRequest.cdoResourcePath]&quot;, &quot;type&quot;: &quot;String&quot;}, &quot;cpCreationResultCode&quot; : {&quot;value&quot; : &quot;#[flowVars.entryRequest.result.status]&quot;, &quot;type&quot;: &quot;String&quot;} }" doc:name="set process variables"/>
......@@ -533,22 +536,64 @@ http://www.mulesoft.org/schema/mule/scripting http://www.mulesoft.org/schema/mul
<logger message="#[&quot;URI: &quot; + message.inboundProperties.'http.request.uri' + &quot;\nBODY: &quot; + message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
</sub-flow>
<flow name="constraintProblemSolution_POST_CPSolver">
<set-variable variableName="designatedSolver" value="#[json:designatedSolver]" doc:name="DesignatedSolver Variable"/>
<logger message="designatedSolver: #[flowVars.designatedSolver]" level="INFO" doc:name="Logger"/>
<jackson2:from-json config-ref="ToSolutionRequestImpl" doc:name="JSON to eu.melodic.models.services.process.SolutionRequestImpl"/>
<set-property propertyName="use-external-optimizer" value="${cp_solver.useUtilityGenerator}" encoding="ISO-8859-6" doc:name="Property" />
<auto-transformer doc:name="Transform to eu.melodic.models.interfaces.cpSolver.ConstraintProblemSolutionRequestImpl" returnClass="eu.melodic.models.interfaces.cpSolver.ConstraintProblemSolutionRequestImpl" />
<jackson2:write-value-as-string config-ref="ToConstraintProblemRequestImpl" doc:name="To JSON"/>
<set-property propertyName="Content-Type" value="application/json" doc:name="set Content-Type to application/json"/>
<set-property propertyName="authorization" value="#[message.inboundProperties.authorization]" doc:name="Set authorization token"/>
<logger message="Sending request to CP Solver: #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
<until-successful maxRetries="${eai.http.failover.nb_of_retries}" millisBetweenRetries="${eai.http.failover.timeout}" doc:name="Until Successful" synchronous="true">
<processor-chain doc:name="Processor Chain">
<http:request config-ref="CPSolver_HTTP_Request_Configuration" path="/constraintProblemSolution" method="POST" doc:name="CPSolver">
<http:failure-status-code-validator values="0"/>
</http:request>
</processor-chain>
</until-successful>
<set-property propertyName="http.status" value="#[message.inboundProperties.'http.status']" doc:name="Copy_of_Set Http status"/>
<flow-ref name="LogPayload" doc:name="LogPayload"/>
<choice doc:name="Choice">
<when expression="#['PTSOLVER'.equals(flowVars.designatedSolver)]">
<logger message="Sending request to PT Solver: #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="PTSolver - Logger"/>
<until-successful maxRetries="${eai.http.failover.nb_of_retries}" millisBetweenRetries="${eai.http.failover.timeout}" synchronous="true" doc:name="Copy_of_Until Successful">
<processor-chain doc:name="Copy_of_Processor Chain">
<http:request config-ref="PT_Solver_HTTP_Request_Configuration" path="/constraintProblemSolution" method="POST" doc:name="PtSolver">
<http:failure-status-code-validator values="0"/>
</http:request>
</processor-chain>
</until-successful>
<set-property propertyName="http.status" value="#[message.inboundProperties.'http.status']" doc:name="Set Http status"/>
<flow-ref name="LogPayload" doc:name="LogPayload"/>
</when>
<when expression="#['GENETICSOLVER'.equals(flowVars.designatedSolver)]">
<logger message="Sending request to Genetic Solver: #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Genetic - Logger"/>
<until-successful maxRetries="${eai.http.failover.nb_of_retries}" millisBetweenRetries="${eai.http.failover.timeout}" synchronous="true" doc:name="Copy_of_Until Successful">
<processor-chain doc:name="Copy_of_Processor Chain">
<http:request config-ref="Genetic_Solver_HTTP_Request_Configuration" path="/constraintProblemSolution" method="POST" doc:name="GeneticSolver">
<http:failure-status-code-validator values="0"/>
</http:request>
</processor-chain>
</until-successful>
<set-property propertyName="http.status" value="#[message.inboundProperties.'http.status']" doc:name="Set Http status"/>
<flow-ref name="LogPayload" doc:name="LogPayload"/>
</when>
<when expression="#['NCSOLVER'.equals(flowVars.designatedSolver)]">
<logger message="Sending request to NC Solver: #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="NCSolver - Logger"/>
<until-successful maxRetries="${eai.http.failover.nb_of_retries}" millisBetweenRetries="${eai.http.failover.timeout}" synchronous="true" doc:name="Copy_of_Until Successful">
<processor-chain doc:name="Copy_of_Processor Chain">
<http:request config-ref="NC_Solver_HTTP_Request_Configuration" path="/constraintProblemSolution" method="POST" doc:name="NCSolver">
<http:failure-status-code-validator values="0"/>
</http:request>
</processor-chain>
</until-successful>
<set-property propertyName="http.status" value="#[message.inboundProperties.'http.status']" doc:name="Set Http status"/>
<flow-ref name="LogPayload" doc:name="LogPayload"/>
</when>
<otherwise>
<logger message="Sending request to CP Solver: #[message.payloadAs(java.lang.String)]" level="INFO" doc:name="Logger"/>
<until-successful maxRetries="${eai.http.failover.nb_of_retries}" millisBetweenRetries="${eai.http.failover.timeout}" synchronous="true" doc:name="Until Successful">
<processor-chain doc:name="Processor Chain">
<http:request config-ref="CPSolver_HTTP_Request_Configuration" path="/constraintProblemSolution" method="POST" doc:name="CPSolver">
<http:failure-status-code-validator values="0"/>
</http:request>
</processor-chain>
</until-successful>
<set-property propertyName="http.status" value="#[message.inboundProperties.'http.status']" doc:name="Copy_of_Set Http status"/>
<flow-ref name="LogPayload" doc:name="LogPayload"/>
</otherwise>
</choice>
</flow>
<flow name="RefreshTokenGET">
<logger message="Sending refresh Token request to JWTServer" level="INFO" doc:name="Logger"/>
......
......@@ -23,6 +23,7 @@ public class CPSolverTransformer {
interfaceRequest.setCdoModelsPath(req.getCdoResourcePath());
interfaceRequest.setNotificationURI("/api/cpSolver/solutionNotification/" + req.getProcessId() +"/" + req.getNotificationSubject());
interfaceRequest.setWatermark(req.getWatermark());
interfaceRequest.setTimeLimit(120); //2 minutes
return interfaceRequest;
}
......
......@@ -30,6 +30,18 @@ cp_solver.http.host=mc3
cp_solver.http.port=8093
cp_solver.useUtilityGenerator=false
pt_solver.http.host=mc3
pt_solver.http.port=8090
pt_solver.useUtilityGenerator=false
nc_solver.http.host=mc3
nc_solver.http.port=8090
nc_solver.useUtilityGenerator=false
genetic_solver.http.host=mc3
genetic_solver.http.port=8090
genetic_solver.useUtilityGenerator=false
#http retry configuration when requesting external systems
eai.http.failover.nb_of_retries=10
eai.http.failover.timeout=5000
......
......@@ -209,8 +209,12 @@ public class ApplicationDeploymentExecutor {
if (execution.getVariable("designatedSolver") != null){
desingatedSolver =(String)execution.getVariable("designatedSolver");
}
log.warn("Designated Solver: "+desingatedSolver+", nevertheless using CP Solver."); //currently only cp-solver implemented and tested. To change when new solvers appear.
SolutionRequest request = prepareSolutionRequest(execution.getVariable(APPLICATION_ID_VARIABLE).toString(), execution.getVariable("cpCdoPath").toString(), execution.getVariable("businessKey").toString());
else {
log.warn("Designated Solver was not defined, using CP Solver.");
desingatedSolver = SolutionRequest.DesignatedSolverType.CPSOLVER.name();
}
log.info("Designated Solver: "+ desingatedSolver);
SolutionRequest request = prepareSolutionRequest(execution.getVariable(APPLICATION_ID_VARIABLE).toString(), execution.getVariable("cpCdoPath").toString(), execution.getVariable("businessKey").toString(), desingatedSolver);
log.info("ConstraintProblemSolutionRequest prepared. Sending...");
sendAuthorizedPOSTRequest(execution, request, "solution", execution.getVariable(ACCESS_TOKEN_VARIABLE).toString());
log.info("ConstraintProblemSolutionRequest sent.");
......@@ -417,12 +421,13 @@ public class ApplicationDeploymentExecutor {
return request;
}
private SolutionRequest prepareSolutionRequest(String applicationId, String cdoResourcePath, String uuid ) {
private SolutionRequest prepareSolutionRequest(String applicationId, String cdoResourcePath, String uuid, String designatedSolver ) {
SolutionRequest request = new SolutionRequestImpl();
request.setCdoResourcePath(cdoResourcePath);
request.setApplicationId(applicationId);
request.setNotificationSubject("ConstraintProblemSolutionNotification");
request.setProcessId(uuid);
request.setDesignatedSolver(SolutionRequest.DesignatedSolverType.valueOf(designatedSolver));
request.setWatermark(prepareWatermark(uuid));
return request;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment