mirror of
https://github.com/overcuriousity/autopsy-flatpak.git
synced 2025-07-17 18:17:43 +00:00
Merge pull request #6850 from rcordovano/7090-ingest-mgr-concurrent-modification-ex
7090 Fix concurrent mod ex in IngestManager
This commit is contained in:
commit
4c32218780
@ -125,7 +125,9 @@ public class IngestManager implements IngestProgressSnapshotProvider {
|
|||||||
private final int numberOfFileIngestThreads;
|
private final int numberOfFileIngestThreads;
|
||||||
private final AtomicLong nextIngestManagerTaskId = new AtomicLong(0L);
|
private final AtomicLong nextIngestManagerTaskId = new AtomicLong(0L);
|
||||||
private final ExecutorService startIngestJobsExecutor = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("IM-start-ingest-jobs-%d").build()); //NON-NLS;
|
private final ExecutorService startIngestJobsExecutor = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("IM-start-ingest-jobs-%d").build()); //NON-NLS;
|
||||||
|
@GuardedBy("startIngestJobFutures")
|
||||||
private final Map<Long, Future<Void>> startIngestJobFutures = new ConcurrentHashMap<>();
|
private final Map<Long, Future<Void>> startIngestJobFutures = new ConcurrentHashMap<>();
|
||||||
|
@GuardedBy("ingestJobsById")
|
||||||
private final Map<Long, IngestJob> ingestJobsById = new HashMap<>();
|
private final Map<Long, IngestJob> ingestJobsById = new HashMap<>();
|
||||||
private final ExecutorService dataSourceLevelIngestJobTasksExecutor = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("IM-data-source-ingest-%d").build()); //NON-NLS;
|
private final ExecutorService dataSourceLevelIngestJobTasksExecutor = Executors.newSingleThreadExecutor(new ThreadFactoryBuilder().setNameFormat("IM-data-source-ingest-%d").build()); //NON-NLS;
|
||||||
private final ExecutorService fileLevelIngestJobTasksExecutor;
|
private final ExecutorService fileLevelIngestJobTasksExecutor;
|
||||||
@ -338,10 +340,12 @@ public class IngestManager implements IngestProgressSnapshotProvider {
|
|||||||
if (job.hasIngestPipeline()) {
|
if (job.hasIngestPipeline()) {
|
||||||
long taskId = nextIngestManagerTaskId.incrementAndGet();
|
long taskId = nextIngestManagerTaskId.incrementAndGet();
|
||||||
Future<Void> task = startIngestJobsExecutor.submit(new StartIngestJobTask(taskId, job));
|
Future<Void> task = startIngestJobsExecutor.submit(new StartIngestJobTask(taskId, job));
|
||||||
|
synchronized (startIngestJobFutures) {
|
||||||
startIngestJobFutures.put(taskId, task);
|
startIngestJobFutures.put(taskId, task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Queues an ingest job for for a data source. Either all of the files in
|
* Queues an ingest job for for a data source. Either all of the files in
|
||||||
@ -357,10 +361,12 @@ public class IngestManager implements IngestProgressSnapshotProvider {
|
|||||||
if (job.hasIngestPipeline()) {
|
if (job.hasIngestPipeline()) {
|
||||||
long taskId = nextIngestManagerTaskId.incrementAndGet();
|
long taskId = nextIngestManagerTaskId.incrementAndGet();
|
||||||
Future<Void> task = startIngestJobsExecutor.submit(new StartIngestJobTask(taskId, job));
|
Future<Void> task = startIngestJobsExecutor.submit(new StartIngestJobTask(taskId, job));
|
||||||
|
synchronized (startIngestJobFutures) {
|
||||||
startIngestJobFutures.put(taskId, task);
|
startIngestJobFutures.put(taskId, task);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Immediately starts an ingest job for one or more data sources.
|
* Immediately starts an ingest job for one or more data sources.
|
||||||
@ -518,9 +524,11 @@ public class IngestManager implements IngestProgressSnapshotProvider {
|
|||||||
* @param reason The cancellation reason.
|
* @param reason The cancellation reason.
|
||||||
*/
|
*/
|
||||||
public void cancelAllIngestJobs(IngestJob.CancellationReason reason) {
|
public void cancelAllIngestJobs(IngestJob.CancellationReason reason) {
|
||||||
|
synchronized (startIngestJobFutures) {
|
||||||
startIngestJobFutures.values().forEach((handle) -> {
|
startIngestJobFutures.values().forEach((handle) -> {
|
||||||
handle.cancel(true);
|
handle.cancel(true);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
synchronized (ingestJobsById) {
|
synchronized (ingestJobsById) {
|
||||||
this.ingestJobsById.values().forEach((job) -> {
|
this.ingestJobsById.values().forEach((job) -> {
|
||||||
job.cancel(reason);
|
job.cancel(reason);
|
||||||
@ -939,8 +947,10 @@ public class IngestManager implements IngestProgressSnapshotProvider {
|
|||||||
if (progress != null) {
|
if (progress != null) {
|
||||||
progress.setDisplayName(NbBundle.getMessage(this.getClass(), "IngestManager.StartIngestJobsTask.run.cancelling", displayName));
|
progress.setDisplayName(NbBundle.getMessage(this.getClass(), "IngestManager.StartIngestJobsTask.run.cancelling", displayName));
|
||||||
}
|
}
|
||||||
|
synchronized (startIngestJobFutures) {
|
||||||
Future<?> handle = startIngestJobFutures.remove(threadId);
|
Future<?> handle = startIngestJobFutures.remove(threadId);
|
||||||
handle.cancel(true);
|
handle.cancel(true);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -954,9 +964,11 @@ public class IngestManager implements IngestProgressSnapshotProvider {
|
|||||||
if (null != progress) {
|
if (null != progress) {
|
||||||
progress.finish();
|
progress.finish();
|
||||||
}
|
}
|
||||||
|
synchronized (startIngestJobFutures) {
|
||||||
startIngestJobFutures.remove(threadId);
|
startIngestJobFutures.remove(threadId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user