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;
57 this.displayName = displayName;
65 private static final AtomicLong
nextId =
new AtomicLong(0L);
66 private final long id;
84 this.dataSourceJobs =
new ConcurrentHashMap<>();
85 for (Content dataSource : dataSources) {
86 DataSourceIngestJob dataSourceIngestJob =
new DataSourceIngestJob(
this, dataSource, settings, doUI);
87 this.dataSourceJobs.put(dataSourceIngestJob.getId(), dataSourceIngestJob);
89 incompleteJobsCount =
new AtomicInteger(dataSourceJobs.size());
109 boolean hasIngestPipeline() {
116 for (DataSourceIngestJob dataSourceJob : this.dataSourceJobs.values()) {
117 if (dataSourceJob.hasIngestPipeline()) {
130 synchronized List<IngestModuleError> start() {
131 List<IngestModuleError> errors =
new ArrayList<>();
133 errors.add(
new IngestModuleError(
"IngestJob",
new IllegalStateException(
"Job already started")));
146 for (DataSourceIngestJob dataSourceJob : this.dataSourceJobs.values()) {
147 errors.addAll(dataSourceJob.start());
148 if (errors.isEmpty() ==
false) {
156 if (errors.isEmpty()) {
157 for (DataSourceIngestJob dataSourceJob : this.dataSourceJobs.values()) {
158 IngestManager.getInstance().fireDataSourceAnalysisStarted(
id, dataSourceJob.getId(), dataSourceJob.getDataSource());
161 cancel(CancellationReason.INGEST_MODULES_STARTUP_FAILED);
191 List<DataSourceIngestJob.Snapshot> getDataSourceIngestJobSnapshots() {
192 List<DataSourceIngestJob.Snapshot> snapshots =
new ArrayList<>();
193 this.dataSourceJobs.values().stream().forEach((dataSourceJob) -> {
194 snapshots.add(dataSourceJob.getSnapshot(
true));
221 this.dataSourceJobs.values().stream().forEach((job) -> {
224 this.cancelled =
true;
225 this.cancellationReason = reason;
253 void dataSourceJobFinished(DataSourceIngestJob job) {
255 if (!job.isCancelled()) {
256 ingestManager.fireDataSourceAnalysisCompleted(
id, job.getId(), job.getDataSource());
258 IngestManager.getInstance().fireDataSourceAnalysisCancelled(
id, job.getId(), job.getDataSource());
260 if (incompleteJobsCount.decrementAndGet() == 0) {
261 ingestManager.finishIngestJob(
this);
283 private final DataSourceIngestJob.Snapshot
snapshot;
315 return snapshot.getCancellationReason();
326 return snapshot.getCancelledDataSourceIngestModules();
335 dataSourceModule = null;
336 fileIngestRunning =
false;
337 fileIngestStartTime = null;
338 dataSourceProcessingSnapshots =
new ArrayList<>();
339 for (DataSourceIngestJob dataSourceJob : dataSourceJobs.values()) {
340 DataSourceIngestJob.Snapshot snapshot = dataSourceJob.getSnapshot(getIngestTasksSnapshot);
342 if (null == dataSourceModule) {
343 DataSourceIngestPipeline.PipelineModule module = snapshot.getDataSourceLevelIngestModule();
344 if (null != module) {
348 if (snapshot.fileIngestIsRunning()) {
349 fileIngestRunning =
true;
351 Date childFileIngestStartTime = snapshot.fileIngestStartTime();
352 if (null != childFileIngestStartTime && (null == fileIngestStartTime || childFileIngestStartTime.before(fileIngestStartTime))) {
353 fileIngestStartTime = childFileIngestStartTime;
386 return new Date(this.fileIngestStartTime.getTime());
414 return Collections.unmodifiableList(this.dataSourceProcessingSnapshots);
426 private final DataSourceIngestJob
job;
427 private final DataSourceIngestPipeline.PipelineModule
module;
442 this.cancelled = job.currentDataSourceIngestModuleIsCancelled();
452 return this.
module.getDisplayName();
462 return this.
module.getProcessingStartTime();
492 if (this.job.getCurrentDataSourceIngestModule() == this.
module) {
493 this.job.cancelCurrentDataSourceIngestModule();
DataSourceIngestModuleHandle(DataSourceIngestJob job, DataSourceIngestPipeline.PipelineModule module)
List< String > getCancelledDataSourceIngestModules()
static synchronized IngestManager getInstance()
CancellationReason cancellationReason
CancellationReason(String displayName)
final DataSourceIngestPipeline.PipelineModule module
final boolean jobCancelled
boolean fileIngestIsRunning()
final AtomicInteger incompleteJobsCount
final DataSourceIngestJob.Snapshot snapshot
final Map< Long, DataSourceIngestJob > dataSourceJobs
DataSourceIngestModuleHandle runningDataSourceIngestModule()
List< DataSourceProcessingSnapshot > getDataSourceSnapshots()
final IngestJob.CancellationReason jobCancellationReason
ProgressSnapshot getSnapshot()
synchronized CancellationReason getCancellationReason()
INGEST_MODULES_STARTUP_FAILED
final DataSourceIngestJob job
synchronized boolean isCancelled()
synchronized CancellationReason getCancellationReason()
DataSourceProcessingSnapshot(DataSourceIngestJob.Snapshot snapshot)
static final AtomicLong nextId
synchronized void cancel(CancellationReason reason)
boolean fileIngestRunning
ProgressSnapshot(boolean getIngestTasksSnapshot)
synchronized CancellationReason getCancellationReason()
ProgressSnapshot getSnapshot(boolean getIngestTasksSnapshot)
synchronized void cancel()
Date fileIngestStartTime()
DataSourceIngestModuleHandle dataSourceModule
final List< DataSourceProcessingSnapshot > dataSourceProcessingSnapshots