[
https://issues.apache.org/jira/browse/ZEST-128?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15005107#comment-15005107
]
Niclas Hedhman commented on ZEST-128:
-------------------------------------
I have removed transient schedules. Only Durable ones now exists.
The flow is roughly like this;
ExecutionMixin manages the timingQueue, where each Schedule's next execution
time is stored. The timingQueue is a SortedSet (TreeSet)
ExecutionMixin waits until the first entry is time to execute. It then removes
the entry from the timingQueue, updates the Schedule's nextRun. If the nextRun
is "some time" (!= Long.MIN_VALUE) the ScheduleTime is placed back on the
timingQueue. ExecutionMixin then submits a TaskRunner to handle the execution
of a Schedule's Task.
TaskRunner manages the Schedule's state machine, i.e. starting,
completedSuccesssful, completedException. UnitOfWorkPropogation is used for the
TaskRunner, but it has no Retry.
The Task can either use the UnitOfWork that is created in the
TaskRunner[UowConcern], OR if the Task wants its own Usecase, Retry or
DiscardOn options, those can be declared on the run() method of the Task. Task
declares the UnitOfWorkConcern, so no additional declaration required;
{code}
@Override
@UnitOfWorkPropagation( usecase = "Fetch Load Data" )
@UnitOfWorkRetry( retry = 5, initialDelay = 10000, delayFactory = 10000
)
@UnitOfWorkDiscardOn( LoadDataDeclarationNotValidException.class )
public void run()
{
:
{code}
> Scheduler Library looses schedules
> ----------------------------------
>
> Key: ZEST-128
> URL: https://issues.apache.org/jira/browse/ZEST-128
> Project: Zest
> Issue Type: Bug
> Affects Versions: 2.1
> Reporter: Niclas Hedhman
> Assignee: Niclas Hedhman
> Priority: Critical
>
> The Scheduler Library doesn't manage to keep the schedules running. Some
> seems to get lost, and many are never run at all.
> I have modified the existing test case to show that being the case. Below,
> the task is only run once.
> From my app, I am pretty sure it doesn't matter whether it is the same Task
> instance or separate instances... They get lost...
> {code:Title=SchedulerTest.java}
> @Test
> public void testOnce()
> throws UnitOfWorkCompletionException
> {
> final Usecase usecase = UsecaseBuilder.newUsecase( "TestOnce" );
> final String taskIdentity;
> try( UnitOfWork uow = module.newUnitOfWork( usecase ) )
> {
> Scheduler scheduler = module.findService( Scheduler.class ).get();
> FooTask task = createFooTask( uow, usecase.name(), BAZAR );
> taskIdentity = task.identity().get();
> scheduler.scheduleOnce( task, 1, true );
> scheduler.scheduleOnce( task, 2, true );
> scheduler.scheduleOnce( task, 3, true );
> scheduler.scheduleOnce( task, 4, true );
> uow.complete();
> }
> await( usecase.name() )
> .until( taskOutput( taskIdentity ), equalTo( 4 ) );
> }
> {code}
> {code:Title=FooTask.java}
> @UseDefaults
> Property<Integer> runCounter();
> abstract class Mixin
> implements Runnable
> {
> :
> :
> :
> @Override
> public void run()
> {
> synchronized( this )
> {
> me.runCounter().set( me.runCounter().get() + 1 );
> }
> :
> :
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)