19 package org.sleuthkit.autopsy.ingest;
21 import java.util.ArrayList;
22 import java.util.Collection;
23 import java.util.Collections;
24 import java.util.Date;
25 import java.util.List;
27 import java.util.concurrent.ConcurrentHashMap;
28 import java.util.concurrent.atomic.AtomicInteger;
29 import java.util.concurrent.atomic.AtomicLong;
31 import org.openide.util.NbBundle;
56 this.displayName = displayName;
64 private final static AtomicLong
nextId =
new AtomicLong(0L);
65 private final long id;
81 this.dataSourceJobs =
new ConcurrentHashMap<>();
82 for (Content dataSource : dataSources) {
83 DataSourceIngestJob dataSourceIngestJob =
new DataSourceIngestJob(
this, dataSource, settings, doUI);
84 this.dataSourceJobs.put(dataSourceIngestJob.getId(), dataSourceIngestJob);
86 incompleteJobsCount =
new AtomicInteger(dataSourceJobs.size());
103 this.dataSourceJobs =
new ConcurrentHashMap<>();
104 DataSourceIngestJob dataSourceIngestJob =
new DataSourceIngestJob(
this, dataSource, files, settings, doUI);
105 this.dataSourceJobs.put(dataSourceIngestJob.getId(), dataSourceIngestJob);
106 incompleteJobsCount =
new AtomicInteger(dataSourceJobs.size());
126 boolean hasIngestPipeline() {
133 for (DataSourceIngestJob dataSourceJob : this.dataSourceJobs.values()) {
134 if (dataSourceJob.hasIngestPipeline()) {
147 List<IngestModuleError> start() {
156 List<IngestModuleError> errors =
new ArrayList<>();
157 for (DataSourceIngestJob dataSourceJob : this.dataSourceJobs.values()) {
158 errors.addAll(dataSourceJob.start());
159 if (errors.isEmpty() ==
false) {
167 if (errors.isEmpty()) {
168 for (DataSourceIngestJob dataSourceJob : this.dataSourceJobs.values()) {
169 IngestManager.getInstance().fireDataSourceAnalysisStarted(
id, dataSourceJob.getId(), dataSourceJob.getDataSource());
172 cancel(CancellationReason.INGEST_MODULES_STARTUP_FAILED);
202 List<DataSourceIngestJob.Snapshot> getDataSourceIngestJobSnapshots() {
203 List<DataSourceIngestJob.Snapshot> snapshots =
new ArrayList<>();
204 this.dataSourceJobs.values().stream().forEach((dataSourceJob) -> {
205 snapshots.add(dataSourceJob.getSnapshot(
true));
232 this.cancellationReason = reason;
233 this.dataSourceJobs.values().stream().forEach((job) -> {
263 void dataSourceJobFinished(DataSourceIngestJob job) {
265 if (!job.isCancelled()) {
266 ingestManager.fireDataSourceAnalysisCompleted(
id, job.getId(), job.getDataSource());
268 IngestManager.getInstance().fireDataSourceAnalysisCancelled(
id, job.getId(), job.getDataSource());
270 if (incompleteJobsCount.decrementAndGet() == 0) {
271 ingestManager.finishIngestJob(
this);
293 private final DataSourceIngestJob.Snapshot
snapshot;
325 return snapshot.getCancellationReason();
336 return snapshot.getCancelledDataSourceIngestModules();
345 dataSourceModule = null;
346 fileIngestRunning =
false;
347 fileIngestStartTime = null;
348 dataSourceProcessingSnapshots =
new ArrayList<>();
349 for (DataSourceIngestJob dataSourceJob : dataSourceJobs.values()) {
350 DataSourceIngestJob.Snapshot snapshot = dataSourceJob.getSnapshot(getIngestTasksSnapshot);
352 if (null == dataSourceModule) {
353 DataSourceIngestPipeline.PipelineModule module = snapshot.getDataSourceLevelIngestModule();
354 if (null != module) {
358 if (snapshot.fileIngestIsRunning()) {
359 fileIngestRunning =
true;
361 Date childFileIngestStartTime = snapshot.fileIngestStartTime();
362 if (null != childFileIngestStartTime && (null == fileIngestStartTime || childFileIngestStartTime.before(fileIngestStartTime))) {
363 fileIngestStartTime = childFileIngestStartTime;
396 return new Date(this.fileIngestStartTime.getTime());
424 return Collections.unmodifiableList(this.dataSourceProcessingSnapshots);
436 private final DataSourceIngestJob
job;
437 private final DataSourceIngestPipeline.PipelineModule
module;
452 this.cancelled = job.currentDataSourceIngestModuleIsCancelled();
462 return this.
module.getDisplayName();
472 return this.
module.getProcessingStartTime();
502 if (this.job.getCurrentDataSourceIngestModule() == this.
module) {
503 this.job.cancelCurrentDataSourceIngestModule();
DataSourceIngestModuleHandle(DataSourceIngestJob job, DataSourceIngestPipeline.PipelineModule module)
List< String > getCancelledDataSourceIngestModules()
static synchronized IngestManager getInstance()
CancellationReason(String displayName)
final DataSourceIngestPipeline.PipelineModule module
final boolean jobCancelled
boolean fileIngestIsRunning()
final AtomicInteger incompleteJobsCount
void cancel(CancellationReason reason)
final DataSourceIngestJob.Snapshot snapshot
final Map< Long, DataSourceIngestJob > dataSourceJobs
DataSourceIngestModuleHandle runningDataSourceIngestModule()
List< DataSourceProcessingSnapshot > getDataSourceSnapshots()
final IngestJob.CancellationReason jobCancellationReason
CancellationReason getCancellationReason()
ProgressSnapshot getSnapshot()
INGEST_MODULES_STARTUP_FAILED
final DataSourceIngestJob job
DataSourceProcessingSnapshot(DataSourceIngestJob.Snapshot snapshot)
static final AtomicLong nextId
boolean fileIngestRunning
ProgressSnapshot(boolean getIngestTasksSnapshot)
volatile CancellationReason cancellationReason
ProgressSnapshot getSnapshot(boolean getIngestTasksSnapshot)
CancellationReason getCancellationReason()
Date fileIngestStartTime()
CancellationReason getCancellationReason()
DataSourceIngestModuleHandle dataSourceModule
final List< DataSourceProcessingSnapshot > dataSourceProcessingSnapshots