Commit Graph

1928 Commits

Author SHA1 Message Date
Mahmoud Ben Hassine
4dc406ef60 BATCH-2564: make AutomaticJobRegistrar implement SmartLifeCycle
Before this commit, the AutomaticJobRegistrar was started on
ContextRefreshedEvent event. This is sometimes too late to register jobs
especially when other life cycle components that use the jobs are started
before this registrar.

This commit changes the AutomaticJobRegistrar to implement SmartLifeCycle
and makes its autoStartup and phase properties configurable.

It should be noted that the "onApplicationEvent" method has been removed
even if it is a public API. This method is not intended to be used by
client code and even if it was, its usage is considered wrong anyway.

Resolves BATCH-2564
2018-02-28 10:51:13 -06:00
Mahmoud Ben Hassine
daf0ecfc9f BATCH-2491: use LinkedHashSet instead of HashSet for command line options
Before this commit, options passed on the command line were collected
in a HashSet. This does not keep options order as they are passed in
the command line.

This commit changes the "opts" variable type to LinkedHashSet.
Note there is no test for this change as "opts" is a local variable to
the main method.

Resolves BATCH-2491
2018-02-26 13:59:08 -06:00
Mahmoud Ben Hassine
1ed5a33bd1 BATCH-2445: make annotation based chunk listeners available to non-fault tolerant steps
Before this commit, annotation based chunk listeners were not registered
when using a non-fault tolerant step builder.

This commit moves the code of chunk listener annotations handling to the
AbstractTaskletStepBuilder so that other tasklet builders can use it.

Resolves BATCH-2445
2018-02-26 12:53:47 -06:00
Mahmoud Ben Hassine
e11b838452 BATCH-2401: fix CPU intensive loop while polling partitions completion
Before this commit, the JsrPartitionHandler was polling partitions
completion continuously. This causes a high CPU usage.

This commit makes the polling thread sleep for a configurable amount
of time in order to decrease CPU usage during the polling period.

Resolves BATCH-2401
2018-02-26 11:47:09 -06:00
Mahmoud Ben Hassine
b0ffe55113 BATCH-2680: add custom Jackson module to (de)serialize job parameters
Currently, the Jackson2ExecutionContextStringSerializer fails to
deserialize json representations of:

* empty JobParameters instances due to the presence of "empty":true
 in the serialized json String. In this case, Jackson is not able to find a
 property named "empty" in the target type (JobParameters)

* JobParameter instances due to the presence of several constructors.
In this case, Jackson does not know which constructor to use.

This commit fixes these two issues by adding a custom Jackson module with:

* a mixin to ignore the "isEmpty" getter in JobParameters type
* a custom deserializer for JobParameter type

Resolves BATCH-2680
2018-02-26 10:43:52 -06:00
Mahmoud Ben Hassine
7a9a2a9c50 BATCH-2537: add support for @Primary annotated data sources
Currently, when multiple data sources are defined in the context, an
IllegalStateException is thrown even if one of the data sources is
annotated with @Primary (which should be the one to use).

This commit makes it possible to use the data source annotated with
@Primary when multiple data sources are defined. Note that the context
initialization will still fail (with a UnsatisfiedDependencyException
from Spring's bean factory) if multiple data sources are defined and
none of them is annotated with @Primary. If multiple data sources are
defined and none of them is annotated with @Primary but one of them is
named "dataSource", this data source will be used by the batch
configuration due to autowiring by name (this detail has been documented
in the javadoc of @EnableBatchProcessing).

Resolves BATCH-2537
2018-02-26 10:19:08 -06:00
Mahmoud Ben Hassine
79f3a67883 BATCH-2397: fix parameters handling in MethodInvokingTaskletAdapter
When a tasklet is declared with xml using the shortcut version, the
MethodInvokingTaskletAdapter that is created automatically does not
address passing parameters expected by Tasklet#execute (which is
incorrect since the documentation of the schema attribute "method"
says the bean should define a method with the same signature).

This commit fixes parameters passing when using the shortcut version.

Resolves BATCH-2397
2018-01-26 13:15:20 -06:00
Mahmoud Ben Hassine
c78701a871 BATCH-2663: re-initialize filter count when scanning a chunk
Before this commit, the filter count of the contribution was applied
for each item of a scanned chunk. For example, with a chunk of 30,
if the filter count is 10 and an item is skipped during write, then the
filter count is equal to 210 (10 + 20 * 10).

If this commit is applied, the filter count will be re-initialized when
scanning the chunk.

Resolves BATCH-2663
2018-01-24 15:09:07 -06:00
Mahmoud Ben Hassine
d81ab76823 BATCH-2667: update warning message to be more explicit
Before this commit, when a job execution is stopped from a different
JVM than the one running the job, a warning says that the job cannot
be found. This was confusing to some users since the job can be found
in the database (but is actually not defined in the job registry of
the application context of the second JVM).

After this commit is applied, the warning will be more explicit to
inform the user that the job cannot be found in the job registry
(to not be confused with the database)

