You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@syncope.apache.org by GitBox <gi...@apache.org> on 2022/11/15 12:14:14 UTC

[GitHub] [syncope] mmoayyed opened a new pull request, #391: SYNCOPE-1709: Persist Jobs' current status in the database (Backport 2_1_X)

mmoayyed opened a new pull request, #391:
URL: https://github.com/apache/syncope/pull/391

   Backporting https://github.com/apache/syncope/pull/390 to 2_1_X.
   
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@syncope.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [syncope] ilgrosso commented on a diff in pull request #391: SYNCOPE-1709: Persist Jobs' current status in the database (Backport 2_1_X)

Posted by GitBox <gi...@apache.org>.
ilgrosso commented on code in PR #391:
URL: https://github.com/apache/syncope/pull/391#discussion_r1022915553


##########
core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/job/JobStatusUpdater.java:
##########
@@ -0,0 +1,65 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.provisioning.java.job;
+
+import org.apache.syncope.core.persistence.api.dao.JobStatusDAO;
+import org.apache.syncope.core.persistence.api.entity.EntityFactory;
+import org.apache.syncope.core.persistence.api.entity.JobStatus;
+import org.apache.syncope.core.provisioning.api.event.JobStatusEvent;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.context.event.EventListener;
+import org.springframework.scheduling.annotation.Async;
+
+public class JobStatusUpdater {
+
+    @Autowired
+    protected JobStatusDAO jobStatusDAO;
+
+    @Autowired
+    protected EntityFactory entityFactory;
+
+    public JobStatusUpdater(final JobStatusDAO jobStatusDAO, final EntityFactory entityFactory) {
+        this.jobStatusDAO = jobStatusDAO;
+        this.entityFactory = entityFactory;
+    }
+
+    /**
+     * It's important to note that responding to job status updates
+     * must be done in async mode, and via a separate special thread executor
+     * that attempts to synchronize job execution serially by only making one thread
+     * active at a given time. Not doing so will force the event executor to launch
+     * separate threads per each status update, which would result in multiple concurrent
+     * INSERT operations on the database, and failing.
+     *
+     * @param event the event
+     */
+    @Async("jobStatusUpdaterThreadExecutor")
+    @EventListener
+    public void update(final JobStatusEvent event) {
+        System.out.println("Updating " + event.getJobRefDesc() + " " + event.getJobStatus());

Review Comment:
   Please either remove this line or turn it into a proper `LOG` statement



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@syncope.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [syncope] mmoayyed merged pull request #391: SYNCOPE-1709: Persist Jobs' current status in the database (Backport 2_1_X)

Posted by GitBox <gi...@apache.org>.
mmoayyed merged PR #391:
URL: https://github.com/apache/syncope/pull/391


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@syncope.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [syncope] ilgrosso commented on a diff in pull request #391: SYNCOPE-1709: Persist Jobs' current status in the database (Backport 2_1_X)

Posted by GitBox <gi...@apache.org>.
ilgrosso commented on code in PR #391:
URL: https://github.com/apache/syncope/pull/391#discussion_r1022755891


##########
core/logic/src/main/java/org/apache/syncope/core/logic/AbstractExecutableLogic.java:
##########
@@ -28,19 +26,22 @@
 import org.apache.syncope.common.rest.api.batch.BatchResponseItem;
 import org.apache.syncope.core.persistence.api.dao.search.OrderByClause;
 
+import java.util.Date;

Review Comment:
   Please keep consistent import style (checkstyle definition was not aligned with `master`'s)



##########
core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAJobStatusDAO.java:
##########
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.syncope.core.persistence.jpa.dao;
+
+import org.apache.syncope.core.persistence.api.dao.JobStatusDAO;
+import org.apache.syncope.core.persistence.api.entity.JobStatus;
+import org.apache.syncope.core.persistence.jpa.entity.JPAJobStatus;
+import org.springframework.transaction.annotation.Transactional;
+
+public class JPAJobStatusDAO extends AbstractDAO<JobStatus> implements JobStatusDAO {

Review Comment:
   This needs to be annotated with `@Repository`



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@syncope.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org