Skip to content
Snippets Groups Projects
Commit 11b5b676 authored by srosse's avatar srosse
Browse files

OO-29: stop the backgroundthreadmanager

parent 8d17956d
No related branches found
No related tags found
No related merge requests found
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:property-placeholder location="classpath:serviceconfig/olat.properties, classpath:olat.local.properties" />
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<bean id="repositoryModule" class="org.olat.repository.RepositoryModule" depends-on="userModule">
......@@ -32,7 +27,7 @@
</bean>
<!-- BackgroundTaskQueueManager for increment launch-,download-counter and set LastUsage in background thread -->
<bean id="org.olat.core.commons.persistence.async.BackgroundTaskQueueManager" class="org.olat.repository.async.BackgroundTaskQueueManager">
<bean id="org.olat.core.commons.persistence.async.BackgroundTaskQueueManager" class="org.olat.repository.async.BackgroundTaskQueueManager" destroy-method="destroy">
<!-- Number of retries when a task failed e.g. incrementLaunchCounter try 20 times to increment when a exception occurs -->
<property name="maxRetry" value="20"/>
</bean>
......
......@@ -57,6 +57,18 @@ public class BackgroundTaskQueueManager extends BasicManager {
taskExecutor.start();
}
/**
* [used by spring]
*/
public void destroy() {
taskExecutor.stopExecutor();
addTask(new BackgroundTask() {
@Override
public void execute() { /* */ }
@Override
public void setMaxRetry(int maxRetry) { /* */ }
});
}
public Queue<BackgroundTask> getQueue() {
return backgroundTaskQueue;
......
......@@ -38,16 +38,20 @@ import org.olat.core.logging.Tracing;
*/
public class TaskExecutorThread extends Thread {
private static OLog log = Tracing.createLoggerFor(TaskExecutorThread.class);
Queue<BackgroundTask> taskQueue;
private Queue<BackgroundTask> taskQueue;
private volatile boolean running = true;
public TaskExecutorThread(Queue<BackgroundTask> taskQueue) {
super("TaskExecutorThread");
this.taskQueue = taskQueue;
}
public void stopExecutor() {
running = false;
}
public void run() {
log.info("TaskExecutorThread started");
boolean running = true;
while(running) {
synchronized(taskQueue) {
if (taskQueue.size() == 0) {
......
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