From fdbbc0520e69c1104772fa74c39c78a9ae47fe5d Mon Sep 17 00:00:00 2001 From: Richard Cordovano Date: Mon, 9 Jun 2014 12:03:40 -0400 Subject: [PATCH] Add code to ensure that every ingest job that starts get at least one task --- .../ingest/DataSourceIngestTaskScheduler.java | 72 ------------------- ...cheduler.java => IngestTaskScheduler.java} | 0 2 files changed, 72 deletions(-) delete mode 100755 Core/src/org/sleuthkit/autopsy/ingest/DataSourceIngestTaskScheduler.java rename Core/src/org/sleuthkit/autopsy/ingest/{FileIngestTaskScheduler.java => IngestTaskScheduler.java} (100%) diff --git a/Core/src/org/sleuthkit/autopsy/ingest/DataSourceIngestTaskScheduler.java b/Core/src/org/sleuthkit/autopsy/ingest/DataSourceIngestTaskScheduler.java deleted file mode 100755 index 2acc58a5a1..0000000000 --- a/Core/src/org/sleuthkit/autopsy/ingest/DataSourceIngestTaskScheduler.java +++ /dev/null @@ -1,72 +0,0 @@ -/* - * Autopsy Forensic Browser - * - * Copyright 2012-2014 Basis Technology Corp. - * Contact: carrier sleuthkit org - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.sleuthkit.autopsy.ingest; - -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.LinkedBlockingQueue; -import java.util.logging.Level; -import java.util.logging.Logger; -import org.sleuthkit.datamodel.Content; - -final class DataSourceIngestTaskScheduler implements IngestTaskQueue { - - private static final DataSourceIngestTaskScheduler instance = new DataSourceIngestTaskScheduler(); - private final List tasks = new ArrayList<>(); // Guarded by this - private final LinkedBlockingQueue tasksQueue = new LinkedBlockingQueue<>(); - - static DataSourceIngestTaskScheduler getInstance() { - return instance; - } - - private DataSourceIngestTaskScheduler() { - } - - synchronized void scheduleTask(IngestJob job, Content dataSource) throws InterruptedException { - DataSourceIngestTask task = new DataSourceIngestTask(job, dataSource); - tasks.add(task); - try { - // Should not block, queue is (theoretically) unbounded. - tasksQueue.put(task); - } catch (InterruptedException ex) { - tasks.remove(task); - Logger.getLogger(DataSourceIngestTaskScheduler.class.getName()).log(Level.FINE, "Interruption of unexpected block on tasks queue", ex); //NON-NLS - throw ex; - } - } - - @Override - public IngestTask getNextTask() throws InterruptedException { - return tasksQueue.take(); - } - - synchronized void notifyTaskCompleted(DataSourceIngestTask task) { - tasks.remove(task); - } - - synchronized boolean hasIncompleteTasksForIngestJob(IngestJob job) { - long jobId = job.getId(); - for (DataSourceIngestTask task : tasks) { - if (task.getIngestJob().getId() == jobId) { - return true; - } - } - return false; - } -} diff --git a/Core/src/org/sleuthkit/autopsy/ingest/FileIngestTaskScheduler.java b/Core/src/org/sleuthkit/autopsy/ingest/IngestTaskScheduler.java similarity index 100% rename from Core/src/org/sleuthkit/autopsy/ingest/FileIngestTaskScheduler.java rename to Core/src/org/sleuthkit/autopsy/ingest/IngestTaskScheduler.java