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;
/**
* Manages the creation and execution of ingest jobs, i.e., processing of data
* sources by ingest modules.
* Manages the creation and execution of ingest jobs, i.e., the processing of
* data sources by ingest modules.
*/
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() {
if (instance == null) {
@ -157,8 +158,8 @@ public class IngestManager {
}
/**
* Starts an ingest job, i.e., processing by ingest modules, for a
* collection of data sources.
* Starts an ingest job, i.e., processing by ingest modules, for each data
* source in a collection of data sources.
*
* @param dataSources The data sources to be processed.
* @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.
*/
@ -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.
* @deprecated Use removeIngestJobEventListener() and/or
@ -263,10 +264,11 @@ public class IngestManager {
}
/**
* Starts the ingest monitor and submits task execution tasks (Callable
* objects) to the data source ingest and file ingest thread pools. The task
* execution tasks are simple consumers that will normally run as long as
* the application runs
* Constructs a manager of the creation and execution of ingest jobs, i.e.,
* the processing of data sources by ingest modules. The manager immediately
* submits ingest task executers (Callable objects) to the data source level
* 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() {
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.
*/
private void startDataSourceIngestThread() {
@ -302,8 +304,8 @@ public class IngestManager {
}
/**
* Submits a ExecuteIngestTasksTask Callable to the data source ingest
* thread pool.
* Submits a ingest task executer Callable to the file level ingest thread
* pool.
*/
private void startFileIngestThread() {
long threadId = nextThreadId.incrementAndGet();
@ -551,6 +553,11 @@ public class IngestManager {
@Override
public Void call() {
try {
/**
* Bail out if there is nothing to do or cancellation has been
* requested.
*/
if (this.dataSources.isEmpty() || Thread.currentThread().isInterrupted()) {
return null;
}
@ -575,21 +582,31 @@ public class IngestManager {
});
progress.start(dataSources.size());
try {
/**
* Try to start the ingest jobs.
*/
int workUnitsCompleted = 0;
for (Content dataSource : this.dataSources) {
try {
/**
* Cancellation check.
*/
if (Thread.currentThread().isInterrupted()) {
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(),
"IngestManager.StartIngestJobsTask.run.progressingDisplayName",
dataSource.getName());
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);
if (!errors.isEmpty() && this.doStartupErrorsMsgBox) {
@ -618,25 +635,16 @@ public class IngestManager {
}
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;
} finally {
if (null != progress) {
progress.finish();
}
ingestJobStarters.remove(threadId);
}
}
}