Resolves BATCH-2667
2018-01-19 21:24:06 +01:00
Michael Minella
7a3a72f5ca Updated copyright date 2017-11-30 15:28:12 -06:00
Alexis Hafner
3a3404412c BATCH-2543 New method on DefaultBatchConfigurer 2017-11-30 15:20:01 -06:00
Michael Minella
f61679b55f Added updates for properties files as well 2017-11-27 12:06:29 -06:00
Michael Minella
8a223e35c6 Fixed javadoc for JobOperator#abandon
The javadoc in the `JobOperator#abandon` indicated that a JobExecution
marked as `ABANDONED` can be restarted (it cannot).

Resolves BATCH-2654
2017-11-22 09:19:03 -06:00
Eduardo Jolo
509be945fc Set the StepExecution ExitStatus in the JobStep doExecute 2017-11-02 12:56:09 -05:00
Michael Minella
fa286dc1e9 Refactored JobExecution for performance
In order to make the Map based JobRepository threadsafe, the
JobExecutino was modified to use a `CopyOnWriteArraySet` for the
collection backing the child `StepExecution` collection.  However, this
collection option has bad performance characteristics when used with
large collections.  When using partitioning, it can be common to have a
large number of `StepExecution` instances to add which drastically hurts
start up time.

This commit remove the use of the `CopyOnWriteArraySet` for the
`JobExecution#stepExecutions` and replaces it with a `LinkedHashSet`
wrapped via `Collection.synchronizedSet`.

Resolves BATCH-2384
2017-11-02 12:38:35 -05:00
Daniel Heinrich
9322fe6fae BATCH-2455 unifie listener ordering
Why:
Listeners should be called in normal order before some event
(i.e. read, write) and after that event in reverse order.

Side effects:
The ordering of Chunk and ItemReader Listeners is changed and will
change some behaviors of users. This change is still neccesary because
it is not only the correct and obviouse way, but also prevents new
users to hack around this problem.
2017-11-02 10:29:09 -05:00
Michael Minella
e5fe6a5de6 Updated DefaultBatchConfigurer to not overwrite when autowiring
This commit prevents autowiring from overwriting a value set for the
`DataSource` if it has already been set.

Resolves BATCH-2636
2017-11-02 09:58:11 -05:00
Michael Minella
52d2c257c5 Version updates 2017-10-23 15:52:55 -05:00
Michael Minella
b2f8f7f9cd Refactored to add a way to copy JobParameters into another via builder
In a previous commit, the JobParametersBuilder was updated to include
some code from Spring Boot that handled the incrementing of
JobParameters for a previous job.  That commit brought over a private
`merge` method that is actually useful for general consumption.

This commit adds a `addJobParameters` method to the builder providing
the same functionality the `merge` method did in a public method.
2017-10-20 12:43:06 -05:00
Michael Minella
63dfe4b912 Polish 2017-10-20 11:57:56 -05:00
Glenn Renfro
a35784dbd6 Support getNextJobParameters from JobParametersBuilder.
resolves BATCH-2640

Cleanup and added tests to JobParametersBuilder.
2017-10-20 11:06:04 -05:00
Michael Minella
24fbb882e6 Updated job.adoc to have java config examples
This commit addresses the job.adoc and how to configure the various
pieces of the framework it covers via java configuration.
2017-10-18 12:00:27 -05:00
setoguchi
f8cc4918d9 fix typo 2017-10-17 10:29:10 -04:00
Michael Minella
7d2a26a136 Add an ItemProcessor that delegates to a java.util.function.Function
This commit adds a new `ItemProcessor` that delegates to a
`java.util.function.Function`.  It also enables users to configure a
`Function` as an `ItemProcessor` via the builders (so they don't need to
worry about the `ItemProcessor` wrapper in the first place).

Resolves BATCH-2641
2017-09-15 16:44:54 -05:00
Michael Minella
b180c75ce0 Housecleaning of build warnings 2017-09-15 15:58:22 -05:00
Michael Minella
340406a61f Polish 2017-09-14 14:29:26 -05:00
Glenn Renfro
6bdbe3029e Remove JavaDoc warnings part 2 2017-09-12 10:52:22 -05:00
Jimmy Praet
3968b77421 fix build on windows 2017-07-19 09:02:19 -05:00
Cameron
9256148cf2 BATCH-2630 - update not to rely on step execution order from DAO 2017-07-17 11:22:40 -05:00
Michael Minella
263e978a1f Updated for various code warnings
This commit addresses a number of deprications and other code warnings.
There are still many more to address, but this is a start.
2017-05-02 12:48:03 -05:00
Michael Minella
4ad00166f8 Changed default ExecutionContext serialization mechanism
The current default for serializing the ExecutionContext is via XStream
using Jettison's driver.  However, recent updates to Jettison make it
incompatible with XStream with no progress on a fix.  Because of this,
and to encourage the use of well supported library combinations, the
default ExecutionContext serialization mechanism for Spring Batch has
been switched to Jackson (via the
Jackson2ExecutionContextStringSerializer).  This commit also depricates
the XStreamExecutionContextStringSerializer for removal at a later date.
However, it is still available for users that require that during a
migration.

