Skip to content
Snippets Groups Projects
Commit 0ac8ab81 authored by srosse's avatar srosse
Browse files

FXOLAT-358: move the special background task manager for the RepositoryManager...

FXOLAT-358: move the special background task manager for the RepositoryManager in the package org.olat.repository
parent 56aefac3
No related branches found
No related tags found
No related merge requests found
Showing
with 33 additions and 32 deletions
......@@ -18,19 +18,20 @@
* University of Zurich, Switzerland.
* <p>
*/
package org.olat.core.commons.persistence.async;
package org.olat.repository.async;
import org.apache.log4j.Logger;
import org.hibernate.HibernateException;
import org.olat.core.commons.persistence.DBFactory;
import org.olat.core.logging.DBRuntimeException;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
/**
* @author Christian Guretzki
*/
public abstract class AbstractBackgroundTask implements BackgroundTask {
private static Logger log = Logger.getLogger(AbstractBackgroundTask.class.getName());
private static OLog log = Tracing.createLoggerFor(AbstractBackgroundTask.class);
private int maxRetry = 1000;// 0 = endless retry
......@@ -124,7 +125,7 @@ public abstract class AbstractBackgroundTask implements BackgroundTask {
while (!this.isTaskDone() && counter < COUNTER_LIMIT) {
try {
log.debug("waitForDone: this.isTaskDone()=" + this.isTaskDone() + " counter=" + counter + " this=" + this);
Thread.currentThread().sleep(200);
Thread.sleep(200);
counter++;
} catch (InterruptedException e) {
// no log
......
......@@ -18,7 +18,7 @@
* University of Zurich, Switzerland.
* <p>
*/
package org.olat.core.commons.persistence.async;
package org.olat.repository.async;
/**
......
......@@ -18,7 +18,7 @@
* University of Zurich, Switzerland.
* <p>
*/
package org.olat.core.commons.persistence.async;
package org.olat.repository.async;
import java.util.Queue;
import java.util.concurrent.ConcurrentLinkedQueue;
......@@ -27,6 +27,8 @@ import org.apache.log4j.Logger;
import org.olat.core.manager.BasicManager;
/**
* !!!This is only for the Repository Manager. It's absolutely forbidden to use for something else!!!
*
* FIFO-queue for background job. Application can put-in 'background-task', the background-job check in a fix interval
* this queue and can execute task. If you look for scheduled tasks check TaskExecutorManager
*
......
......@@ -22,10 +22,9 @@ package org.olat.repository.async;
import java.util.Date;
import org.apache.log4j.Logger;
import org.olat.commons.lifecycle.LifeCycleManager;
import org.olat.core.commons.persistence.DBFactory;
import org.olat.core.commons.persistence.async.AbstractBackgroundTask;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
import org.olat.repository.RepositoryEntry;
import org.olat.repository.RepositoryManager;
......@@ -37,7 +36,7 @@ import org.olat.testutils.codepoints.server.Codepoint;
* @author Christian Guretzki
*/
public class IncrementDownloadCounterBackgroundTask extends AbstractBackgroundTask {
private static Logger log = Logger.getLogger(IncrementDownloadCounterBackgroundTask.class.getName());
private static OLog log = Tracing.createLoggerFor(IncrementDownloadCounterBackgroundTask.class);
private RepositoryEntry repositoryEntry;
......@@ -54,7 +53,7 @@ public class IncrementDownloadCounterBackgroundTask extends AbstractBackgroundTa
reloadedRe.setLastUsage(new Date());
LifeCycleManager lcManager = LifeCycleManager.createInstanceFor(reloadedRe);
if (lcManager.lookupLifeCycleEntry(RepositoryDeletionManager.SEND_DELETE_EMAIL_ACTION) != null) {
Tracing.logAudit("Repository-Deletion: Remove from delete-list repositoryEntry=" + reloadedRe, RepositoryManager.class);
log.audit("Repository-Deletion: Remove from delete-list repositoryEntry=" + reloadedRe);
LifeCycleManager.createInstanceFor(reloadedRe).deleteTimestampFor(RepositoryDeletionManager.SEND_DELETE_EMAIL_ACTION);
}
Codepoint.hierarchicalCodepoint(IncrementDownloadCounterBackgroundTask.class, "executeTask-before-update", 1);
......
......@@ -22,10 +22,9 @@ package org.olat.repository.async;
import java.util.Date;
import org.apache.log4j.Logger;
import org.olat.commons.lifecycle.LifeCycleManager;
import org.olat.core.commons.persistence.DBFactory;
import org.olat.core.commons.persistence.async.AbstractBackgroundTask;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
import org.olat.repository.RepositoryEntry;
import org.olat.repository.RepositoryManager;
......@@ -36,7 +35,7 @@ import org.olat.repository.delete.service.RepositoryDeletionManager;
* @author Christian Guretzki
*/
public class IncrementLaunchCounterBackgroundTask extends AbstractBackgroundTask {
private static Logger log = Logger.getLogger(IncrementLaunchCounterBackgroundTask.class.getName());
private static OLog log = Tracing.createLoggerFor(IncrementLaunchCounterBackgroundTask.class);
private RepositoryEntry repositoryEntry;
......@@ -53,7 +52,7 @@ public class IncrementLaunchCounterBackgroundTask extends AbstractBackgroundTask
reloadedRe.setLastUsage(new Date());
LifeCycleManager lcManager = LifeCycleManager.createInstanceFor(reloadedRe);
if (lcManager.lookupLifeCycleEntry(RepositoryDeletionManager.SEND_DELETE_EMAIL_ACTION) != null) {
Tracing.logAudit("Repository-Deletion: Remove from delete-list repositoryEntry=" + reloadedRe, RepositoryManager.class);
log.audit("Repository-Deletion: Remove from delete-list repositoryEntry=" + reloadedRe);
LifeCycleManager.createInstanceFor(reloadedRe).deleteTimestampFor(RepositoryDeletionManager.SEND_DELETE_EMAIL_ACTION);
}
RepositoryManager.getInstance().updateRepositoryEntry(reloadedRe);
......
......@@ -20,9 +20,9 @@
*/
package org.olat.repository.async;
import org.apache.log4j.Logger;
import org.olat.core.commons.persistence.DBFactory;
import org.olat.core.commons.persistence.async.AbstractBackgroundTask;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
import org.olat.repository.RepositoryEntry;
import org.olat.repository.RepositoryManager;
......@@ -31,7 +31,7 @@ import org.olat.repository.RepositoryManager;
* @author Christian Guretzki
*/
public class SetAccessBackgroundTask extends AbstractBackgroundTask {
private static Logger log = Logger.getLogger(SetAccessBackgroundTask.class.getName());
private static OLog log = Tracing.createLoggerFor(SetAccessBackgroundTask.class);
private RepositoryEntry repositoryEntry;
private int access;
......
......@@ -20,9 +20,9 @@
*/
package org.olat.repository.async;
import org.apache.log4j.Logger;
import org.olat.core.commons.persistence.DBFactory;
import org.olat.core.commons.persistence.async.AbstractBackgroundTask;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
import org.olat.repository.RepositoryEntry;
import org.olat.repository.RepositoryManager;
......@@ -31,7 +31,7 @@ import org.olat.repository.RepositoryManager;
* @author Christian Guretzki
*/
public class SetDescriptionNameBackgroundTask extends AbstractBackgroundTask {
private static Logger log = Logger.getLogger(SetDescriptionNameBackgroundTask.class.getName());
private static OLog log = Tracing.createLoggerFor(SetDescriptionNameBackgroundTask.class);
private RepositoryEntry repositoryEntry;
......
......@@ -22,10 +22,9 @@ package org.olat.repository.async;
import java.util.Date;
import org.apache.log4j.Logger;
import org.olat.commons.lifecycle.LifeCycleManager;
import org.olat.core.commons.persistence.DBFactory;
import org.olat.core.commons.persistence.async.AbstractBackgroundTask;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
import org.olat.repository.RepositoryEntry;
import org.olat.repository.RepositoryManager;
......@@ -36,7 +35,7 @@ import org.olat.repository.delete.service.RepositoryDeletionManager;
* @author Christian Guretzki
*/
public class SetLastUsageBackgroundTask extends AbstractBackgroundTask {
private static Logger log = Logger.getLogger(SetLastUsageBackgroundTask.class.getName());
private static OLog log = Tracing.createLoggerFor(SetLastUsageBackgroundTask.class);
private RepositoryEntry repositoryEntry;
......@@ -52,7 +51,7 @@ public class SetLastUsageBackgroundTask extends AbstractBackgroundTask {
reloadedRe.setLastUsage(new Date());
LifeCycleManager lcManager = LifeCycleManager.createInstanceFor(reloadedRe);
if (lcManager.lookupLifeCycleEntry(RepositoryDeletionManager.SEND_DELETE_EMAIL_ACTION) != null) {
Tracing.logAudit("Repository-Deletion: Remove from delete-list repositoryEntry=" + reloadedRe, RepositoryManager.class);
log.audit("Repository-Deletion: Remove from delete-list repositoryEntry=" + reloadedRe);
lcManager.deleteTimestampFor(RepositoryDeletionManager.SEND_DELETE_EMAIL_ACTION);
}
RepositoryManager.getInstance().updateRepositoryEntry(reloadedRe);
......
......@@ -20,9 +20,9 @@
*/
package org.olat.repository.async;
import org.apache.log4j.Logger;
import org.olat.core.commons.persistence.DBFactory;
import org.olat.core.commons.persistence.async.AbstractBackgroundTask;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
import org.olat.repository.RepositoryEntry;
import org.olat.repository.RepositoryManager;
......@@ -31,7 +31,7 @@ import org.olat.repository.RepositoryManager;
* @author Christian Guretzki
*/
public class SetPropertiesBackgroundTask extends AbstractBackgroundTask {
private static Logger log = Logger.getLogger(SetPropertiesBackgroundTask.class.getName());
private static OLog log = Tracing.createLoggerFor(SetPropertiesBackgroundTask.class);
private RepositoryEntry repositoryEntry;
......
......@@ -18,12 +18,13 @@
* University of Zurich, Switzerland.
* <p>
*/
package org.olat.core.commons.persistence.async;
package org.olat.repository.async;
import java.util.Queue;
import org.apache.log4j.Logger;
import org.olat.core.commons.persistence.DBFactory;
import org.olat.core.logging.OLog;
import org.olat.core.logging.Tracing;
/**
* this is a special task executor system used only for learning resources. If you look for a general task Executor for scheduled tasks
......@@ -32,7 +33,7 @@ import org.olat.core.commons.persistence.DBFactory;
* @author Christian Guretzki
*/
public class TaskExecutorThread extends Thread {
private static Logger log = Logger.getLogger(TaskExecutorThread.class.getName());
private static OLog log = Tracing.createLoggerFor(TaskExecutorThread.class);
Queue<BackgroundTask> taskQueue;
public TaskExecutorThread(Queue<BackgroundTask> taskQueue) {
......@@ -58,7 +59,7 @@ public class TaskExecutorThread extends Thread {
if (taskQueue.size() > 0) {
// Queue is not empty
long startTime = 0;
if (log.isDebugEnabled()) {
if (log.isDebug()) {
startTime = System.currentTimeMillis();
}
if (taskQueue.size() > 10) {
......@@ -76,7 +77,7 @@ public class TaskExecutorThread extends Thread {
}
// running in a seperate thread, we must close db-session after each run.
DBFactory.getInstance().commitAndCloseSession();
if (log.isDebugEnabled()) {
if (log.isDebug()) {
long endTime = System.currentTimeMillis();
log.debug("TaskExecutorThread executed in " + (endTime - startTime) + "ms, executeCount=" + executeCount );
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment