1
0
mirror of https://github.com/elisspace/autopsy.git synced 2026-09-06 02:24:30 +00:00

Merge pull request #831 from rcordovano/thread_count_fix

Change file ingest thread options to better match avaialble processors
This commit is contained in:
Richard Cordovano
2014-07-18 16:13:16 -04:00

View File

@@ -29,9 +29,45 @@ final class AutopsyOptionsPanel extends javax.swing.JPanel {
AutopsyOptionsPanel(AutopsyOptionsPanelController controller) {
initComponents();
numberOfFileIngestThreadsComboBox.setModel(new DefaultComboBoxModel<>(new Integer[]{1, 2, 4, 6, 8, 12, 16}));
int availableProcessors = Runtime.getRuntime().availableProcessors();
restartRequiredLabel.setText(NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.restartRequiredLabel.text", availableProcessors > 2 ? availableProcessors - 2 : 1));
Integer fileIngestThreadCountChoices[] = null;
int recommendedFileIngestThreadCount;
if (availableProcessors >= 16) {
fileIngestThreadCountChoices = new Integer[]{1, 2, 4, 6, 8, 12, 16};
if (availableProcessors >= 18) {
recommendedFileIngestThreadCount = 16;
} else {
recommendedFileIngestThreadCount = 12;
}
} else if (availableProcessors >= 12 && availableProcessors <= 15) {
fileIngestThreadCountChoices = new Integer[]{1, 2, 4, 6, 8, 12};
if (availableProcessors >= 14) {
recommendedFileIngestThreadCount = 12;
} else {
recommendedFileIngestThreadCount = 8;
}
} else if (availableProcessors >= 8 && availableProcessors <= 11) {
fileIngestThreadCountChoices = new Integer[]{1, 2, 4, 6, 8};
if (availableProcessors >= 10) {
recommendedFileIngestThreadCount = 8;
} else {
recommendedFileIngestThreadCount = 6;
}
} else if (availableProcessors >= 6 && availableProcessors <= 7) {
fileIngestThreadCountChoices = new Integer[]{1, 2, 4, 6};
recommendedFileIngestThreadCount = 4;
} else if (availableProcessors >= 4 && availableProcessors <= 5) {
fileIngestThreadCountChoices = new Integer[]{1, 2, 4};
recommendedFileIngestThreadCount = 2;
} else if (availableProcessors >= 2 && availableProcessors <= 3) {
fileIngestThreadCountChoices = new Integer[]{1, 2};
recommendedFileIngestThreadCount = 1;
} else {
fileIngestThreadCountChoices = new Integer[]{1};
recommendedFileIngestThreadCount = 1;
}
numberOfFileIngestThreadsComboBox.setModel(new DefaultComboBoxModel<>(fileIngestThreadCountChoices));
restartRequiredLabel.setText(NbBundle.getMessage(AutopsyOptionsPanel.class, "AutopsyOptionsPanel.restartRequiredLabel.text", recommendedFileIngestThreadCount));
// TODO listen to changes in form fields and call controller.changed()
}