OHFJIRA-27 - Add support for clustered jobs (quartz)#33
Conversation
pjuza
left a comment
There was a problem hiding this comment.
Quite big implementation :).
I don't have any critical comments, only many smallers. I'm not able to validate the whole model (because it's too big ...) but I believe it's ok ...
| * @see QuartzSimpleTrigger | ||
| * @since 2.0 | ||
| */ | ||
| public enum ClusterExecuteType { |
There was a problem hiding this comment.
Wouldn't be better ScheduledJobType?
There was a problem hiding this comment.
I dont know. This is not for job, but it is for trigger. And maybe this is not good. I will add this setting into job. And name can be JobExecuteTypeInCluster.
| import org.quartz.SimpleTrigger; | ||
|
|
||
| /** | ||
| * Defined one {@link SimpleTrigger} in {@link QuartzJob}. |
There was a problem hiding this comment.
Better describe why use this annotation instead of QuartzCronTrigger
| /** | ||
| * See documentation in {@link SimpleTrigger#MISFIRE_INSTRUCTION_SMART_POLICY}. | ||
| * | ||
| * @see SimpleTrigger |
| /** | ||
| * Factory for create new {@link Trigger}s instance. | ||
| * <p> | ||
| * Every trigger instance running concurrent in all nodes in cluster at the same time |
There was a problem hiding this comment.
language mistake - Every trigger instance is able to running in ...
Factory for create new => Factory class for creating new ...
| * | ||
| * @return execute type in cluster mode | ||
| */ | ||
| ClusterExecuteType clusterExecuteType(); |
There was a problem hiding this comment.
Why is there not default value? I would expect concurrent ...
There was a problem hiding this comment.
I think that default value is not good idea. Set this attribute is important and when he has default value, many user not fill them.
| * Job running concurrent in all nodes in cluster at the same time. | ||
| * </p> | ||
| * | ||
| * @author Petr Juza |
There was a problem hiding this comment.
I don't know why there are so many @see items in specific implementations, I would remove them.
There was a problem hiding this comment.
I will remove it
| * | ||
| * @return cron triggers | ||
| */ | ||
| QuartzCronTrigger[] cronTriggers() default {}; |
There was a problem hiding this comment.
Is it possible to set cron and simple triggers at the same time?
If not then add description to JavaDoc + it's possible to define common parent class/annotation and then have only one trigger parameter?
There was a problem hiding this comment.
Yes it is. One job can have one or more QuartzCronTrigger and one or more QuartzSimpleTrigger at the same time.
|
|
||
| /** | ||
| * Defined one quartz {@link Job} with default group name {@value #OPEN_HUB_JOB_GROUP_NAME}. | ||
| * For base use see in {@link {@link QuartzJob}}. |
| * | ||
| * @return name | ||
| */ | ||
| String name() default StringUtils.EMPTY; |
There was a problem hiding this comment.
I see method in QuartzUtils for generating job's name. Wouldn't be better to define JobNameGenerator interface with default implementation from QuartzUtils?
There was a problem hiding this comment.
In QuartzUtils is not method for generate job name, but for generate trigger name. Job name is defined in annotation attribute name. I will create TriggerNameGenerator interface.
| */ | ||
| @Bean(name = "quartzProperties") | ||
| @Profile(Profiles.POSTGRES) | ||
| public Properties quartzPostgresProperties() { |
There was a problem hiding this comment.
I would define it in property file because when you add new DB then you should always add new method to the code.
pjuza
left a comment
There was a problem hiding this comment.
I went through all your comments and it's OK for me.
Only one thing - how to solve when new database type will be used? At this moment you should add new code and it's not flexible ...
|
You have right, this is not good solution. I will change it and move properties into configuration file application-h2.cfg or application-postgres.cfg. |
9103f7e to
3e2167b
Compare
|
It is ready for review. Changes:
|
pjuza
left a comment
There was a problem hiding this comment.
Two common points:
- test coverage descreased about 6% - it's too much, please add more unit tests
- please add wiki pages with information about using your quartz API. It will be helpful to better understand your code
| * @param env environment | ||
| * @param propertyNamePrefix prefix for property names | ||
| * @return {@link Properties} with properties that name start with propertyNamePrefix | ||
| */ |
There was a problem hiding this comment.
Consider to use Tools.getAllKnownPropertyNames in implementation ...
There was a problem hiding this comment.
I will use it. One small disadvantage is, that list will be use twice (first for getting names and second for getting values for names).
| * {@link QuartzCronTrigger}. | ||
| * <p> | ||
| * Annotation can be added on method and this method will be called when trigger will be executed. | ||
| * </p> |
There was a problem hiding this comment.
if you have starting and ending element p then it will create two empty lines and you propably want to have one line, don't you?
There was a problem hiding this comment.
I dont understand. Where is two empty lines? In HTML or in source code?
There was a problem hiding this comment.
When you use ending p and starting p ...
| * Annotation can be added on method and this method will be called when trigger will be executed. | ||
| * </p> | ||
| * <p> | ||
| * Every job must have at least one {@link QuartzCronTrigger} or {@link QuartzSimpleTrigger}. And one job can have |
There was a problem hiding this comment.
it's quite complicated sentence :)
| //-------------------------------------------------- SET / GET ----------------------------------------------------- | ||
|
|
||
| @Override | ||
| public void setApplicationContext(final ApplicationContext applicationContext) { |
There was a problem hiding this comment.
We have already full AOP support thus you can use @configured ...
There was a problem hiding this comment.
I used Autowired for load ApplicationContext property
9bb7fd1 to
3397711
Compare
Issue: OHFJIRA-27
3397711 to
f2e129c
Compare
hanusto
left a comment
There was a problem hiding this comment.
For this moment these PR meets the requirements.
In cluster we need two types of job:
Solution:
JIRA:
https://openhubframework.atlassian.net/browse/OHFJIRA-27