Class SolverExecutor
- java.lang.Object
-
- org.kie.server.services.taskassigning.planning.RunnableBase
-
- org.kie.server.services.taskassigning.planning.SolverExecutor
-
- All Implemented Interfaces:
Runnable
public class SolverExecutor extends RunnableBase
This class is intended to manage the solver life-cycle in a multi-threaded environment.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSolverExecutor.SolverExecutorException-
Nested classes/interfaces inherited from class org.kie.server.services.taskassigning.planning.RunnableBase
RunnableBase.Status
-
-
Field Summary
-
Fields inherited from class org.kie.server.services.taskassigning.planning.RunnableBase
status
-
-
Constructor Summary
Constructors Constructor Description SolverExecutor(SolverDef solverDef, org.kie.server.services.api.KieServerRegistry registry, org.optaplanner.core.api.solver.event.SolverEventListener<org.kie.server.services.taskassigning.core.model.TaskAssigningSolution> eventListener)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddProblemFactChanges(List<org.optaplanner.core.impl.solver.ProblemFactChange<org.kie.server.services.taskassigning.core.model.TaskAssigningSolution>> changes)Thread-safe method that adds a list of ProblemFactChanges to the current solver.protected org.optaplanner.core.api.solver.Solver<org.kie.server.services.taskassigning.core.model.TaskAssigningSolution>buildSolver(SolverDef solverDef, org.kie.server.services.api.KieServerRegistry registry)voiddestroy()This method programmes the subsequent finalization of the solver (if it was started) that will be produced as soon as possible by invoking the solver.terminateEarly() method.booleanisStarted()booleanisStopped()voidrun()voidstart(org.kie.server.services.taskassigning.core.model.TaskAssigningSolution solution)This method is invoked from a different thread for starting the solver and must be invoked only one time.voidstop()Stops the solver.-
Methods inherited from class org.kie.server.services.taskassigning.planning.RunnableBase
isAlive, isDestroyed
-
-
-
-
Constructor Detail
-
SolverExecutor
public SolverExecutor(SolverDef solverDef, org.kie.server.services.api.KieServerRegistry registry, org.optaplanner.core.api.solver.event.SolverEventListener<org.kie.server.services.taskassigning.core.model.TaskAssigningSolution> eventListener)
-
-
Method Detail
-
start
public void start(org.kie.server.services.taskassigning.core.model.TaskAssigningSolution solution)
This method is invoked from a different thread for starting the solver and must be invoked only one time. If the solver was already started an exception is thrown so callers of this method should call the isStarted() method to verify. This method is not thread-safe so it's expected that any synchronization required between the isStarted(), start() and stop() methods is performed by the callers. However it's normally not expected that multiple threads might try to start the same solver runner instance.- Parameters:
solution- a valid solution for starting the solver with.
-
buildSolver
protected org.optaplanner.core.api.solver.Solver<org.kie.server.services.taskassigning.core.model.TaskAssigningSolution> buildSolver(SolverDef solverDef, org.kie.server.services.api.KieServerRegistry registry)
-
isStarted
public boolean isStarted()
- Returns:
- true if the solver has been started, false in any other case.
-
isStopped
public boolean isStopped()
-
stop
public void stop()
Stops the solver.
-
destroy
public void destroy()
This method programmes the subsequent finalization of the solver (if it was started) that will be produced as soon as possible by invoking the solver.terminateEarly() method. If the solver wasn't started it just finalizes current thread.- Overrides:
destroyin classRunnableBase
-
addProblemFactChanges
public void addProblemFactChanges(List<org.optaplanner.core.impl.solver.ProblemFactChange<org.kie.server.services.taskassigning.core.model.TaskAssigningSolution>> changes)
Thread-safe method that adds a list of ProblemFactChanges to the current solver. If the solver has not been started an exception is thrown, so it's expected that callers of this method should call isStarted() method to verify.- Parameters:
changes- a list of problem fact changes to program in current solver.
-
run
public void run()
-
-