Merge pull request #1024 from rcordovano/develop

Add cancellation data to data source ingest job snapshots
This commit is contained in:
Richard Cordovano
2015-02-02 18:47:18 -05:00
2 changed files with 30 additions and 4 deletions
@@ -19,10 +19,12 @@
package org.sleuthkit.autopsy.ingest;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.atomic.AtomicLong;
import java.util.logging.Level;
@@ -116,7 +118,8 @@ final class DataSourceIngestJob {
*/
private volatile boolean currentDataSourceIngestModuleCancelled;
private volatile boolean cancelled;
private final List<String> cancelledDataSourceIngestModules = new CopyOnWriteArrayList<>();
/**
* A data source ingest job uses the task scheduler singleton to create and
* queue the ingest tasks that make up the job.
@@ -841,10 +844,13 @@ final class DataSourceIngestJob {
/**
* Rescind a temporary cancellation of data source level ingest that was
* used to stop a single data source level ingest module fro this job.
* used to stop a single data source level ingest module for this job.
*
* @param moduleDisplayName The display name of the module that was stopped.
*/
void currentDataSourceIngestModuleCancellationCompleted() {
void currentDataSourceIngestModuleCancellationCompleted(String moduleDisplayName) {
this.currentDataSourceIngestModuleCancelled = false;
this.cancelledDataSourceIngestModules.add(moduleDisplayName);
if (this.runInteractively) {
/**
@@ -976,6 +982,8 @@ final class DataSourceIngestJob {
private final long processedFiles;
private final long estimatedFilesToProcess;
private final IngestTasksScheduler.IngestJobTasksSnapshot tasksSnapshot;
private final boolean jobCancelled;
private final List<String> cancelledDataSourceModules;
/**
* Constructs an object to store basic diagnostic statistics for a data
@@ -1015,6 +1023,9 @@ final class DataSourceIngestJob {
* Get a snapshot of the tasks currently in progress for this job.
*/
this.tasksSnapshot = DataSourceIngestJob.taskScheduler.getTasksSnapshotForJob(this.jobId);
this.jobCancelled = cancelled;
this.cancelledDataSourceModules = new ArrayList<>(DataSourceIngestJob.this.cancelledDataSourceIngestModules);
}
/**
@@ -1118,6 +1129,21 @@ final class DataSourceIngestJob {
return this.tasksSnapshot.getRunningListSize();
}
boolean getCancelled() {
return this.jobCancelled;
}
/**
* Gets a list of the display names of any canceled data source level ingest
* modules
*
* @return A list of canceled data source level ingest module display names,
* possibly empty.
*/
List<String> getCancelledDataSourceIngestModules() {
return Collections.unmodifiableList(this.cancelledDataSourceModules);
}
}
}
@@ -109,7 +109,7 @@ final class DataSourceIngestPipeline {
if (this.job.isCancelled()) {
break;
} else if (this.job.currentDataSourceIngestModuleIsCancelled()) {
this.job.currentDataSourceIngestModuleCancellationCompleted();
this.job.currentDataSourceIngestModuleCancellationCompleted(currentModule.getDisplayName());
}
}
this.currentModule = null;