Class SolutionSynchronizer
- java.lang.Object
-
- org.kie.server.services.taskassigning.planning.RunnableBase
-
- org.kie.server.services.taskassigning.planning.SolutionSynchronizer
-
- All Implemented Interfaces:
Runnable
public class SolutionSynchronizer extends RunnableBase
This class manages the periodical reading (polling strategy) of current tasks from the jBPM runtime and depending on the "action" INIT_SOLVER_EXECUTOR / SYNCHRONIZE_SOLUTION determines if the solver executor must be restarted with a fully recovered solution or instead the tasks updated information is used for calculating the required changes for the proper solution update. If any changes are calculated they are notified to the resultConsumer. This class implements proper retries in case of connection issues with the target jBPM runtime, etc.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSolutionSynchronizer.Result-
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 SolutionSynchronizer(SolverExecutor solverExecutor, TaskAssigningRuntimeDelegate delegate, org.kie.server.services.taskassigning.user.system.api.UserSystemService userSystem, Duration syncInterval, Duration usersSyncInterval, SolverHandlerContext context, Consumer<SolutionSynchronizer.Result> resultConsumer)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidapplyResult(SolutionSynchronizer.Result result)protected List<org.optaplanner.core.impl.solver.ProblemFactChange<org.kie.server.services.taskassigning.core.model.TaskAssigningSolution>>buildChanges(org.kie.server.services.taskassigning.core.model.TaskAssigningSolution solution, List<org.kie.server.api.model.taskassigning.TaskData> updatedTaskDataList)protected List<org.optaplanner.core.impl.solver.ProblemFactChange<org.kie.server.services.taskassigning.core.model.TaskAssigningSolution>>buildChanges(org.kie.server.services.taskassigning.core.model.TaskAssigningSolution solution, List<org.kie.server.api.model.taskassigning.TaskData> updatedTaskDataList, List<org.kie.server.services.taskassigning.user.system.api.User> updatedUserList)protected List<org.optaplanner.core.impl.solver.ProblemFactChange<org.kie.server.services.taskassigning.core.model.TaskAssigningSolution>>buildChanges(org.kie.server.services.taskassigning.core.model.TaskAssigningSolution solution, org.apache.commons.lang3.tuple.Pair<List<org.kie.server.api.model.taskassigning.TaskData>,LocalDateTime> tasksUpdateResult, org.apache.commons.lang3.tuple.Pair<Boolean,List<org.kie.server.services.taskassigning.user.system.api.User>> usersUpdateResult)protected org.kie.server.services.taskassigning.core.model.TaskAssigningSolutionbuildSolution(List<org.kie.server.api.model.taskassigning.TaskData> taskDataList, List<org.kie.server.services.taskassigning.user.system.api.User> externalUsers)protected longcalculateNextUnchangedPeriodTime(Duration unchangedPeriodTimeoutShift)protected longcalculateNextUsersSyncTime()voiddestroy()Starts the synchronizing finalization, that will be produced as soon as possible.protected longgetSystemTime()voidinitSolverExecutor()protected booleanisUnchangedPeriodTime()protected booleanisUsersSyncTime()voidrun()voidsynchronizeSolution(org.kie.server.services.taskassigning.core.model.TaskAssigningSolution solution, LocalDateTime fromLastModificationDate)Starts the synchronization of the solution from the indicated last modification date.voidsynchronizeSolution(org.kie.server.services.taskassigning.core.model.TaskAssigningSolution solution, LocalDateTime fromLastModificationDate, Duration unchangedPeriodTimeout)Starts the synchronization of the solution from the indicated last modification date.-
Methods inherited from class org.kie.server.services.taskassigning.planning.RunnableBase
isAlive, isDestroyed
-
-
-
-
Constructor Detail
-
SolutionSynchronizer
public SolutionSynchronizer(SolverExecutor solverExecutor, TaskAssigningRuntimeDelegate delegate, org.kie.server.services.taskassigning.user.system.api.UserSystemService userSystem, Duration syncInterval, Duration usersSyncInterval, SolverHandlerContext context, Consumer<SolutionSynchronizer.Result> resultConsumer)
-
-
Method Detail
-
initSolverExecutor
public void initSolverExecutor()
-
synchronizeSolution
public void synchronizeSolution(org.kie.server.services.taskassigning.core.model.TaskAssigningSolution solution, LocalDateTime fromLastModificationDate)Starts the synchronization of the solution from the indicated last modification date.- Parameters:
solution- a non null solution instance to synchronize.fromLastModificationDate- filtering parameter for reading the modifications.
-
synchronizeSolution
public void synchronizeSolution(org.kie.server.services.taskassigning.core.model.TaskAssigningSolution solution, LocalDateTime fromLastModificationDate, Duration unchangedPeriodTimeout)Starts the synchronization of the solution from the indicated last modification date.- Parameters:
solution- a non null solution instance to synchronize.fromLastModificationDate- filtering parameter for reading the modifications.unchangedPeriodTimeout- a non null period of time for returning from the synchronization if no changes were produced during that period. A negative or zero period is ignored.
-
destroy
public void destroy()
Starts the synchronizing finalization, that will be produced as soon as possible. It's a non thread-safe method, but only first invocation has effect.- Overrides:
destroyin classRunnableBase
-
run
public void run()
-
applyResult
protected void applyResult(SolutionSynchronizer.Result result)
-
isUsersSyncTime
protected boolean isUsersSyncTime()
-
calculateNextUsersSyncTime
protected long calculateNextUsersSyncTime()
-
isUnchangedPeriodTime
protected boolean isUnchangedPeriodTime()
-
calculateNextUnchangedPeriodTime
protected long calculateNextUnchangedPeriodTime(Duration unchangedPeriodTimeoutShift)
-
getSystemTime
protected long getSystemTime()
-
buildChanges
protected List<org.optaplanner.core.impl.solver.ProblemFactChange<org.kie.server.services.taskassigning.core.model.TaskAssigningSolution>> buildChanges(org.kie.server.services.taskassigning.core.model.TaskAssigningSolution solution, org.apache.commons.lang3.tuple.Pair<List<org.kie.server.api.model.taskassigning.TaskData>,LocalDateTime> tasksUpdateResult, org.apache.commons.lang3.tuple.Pair<Boolean,List<org.kie.server.services.taskassigning.user.system.api.User>> usersUpdateResult)
-
buildChanges
protected List<org.optaplanner.core.impl.solver.ProblemFactChange<org.kie.server.services.taskassigning.core.model.TaskAssigningSolution>> buildChanges(org.kie.server.services.taskassigning.core.model.TaskAssigningSolution solution, List<org.kie.server.api.model.taskassigning.TaskData> updatedTaskDataList)
-
buildChanges
protected List<org.optaplanner.core.impl.solver.ProblemFactChange<org.kie.server.services.taskassigning.core.model.TaskAssigningSolution>> buildChanges(org.kie.server.services.taskassigning.core.model.TaskAssigningSolution solution, List<org.kie.server.api.model.taskassigning.TaskData> updatedTaskDataList, List<org.kie.server.services.taskassigning.user.system.api.User> updatedUserList)
-
-