public class DefaultOperationReservationService extends java.lang.Object implements OperationReservationService
Basic implementation of the OperationReservationService which implemented
using core TaskRepository service to
find and save reserved operations.
Service implementation provides ability to restrict count of tasks that could be reserved by one request.
NOTE: this is very simple implementation, its count each task as single operation,
it means if the task constains more then one operation - all operations
of a task will be reserved as single reservation.
So, this implementation may be used only in the environments where tasks has single operation,
or where all tasks has same amout of operations. In the environments where tasks has broad structure
it was hard to predict reservation density.
To constraint this behaviour, task-related constraint may be used, this constaint should
match operations count within the task, and allow to reserve only tasks which has only one operation included.
TODO: Another implementation which would allow to reserve only requested number of operations.
TODO: To support this feature, the domain should allow to launch tasks partialy,
TODO: atm all operations of the tasks become 'PENDING' after Task.prepareExecution() trace.
TODO: Also, total amount of reserved tasks could be limited. [ Constraint ]
TODO: add task-related constraints, which would allow to setup constraints to check tasks consitensy
| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_RESERVATION_LIMIT |
| Constructor and Description |
|---|
DefaultOperationReservationService(org.ametiste.routine.domain.task.TaskRepository taskRepository) |
DefaultOperationReservationService(org.ametiste.routine.domain.task.TaskRepository taskRepository,
int reservationLimit) |
| Modifier and Type | Method and Description |
|---|---|
java.util.List<org.ametiste.routine.domain.task.ExecutionLine> |
reserveOperationsExecution(int reservationCount)
Reserv the number of 'NEW' task's operations for next termination, provides information about
operations reserved.
|
public static final int DEFAULT_RESERVATION_LIMIT
public DefaultOperationReservationService(org.ametiste.routine.domain.task.TaskRepository taskRepository)
public DefaultOperationReservationService(org.ametiste.routine.domain.task.TaskRepository taskRepository,
int reservationLimit)
@Transactional public java.util.List<org.ametiste.routine.domain.task.ExecutionLine> reserveOperationsExecution(int reservationCount)
OperationReservationServiceReserv the number of 'NEW' task's operations for next termination, provides information about operations reserved.
Note, if the service can't find enough operations to reserv, available amount would be reserved.
For example, if only 5 'NEW' opertions are available, and requested reservation count is 7, only 5 operations will be reserved.
If there is 0 of 'NEW' operations, nothing will be reserved.
reserveOperationsExecution in interface OperationReservationServicereservationCount - maximu reservated operations count