Renamed classes to better represent what they are doing
This commit is contained in:
@@ -37,9 +37,9 @@ import ch.psi.jcae.ChannelService;
|
||||
/**
|
||||
* Main engine for data acquisition.
|
||||
*/
|
||||
public class AcquisitionEngine {
|
||||
public class ExecutionEngine {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(AcquisitionEngine.class.getName());
|
||||
private static final Logger logger = Logger.getLogger(ExecutionEngine.class.getName());
|
||||
|
||||
private final ChannelService cService;
|
||||
private final ZMQDataService zmqService;
|
||||
@@ -48,7 +48,7 @@ public class AcquisitionEngine {
|
||||
private final Map<String, Future<?>> erequests = new HashMap<>();
|
||||
|
||||
@Inject
|
||||
public AcquisitionEngine(ChannelService cService, ZMQDataService zmqService) {
|
||||
public ExecutionEngine(ChannelService cService, ZMQDataService zmqService) {
|
||||
this.zmqService = zmqService;
|
||||
this.cService = cService;
|
||||
}
|
||||
@@ -63,11 +63,11 @@ public class AcquisitionEngine {
|
||||
public void submit(String trackingId, EDescriptor edescriptor){
|
||||
|
||||
logger.info("Submitting new scan with trackingId " + trackingId);
|
||||
if(erequests.keySet().contains(trackingId) && !erequests.get(trackingId).isDone()){ // Allow finished tracking ids to be reused for new scans
|
||||
if(erequests.keySet().contains(trackingId) && !erequests.get(trackingId).isDone()){ // Allow finished tracking ids to be reused for new tasks
|
||||
throw new IllegalArgumentException("A request with tracking ID "+trackingId+" is already submitted");
|
||||
}
|
||||
|
||||
AcquisitionJob job = new AcquisitionJob(cService, zmqService, trackingId, edescriptor);
|
||||
ExecutionJob job = new ExecutionJob(cService, zmqService, trackingId, edescriptor);
|
||||
Future<?> future = eservice.submit(job);
|
||||
erequests.put(trackingId, future);
|
||||
}
|
||||
@@ -91,17 +91,19 @@ public class AcquisitionEngine {
|
||||
|
||||
/**
|
||||
* Terminate the request which is identified by its tracking id. If the request
|
||||
* is still in the execution queue it gets removed there.
|
||||
* is still in the execution queue it gets removed there.
|
||||
*
|
||||
* @param trackingId
|
||||
*/
|
||||
public void terminate(String trackingId){
|
||||
logger.info("Terminate scan with trackingId "+trackingId);
|
||||
logger.info("Terminate TrackingId: "+trackingId);
|
||||
|
||||
final Future<?> f = erequests.get(trackingId);
|
||||
if(f==null){
|
||||
throw new IllegalArgumentException("There is no request running/pending with tracking id "+trackingId);
|
||||
}
|
||||
f.cancel(true);
|
||||
|
||||
try{
|
||||
f.get(10, TimeUnit.SECONDS);
|
||||
}
|
||||
@@ -31,9 +31,9 @@ import com.google.common.eventbus.EventBus;
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
public class AcquisitionJob implements Runnable {
|
||||
public class ExecutionJob implements Runnable {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(AcquisitionJob.class.getName());
|
||||
private static final Logger logger = Logger.getLogger(ExecutionJob.class.getName());
|
||||
|
||||
private final ChannelService cService;
|
||||
private final ZMQDataService zmqService;
|
||||
@@ -41,7 +41,7 @@ public class AcquisitionJob implements Runnable {
|
||||
private final String trackingId;
|
||||
private final EDescriptor edescriptor;
|
||||
|
||||
public AcquisitionJob(ChannelService cService, ZMQDataService zmqService, String trackingId, EDescriptor edescriptor) {
|
||||
public ExecutionJob(ChannelService cService, ZMQDataService zmqService, String trackingId, EDescriptor edescriptor) {
|
||||
this.zmqService = zmqService;
|
||||
this.cService = cService;
|
||||
this.trackingId = trackingId;
|
||||
@@ -21,7 +21,7 @@ public class ResourceBinder extends AbstractBinder {
|
||||
bind(channelService).to(ChannelService.class);
|
||||
bind(AcquisitionConfiguration.class).to(AcquisitionConfiguration.class).in(Singleton.class);
|
||||
|
||||
bind(AcquisitionEngine.class).to(AcquisitionEngine.class).in(Singleton.class);
|
||||
bind(ExecutionEngine.class).to(ExecutionEngine.class).in(Singleton.class);
|
||||
|
||||
bind(zmqService).to(ZMQDataService.class);
|
||||
}
|
||||
|
||||
@@ -31,19 +31,18 @@ import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.core.MediaType;
|
||||
|
||||
import ch.psi.fda.edescriptor.EDescriptor;
|
||||
import ch.psi.fda.rest.AcquisitionEngine;
|
||||
import ch.psi.fda.rest.ExecutionEngine;
|
||||
|
||||
@Path("fda")
|
||||
public class FDAService {
|
||||
public class ExecutionService {
|
||||
|
||||
@Inject
|
||||
private AcquisitionEngine aengine;
|
||||
private ExecutionEngine aengine;
|
||||
|
||||
@PUT
|
||||
@Path("{trackingId}")
|
||||
@Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
|
||||
public void execute(@PathParam("trackingId") String trackingId, EDescriptor edescriptor) throws InterruptedException{
|
||||
System.out.println("----- "+ trackingId);
|
||||
aengine.submit(trackingId, edescriptor);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user