Timer Tasks in Java EE are not very comfortable. Is there any util, to configure timer with cron syntax like "0 20 20 * * "?
I wonder, if it would be a good way to use Quartzinside (clustered) Java EE application. According to http://www.prozesse-und-systeme.de/serverClustering.html (german page) there limits with Quartz and Java EE clustering:
JDBC must be used as job store for Quartz
Only cluster associated Quartz instances are allowed to use this JDBC job store
All cluster nodes must be synchronized to the split second
All cluster nodes must use the same quartz.properties file
I would prefer an easier way for configuration of timer service, instead an not Java EE managed scheduler.
Quartz definitely support cron-like syntax (with the CronTrigger) but your requirements are not clear. Also maybe have a look at Jcrontab or cron4j.
As a side note, the ability to declaratively create cron-like schedules to trigger EJB methods is one of the most important enhancement of the Timer Service in EJB 3.1 (using the #Schedule annotation). Below, an example taken from New Features in EJB 3.1:
#Stateless
public class NewsLetterGeneratorBean implements NewsLetterGenerator {
#Schedule(second="0", minute="0", hour="0",
dayOfMonth="1", month="*", year="*")
public void generateMonthlyNewsLetter() {
... Code to generate the monthly news letter goes here...
}
}
Related
Below is the basic example of submitting a callable/runable to executor service:
// Executor: instance of Hazelcast's durable executor service
// Task: a simple callable
future = executor.submit(task);
There isn't currently a way in the API.
With a normal Java runnable/callable (no Hazelcast) there isn't really a way either.
You can obviously capture the timestamp in your code just before the submit and after the future is available.
In a callable, at the start and end of the run() method you could capture the timestamps, and somehow include that in the result returned.
Not really an elegant answer!
I need help in creating cron expression for Mule scheduler job.
Scenario : Job should run in every month from 3rd day to 6th day for every 2 hours(intra day) and those days should be working days(Monday to Friday only).
I tried below cron expression in cronMaker : 0 0 7-20/2 3-5 * Mon-Fri *
Here i am getting error for this above expression.
Please help me to resolve this issue. Thank you in Advance.
If you try the same cron expression in an actual Mule application -I used Mule runtime 4.3- using a Scheduler source you will get the following error:
Support for specifying both a day-of-week AND a day-of-month parameter is not implemented.
This is a limitation of the Quartz library that the Scheduler uses in its implementation. This means it is not possible to use that kind of cron expression in a Mule Scheduler, or a Quartz Java application.
Likely CronMaker has the same limitation but it is not showing the full error message.
Updated:
You can avoid the limitation by using only one of the conditions, for example day-of-month (it will trigger less activations) and at the beginning of the flow add a choice with a condition to check for the day of the week using a DataWeave expression. With the choice you can avoid executing the rest of the flow if it is not the right day.
There are no other similar flow source components that I'm aware of. You can try to create your own in Java using Mule SDK.
The regular setup of Quartz cron-based tasks looks like this:
IJobDetail firstJob = JobBuilder.Create<FirstJob>()
.WithIdentity("firstJob")
.Build();
ITrigger firstTrigger = TriggerBuilder.Create()
.WithIdentity("firstTrigger")
.StartNow()
.WithCronSchedule("0 * 8-22 * * ?")
.Build();
FirstJob is a specific class that implements IJob interface from Quartz. In my case I may have multiple job classes implementing that interface, each does particular type of work that needs to be scheduled.
Therefore seems I'm forced to set up as many job detail instances as I have job classes, i.e. repeat the code. Is there any other way to simplify and shorten it and have a collection of job detail objects not implicitly passing the job class names? Say, all my job classed would implement a CustomInterface : IJob, and I would rather use CustomInterface name somewhere setting up the job details.
Resolved.
IJobDetail job = JobBuilder.Create(Type.GetType(jobDetail.JobKey.Name))
I am trying to understand how exactly Apache Spark scheduler works. To do so, i've set a local cluster with one master and two workers. I only submit one application, which simply reads 4 files (2 small (~10MB) and 2 big(~1,1GB)),joins them and collects the result. In addition, i cache in memory the two small files.
I am running the standalone cluster mode with FIFO.I've understood how the stages are formed but i cannot figure out how the flow of data is determined(the arrows). When i look at SparkUI, i notice that each time,even though the stages are formed in the same way, the arrows( flow of data and control i guess) are different. It's like the scheduler works non-deterministically.
I've read the relative chapters (about DAG and Task Scheduler) from Jacek Laskowski's book, but it isn't still clear in my head how the flow of control is determined . Thanks in advance for the help.
Cheers,
Jim
It's like the scheduler works non-deterministically.
Yes, there's some randomness in scheduling tasks to make it more "fair". In that sense Spark scheduler does work "non-deterministically", but within acceptable limits of execution placement (i.e. assigning tasks with lesser location preferences to executors).
The component in Apache Spark that does the work of selecting a task for a task set (that corresponds to a stage) is TaskSetManager:
Schedules the tasks within a single TaskSet in the TaskSchedulerImpl. This class keeps track of each task, retries tasks if they fail (up to a limited number of times), and handles locality-aware scheduling for this TaskSet via delay scheduling. The main interfaces to it are resourceOffer, which asks the TaskSet whether it wants to run a task on one node, and statusUpdate, which tells it that one of its tasks changed state (e.g. finished).
I have multiple Spring batch jobs that I am required to schedule such that they are triggered at the same time.So far I am not having luck around this and I also do not under stand why.I read some where that having multiple jobs to trigger on same CRON expression(e.g. after every 10 mins) is not possible with Quartz and I have to increase the SIZE of the thread pool some how to make it possible.I just want to understand is this correct?If yes then is there an alternate way of achieving this sort of concurrency and if not then how can I increase the thread pool size in the xml configuration?Many Thanks in advance