Merge pull request #751 from rcordovano/java7_ingest_snapshots

Java7 ingest snapshots
This commit is contained in:
Richard Cordovano 2014-06-12 09:50:09 -04:00
commit 9b29b037f4
4 changed files with 40 additions and 27 deletions

View File

@ -75,7 +75,7 @@ final class DataSourceIngestPipeline {
for (DataSourceIngestModuleDecorator module : modules) { for (DataSourceIngestModuleDecorator module : modules) {
try { try {
module.startUp(context); module.startUp(context);
} catch (Exception ex) { } catch (Exception ex) { // Catch-all exception firewall
errors.add(new IngestModuleError(module.getDisplayName(), ex)); errors.add(new IngestModuleError(module.getDisplayName(), ex));
} }
} }
@ -92,7 +92,7 @@ final class DataSourceIngestPipeline {
module.getDisplayName(), dataSource.getName())); module.getDisplayName(), dataSource.getName()));
task.updateProgressStatus(module.getDisplayName(), null); task.updateProgressStatus(module.getDisplayName(), null);
module.process(dataSource, new DataSourceIngestModuleProgress(progress)); module.process(dataSource, new DataSourceIngestModuleProgress(progress));
} catch (Exception ex) { } catch (Exception ex) { // Catch-all exception firewall
errors.add(new IngestModuleError(module.getDisplayName(), ex)); errors.add(new IngestModuleError(module.getDisplayName(), ex));
} }
if (context.isJobCancelled()) { if (context.isJobCancelled()) {

View File

@ -77,7 +77,7 @@ final class FileIngestPipeline {
for (FileIngestModuleDecorator module : modules) { for (FileIngestModuleDecorator module : modules) {
try { try {
module.startUp(context); module.startUp(context);
} catch (Exception ex) { } catch (Exception ex) { // Catch-all exception firewall
errors.add(new IngestModuleError(module.getDisplayName(), ex)); errors.add(new IngestModuleError(module.getDisplayName(), ex));
} }
} }
@ -98,7 +98,7 @@ final class FileIngestPipeline {
try { try {
task.updateProgressStatus(module.getDisplayName(), file); task.updateProgressStatus(module.getDisplayName(), file);
module.process(file); module.process(file);
} catch (Exception ex) { } catch (Exception ex) { // Catch-all exception firewall
errors.add(new IngestModuleError(module.getDisplayName(), ex)); errors.add(new IngestModuleError(module.getDisplayName(), ex));
} }
if (context.isJobCancelled()) { if (context.isJobCancelled()) {

View File

@ -20,14 +20,13 @@ package org.sleuthkit.autopsy.ingest;
import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener; import java.beans.PropertyChangeListener;
import java.time.Duration; import java.util.Date;
import java.time.LocalTime;
import java.util.List; import java.util.List;
import javax.swing.JDialog; import javax.swing.JDialog;
import javax.swing.table.AbstractTableModel; import javax.swing.table.AbstractTableModel;
import javax.swing.table.TableColumn; import javax.swing.table.TableColumn;
import org.sleuthkit.datamodel.AbstractFile;
import org.apache.commons.lang3.time.DurationFormatUtils; import org.apache.commons.lang3.time.DurationFormatUtils;
import org.sleuthkit.datamodel.AbstractFile;
public class IngestProgressSnapshotPanel extends javax.swing.JPanel { public class IngestProgressSnapshotPanel extends javax.swing.JPanel {
@ -133,8 +132,12 @@ public class IngestProgressSnapshotPanel extends javax.swing.JPanel {
cellValue = snapshot.getStartTime(); cellValue = snapshot.getStartTime();
break; break;
case 5: case 5:
long elapsedTime = Duration.between(snapshot.getStartTime(), LocalTime.now()).toMillis(); Date now = new Date();
cellValue = DurationFormatUtils.formatDurationHMS(elapsedTime); long elapsedTime = now.getTime() - snapshot.getStartTime().getTime();
cellValue = DurationFormatUtils.formatDurationHMS(elapsedTime);
// TODO: Restore when we go to Java 8
// long elapsedTime = Duration.between(snapshot.getStartTime(), LocalTime.now()).toMillis();
// cellValue = DurationFormatUtils.formatDurationHMS(elapsedTime);
break; break;
default: default:
cellValue = null; cellValue = null;

View File

@ -18,15 +18,15 @@
*/ */
package org.sleuthkit.autopsy.ingest; package org.sleuthkit.autopsy.ingest;
import java.time.LocalTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import org.sleuthkit.datamodel.AbstractFile; import org.sleuthkit.datamodel.AbstractFile;
import org.sleuthkit.datamodel.Content; import org.sleuthkit.datamodel.Content;
class IngestTask { class IngestTask {
private final IngestJob job; private final IngestJob job;
private final ProgressSnapshots snapshots; private final ProgressSnapshots snapshots;
private long threadId; private long threadId;
@ -39,58 +39,68 @@ class IngestTask {
IngestJob getIngestJob() { IngestJob getIngestJob() {
return job; return job;
} }
void updateProgressStatus(String ingestModuleDisplayName, AbstractFile file) { void updateProgressStatus(String ingestModuleDisplayName, AbstractFile file) {
snapshots.update(new ProgressSnapshot(threadId, job.getDataSource(), ingestModuleDisplayName, file)); snapshots.update(new ProgressSnapshot(threadId, job.getDataSource(), ingestModuleDisplayName, file));
} }
void execute(long threadId) throws InterruptedException { void execute(long threadId) throws InterruptedException {
this.threadId = threadId; this.threadId = threadId;
} }
public static final class ProgressSnapshot { public static final class ProgressSnapshot {
private final long threadId; private final long threadId;
private final Content dataSource; private final Content dataSource;
private final String ingestModuleDisplayName; private final String ingestModuleDisplayName;
private final AbstractFile file; private final AbstractFile file;
private final LocalTime startTime; private final Date startTime;
// TODO: Restore when we go to Java 8
// private final LocalTime startTime;
private ProgressSnapshot(long threadId, Content dataSource, String ingestModuleDisplayName, AbstractFile file) { private ProgressSnapshot(long threadId, Content dataSource, String ingestModuleDisplayName, AbstractFile file) {
this.threadId = threadId; this.threadId = threadId;
this.dataSource = dataSource; this.dataSource = dataSource;
this.ingestModuleDisplayName = ingestModuleDisplayName; this.ingestModuleDisplayName = ingestModuleDisplayName;
this.file = file; this.file = file;
startTime = LocalTime.now(); startTime = new Date();
// TODO: Restore when we go to Java 8
// startTime = LocalTime.now();
} }
long getThreadId() { long getThreadId() {
return threadId; return threadId;
} }
Content getDataSource() { Content getDataSource() {
return dataSource; return dataSource;
} }
String getModuleDisplayName() { String getModuleDisplayName() {
return ingestModuleDisplayName; return ingestModuleDisplayName;
} }
AbstractFile getFile() { AbstractFile getFile() {
return file; return file;
} }
LocalTime getStartTime() { Date getStartTime() {
return startTime; return startTime;
} }
// TODO: Restore when we go to Java 8
// LocalTime getStartTime() {
// return startTime;
// }
} }
static final class ProgressSnapshots { static final class ProgressSnapshots {
private final ConcurrentHashMap<Long, IngestTask.ProgressSnapshot> snapshots = new ConcurrentHashMap<>(); // Maps ingest thread ids to progress snapshots. private final ConcurrentHashMap<Long, IngestTask.ProgressSnapshot> snapshots = new ConcurrentHashMap<>(); // Maps ingest thread ids to progress snapshots.
void update(ProgressSnapshot snapshot) { void update(ProgressSnapshot snapshot) {
snapshots.put(snapshot.getThreadId(), snapshot); snapshots.put(snapshot.getThreadId(), snapshot);
} }
List<ProgressSnapshot> getSnapshots() { List<ProgressSnapshot> getSnapshots() {
return new ArrayList(snapshots.values()); return new ArrayList(snapshots.values());
} }