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 final static AtomicLong 
nextId = 
new AtomicLong(0L);
 
   66     private final long id;
 
   82         this.dataSourceJobs = 
new ConcurrentHashMap<>();
 
   83         for (Content dataSource : dataSources) {
 
   84             DataSourceIngestJob dataSourceIngestJob = 
new DataSourceIngestJob(
this, dataSource, settings, doUI);
 
   85             this.dataSourceJobs.put(dataSourceIngestJob.getId(), dataSourceIngestJob);
 
   87         incompleteJobsCount = 
new AtomicInteger(dataSourceJobs.size());
 
  107     boolean hasIngestPipeline() {
 
  114         for (DataSourceIngestJob dataSourceJob : this.dataSourceJobs.values()) {
 
  115             if (dataSourceJob.hasIngestPipeline()) {
 
  128     List<IngestModuleError> start() {
 
  137         List<IngestModuleError> errors = 
new ArrayList<>();
 
  138         for (DataSourceIngestJob dataSourceJob : this.dataSourceJobs.values()) {
 
  139             errors.addAll(dataSourceJob.start());
 
  140             if (errors.isEmpty() == 
false) {
 
  148         if (errors.isEmpty()) {
 
  149             for (DataSourceIngestJob dataSourceJob : this.dataSourceJobs.values()) {
 
  150                 IngestManager.getInstance().fireDataSourceAnalysisStarted(
id, dataSourceJob.getId(), dataSourceJob.getDataSource());
 
  153             cancel(CancellationReason.INGEST_MODULES_STARTUP_FAILED);
 
  183     List<DataSourceIngestJob.Snapshot> getDataSourceIngestJobSnapshots() {
 
  184         List<DataSourceIngestJob.Snapshot> snapshots = 
new ArrayList<>();
 
  185         this.dataSourceJobs.values().stream().forEach((dataSourceJob) -> {
 
  186             snapshots.add(dataSourceJob.getSnapshot(
true));
 
  213         this.cancellationReason = reason;
 
  214         this.dataSourceJobs.values().stream().forEach((job) -> {
 
  244     void dataSourceJobFinished(DataSourceIngestJob job) {
 
  246         if (!job.isCancelled()) {
 
  247             ingestManager.fireDataSourceAnalysisCompleted(
id, job.getId(), job.getDataSource());
 
  249             IngestManager.getInstance().fireDataSourceAnalysisCancelled(
id, job.getId(), job.getDataSource());
 
  251         if (incompleteJobsCount.decrementAndGet() == 0) {
 
  252             ingestManager.finishIngestJob(
this);
 
  274             private final DataSourceIngestJob.Snapshot 
snapshot;
 
  306                 return snapshot.getCancellationReason();
 
  317                 return snapshot.getCancelledDataSourceIngestModules();
 
  326             dataSourceModule = null;
 
  327             fileIngestRunning = 
false;
 
  328             fileIngestStartTime = null;
 
  329             dataSourceProcessingSnapshots = 
new ArrayList<>();
 
  330             for (DataSourceIngestJob dataSourceJob : dataSourceJobs.values()) {
 
  331                 DataSourceIngestJob.Snapshot snapshot = dataSourceJob.getSnapshot(getIngestTasksSnapshot);
 
  333                 if (null == dataSourceModule) {
 
  334                     DataSourceIngestPipeline.PipelineModule module = snapshot.getDataSourceLevelIngestModule();
 
  335                     if (null != module) {
 
  339                 if (snapshot.fileIngestIsRunning()) {
 
  340                     fileIngestRunning = 
true;
 
  342                 Date childFileIngestStartTime = snapshot.fileIngestStartTime();
 
  343                 if (null != childFileIngestStartTime && (null == fileIngestStartTime || childFileIngestStartTime.before(fileIngestStartTime))) {
 
  344                     fileIngestStartTime = childFileIngestStartTime;
 
  377             return new Date(this.fileIngestStartTime.getTime());
 
  405             return Collections.unmodifiableList(this.dataSourceProcessingSnapshots);
 
  417         private final DataSourceIngestJob 
job;
 
  418         private final DataSourceIngestPipeline.PipelineModule 
module;
 
  433             this.cancelled = job.currentDataSourceIngestModuleIsCancelled();
 
  443             return this.
module.getDisplayName();
 
  453             return this.
module.getProcessingStartTime();
 
  483             if (this.job.getCurrentDataSourceIngestModule() == this.
module) {
 
  484                 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