Resolves BATCH-2575
2017-03-22 15:25:14 -05:00
Michael Minella
a6c4dacbbe Refactored bootstrapping of JSR-352 base context
Spring Batch's implementation of JSR-352 previously relied on Spring's
ContextSingletonBeanFactoryLocator.  However, this has been removed in
Spring 5 as a relic of older EJB based use cases.  This commit now
lazily bootstraps the base context on it's own when the first
JsrJobOperator is requested.

Resolves BATCH-2572
2017-03-09 12:16:41 -06:00
Philippe Marschall
f78aa275c0 BATCH-2396 Guard Serializable check message
The exception message for the Serializable check in
DefaultExecutionContextSerializer is always generated. For large
contexts this can quickly put a log of pressure on the allocator and
the heap.

This commit contains the following changes:

 * generate the exception message for non-serializable values in
   DefaultExecutionContextSerializer only when needed

I have signed and agree to the terms of the SpringSource Individual
Contributor License Agreement.

Issue: BATCH-2396
2017-02-02 12:25:11 -06:00
Michael Minella
54a90beed7 Upgraded Mockito
This commit upgrades mockito to the latest currently available version
as well as does some additional cleanup.
2017-01-24 14:18:05 -06:00
Michael Minella
26b02fb836 Replaced snapshot versions and addressed deprications
This commit moves all SNAPSHOT dependencies to the latest available
released versions.  It also addresses a number of deprications in the
Spring Data realm.  Specifically around the deprication of the
Neo4JOperations and the package reorganization within Hibernate.
2016-12-30 14:04:58 -06:00
Michael Minella
80a153527f Updated test based on new error message returned by Spring Framework 5 2016-11-18 10:33:41 -06:00
Michael Minella
a75b067ebc Added builder for JdbcCursorItemReader
This provides a builder for the JdbcCursorItemReader to simplify java
configuration.

Resolves BATCH-2555
2016-11-18 09:18:26 -06:00
Michael Minella
eb2f752b16 Unwrap StepListenerFailedException when determining skip/rollback
When determining if an exception should be skipped or not, the business
exception should be used.  However, when an exception is thrown in the
listener, it's wrapped by a `StepListenerFailedException`.  This leads
to it hiding the underlying exception.  This commit will unwrap the
cause of a `StepListenerFailedException` and use that to determine if it
should be skipped or not.

Resolves BATCH-2322
2016-10-17 11:27:15 -05:00
Michael Minella
ca847e2760 Addressed stopped jobs from a job step
Prior to this commit, when using the `JobStep`, if the child job was
stopped (left in the `STOPPED` state), the step executing that job was
marked as `COMPLETE`, preventing it from being restarted.  This commit
now marks a step that was executing the stopped job also as stopped,
allowing for it to be restarted.

Resolves BATCH-2429
2016-10-14 12:07:48 -05:00
Michael Minella
23f599f1f5 Updated test to dynamically obtain java executable location 2016-10-03 12:56:33 -05:00
Michael Minella
f4c0530730 Upgraded dependency versions and minor polish 2016-08-09 13:19:14 -05:00
Michael Minella
e375771ba6 Fixed doc tags 2016-08-08 15:33:39 -05:00
Billy Korando
e754c8617a Update EnableBatchProcessing.java
Updating the Javadoc for EnablebatchProcessing to include additional beans it puts in context.
2016-08-08 15:16:23 -05:00
Nick Vanderhoven
f7e10909f9 BATCH-2513 Fix for typo in log statement of AbstractListenerFactoryBean.isListener 2016-08-08 13:21:36 -05:00
Andy Wilkinson
5867606f4b Tighten up AutomaticJobRegistrar’s event listening
Previously, AutomaticJobRegistrar listened to all ApplicationEvents
despite only being interested in two ApplicationContextEvents, namely
ContextRefreshedEvent and ContextClosedEvent. This could lead to
an AutomaticJobRegistrar instance being created earlier than necessary.

This commits tightens up AutomaticJobRegistrar so that it only listens
to ApplicationContextEvents.

Closes BATCH-2506
See https://github.com/spring-projects/spring-boot/issues/2395
2016-07-20 22:25:58 -05:00
Michael Minella
ade242f2c4 Updated SimpleStepExecutionSplitter to return a Set with addressable elements 2016-04-19 16:31:23 -05:00
Michael Minella
6e0d0531ce Fixes default schema version 2016-04-19 16:14:22 -05:00
Marten Deinum
22109eea84 This commit adds a ExecutionContextSerializer based on Jackson2.
It has been tested with Jackson 2.3.3 which is the Jackson version
used with the Spring dependency.

Tests have been updated to use Hamcrest matchers and made a bit more reusable.
2016-04-19 12:54:59 -05:00
mark kouba
f6d22f4f80 add shutdown for thread pool task executor so it cleans up and shutdowns
correctly before method exits.
2015-11-25 16:18:56 -06:00
Michael Minella
eafa7ee152 BATCH-2313: Fixed regression of BATCH-2153 by updating HashMap to ConcurrentHashMap 2015-10-15 16:04:00 -05:00