mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-15 09:17:42 +00:00
Improve restoration batching of data sources to ingest jobs start API
This commit is contained in:
parent
af9b535323
commit
41bfa204a2
@ -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,94 +553,100 @@ public class IngestManager {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Void call() {
|
public Void call() {
|
||||||
if (this.dataSources.isEmpty() || Thread.currentThread().isInterrupted()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set up a progress bar.
|
|
||||||
*/
|
|
||||||
final String displayName = NbBundle.getMessage(this.getClass(),
|
|
||||||
"IngestManager.StartIngestJobsTask.run.displayName");
|
|
||||||
progress = ProgressHandleFactory.createHandle(displayName, new Cancellable() {
|
|
||||||
@Override
|
|
||||||
public boolean cancel() {
|
|
||||||
if (progress != null) {
|
|
||||||
progress.setDisplayName(NbBundle.getMessage(this.getClass(),
|
|
||||||
"IngestManager.StartIngestJobsTask.run.cancelling",
|
|
||||||
displayName));
|
|
||||||
}
|
|
||||||
Future<?> handle = ingestJobStarters.remove(threadId);
|
|
||||||
handle.cancel(true);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
progress.start(dataSources.size());
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
/**
|
||||||
|
* Bail out if there is nothing to do or cancellation has been
|
||||||
|
* requested.
|
||||||
|
*/
|
||||||
|
if (this.dataSources.isEmpty() || Thread.currentThread().isInterrupted()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Set up a progress bar.
|
||||||
|
*/
|
||||||
|
final String displayName = NbBundle.getMessage(this.getClass(),
|
||||||
|
"IngestManager.StartIngestJobsTask.run.displayName");
|
||||||
|
progress = ProgressHandleFactory.createHandle(displayName, new Cancellable() {
|
||||||
|
@Override
|
||||||
|
public boolean cancel() {
|
||||||
|
if (progress != null) {
|
||||||
|
progress.setDisplayName(NbBundle.getMessage(this.getClass(),
|
||||||
|
"IngestManager.StartIngestJobsTask.run.cancelling",
|
||||||
|
displayName));
|
||||||
|
}
|
||||||
|
Future<?> handle = ingestJobStarters.remove(threadId);
|
||||||
|
handle.cancel(true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
progress.start(dataSources.size());
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Try to start the ingest jobs.
|
||||||
|
*/
|
||||||
int workUnitsCompleted = 0;
|
int workUnitsCompleted = 0;
|
||||||
for (Content dataSource : this.dataSources) {
|
for (Content dataSource : this.dataSources) {
|
||||||
try {
|
|
||||||
if (Thread.currentThread().isInterrupted()) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
String progressMessage = NbBundle.getMessage(this.getClass(),
|
/**
|
||||||
"IngestManager.StartIngestJobsTask.run.progressingDisplayName",
|
* Cancellation check.
|
||||||
dataSource.getName());
|
*/
|
||||||
progress.progress(progressMessage);
|
if (Thread.currentThread().isInterrupted()) {
|
||||||
|
return null;
|
||||||
/**
|
|
||||||
* Start an ingest job for the data source.
|
|
||||||
*/
|
|
||||||
List<IngestModuleError> errors = IngestJob.startJob(dataSource, this.settings);
|
|
||||||
if (!errors.isEmpty() && this.doStartupErrorsMsgBox) {
|
|
||||||
StringBuilder moduleStartUpErrors = new StringBuilder();
|
|
||||||
for (IngestModuleError error : errors) {
|
|
||||||
String moduleName = error.getModuleDisplayName();
|
|
||||||
moduleStartUpErrors.append(moduleName);
|
|
||||||
moduleStartUpErrors.append(": ");
|
|
||||||
moduleStartUpErrors.append(error.getModuleError().getLocalizedMessage());
|
|
||||||
moduleStartUpErrors.append("\n");
|
|
||||||
}
|
|
||||||
StringBuilder notifyMessage = new StringBuilder();
|
|
||||||
notifyMessage.append(NbBundle.getMessage(this.getClass(),
|
|
||||||
"IngestManager.StartIngestJobsTask.run.startupErr.dlgMsg"));
|
|
||||||
notifyMessage.append("\n");
|
|
||||||
notifyMessage.append(NbBundle.getMessage(this.getClass(),
|
|
||||||
"IngestManager.StartIngestJobsTask.run.startupErr.dlgSolution"));
|
|
||||||
notifyMessage.append("\n");
|
|
||||||
notifyMessage.append(NbBundle.getMessage(this.getClass(),
|
|
||||||
"IngestManager.StartIngestJobsTask.run.startupErr.dlgErrorList",
|
|
||||||
moduleStartUpErrors.toString()));
|
|
||||||
notifyMessage.append("\n\n");
|
|
||||||
JOptionPane.showMessageDialog(null, notifyMessage.toString(),
|
|
||||||
NbBundle.getMessage(this.getClass(),
|
|
||||||
"IngestManager.StartIngestJobsTask.run.startupErr.dlgTitle"), JOptionPane.ERROR_MESSAGE);
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 this data source.
|
||||||
|
*/
|
||||||
|
List<IngestModuleError> errors = IngestJob.startJob(dataSource, this.settings);
|
||||||
|
if (!errors.isEmpty() && this.doStartupErrorsMsgBox) {
|
||||||
|
StringBuilder moduleStartUpErrors = new StringBuilder();
|
||||||
|
for (IngestModuleError error : errors) {
|
||||||
|
String moduleName = error.getModuleDisplayName();
|
||||||
|
moduleStartUpErrors.append(moduleName);
|
||||||
|
moduleStartUpErrors.append(": ");
|
||||||
|
moduleStartUpErrors.append(error.getModuleError().getLocalizedMessage());
|
||||||
|
moduleStartUpErrors.append("\n");
|
||||||
|
}
|
||||||
|
StringBuilder notifyMessage = new StringBuilder();
|
||||||
|
notifyMessage.append(NbBundle.getMessage(this.getClass(),
|
||||||
|
"IngestManager.StartIngestJobsTask.run.startupErr.dlgMsg"));
|
||||||
|
notifyMessage.append("\n");
|
||||||
|
notifyMessage.append(NbBundle.getMessage(this.getClass(),
|
||||||
|
"IngestManager.StartIngestJobsTask.run.startupErr.dlgSolution"));
|
||||||
|
notifyMessage.append("\n");
|
||||||
|
notifyMessage.append(NbBundle.getMessage(this.getClass(),
|
||||||
|
"IngestManager.StartIngestJobsTask.run.startupErr.dlgErrorList",
|
||||||
|
moduleStartUpErrors.toString()));
|
||||||
|
notifyMessage.append("\n\n");
|
||||||
|
JOptionPane.showMessageDialog(null, notifyMessage.toString(),
|
||||||
|
NbBundle.getMessage(this.getClass(),
|
||||||
|
"IngestManager.StartIngestJobsTask.run.startupErr.dlgTitle"), JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
|
|
||||||
|
progress.progress(progressMessage, ++workUnitsCompleted);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
} finally {
|
} finally {
|
||||||
progress.finish();
|
if (null != progress) {
|
||||||
|
progress.finish();
|
||||||
|
}
|
||||||
ingestJobStarters.remove(threadId);
|
ingestJobStarters.remove(threadId);
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
x
Reference in New Issue
Block a user