Repository: syncope Updated Branches: refs/heads/1_2_X 92994299f -> fed10a7a7 (forced update)
[SYNCOPE-660]This closes #7 Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/fed10a7a Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/fed10a7a Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/fed10a7a Branch: refs/heads/1_2_X Commit: fed10a7a779b22cbb58ed824f4b386c2ec19f667 Parents: 69c0950 Author: giacomolm <[email protected]> Authored: Mon Jun 22 12:28:38 2015 +0200 Committer: giacomolm <[email protected]> Committed: Mon Jun 22 13:15:38 2015 +0200 ---------------------------------------------------------------------- .../apache/syncope/core/quartz/AbstractTaskJob.java | 16 +++++++++++++++- core/src/main/resources/content.xml | 5 +++++ core/src/test/resources/content.xml | 7 ++++++- 3 files changed, 26 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/fed10a7a/core/src/main/java/org/apache/syncope/core/quartz/AbstractTaskJob.java ---------------------------------------------------------------------- diff --git a/core/src/main/java/org/apache/syncope/core/quartz/AbstractTaskJob.java b/core/src/main/java/org/apache/syncope/core/quartz/AbstractTaskJob.java index 9538311..52615ae 100644 --- a/core/src/main/java/org/apache/syncope/core/quartz/AbstractTaskJob.java +++ b/core/src/main/java/org/apache/syncope/core/quartz/AbstractTaskJob.java @@ -29,6 +29,7 @@ import org.apache.syncope.core.audit.AuditManager; import org.apache.syncope.core.notification.NotificationManager; import org.apache.syncope.core.persistence.beans.Task; import org.apache.syncope.core.persistence.beans.TaskExec; +import org.apache.syncope.core.persistence.dao.ConfDAO; import org.apache.syncope.core.persistence.dao.TaskDAO; import org.apache.syncope.core.persistence.dao.TaskExecDAO; import org.apache.syncope.core.util.ExceptionUtil; @@ -81,6 +82,12 @@ public abstract class AbstractTaskJob implements TaskJob { private TaskExecDAO taskExecDAO; /** + * Configuration DAO. + */ + @Autowired + private ConfDAO confDAO; + + /** * Notification manager. */ @Autowired @@ -194,9 +201,16 @@ public abstract class AbstractTaskJob implements TaskJob { LOG.info("Interrupting job time {} ", (new SimpleDateFormat(SyncopeConstants.DEFAULT_DATE_PATTERN, Locale. getDefault())).format(new Date())); thread.interrupt(); + if (thread.isAlive()) { + long maxRetry = confDAO.find("tasks.interruptMaxRetries", "0").getValues().get(0).getLongValue(); + for (int i = 0; i <= maxRetry && thread.isAlive(); i++) { + thread.interrupt(); + } + //if the thread is still alive, it should be available in the next stop + if(thread.isAlive()) this.runningThread.set(thread); + } } else { LOG.warn("Unable to retrieve the right thread related to the current job execution"); } } -; } http://git-wip-us.apache.org/repos/asf/syncope/blob/fed10a7a/core/src/main/resources/content.xml ---------------------------------------------------------------------- diff --git a/core/src/main/resources/content.xml b/core/src/main/resources/content.xml index 827e6c9..90a17cd 100644 --- a/core/src/main/resources/content.xml +++ b/core/src/main/resources/content.xml @@ -77,6 +77,11 @@ under the License. mandatoryCondition="true" multivalue="0" uniqueConstraint="0" readonly="0"/> <CAttr id="11" owner_id="1" schema_name="log.lastlogindate"/> <CAttrValue id="11" attribute_id="11" booleanValue="1"/> + + <CSchema name="tasks.interruptMaxRetries" type="Long" + mandatoryCondition="true" multivalue="0" uniqueConstraint="0" readonly="0"/> + <CAttr id="12" owner_id="1" schema_name="tasks.interruptMaxRetries"/> + <CAttrValue id="12" attribute_id="12" longValue="20"/> <!-- For usage with admin console --> <CSchema name="admin.user.layout" type="String" http://git-wip-us.apache.org/repos/asf/syncope/blob/fed10a7a/core/src/test/resources/content.xml ---------------------------------------------------------------------- diff --git a/core/src/test/resources/content.xml b/core/src/test/resources/content.xml index a361a6d..d1ec455 100644 --- a/core/src/test/resources/content.xml +++ b/core/src/test/resources/content.xml @@ -71,12 +71,17 @@ under the License. <CAttr id="9" owner_id="1" schema_name="authentication.statuses"/> <CAttrValue id="9" attribute_id="9" stringValue="created"/> <CAttrValue id="10" attribute_id="9" stringValue="active"/> - + <!-- Save user login date upon successful authentication --> <CSchema name="log.lastlogindate" type="Boolean" mandatoryCondition="true" multivalue="0" uniqueConstraint="0" readonly="0"/> <CAttr id="11" owner_id="1" schema_name="log.lastlogindate"/> <CAttrValue id="11" attribute_id="11" booleanValue="1"/> + + <CSchema name="tasks.interruptMaxRetries" type="Long" + mandatoryCondition="true" multivalue="0" uniqueConstraint="0" readonly="0"/> + <CAttr id="12" owner_id="1" schema_name="tasks.interruptMaxRetries"/> + <CAttrValue id="12" attribute_id="12" longValue="20"/> <!-- For usage with admin console --> <CSchema name="admin.user.layout" type="String"
