add job service to be able to cancel plot requests
This commit is contained in:
@@ -13,6 +13,7 @@ import java.util.Collection;
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
|
||||
import org.lucares.pdb.api.AbortException;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
@@ -37,6 +38,8 @@ public class Gnuplot {
|
||||
public void plot(final GnuplotSettings settings, final Collection<DataSeries> dataSeries)
|
||||
throws IOException, InterruptedException {
|
||||
|
||||
AbortException.abortIfInterrupted();
|
||||
|
||||
final GnuplotFileGenerator generator = new GnuplotFileGenerator();
|
||||
|
||||
final String gnuplotFileContent = generator.generate(settings, dataSeries);
|
||||
|
||||
@@ -17,6 +17,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.lucares.collections.LongList;
|
||||
import org.lucares.pdb.api.AbortException;
|
||||
import org.lucares.pdb.api.DateTimeRange;
|
||||
import org.lucares.pdb.api.GroupResult;
|
||||
import org.lucares.pdb.api.Query;
|
||||
@@ -145,7 +146,7 @@ public class Plotter {
|
||||
return new PlotResult(outputFile, dataSeries, thumbnail);
|
||||
} catch (final InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
throw new IllegalStateException("Plotting was interrupted.");
|
||||
throw new AbortException();
|
||||
} catch (final IOException e) {
|
||||
throw new InternalPlottingException("Plotting failed: " + e.getMessage(), e);
|
||||
} finally {
|
||||
@@ -176,6 +177,8 @@ public class Plotter {
|
||||
|
||||
final Iterator<LongList> it = timeValueStream.iterator();
|
||||
while (it.hasNext()) {
|
||||
AbortException.abortIfInterrupted();
|
||||
|
||||
final LongList entry = it.next();
|
||||
|
||||
for (int i = 0; i < entry.size(); i += 2) {
|
||||
|
||||
Reference in New Issue
Block a user