tinatian/liferay-portal — pull request #36 by lipusz (2014-12-03 11:31:36+00:00)
Title: [TECHNICAL SUPPORT] LPS-51676 ldap.import.on.startup=true has no effect

https://issues.liferay.com/browse/LPS-51676

Hey Tina,

This pull restores the behavior we had before https://issues.liferay.com/browse/LPS-30707 (liferay@e2b985f).

Here is a brief summary:
1- https://issues.liferay.com/browse/LPS-4735 (liferay@2c29fc52913f448e34080797c69bade2c71dd6a6) added a delay to triggers' start date in order to avoid possible NPE on startup due to missing beans, APIs etc.

2- https://issues.liferay.com/browse/LPS-23983 (liferay@62bfec74bdf74ec0d3a0dcd0f354bccf6ecdfc7b) added the SchedulerLifecycle to make sure we don't init quartz too early

3- https://issues.liferay.com/browse/LPS-30527 (liferay@d007c1d5a2578e9d259f6b930878f296731a51d0) moved the logic that executes an LDAP import on startup from the PortalInstances#init to the LDAPImportMessageListener

Therefore, the startup import depends on the scheduled LDAP import job (defined in the liferay-portlet.xml)

4- https://issues.liferay.com/browse/LPS-30707 (liferay@e2b985f859c618d0a699beaecbf6ef0a21f8d03c) removed the delay from the getQuartzTrigger method

5- Due to the increased startup time (6.2 <=), the interval between loading and scheduling of the triggers from the xmls and starting the SchedulerEngine is enough to pass the missfireTreshold in some cases, thus, no LDAP import will occur on startup when e.g. it's configured to a 1 day interval, even if property

````properties
ldap.import.on.startup=true
````

is set.

----------------------

Norbi and I believe that https://issues.liferay.com/browse/LPS-30527 was rather a workaround than a complete solution, since the startup LDAP import (if enabled) should be executed regardless of how the scheduled import is configured.

Of course, we should also avoid parallel import on startup, that is (at least) resolved by that LPS.

We were thinking about possible "ultimate" solutions, such as
1. Define a specific missfire strategy for the LDAP import trigger like
````java
// QuartzSchedulerEngine#getQuartzTrigger

triggerBuilder.withSchedule(simpleScheduleBuilder.withMisfireHandlingInstructionFireNow());
````
Problems:
- the method is a general one for scheduling
- there is no way (currently) to define such settings for the triggers in the liferay-portlet.xml

2. Create the LDAPImport trigger programmatically so we we'd be able to set the missfire strategy
Cons: loosing ability to dynamically configure the LDAP import scheduled jobs (no liferay-portlet.xml)

3. Create a new "run-once" task for the startup LDAP import when we start the SchedulerEngine so it's start date would not pass the missfire treshold
Cons: how to ensure we don't import twice on startup (1. "run-once" task 2. scheduled import)

Sorry for the long words, but I wanted to put you in context. ;-)

We're looking forwards to you ideas.

Regards,
-tibor

/cc @NorbertKocsis