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;
40 private static final AtomicLong
nextId =
new AtomicLong(0L);
41 private final long id;
58 this.dataSourceJobs =
new ConcurrentHashMap<>();
59 for (
Content dataSource : dataSources) {
60 DataSourceIngestJob dataSourceIngestJob =
new DataSourceIngestJob(
this, dataSource, settings, runInteractively);
61 this.dataSourceJobs.put(dataSourceIngestJob.getId(), dataSourceIngestJob);
63 incompleteJobsCount =
new AtomicInteger(dataSourceJobs.size());
81 boolean hasIngestPipeline() {
82 for (DataSourceIngestJob dataSourceJob : this.dataSourceJobs.values()) {
83 if (dataSourceJob.hasIngestPipeline()) {
96 synchronized List<IngestModuleError> start() {
97 List<IngestModuleError> errors =
new ArrayList<>();
99 errors.add(
new IngestModuleError(
"IngestJob",
new IllegalStateException(
"Job already started")));
104 for (DataSourceIngestJob dataSourceJob : this.dataSourceJobs.values()) {
105 errors.addAll(dataSourceJob.start());
106 if (!errors.isEmpty()) {
119 if (!errors.isEmpty()) {
120 for (DataSourceIngestJob dataSourceJob : this.dataSourceJobs.values()) {
121 dataSourceJob.cancel();
152 List<DataSourceIngestJob.Snapshot> getDataSourceIngestJobSnapshots() {
153 List<DataSourceIngestJob.Snapshot> snapshots =
new ArrayList<>();
154 for (DataSourceIngestJob dataSourceJob : this.dataSourceJobs.values()) {
155 snapshots.add(dataSourceJob.getSnapshot(
true));
167 for (DataSourceIngestJob job : this.dataSourceJobs.values()) {
170 this.cancelled =
true;
189 void dataSourceJobFinished(DataSourceIngestJob dataSourceIngestJob) {
190 if (incompleteJobsCount.decrementAndGet() == 0) {
212 private final DataSourceIngestJob.Snapshot
snapshot;
246 return snapshot.getCancelledDataSourceIngestModules();
255 dataSourceModule = null;
256 fileIngestRunning =
false;
257 fileIngestStartTime = null;
258 dataSourceProcessingSnapshots =
new ArrayList<>();
259 for (DataSourceIngestJob dataSourceJob : dataSourceJobs.values()) {
260 DataSourceIngestJob.Snapshot snapshot = dataSourceJob.getSnapshot(getIngestTasksSnapshot);
262 if (null == dataSourceModule) {
263 DataSourceIngestPipeline.PipelineModule module = snapshot.getDataSourceLevelIngestModule();
264 if (null != module) {
268 if (snapshot.fileIngestIsRunning()) {
269 fileIngestRunning =
true;
271 Date childFileIngestStartTime = snapshot.fileIngestStartTime();
272 if (null != childFileIngestStartTime && (null == fileIngestStartTime || childFileIngestStartTime.before(fileIngestStartTime))) {
273 fileIngestStartTime = childFileIngestStartTime;
305 return new Date(this.fileIngestStartTime.getTime());
324 return Collections.unmodifiableList(this.dataSourceProcessingSnapshots);
336 private final DataSourceIngestJob
job;
337 private final DataSourceIngestPipeline.PipelineModule
module;
352 this.cancelled = job.currentDataSourceIngestModuleIsCancelled();
362 return this.
module.getDisplayName();
372 return this.
module.getProcessingStartTime();
402 if (this.job.getCurrentDataSourceIngestModule() == this.
module) {
403 this.job.cancelCurrentDataSourceIngestModule();
DataSourceIngestModuleHandle(DataSourceIngestJob job, DataSourceIngestPipeline.PipelineModule module)
List< String > getCancelledDataSourceIngestModules()
static synchronized IngestManager getInstance()
final DataSourceIngestPipeline.PipelineModule module
final boolean jobCancelled
boolean fileIngestIsRunning()
final AtomicInteger incompleteJobsCount
volatile boolean cancelled
final DataSourceIngestJob.Snapshot snapshot
final Map< Long, DataSourceIngestJob > dataSourceJobs
DataSourceIngestModuleHandle runningDataSourceIngestModule()
List< DataSourceProcessingSnapshot > getDataSourceSnapshots()
ProgressSnapshot getSnapshot()
final DataSourceIngestJob job
DataSourceProcessingSnapshot(DataSourceIngestJob.Snapshot snapshot)
static final AtomicLong nextId
boolean fileIngestRunning
ProgressSnapshot(boolean getIngestTasksSnapshot)
ProgressSnapshot getSnapshot(boolean getIngestTasksSnapshot)
Date fileIngestStartTime()
DataSourceIngestModuleHandle dataSourceModule
final List< DataSourceProcessingSnapshot > dataSourceProcessingSnapshots