19 package org.sleuthkit.autopsy.ingest;
 
   21 import java.text.SimpleDateFormat;
 
   22 import java.util.ArrayList;
 
   23 import java.util.Collections;
 
   24 import java.util.Date;
 
   25 import java.util.List;
 
   27 import javax.swing.JDialog;
 
   28 import javax.swing.table.AbstractTableModel;
 
   29 import javax.swing.table.TableColumn;
 
   30 import org.apache.commons.lang3.time.DurationFormatUtils;
 
   31 import org.openide.util.NbBundle;
 
   36 @SuppressWarnings(
"PMD.SingularField") 
 
   37 class IngestProgressSnapshotPanel extends javax.swing.JPanel {
 
   39     private final JDialog parent;
 
   40     private final IngestProgressSnapshotProvider snapshotProvider;
 
   41     private final IngestThreadActivitySnapshotsTableModel threadActivityTableModel;
 
   42     private final IngestJobTableModel jobTableModel;
 
   43     private final ModuleTableModel moduleTableModel;
 
   45     IngestProgressSnapshotPanel(JDialog parent, IngestProgressSnapshotProvider snapshotProvider) {
 
   47         this.snapshotProvider = snapshotProvider;
 
   48         threadActivityTableModel = 
new IngestThreadActivitySnapshotsTableModel();
 
   49         jobTableModel = 
new IngestJobTableModel();
 
   50         moduleTableModel = 
new ModuleTableModel();
 
   52         customizeComponents();
 
   55     private void customizeComponents() {
 
   56         threadActivitySnapshotsTable.setModel(threadActivityTableModel);
 
   57         jobTable.setModel(jobTableModel);
 
   58         moduleTable.setModel(moduleTableModel);
 
   60         int width = snapshotsScrollPane.getPreferredSize().width;
 
   61         for (
int i = 0; i < threadActivitySnapshotsTable.getColumnCount(); ++i) {
 
   62             TableColumn column = threadActivitySnapshotsTable.getColumnModel().getColumn(i);
 
   65                     column.setPreferredWidth(((
int) (width * 0.02)));
 
   68                     column.setPreferredWidth(((
int) (width * 0.20)));
 
   71                     column.setPreferredWidth(((
int) (width * 0.15)));
 
   74                     column.setPreferredWidth(((
int) (width * 0.35)));
 
   77                     column.setPreferredWidth(((
int) (width * 0.18)));
 
   80                     column.setPreferredWidth(((
int) (width * 0.10)));
 
   85         threadActivitySnapshotsTable.setFillsViewportHeight(
true);
 
   90         private final String[] columnNames = {NbBundle.getMessage(this.getClass(),
 
   91             "IngestProgressSnapshotPanel.SnapshotsTableModel.colNames.threadID"),
 
   92             NbBundle.getMessage(this.getClass(),
 
   93             "IngestProgressSnapshotPanel.SnapshotsTableModel.colNames.activity"),
 
   94             NbBundle.getMessage(this.getClass(),
 
   95             "IngestProgressSnapshotPanel.SnapshotsTableModel.colNames.dataSource"),
 
   96             NbBundle.getMessage(this.getClass(),
 
   97             "IngestProgressSnapshotPanel.SnapshotsTableModel.colNames.file"),
 
   98             NbBundle.getMessage(this.getClass(),
 
   99             "IngestProgressSnapshotPanel.SnapshotsTableModel.colNames.startTime"),
 
  100             NbBundle.getMessage(this.getClass(),
 
  101             "IngestProgressSnapshotPanel.SnapshotsTableModel.colNames.elapsedTime"),
 
  102             NbBundle.getMessage(this.getClass(),
 
  103             "IngestProgressSnapshotPanel.SnapshotsTableModel.colNames.jobID")};
 
  111             snapshots = snapshotProvider.getIngestThreadActivitySnapshots();
 
  112             fireTableDataChanged();
 
  117             return snapshots.size();
 
  122             return columnNames.length;
 
  127             return columnNames[col];
 
  134             switch (columnIndex) {
 
  136                     cellValue = snapshot.getThreadId();
 
  139                     cellValue = snapshot.getModuleDisplayName();
 
  142                     cellValue = snapshot.getDataSourceName();
 
  145                     cellValue = snapshot.getFileName();
 
  148                     cellValue = snapshot.getStartTime();
 
  151                     Date now = 
new Date();
 
  152                     long elapsedTime = now.getTime() - snapshot.getStartTime().getTime();
 
  153                     cellValue = DurationFormatUtils.formatDurationHMS(elapsedTime);
 
  156                     cellValue = snapshot.getIngestJobId();
 
  168         private static final long serialVersionUID = 1L;
 
  170         private final String[] columnNames = {
 
  171             NbBundle.getMessage(this.getClass(), 
"IngestJobTableModel.colName.jobID"),
 
  172             NbBundle.getMessage(this.getClass(), 
"IngestJobTableModel.colName.dataSource"),
 
  173             NbBundle.getMessage(this.getClass(), 
"IngestJobTableModel.colName.start"),
 
  174             NbBundle.getMessage(this.getClass(), 
"IngestJobTableModel.colName.tier"),
 
  175             NbBundle.getMessage(this.getClass(), 
"IngestJobTableModel.colName.numProcessed"),
 
  176             NbBundle.getMessage(this.getClass(), 
"IngestJobTableModel.colName.filesPerSec"),
 
  177             NbBundle.getMessage(this.getClass(), 
"IngestJobTableModel.colName.inProgress"),
 
  178             NbBundle.getMessage(this.getClass(), 
"IngestJobTableModel.colName.filesQueued"),
 
  179             NbBundle.getMessage(this.getClass(), 
"IngestJobTableModel.colName.dirQueued"),
 
  180             NbBundle.getMessage(this.getClass(), 
"IngestJobTableModel.colName.rootQueued"),
 
  181             NbBundle.getMessage(this.getClass(), 
"IngestJobTableModel.colName.streamingQueued"),
 
  182             NbBundle.getMessage(this.getClass(), 
"IngestJobTableModel.colName.dsQueued"),
 
  183             NbBundle.getMessage(this.getClass(), 
"IngestJobTableModel.colName.artifactsQueued"),
 
  184             NbBundle.getMessage(this.getClass(), 
"IngestJobTableModel.colName.resultsQueued")};
 
  193             jobSnapshots = snapshotProvider.getIngestJobSnapshots();
 
  194             fireTableDataChanged();
 
  199             return jobSnapshots.size();
 
  204             return columnNames.length;
 
  209             return columnNames[col];
 
  216             switch (columnIndex) {
 
  218                     cellValue = snapShot.getJobId();
 
  221                     cellValue = snapShot.getDataSource();
 
  224                     SimpleDateFormat dateFormat = 
new SimpleDateFormat(
"yyyy/MM/dd HH:mm:ss");
 
  225                     cellValue = dateFormat.format(
new Date(snapShot.getJobStartTime()));
 
  228                     cellValue = snapShot.getCurrentIngestModuleTier();
 
  231                     cellValue = snapShot.getFilesProcessed();
 
  234                     cellValue = snapShot.getFilesProcessedPerSec();
 
  237                     cellValue = snapShot.getRunningListSize();
 
  240                     cellValue = snapShot.getFileQueueSize();
 
  243                     cellValue = snapShot.getDirQueueSize();
 
  246                     cellValue = snapShot.getRootQueueSize();
 
  249                     cellValue = snapShot.getStreamingQueueSize();
 
  252                     cellValue = snapShot.getDsQueueSize();
 
  255                     cellValue = snapShot.getDataArtifactTasksQueueSize();
 
  258                     cellValue = snapShot.getAnalysisResultTasksQueueSize();
 
  270         private static final long serialVersionUID = 1L;
 
  279                 this.duration = duration;
 
  308         private final String[] columnNames = {NbBundle.getMessage(this.getClass(), 
"ModuleTableModel.colName.module"),
 
  309             NbBundle.getMessage(this.getClass(),
 
  310             "ModuleTableModel.colName.duration")};
 
  311         private final List<ModuleStats> moduleStats = 
new ArrayList<>();
 
  319             Map<String, Long> moduleStatMap = snapshotProvider.getModuleRunTimes();
 
  322             for (String k : moduleStatMap.keySet()) {
 
  323                 moduleStats.add(
new ModuleStats(k, moduleStatMap.get(k)));
 
  324                 totalTime += moduleStatMap.get(k);
 
  326             Collections.sort(moduleStats);
 
  327             fireTableDataChanged();
 
  332             return moduleStats.size();
 
  337             return columnNames.length;
 
  342             return columnNames[col];
 
  347             ModuleStats moduleStat = moduleStats.get(rowIndex);
 
  349             switch (columnIndex) {
 
  351                     cellValue = moduleStat.
getName();
 
  354                     cellValue = DurationFormatUtils.formatDurationHMS(moduleStat.
getDuration()) + 
" (" + (moduleStat.
getDuration() * 100) / totalTime + 
"%)";
 
  370     @SuppressWarnings(
"unchecked")
 
  372     private 
void initComponents() {
 
  373         java.awt.GridBagConstraints gridBagConstraints;
 
  375         snapshotsScrollPane = 
new javax.swing.JScrollPane();
 
  376         threadActivitySnapshotsTable = 
new javax.swing.JTable();
 
  377         jobScrollPane = 
new javax.swing.JScrollPane();
 
  378         jobTable = 
new javax.swing.JTable();
 
  379         refreshButton = 
new javax.swing.JButton();
 
  380         closeButton = 
new javax.swing.JButton();
 
  381         moduleScrollPane = 
new javax.swing.JScrollPane();
 
  382         moduleTable = 
new javax.swing.JTable();
 
  383         jPanel1 = 
new javax.swing.JPanel();
 
  385         setMinimumSize(
new java.awt.Dimension(500, 500));
 
  386         setPreferredSize(
new java.awt.Dimension(1500, 700));
 
  387         setLayout(
new java.awt.GridBagLayout());
 
  389         threadActivitySnapshotsTable.setModel(
new javax.swing.table.DefaultTableModel(
 
  397         snapshotsScrollPane.setViewportView(threadActivitySnapshotsTable);
 
  399         gridBagConstraints = 
new java.awt.GridBagConstraints();
 
  400         gridBagConstraints.gridx = 0;
 
  401         gridBagConstraints.gridy = 0;
 
  402         gridBagConstraints.gridwidth = 2;
 
  403         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
 
  404         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
 
  405         gridBagConstraints.weightx = 1.0;
 
  406         gridBagConstraints.weighty = 1.0;
 
  407         gridBagConstraints.insets = 
new java.awt.Insets(11, 10, 0, 10);
 
  408         add(snapshotsScrollPane, gridBagConstraints);
 
  410         jobTable.setModel(
new javax.swing.table.DefaultTableModel(
 
  418         jobScrollPane.setViewportView(jobTable);
 
  420         gridBagConstraints = 
new java.awt.GridBagConstraints();
 
  421         gridBagConstraints.gridx = 0;
 
  422         gridBagConstraints.gridy = 1;
 
  423         gridBagConstraints.gridwidth = 2;
 
  424         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
 
  425         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
 
  426         gridBagConstraints.weightx = 1.0;
 
  427         gridBagConstraints.weighty = 1.0;
 
  428         gridBagConstraints.insets = 
new java.awt.Insets(6, 10, 0, 10);
 
  429         add(jobScrollPane, gridBagConstraints);
 
  431         org.openide.awt.Mnemonics.setLocalizedText(refreshButton, 
org.openide.util.NbBundle.getMessage(IngestProgressSnapshotPanel.class, 
"IngestProgressSnapshotPanel.refreshButton.text")); 
 
  432         refreshButton.addActionListener(
new java.awt.event.ActionListener() {
 
  433             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  434                 refreshButtonActionPerformed(evt);
 
  437         gridBagConstraints = 
new java.awt.GridBagConstraints();
 
  438         gridBagConstraints.gridx = 0;
 
  439         gridBagConstraints.gridy = 3;
 
  440         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
 
  441         gridBagConstraints.weightx = 1.0;
 
  442         add(refreshButton, gridBagConstraints);
 
  444         org.openide.awt.Mnemonics.setLocalizedText(closeButton, 
org.openide.util.NbBundle.getMessage(IngestProgressSnapshotPanel.class, 
"IngestProgressSnapshotPanel.closeButton.text")); 
 
  445         closeButton.addActionListener(
new java.awt.event.ActionListener() {
 
  446             public void actionPerformed(java.awt.event.ActionEvent evt) {
 
  447                 closeButtonActionPerformed(evt);
 
  450         gridBagConstraints = 
new java.awt.GridBagConstraints();
 
  451         gridBagConstraints.gridx = 1;
 
  452         gridBagConstraints.gridy = 3;
 
  453         gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
 
  454         gridBagConstraints.insets = 
new java.awt.Insets(6, 6, 11, 10);
 
  455         add(closeButton, gridBagConstraints);
 
  457         moduleTable.setModel(
new javax.swing.table.DefaultTableModel(
 
  465         moduleScrollPane.setViewportView(moduleTable);
 
  467         gridBagConstraints = 
new java.awt.GridBagConstraints();
 
  468         gridBagConstraints.gridx = 0;
 
  469         gridBagConstraints.gridy = 2;
 
  470         gridBagConstraints.gridwidth = 2;
 
  471         gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
 
  472         gridBagConstraints.anchor = java.awt.GridBagConstraints.NORTHWEST;
 
  473         gridBagConstraints.weightx = 1.0;
 
  474         gridBagConstraints.weighty = 1.0;
 
  475         gridBagConstraints.insets = 
new java.awt.Insets(6, 10, 0, 10);
 
  476         add(moduleScrollPane, gridBagConstraints);
 
  477         add(jPanel1, 
new java.awt.GridBagConstraints());
 
  480     private void closeButtonActionPerformed(java.awt.event.ActionEvent evt) {
 
  484     private void refreshButtonActionPerformed(java.awt.event.ActionEvent evt) {
 
  485         threadActivityTableModel.refresh();
 
  486         jobTableModel.refresh();
 
  487         moduleTableModel.refresh();
 
  490     private javax.swing.JButton closeButton;
 
  491     private javax.swing.JPanel jPanel1;
 
  492     private javax.swing.JScrollPane jobScrollPane;
 
  493     private javax.swing.JTable jobTable;
 
  494     private javax.swing.JScrollPane moduleScrollPane;
 
  495     private javax.swing.JTable moduleTable;
 
  496     private javax.swing.JButton refreshButton;
 
  497     private javax.swing.JScrollPane snapshotsScrollPane;
 
  498     private javax.swing.JTable threadActivitySnapshotsTable;
 
Object getValueAt(int rowIndex, int columnIndex)
 
Object getValueAt(int rowIndex, int columnIndex)
 
String getColumnName(int col)
 
String getColumnName(int col)
 
IngestThreadActivitySnapshotsTableModel()
 
int compareTo(ModuleStats o)
 
List< IngestJobProgressSnapshot > jobSnapshots
 
String getColumnName(int col)
 
List< IngestManager.IngestThreadActivitySnapshot > snapshots
 
Object getValueAt(int rowIndex, int columnIndex)