Formatting.

This commit is contained in:
U-BASIS\dgrove 2017-11-30 16:59:39 -05:00
parent a6b115b35e
commit a5408e8a4a
2 changed files with 30 additions and 29 deletions

View File

@ -108,57 +108,58 @@ final class AutoIngestMetricsCollector {
static final class MetricsSnapshot { static final class MetricsSnapshot {
private final List<JobMetric> completedJobMetrics = new ArrayList<>(); private final List<JobMetric> completedJobMetrics = new ArrayList<>();
/** /**
* Gets a list of completed job metrics. * Gets a list of completed job metrics.
* *
* @return The completed job metrics. * @return The completed job metrics.
*/ */
List<JobMetric> getCompletedJobMetrics() { List<JobMetric> getCompletedJobMetrics() {
return new ArrayList<>(completedJobMetrics); return new ArrayList<>(completedJobMetrics);
} }
/** /**
* Adds a new metric to the list of completed job metrics. * Adds a new metric to the list of completed job metrics.
* *
* @param completedDate The completed job date. * @param completedDate The completed job date.
* @param dataSourceSize The data source size. * @param dataSourceSize The data source size.
*/ */
void addCompletedJobMetric(java.util.Date completedDate, long dataSourceSize) { void addCompletedJobMetric(java.util.Date completedDate, long dataSourceSize) {
completedJobMetrics.add(new JobMetric(completedDate, dataSourceSize)); completedJobMetrics.add(new JobMetric(completedDate, dataSourceSize));
} }
} }
/** /**
* A single job metric for an auto ingest cluster. * A single job metric for an auto ingest cluster.
*/ */
static final class JobMetric { static final class JobMetric {
private final long completedDate; private final long completedDate;
private final long dataSourceSize; private final long dataSourceSize;
/** /**
* Instantiates a job metric. * Instantiates a job metric.
* *
* @param completedDate The job completion date. * @param completedDate The job completion date.
* @param dataSourceSize The data source size. * @param dataSourceSize The data source size.
*/ */
JobMetric(java.util.Date completedDate, long dataSourceSize) { JobMetric(java.util.Date completedDate, long dataSourceSize) {
this.completedDate = completedDate.getTime(); this.completedDate = completedDate.getTime();
this.dataSourceSize = dataSourceSize; this.dataSourceSize = dataSourceSize;
} }
/** /**
* Gets the job completion date, formatted in milliseconds. * Gets the job completion date, formatted in milliseconds.
* *
* @return The job completion date. * @return The job completion date.
*/ */
long getCompletedDate() { long getCompletedDate() {
return completedDate; return completedDate;
} }
/** /**
* Gets the data source size. * Gets the data source size.
* *
* @return The data source size. * @return The data source size.
*/ */
long getDataSourceSize() { long getDataSourceSize() {

View File

@ -34,14 +34,14 @@ import org.sleuthkit.autopsy.experimental.autoingest.AutoIngestMetricsCollector.
* Displays auto ingest metrics for a cluster. * Displays auto ingest metrics for a cluster.
*/ */
final class AutoIngestMetricsDialog extends javax.swing.JDialog { final class AutoIngestMetricsDialog extends javax.swing.JDialog {
private static final int GIGABYTE_SIZE = 1073741824; private static final int GIGABYTE_SIZE = 1073741824;
private final AutoIngestMetricsCollector autoIngestMetricsCollector; private final AutoIngestMetricsCollector autoIngestMetricsCollector;
/** /**
* Creates an instance of AutoIngestMetricsDialog * Creates an instance of AutoIngestMetricsDialog
* *
* @param parent The parent container. * @param parent The parent container.
*/ */
@Messages({ @Messages({
@ -62,39 +62,39 @@ final class AutoIngestMetricsDialog extends javax.swing.JDialog {
setLocationRelativeTo(parent); setLocationRelativeTo(parent);
setVisible(true); setVisible(true);
} }
/** /**
* Update the metrics shown in the report text area. * Update the metrics shown in the report text area.
*/ */
private void updateMetrics() { private void updateMetrics() {
if(datePicker.getDate() == null) { if (datePicker.getDate() == null) {
return; return;
} }
AutoIngestMetricsCollector.MetricsSnapshot metricsSnapshot = autoIngestMetricsCollector.queryCoordinationServiceForMetrics(); AutoIngestMetricsCollector.MetricsSnapshot metricsSnapshot = autoIngestMetricsCollector.queryCoordinationServiceForMetrics();
List<JobMetric> completedJobMetrics = metricsSnapshot.getCompletedJobMetrics(); List<JobMetric> completedJobMetrics = metricsSnapshot.getCompletedJobMetrics();
int jobsCompleted = 0; int jobsCompleted = 0;
long dataSourceSizeTotal = 0; long dataSourceSizeTotal = 0;
long pickedDate = datePicker.getDate().atStartOfDay().toEpochSecond(ZoneOffset.UTC) * 1000; long pickedDate = datePicker.getDate().atStartOfDay().toEpochSecond(ZoneOffset.UTC) * 1000;
for(JobMetric jobMetric : completedJobMetrics) { for (JobMetric jobMetric : completedJobMetrics) {
if(jobMetric.getCompletedDate() >= pickedDate) { if (jobMetric.getCompletedDate() >= pickedDate) {
jobsCompleted++; jobsCompleted++;
dataSourceSizeTotal += jobMetric.getDataSourceSize(); dataSourceSizeTotal += jobMetric.getDataSourceSize();
} }
} }
SimpleDateFormat dateFormatter = new SimpleDateFormat("MMM d, yyyy"); SimpleDateFormat dateFormatter = new SimpleDateFormat("MMM d, yyyy");
reportTextArea.setText(String.format( reportTextArea.setText(String.format(
"Since %s:\n" + "Since %s:\n"
"Number of Jobs Completed: %d\n" + + "Number of Jobs Completed: %d\n"
"Total Size of Data Sources: %.1f GB\n", + "Total Size of Data Sources: %.1f GB\n",
dateFormatter.format(Date.valueOf(datePicker.getDate())), dateFormatter.format(Date.valueOf(datePicker.getDate())),
jobsCompleted, jobsCompleted,
(double)dataSourceSizeTotal / GIGABYTE_SIZE (double) dataSourceSizeTotal / GIGABYTE_SIZE
)); ));
} }
/** /**
* Exception type thrown when there is an error completing an auto ingest * Exception type thrown when there is an error completing an auto ingest
* metrics dialog operation. * metrics dialog operation.
@ -226,4 +226,4 @@ final class AutoIngestMetricsDialog extends javax.swing.JDialog {
private javax.swing.JTextArea reportTextArea; private javax.swing.JTextArea reportTextArea;
private javax.swing.JLabel startingDataLabel; private javax.swing.JLabel startingDataLabel;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
} }