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) {
try {
module.startUp(context);
} catch (Exception ex) {
} catch (Exception ex) { // Catch-all exception firewall
errors.add(new IngestModuleError(module.getDisplayName(), ex));
}
}
@ -92,7 +92,7 @@ final class DataSourceIngestPipeline {
module.getDisplayName(), dataSource.getName()));
task.updateProgressStatus(module.getDisplayName(), null);
module.process(dataSource, new DataSourceIngestModuleProgress(progress));
} catch (Exception ex) {
} catch (Exception ex) { // Catch-all exception firewall
errors.add(new IngestModuleError(module.getDisplayName(), ex));
}
if (context.isJobCancelled()) {

View File

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

View File

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

View File

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