Improve restoration batching of data sources to ingest jobs start API

This commit is contained in:
Richard Cordovano 2014-12-08 23:58:10 -05:00
parent af9b535323
commit 41bfa204a2

View File

@ -47,8 +47,8 @@ import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.Content; import org.sleuthkit.datamodel.Content;
/** /**
* Manages the creation and execution of ingest jobs, i.e., processing of data * Manages the creation and execution of ingest jobs, i.e., the processing of
* sources by ingest modules. * data sources by ingest modules.
*/ */
public class IngestManager { public class IngestManager {
@ -130,9 +130,10 @@ public class IngestManager {
}; };
/** /**
* Gets the ingest manager. * Gets the manager of the creation and execution of ingest jobs, i.e., the
* processing of data sources by ingest modules.
* *
* @return A singleton IngestManager object. * @return A singleton ingest manager object.
*/ */
public synchronized static IngestManager getInstance() { public synchronized static IngestManager getInstance() {
if (instance == null) { if (instance == null) {
@ -157,8 +158,8 @@ public class IngestManager {
} }
/** /**
* Starts an ingest job, i.e., processing by ingest modules, for a * Starts an ingest job, i.e., processing by ingest modules, for each data
* collection of data sources. * source in a collection of data sources.
* *
* @param dataSources The data sources to be processed. * @param dataSources The data sources to be processed.
* @param settings The ingest job settings. * @param settings The ingest job settings.
@ -179,7 +180,7 @@ public class IngestManager {
} }
/** /**
* Queries whether any ingest jobs are in progress. * Queries whether or not any ingest jobs are in progress.
* *
* @return True or false. * @return True or false.
*/ */
@ -250,7 +251,7 @@ public class IngestManager {
} }
/** /**
* Remove an ingest job and ingest module event property change listener. * Removes an ingest job and ingest module event property change listener.
* *
* @param listener The PropertyChangeListener to unregister. * @param listener The PropertyChangeListener to unregister.
* @deprecated Use removeIngestJobEventListener() and/or * @deprecated Use removeIngestJobEventListener() and/or
@ -263,10 +264,11 @@ public class IngestManager {
} }
/** /**
* Starts the ingest monitor and submits task execution tasks (Callable * Constructs a manager of the creation and execution of ingest jobs, i.e.,
* objects) to the data source ingest and file ingest thread pools. The task * the processing of data sources by ingest modules. The manager immediately
* execution tasks are simple consumers that will normally run as long as * submits ingest task executers (Callable objects) to the data source level
* the application runs * ingest and file level ingest thread pools. The ingest task executers are
* simple consumers that will normally run as long as the application runs.
*/ */
private IngestManager() { private IngestManager() {
startDataSourceIngestThread(); startDataSourceIngestThread();
@ -292,7 +294,7 @@ public class IngestManager {
} }
/** /**
* Submits a ExecuteIngestTasksTask Callable to the data source ingest task * Submits an ingest task executer Callable to the data source level ingest
* thread pool. * thread pool.
*/ */
private void startDataSourceIngestThread() { private void startDataSourceIngestThread() {
@ -302,8 +304,8 @@ public class IngestManager {
} }
/** /**
* Submits a ExecuteIngestTasksTask Callable to the data source ingest * Submits a ingest task executer Callable to the file level ingest thread
* thread pool. * pool.
*/ */
private void startFileIngestThread() { private void startFileIngestThread() {
long threadId = nextThreadId.incrementAndGet(); long threadId = nextThreadId.incrementAndGet();
@ -551,6 +553,11 @@ public class IngestManager {
@Override @Override
public Void call() { public Void call() {
try {
/**
* Bail out if there is nothing to do or cancellation has been
* requested.
*/
if (this.dataSources.isEmpty() || Thread.currentThread().isInterrupted()) { if (this.dataSources.isEmpty() || Thread.currentThread().isInterrupted()) {
return null; return null;
} }
@ -575,21 +582,31 @@ public class IngestManager {
}); });
progress.start(dataSources.size()); progress.start(dataSources.size());
try { /**
* Try to start the ingest jobs.
*/
int workUnitsCompleted = 0; int workUnitsCompleted = 0;
for (Content dataSource : this.dataSources) { for (Content dataSource : this.dataSources) {
try {
/**
* Cancellation check.
*/
if (Thread.currentThread().isInterrupted()) { if (Thread.currentThread().isInterrupted()) {
return null; return null;
} }
/**
* Add a "subtitle" to the display name of the progress bar
* to indicate an ingest job is being started for this data
* source.
*/
String progressMessage = NbBundle.getMessage(this.getClass(), String progressMessage = NbBundle.getMessage(this.getClass(),
"IngestManager.StartIngestJobsTask.run.progressingDisplayName", "IngestManager.StartIngestJobsTask.run.progressingDisplayName",
dataSource.getName()); dataSource.getName());
progress.progress(progressMessage); progress.progress(progressMessage);
/** /**
* Start an ingest job for the data source. * Start an ingest job for this data source.
*/ */
List<IngestModuleError> errors = IngestJob.startJob(dataSource, this.settings); List<IngestModuleError> errors = IngestJob.startJob(dataSource, this.settings);
if (!errors.isEmpty() && this.doStartupErrorsMsgBox) { if (!errors.isEmpty() && this.doStartupErrorsMsgBox) {
@ -618,25 +635,16 @@ public class IngestManager {
} }
progress.progress(progressMessage, ++workUnitsCompleted); progress.progress(progressMessage, ++workUnitsCompleted);
} catch (Throwable ex) {
/**
* This is an exceptions firewall.
*/
logger.log(Level.SEVERE, "Failed to create ingest job for " + dataSource.getName(), ex); //NON-NLS
if (this.doStartupErrorsMsgBox) {
JOptionPane.showMessageDialog(null, ex.getLocalizedMessage(),
NbBundle.getMessage(this.getClass(),
"IngestManager.StartIngestJobsTask.run.startupErr.dlgTitle"), JOptionPane.ERROR_MESSAGE);
}
}
}
} finally {
progress.finish();
ingestJobStarters.remove(threadId);
} }
return null; return null;
} finally {
if (null != progress) {
progress.finish();
}
ingestJobStarters.remove(threadId);
}
} }
} }