52 lines
1.4 KiB
Java
52 lines
1.4 KiB
Java
package org.gcube.data.publishing.gCatFeeder.service.engine.impl;
|
|
|
|
import java.util.concurrent.ThreadPoolExecutor;
|
|
|
|
import javax.inject.Singleton;
|
|
|
|
import org.gcube.data.publishing.gCatFeeder.service.engine.ExecutionManager;
|
|
import org.gcube.data.publishing.gCatFeeder.service.model.ExecutionDescriptor;
|
|
import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
@Singleton
|
|
public class ExecutionManagerImpl implements ExecutionManager {
|
|
|
|
private ThreadPoolExecutor executor=null;
|
|
private static final Logger log= LoggerFactory.getLogger(ExecutionManagerImpl.class);
|
|
|
|
|
|
@Override
|
|
public synchronized void submit(ExecutionDescriptor desc) {
|
|
log.debug("Checking if {} is already in queue");
|
|
ExecutionTask toSubmit=new ExecutionTask(desc);
|
|
if(!executor.getQueue().contains(toSubmit)) {
|
|
log.trace("Inserting execution in queue {} ");
|
|
executor.execute(toSubmit);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
public void stop() {
|
|
// Clear queue
|
|
// Stop all
|
|
}
|
|
|
|
@Override
|
|
public void load() {
|
|
// connect to persistence
|
|
// load all pending
|
|
throw new RuntimeException("NOT YET IMPLEMENTED");
|
|
}
|
|
|
|
@Override
|
|
public synchronized void init(ExecutionManagerConfiguration config) {
|
|
// NEED TO BE IDEMPOTENT
|
|
if(executor==null) {
|
|
throw new RuntimeException("NOT YET IMPLEMENTED");
|
|
// executor=new ThreadPoolExecutor(corePoolSize, maximumPoolSize, keepAliveTime, unit, new ConcurrentLinkedQueue<ExecutionTask>());
|
|
}
|
|
}
|
|
|
|
}
|