Gitlab Community Edition Instance

Commit 3ac0b15d authored by mhellka's avatar mhellka
Browse files

Run cron jobs in parallel, if required.

parent 3c29fc27
......@@ -3,12 +3,12 @@ package de.gwdg.cdstar.runtime.services;
import java.io.Closeable;
import java.io.IOException;
import java.util.concurrent.Callable;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.ThreadFactory;
import java.util.concurrent.ScheduledThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import de.gwdg.cdstar.NamedThreadFactory;
import de.gwdg.cdstar.Utils;
import de.gwdg.cdstar.runtime.RuntimeContext;
import de.gwdg.cdstar.runtime.listener.RuntimeListener;
......@@ -33,12 +33,7 @@ public class CronFeature implements RuntimeListener {
private ScheduledExecutorService pool;
public CronServiceImpl() {
pool = Executors.newScheduledThreadPool(1, new ThreadFactory() {
@Override
public Thread newThread(Runnable r) {
return new Thread(r, "cron");
}
});
pool = new ScheduledThreadPoolExecutor(4, new NamedThreadFactory("cron"));
}
@Override
......
package de.gwdg.cdstar.runtime.services;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
/**
* Same as {@link ScheduledExecutorService}, but without any methods inherited
* from {@link ExecutorService}
*/
public interface CronService {
ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit);
/**
* Execute a one-shot {@link Runnable} after the given delay.
*/
public ScheduledFuture<?> schedule(Runnable command, long delay, TimeUnit unit);
<V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit);
/**
* Execute a one-shot {@link Callable} after the given delay and return its
* value.
*/
public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit);
ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit);
/**
* Execute a {@link Runnable} repeatedly at a fixed rate. If the execution of a
* task takes longer than the period, it will delay (or suppress) subsequent
* executions to prevent overlapping tasks. Any exception will end the schedule
* for this task.
*/
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit);
ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay,
TimeUnit unit);
/**
* Execute a {@link Runnable} repeatedly with a fixed delay between executions.
* Any exception will end the schedule for this task.
*/
public ScheduledFuture<?> scheduleWithFixedDelay(Runnable command, long initialDelay, long delay, TimeUnit unit);
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment