Add early out for cancelled jobs to process() for ingest module pipelines

This commit is contained in:
Richard Cordovano 2015-07-28 10:09:21 -04:00
parent 682d142263
commit b0e488c692
2 changed files with 56 additions and 49 deletions

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2014 Basis Technology Corp. * Copyright 2014-2015 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -96,31 +96,34 @@ final class DataSourceIngestPipeline {
*/ */
synchronized List<IngestModuleError> process(DataSourceIngestTask task) { synchronized List<IngestModuleError> process(DataSourceIngestTask task) {
List<IngestModuleError> errors = new ArrayList<>(); List<IngestModuleError> errors = new ArrayList<>();
Content dataSource = task.getDataSource(); if (!this.job.isCancelled()) {
for (PipelineModule module : modules) { Content dataSource = task.getDataSource();
try { for (PipelineModule module : modules) {
this.currentModule = module; try {
String displayName = NbBundle.getMessage(this.getClass(), this.currentModule = module;
"IngestJob.progress.dataSourceIngest.displayName", String displayName = NbBundle.getMessage(this.getClass(),
module.getDisplayName(), dataSource.getName()); "IngestJob.progress.dataSourceIngest.displayName",
this.job.updateDataSourceIngestProgressBarDisplayName(displayName); module.getDisplayName(), dataSource.getName());
this.job.switchDataSourceIngestProgressBarToIndeterminate(); this.job.updateDataSourceIngestProgressBarDisplayName(displayName);
DataSourceIngestPipeline.ingestManager.setIngestTaskProgress(task, module.getDisplayName()); this.job.switchDataSourceIngestProgressBarToIndeterminate();
logger.log(Level.INFO, "{0} analysis of {1} (jobId={2}) starting", new Object[]{module.getDisplayName(), this.job.getDataSource().getName(), this.job.getDataSource().getId()}); DataSourceIngestPipeline.ingestManager.setIngestTaskProgress(task, module.getDisplayName());
module.process(dataSource, new DataSourceIngestModuleProgress(this.job)); logger.log(Level.INFO, "{0} analysis of {1} (jobId={2}) starting", new Object[]{module.getDisplayName(), this.job.getDataSource().getName(), this.job.getDataSource().getId()});
logger.log(Level.INFO, "{0} analysis of {1} (jobId={2}) finished", new Object[]{module.getDisplayName(), this.job.getDataSource().getName(), this.job.getDataSource().getId()}); module.process(dataSource, new DataSourceIngestModuleProgress(this.job));
} catch (Throwable ex) { // Catch-all exception firewall logger.log(Level.INFO, "{0} analysis of {1} (jobId={2}) finished", new Object[]{module.getDisplayName(), this.job.getDataSource().getName(), this.job.getDataSource().getId()});
errors.add(new IngestModuleError(module.getDisplayName(), ex)); } catch (Throwable ex) { // Catch-all exception firewall
String msg = ex.getMessage(); errors.add(new IngestModuleError(module.getDisplayName(), ex));
// Jython run-time errors don't seem to have a message, but have details in toString. String msg = ex.getMessage();
if (msg == null) // Jython run-time errors don't seem to have a message, but have details in toString.
msg = ex.toString(); if (msg == null) {
MessageNotifyUtil.Notify.error(module.getDisplayName() + " Error", msg); msg = ex.toString();
} }
if (this.job.isCancelled()) { MessageNotifyUtil.Notify.error(module.getDisplayName() + " Error", msg);
break; }
} else if (this.job.currentDataSourceIngestModuleIsCancelled()) { if (this.job.isCancelled()) {
this.job.currentDataSourceIngestModuleCancellationCompleted(currentModule.getDisplayName()); break;
} else if (this.job.currentDataSourceIngestModuleIsCancelled()) {
this.job.currentDataSourceIngestModuleCancellationCompleted(currentModule.getDisplayName());
}
} }
} }
this.currentModule = null; this.currentModule = null;

View File

@ -1,7 +1,7 @@
/* /*
* Autopsy Forensic Browser * Autopsy Forensic Browser
* *
* Copyright 2014 Basis Technology Corp. * Copyright 2014-2015 Basis Technology Corp.
* Contact: carrier <at> sleuthkit <dot> org * Contact: carrier <at> sleuthkit <dot> org
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
@ -113,26 +113,29 @@ final class FileIngestPipeline {
*/ */
synchronized List<IngestModuleError> process(FileIngestTask task) { synchronized List<IngestModuleError> process(FileIngestTask task) {
List<IngestModuleError> errors = new ArrayList<>(); List<IngestModuleError> errors = new ArrayList<>();
AbstractFile file = task.getFile();
for (PipelineModule module : this.modules) {
try {
FileIngestPipeline.ingestManager.setIngestTaskProgress(task, module.getDisplayName());
module.process(file);
} catch (Throwable ex) { // Catch-all exception firewall
errors.add(new IngestModuleError(module.getDisplayName(), ex));
String msg = ex.getMessage();
// Jython run-time errors don't seem to have a message, but have details in toString.
if (msg == null)
msg = ex.toString();
MessageNotifyUtil.Notify.error(module.getDisplayName() + " Error", msg);
}
if (this.job.isCancelled()) {
break;
}
}
file.close();
if (!this.job.isCancelled()) { if (!this.job.isCancelled()) {
IngestManager.getInstance().fireFileIngestDone(file); AbstractFile file = task.getFile();
for (PipelineModule module : this.modules) {
try {
FileIngestPipeline.ingestManager.setIngestTaskProgress(task, module.getDisplayName());
module.process(file);
} catch (Throwable ex) { // Catch-all exception firewall
errors.add(new IngestModuleError(module.getDisplayName(), ex));
String msg = ex.getMessage();
// Jython run-time errors don't seem to have a message, but have details in toString.
if (msg == null) {
msg = ex.toString();
}
MessageNotifyUtil.Notify.error(module.getDisplayName() + " Error", msg);
}
if (this.job.isCancelled()) {
break;
}
}
file.close();
if (!this.job.isCancelled()) {
IngestManager.getInstance().fireFileIngestDone(file);
}
} }
FileIngestPipeline.ingestManager.setIngestTaskProgressCompleted(task); FileIngestPipeline.ingestManager.setIngestTaskProgressCompleted(task);
return errors; return errors;
@ -145,7 +148,7 @@ final class FileIngestPipeline {
*/ */
synchronized List<IngestModuleError> shutDown() { synchronized List<IngestModuleError> shutDown() {
List<IngestModuleError> errors = new ArrayList<>(); List<IngestModuleError> errors = new ArrayList<>();
if(this.running == true){ // Don't shut down pipelines that never started if (this.running == true) { // Don't shut down pipelines that never started
for (PipelineModule module : this.modules) { for (PipelineModule module : this.modules) {
try { try {
module.shutDown(); module.shutDown();
@ -153,8 +156,9 @@ final class FileIngestPipeline {
errors.add(new IngestModuleError(module.getDisplayName(), ex)); errors.add(new IngestModuleError(module.getDisplayName(), ex));
String msg = ex.getMessage(); String msg = ex.getMessage();
// Jython run-time errors don't seem to have a message, but have details in toString. // Jython run-time errors don't seem to have a message, but have details in toString.
if (msg == null) if (msg == null) {
msg = ex.toString(); msg = ex.toString();
}
MessageNotifyUtil.Notify.error(module.getDisplayName() + " Error", msg); MessageNotifyUtil.Notify.error(module.getDisplayName() + " Error", msg);
} }
} }